00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef GCU_APPLICATION_H
00026 #define GCU_APPLICATION_H
00027
00028 #include "dialog-owner.h"
00029 #include <map>
00030 #include <set>
00031 #include <string>
00032 #include <gtk/gtkmain.h>
00033 #include <gtk/gtkwindow.h>
00034 #include <gtk/gtkrecentmanager.h>
00035 #include <gcu/macros.h>
00036
00037 namespace gcu {
00038
00039 class Document;
00040 class Dialog;
00041
00045 class Application: public DialogOwner
00046 {
00047 friend class Document;
00048 friend class Dialog;
00049 public:
00061 Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00062 virtual ~Application ();
00063
00072 void OnHelp (std::string s = "");
00076 bool HasHelp ();
00080 std::string &GetName () {return Name;}
00081
00085 virtual GtkWindow * GetWindow () {return NULL;}
00086
00100 virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00101 {return false;}
00102
00106 char const* GetCurDir () {return CurDir.c_str ();}
00107
00111 void SetCurDir (char const* dir);
00112
00116 void SetCurDir (std::string const &dir);
00117
00123 void ShowURI (std::string& uri);
00124
00130 void OnBug (char const *uri = PACKAGE_BUGREPORT)
00131 {std::string s (uri); ShowURI (s);}
00132
00137 void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00138 {std::string s (uri); ShowURI (s);}
00139
00146 void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00147
00151 bool HasMailAgent () {return MailAgent.length () > 0;}
00152
00156 bool HasWebBrowser () {return WebBrowser.length () > 0;}
00157
00162 GtkWidget *GetImageResolutionWidget ();
00163
00168 GtkWidget *GetImageSizeWidget ();
00169
00173 std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00174
00184 char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00185
00186 protected:
00187
00193 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00194
00195 private:
00196 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00197 void RemoveDocument (Document *Doc);
00198
00199 private:
00200 std::string Name;
00201 std::string HelpName;
00202 std::string HelpBrowser;
00203 std::string HelpFilename;
00204 std::string CurDir;
00205 std::string WebBrowser;
00206 std::string MailAgent;
00207
00208 protected:
00212 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00213
00220 GCU_PROT_PROP (std::set <Document*>, Docs)
00224 GCU_RO_PROP (unsigned, ScreenResolution)
00237 GCU_PROP (unsigned, ImageResolution)
00250 GCU_PROP (unsigned, ImageWidth)
00263 GCU_PROP (unsigned, ImageHeight)
00267 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00268 };
00269
00270 }
00271
00272 #endif // GCU_APPLICATION_H