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 "structs.h"
00030 #include <map>
00031 #include <set>
00032 #include <string>
00033 #include <goffice/app/go-conf.h>
00034 #include <gtk/gtkmain.h>
00035 #include <gtk/gtkwindow.h>
00036 #include <gtk/gtkrecentmanager.h>
00037 #include <gcu/macros.h>
00038
00040 namespace gcu {
00041
00042 class Document;
00043 class Dialog;
00044
00045 #define GCU_CONF_DIR "gchemutils"
00046
00050 class Application: virtual public DialogOwner
00051 {
00052 friend class Document;
00053 friend class Dialog;
00054 public:
00066 Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00070 virtual ~Application ();
00071
00080 void OnHelp (std::string s = "");
00084 bool HasHelp ();
00088 std::string &GetName () {return Name;}
00089
00093 virtual GtkWindow * GetWindow () {return NULL;}
00094
00108 virtual bool FileProcess (G_GNUC_UNUSED const gchar* filename, G_GNUC_UNUSED const gchar* mime_type, G_GNUC_UNUSED bool bSave, G_GNUC_UNUSED GtkWindow *window, G_GNUC_UNUSED Document *pDoc = NULL)
00109 {return false;}
00110
00114 char const* GetCurDir () {return CurDir.c_str ();}
00115
00119 void SetCurDir (char const* dir);
00120
00124 void SetCurDir (std::string const &dir);
00125
00131 void ShowURI (std::string& uri);
00132
00138 void OnBug (char const *uri = PACKAGE_BUGREPORT)
00139 {std::string s (uri); ShowURI (s);}
00140
00145 void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00146 {std::string s (uri); ShowURI (s);}
00147
00154 void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00155
00159 void OnLiveAssistance ();
00160
00165 GtkWidget *GetImageResolutionWidget ();
00166
00171 GtkWidget *GetImageSizeWidget ();
00172
00176 std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00177
00187 char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00188
00198 ContentType Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00199
00210 bool Save (std::string const &uri, const gchar *mime_type, Document const *Doc, ContentType type);
00211
00216 virtual Document *CreateNewDocument () {return NULL;}
00217
00222 static GOConfNode *GetConfDir ();
00223
00224 std::string const &GetIconName () {return IconName;}
00225
00226 protected:
00227
00233 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00234
00235 private:
00236 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00237 void RemoveDocument (Document *Doc);
00238
00239 private:
00240 std::string Name;
00241 std::string HelpName;
00242 std::string HelpBrowser;
00243 std::string HelpFilename;
00244 std::string CurDir;
00245 std::string IconName;
00246 static GOConfNode *m_ConfDir;
00247
00248 protected:
00252 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00253
00260 GCU_PROT_PROP (std::set <Document*>, Docs)
00264 GCU_RO_PROP (unsigned, ScreenResolution)
00278 GCU_PROP (unsigned, ImageResolution)
00292 GCU_PROP (unsigned, ImageWidth)
00306 GCU_PROP (unsigned, ImageHeight)
00318 GCU_PROP (bool, TransparentBackground)
00322 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00323 };
00324
00325 }
00326
00327 #endif // GCU_APPLICATION_H