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
00043 typedef enum {
00044 NormalWindowState,
00045 MaximizedWindowState,
00046 MinimizedWindowState,
00047 FullScreenWindowState
00048 } WindowState;
00049
00050 #define GCU_CONF_DIR "gchemutils"
00051
00055 class Application: virtual public DialogOwner
00056 {
00057 friend class Document;
00058 friend class Dialog;
00059 public:
00071 Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00075 virtual ~Application ();
00076
00085 void OnHelp (std::string s = "");
00089 bool HasHelp ();
00093 std::string &GetName () {return Name;}
00094
00098 virtual GtkWindow * GetWindow () {return NULL;}
00099
00113 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)
00114 {return false;}
00115
00119 char const* GetCurDir () {return CurDir.c_str ();}
00120
00124 void SetCurDir (char const* dir);
00125
00129 void SetCurDir (std::string const &dir);
00130
00136 void ShowURI (std::string& uri);
00137
00143 void OnBug (char const *uri = PACKAGE_BUGREPORT)
00144 {std::string s (uri); ShowURI (s);}
00145
00150 void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00151 {std::string s (uri); ShowURI (s);}
00152
00159 void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00160
00164 void OnLiveAssistance ();
00165
00170 GtkWidget *GetImageResolutionWidget ();
00171
00176 GtkWidget *GetImageSizeWidget ();
00177
00181 std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00182
00192 char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00193
00203 ContentType Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00204
00215 bool Save (std::string const &uri, const gchar *mime_type, Document const *Doc, ContentType type);
00216
00221 virtual Document *CreateNewDocument () {return NULL;}
00222
00227 static GOConfNode *GetConfDir ();
00228
00229 std::string const &GetIconName () {return IconName;}
00230
00238 void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00239
00246 void AddOptions (GOptionContext *context);
00247 static WindowState GetDefaultWindowState () {return DefaultWindowState;}
00248 static Application *GetDefaultApplication ();
00249
00250 protected:
00251
00257 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00258
00259 private:
00260 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00261 void RemoveDocument (Document *Doc);
00262
00263 public:
00264 static WindowState DefaultWindowState;
00265
00266 private:
00267 std::string Name;
00268 std::string HelpName;
00269 std::string HelpBrowser;
00270 std::string HelpFilename;
00271 std::string CurDir;
00272 std::string IconName;
00273 static GOConfNode *m_ConfDir;
00274 std::list<option_data> m_Options;
00275
00276 protected:
00280 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00281
00288 GCU_PROT_PROP (std::set <Document*>, Docs)
00292 GCU_RO_PROP (unsigned, ScreenResolution)
00306 GCU_PROP (unsigned, ImageResolution)
00320 GCU_PROP (unsigned, ImageWidth)
00334 GCU_PROP (unsigned, ImageHeight)
00346 GCU_PROP (bool, TransparentBackground)
00350 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00351 };
00352
00353 }
00354
00355 #endif // GCU_APPLICATION_H