gcu/application.h
Go to the documentation of this file.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 #ifdef HAVE_GO_CONF_SYNC
00033 #include <goffice/app/go-conf.h>
00034 #endif
00035 #include <gtk/gtkmain.h>
00036 #include <gtk/gtkwindow.h>
00037 #include <gtk/gtkrecentmanager.h>
00038 #include <gcu/macros.h>
00039
00041 namespace gcu {
00042
00043 class Document;
00044 class Dialog;
00045
00046 #define GCU_CONF_DIR "gchemutils"
00047
00051 class Application: virtual public DialogOwner
00052 {
00053 friend class Document;
00054 friend class Dialog;
00055 public:
00067 Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00071 virtual ~Application ();
00072
00081 void OnHelp (std::string s = "");
00085 bool HasHelp ();
00089 std::string &GetName () {return Name;}
00090
00094 virtual GtkWindow * GetWindow () {return NULL;}
00095
00109 virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00110 {return false;}
00111
00115 char const* GetCurDir () {return CurDir.c_str ();}
00116
00120 void SetCurDir (char const* dir);
00121
00125 void SetCurDir (std::string const &dir);
00126
00132 void ShowURI (std::string& uri);
00133
00139 void OnBug (char const *uri = PACKAGE_BUGREPORT)
00140 {std::string s (uri); ShowURI (s);}
00141
00146 void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00147 {std::string s (uri); ShowURI (s);}
00148
00155 void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00156
00160 void OnLiveAssistance ();
00161
00166 GtkWidget *GetImageResolutionWidget ();
00167
00172 GtkWidget *GetImageSizeWidget ();
00173
00177 std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00178
00188 char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00189
00199 bool Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00200
00210 bool Save (std::string const &uri, const gchar *mime_type, Document* Doc);
00211
00216 virtual Document *CreateNewDocument () {return NULL;}
00217
00218 #ifdef HAVE_GO_CONF_SYNC
00219
00224 static GOConfNode *GetConfDir ();
00225 #endif
00226
00227 protected:
00228
00234 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00235
00236 private:
00237 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00238 void RemoveDocument (Document *Doc);
00239
00240 private:
00241 std::string Name;
00242 std::string HelpName;
00243 std::string HelpBrowser;
00244 std::string HelpFilename;
00245 std::string CurDir;
00246 #ifdef HAVE_GO_CONF_SYNC
00247 static GOConfNode *m_ConfDir;
00248 #endif
00249
00250 protected:
00254 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00255
00262 GCU_PROT_PROP (std::set <Document*>, Docs)
00266 GCU_RO_PROP (unsigned, ScreenResolution)
00280 GCU_PROP (unsigned, ImageResolution)
00294 GCU_PROP (unsigned, ImageWidth)
00308 GCU_PROP (unsigned, ImageHeight)
00312 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00313 };
00314
00315 }
00316
00317 #endif // GCU_APPLICATION_H