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 <list>
00031 #include <map>
00032 #include <set>
00033 #include <string>
00034 #include <gcu/macros.h>
00035
00037 namespace gcu {
00038
00039 class Document;
00040 class Dialog;
00041 struct option_data;
00042
00046 typedef enum {
00050 NormalWindowState,
00054 MaximizedWindowState,
00058 MinimizedWindowState,
00062 FullScreenWindowState
00063 } WindowState;
00064
00065 #define GCU_CONF_DIR "gchemutils"
00066
00070 class Application: virtual public DialogOwner
00071 {
00072 friend class Document;
00073 friend class Dialog;
00074 friend class ApplicationPrivate;
00075 public:
00087 Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00091 virtual ~Application ();
00092
00101 void OnHelp (std::string s = "");
00105 bool HasHelp ();
00109 std::string &GetName () {return Name;}
00110
00114 virtual GtkWindow * GetWindow () {return NULL;}
00115
00129 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)
00130 {return false;}
00131
00135 char const* GetCurDir () {return CurDir.c_str ();}
00136
00140 void SetCurDir (char const* dir);
00141
00145 void SetCurDir (std::string const &dir);
00146
00152 void ShowURI (std::string& uri);
00153
00159 void OnBug (char const *uri = PACKAGE_BUGREPORT)
00160 {std::string s (uri); ShowURI (s);}
00161
00166 void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00167 {std::string s (uri); ShowURI (s);}
00168
00175 void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00176
00180 void OnLiveAssistance ();
00181
00186 GtkWidget *GetImageResolutionWidget ();
00187
00192 GtkWidget *GetImageSizeWidget ();
00193
00197 std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00198
00208 char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00209
00219 ContentType Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00220
00231 bool Save (std::string const &uri, const gchar *mime_type, Document const *Doc, ContentType type);
00232
00237 virtual Document *CreateNewDocument () {return NULL;}
00238
00243 static GOConfNode *GetConfDir ();
00244
00249 std::string const &GetIconName () {return IconName;}
00250
00258 void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00259
00266 void AddOptions (GOptionContext *context);
00270 static WindowState GetDefaultWindowState () {return DefaultWindowState;}
00275 static Application *GetDefaultApplication ();
00276
00277 protected:
00278
00284 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00285
00286 private:
00287 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00288 void RemoveDocument (Document *Doc);
00289
00290 private:
00291 std::string Name;
00292 std::string HelpName;
00293 std::string HelpBrowser;
00294 std::string HelpFilename;
00295 std::string CurDir;
00296 std::string IconName;
00297 static GOConfNode *m_ConfDir;
00298 std::list<option_data> m_Options;
00299 static WindowState DefaultWindowState;
00300
00301 protected:
00305 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00306
00313 GCU_PROT_PROP (std::set <Document*>, Docs)
00317 GCU_RO_PROP (unsigned, ScreenResolution)
00331 GCU_PROP (unsigned, ImageResolution)
00345 GCU_PROP (unsigned, ImageWidth)
00359 GCU_PROP (unsigned, ImageHeight)
00371 GCU_PROP (bool, TransparentBackground)
00375 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00376 };
00377
00378 }
00379
00380 #endif // GCU_APPLICATION_H