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 "object.h"
00031 #include <list>
00032 #include <map>
00033 #include <set>
00034 #include <string>
00035 #include <gcu/macros.h>
00036
00038 namespace gcu {
00039
00040 class Document;
00041 class Dialog;
00042 struct option_data;
00043 class TypeDesc;
00044
00048 typedef enum {
00052 NormalWindowState,
00056 MaximizedWindowState,
00060 MinimizedWindowState,
00064 FullScreenWindowState
00065 } WindowState;
00066
00067 #define GCU_CONF_DIR "gchemutils"
00068
00072 class Application: virtual public DialogOwner
00073 {
00074 friend class Document;
00075 friend class Dialog;
00076 friend class ApplicationPrivate;
00077 public:
00089 Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00093 virtual ~Application ();
00094
00103 void OnHelp (std::string s = "");
00107 bool HasHelp ();
00111 std::string &GetName () {return Name;}
00112
00116 virtual GtkWindow * GetWindow () {return NULL;}
00117
00131 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)
00132 {return false;}
00133
00137 char const* GetCurDir () {return CurDir.c_str ();}
00138
00142 void SetCurDir (char const* dir);
00143
00147 void SetCurDir (std::string const &dir);
00148
00154 void ShowURI (std::string& uri);
00155
00161 void OnBug (char const *uri = PACKAGE_BUGREPORT)
00162 {std::string s (uri); ShowURI (s);}
00163
00168 void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00169 {std::string s (uri); ShowURI (s);}
00170
00177 void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00178
00182 void OnLiveAssistance ();
00183
00188 GtkWidget *GetImageResolutionWidget ();
00189
00194 GtkWidget *GetImageSizeWidget ();
00195
00199 std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00200
00210 char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00211
00221 ContentType Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00222
00233 bool Save (std::string const &uri, const gchar *mime_type, Document const *Doc, ContentType type);
00234
00239 virtual Document *CreateNewDocument () {return NULL;}
00240
00245 static GOConfNode *GetConfDir ();
00246
00251 std::string const &GetIconName () {return IconName;}
00252
00260 void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00261
00268 void AddOptions (GOptionContext *context);
00272 static WindowState GetDefaultWindowState () {return DefaultWindowState;}
00277 static Application *GetDefaultApplication ();
00278 static Application *GetApplication (char const *name);
00279 static Application *GetApplication (std::string &name);
00280
00281
00291 TypeId AddType (std::string TypeName, Object* (*CreateFunc) (), TypeId id = OtherType);
00292
00303 Object* CreateObject (const std::string& TypeName, Object* parent = NULL);
00304
00315 bool BuildObjectContextualMenu (Object *target, GtkUIManager *UIManager, Object *object, double x, double y);
00323 void AddRule (TypeId type1, RuleId rule, TypeId type2);
00331 void AddRule (const std::string& type1, RuleId rule, const std::string& type2);
00338 const std::set<TypeId>& GetRules (TypeId type, RuleId rule);
00339
00346 const std::set<TypeId>& GetRules (const std::string& type, RuleId rule);
00347
00355 void SetCreationLabel (TypeId Id, std::string Label);
00356
00362 const std::string& GetCreationLabel (TypeId Id);
00363
00369 const std::string& GetCreationLabel (const std::string& TypeName);
00370
00377 void AddMenuCallback (TypeId Id, BuildMenuCb cb);
00378
00379 TypeDesc const *GetTypeDescription (TypeId Id);
00380
00381 protected:
00382
00388 virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00389
00390 private:
00391 void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00392 void RemoveDocument (Document *Doc);
00393
00394 private:
00395 std::string Name;
00396 std::string HelpName;
00397 std::string HelpBrowser;
00398 std::string HelpFilename;
00399 std::string CurDir;
00400 std::string IconName;
00401 static GOConfNode *m_ConfDir;
00402 std::list<option_data> m_Options;
00403 static WindowState DefaultWindowState;
00404 std::map<TypeId, TypeDesc> m_Types;
00405
00406 protected:
00410 std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00411
00418 GCU_PROT_PROP (std::set <Document*>, Docs)
00422 GCU_RO_PROP (unsigned, ScreenResolution)
00436 GCU_PROP (unsigned, ImageResolution)
00450 GCU_PROP (unsigned, ImageWidth)
00464 GCU_PROP (unsigned, ImageHeight)
00476 GCU_PROP (bool, TransparentBackground)
00480 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00481 };
00482
00483 }
00484
00485 #endif // GCU_APPLICATION_H