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 using namespace std;
00038
00039 namespace gcu {
00040
00041 class Document;
00042 class Dialog;
00043
00047 class Application: public DialogOwner
00048 {
00049 friend class Document;
00050 friend class Dialog;
00051 public:
00063 Application (string name, string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00064 virtual ~Application ();
00065
00074 void OnHelp (string s = "");
00078 bool HasHelp ();
00082 string &GetName () {return Name;}
00083
00087 virtual GtkWindow * GetWindow () {return NULL;}
00088
00102 virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00103 {return false;}
00104
00108 char const* GetCurDir () {return CurDir;}
00109
00113 void SetCurDir (char const* dir);
00114
00120 void ShowURI (string& uri);
00121
00127 void OnBug (char *uri = (char*) PACKAGE_BUGREPORT)
00128 {string s (uri); ShowURI (s);}
00129
00134 void OnWeb (char *uri = (char*) "http://gchemutils.nongnu.org/")
00135 {string s (uri); ShowURI (s);}
00136
00143 void OnMail (char *MailAddress = (char*) "mailto:gchemutils-main@nongnu.org");
00144
00148 bool HasMailAgent () {return MailAgent.length () > 0;}
00149
00153 bool HasWebBrowser () {return WebBrowser.length () > 0;}
00154
00159 GtkWidget *GetImageResolutionWidget ();
00160
00165 GtkWidget *GetImageSizeWidget ();
00166
00170 map<string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00171
00181 char const *GetPixbufTypeName (string& filename, char const *mime_type);
00182
00183 protected:
00184
00190 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00191
00192 private:
00193 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00194 void RemoveDocument (Document *Doc) {m_Docs.erase (Doc); if (m_Docs.size () == 0) NoMoreDocsEvent ();}
00195
00196 private:
00197 string Name;
00198 string HelpName;
00199 string HelpBrowser;
00200 string HelpFilename;
00201 char *CurDir;
00202 string WebBrowser;
00203 string MailAgent;
00204
00205 protected:
00209 map<string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00210
00217 GCU_PROT_PROP (set <Document*>, Docs)
00221 GCU_RO_PROP (unsigned, ScreenResolution)
00234 GCU_PROP (unsigned, ImageResolution)
00247 GCU_PROP (unsigned, ImageWidth)
00260 GCU_PROP (unsigned, ImageHeight)
00264 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00265 };
00266
00267 }
00268
00269 #endif // GCU_APPLICATION_H