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 <map>
00029 #include <set>
00030 #include <string>
00031 #include <gtk/gtkmain.h>
00032 #include <gtk/gtkwindow.h>
00033 #include <gtk/gtkrecentmanager.h>
00034 #include <gcu/macros.h>
00035
00036 using namespace std;
00037
00038 namespace gcu {
00039
00040 class Document;
00041
00045 class Application
00046 {
00047 public:
00059 Application (string name, string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00060 virtual ~Application ();
00061
00070 void OnHelp (string s = "");
00074 bool HasHelp ();
00078 string &GetName () {return Name;}
00079
00083 virtual GtkWindow * GetWindow () {return NULL;}
00084
00098 virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00099 {return false;}
00100
00104 char const* GetCurDir () {return CurDir;}
00105
00109 void SetCurDir (char const* dir);
00110 void ShowURI (string& uri);
00111 void OnBug (char *uri = PACKAGE_BUGREPORT)
00112 {string s (uri); ShowURI (s);}
00113 void OnWeb (char *uri = "http://gchemutils.nongnu.org/")
00114 {string s (uri); ShowURI (s);}
00115 void OnMail (char *MailAddress = "mailto:gchemutils-main@nongnu.org");
00116 bool HasMailAgent () {return MailAgent.length () > 0;}
00117 bool HasWebBrowser () {return WebBrowser.length () > 0;}
00118 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00119 void RemoveDocument (Document *Doc) {m_Docs.erase (Doc); if (m_Docs.size () == 0) NoMoreDocsEvent ();}
00120 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00121 GtkWidget *GetImageResolutionWidget ();
00122 map<string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00123 char const *GetPixbufTypeName (string& filename, char const *mime_type);
00124
00125 private:
00126 string Name;
00127 string HelpBrowser;
00128 string HelpFilename;
00129 char *CurDir;
00130
00131 protected:
00132 string WebBrowser;
00133 string MailAgent;
00134 set <Document*> m_Docs;
00135 map<string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00136
00137 GCU_RO_PROP (unsigned, ScreenResolution);
00138 GCU_PROP (unsigned, ImageResolution);
00139 GCU_RO_PROP (GtkRecentManager*, RecentManager);
00140 };
00141
00142 }
00143
00144 #endif // GCU_APPLICATION_H