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: 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 std::string const &GetIconName () {return IconName;}
00228
00229 protected:
00230
00236 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00237
00238 private:
00239 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00240 void RemoveDocument (Document *Doc);
00241
00242 private:
00243 std::string Name;
00244 std::string HelpName;
00245 std::string HelpBrowser;
00246 std::string HelpFilename;
00247 std::string CurDir;
00248 std::string IconName;
00249 #ifdef HAVE_GO_CONF_SYNC
00250 static GOConfNode *m_ConfDir;
00251 #endif
00252
00253 protected:
00257 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00258
00265 GCU_PROT_PROP (std::set <Document*>, Docs)
00269 GCU_RO_PROP (unsigned, ScreenResolution)
00283 GCU_PROP (unsigned, ImageResolution)
00297 GCU_PROP (unsigned, ImageWidth)
00311 GCU_PROP (unsigned, ImageHeight)
00323 GCU_PROP (bool, TransparentBackground)
00327 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00328 };
00329
00330 }
00331
00332 #endif // GCU_APPLICATION_H