gcp/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 GCHEMPAINT_APPLICATION_H
00026 #define GCHEMPAINT_APPLICATION_H
00027
00028 #include <gcu/application.h>
00029 #include <gcu/dialog.h>
00030 #include <gcu/object.h>
00031 #ifdef HAVE_GO_CONF_SYNC
00032 # ifdef GOFFICE_HAS_GLOBAL_HEADER
00033 # include <goffice/goffice.h>
00034 # else
00035 # include <goffice/app/go-conf.h>
00036 # endif
00037 #else
00038 # include <gconf/gconf-client.h>
00039 #endif
00040 #include <set>
00041 #include <string>
00042 #include <map>
00043 #include <list>
00044 #include <stdexcept>
00045
00053 namespace gcp {
00054
00059 typedef struct
00060 {
00064 char const *name;
00068 unsigned char const *data_24;
00069 } IconDesc;
00070
00071 class Target;
00072 class NewFileDlg;
00073 class Tool;
00074 class Document;
00075 struct option_data;
00076 typedef void (*BuildMenuCb) (GtkUIManager *UIManager);
00077
00084 class Application: public gcu::Application
00085 {
00086 public:
00090 Application ();
00094 virtual ~Application ();
00095
00107 void ActivateTool (const std::string& toolname, bool activate);
00108
00123 void ActivateWindowsActionWidget (const char *path, bool activate);
00127 virtual void ClearStatus ();
00133 virtual void SetStatusText (const char* text);
00138 virtual GtkWindow* GetWindow () = 0;
00142 Tool* GetActiveTool () {return m_pActiveTool;}
00146 gcp::Document* GetActiveDocument () {return m_pActiveDoc;}
00152 void SetActiveDocument (gcp::Document* pDoc) {m_pActiveDoc = pDoc;}
00157 Tool* GetTool (const std::string& name) {return m_Tools[name];}
00165 void SetTool (const std::string& toolname, Tool* tool) {m_Tools[toolname] = tool;}
00170 GtkWidget* GetToolItem(const std::string& name) {return ToolItems[name];}
00178 void SetToolItem (const std::string& name, GtkWidget* w) {ToolItems[name] = w;}
00184 void SetCurZ (int Z) {m_CurZ = Z;}
00188 int GetCurZ () {return m_CurZ;}
00192 void OnSaveAs ();
00204 bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, gcu::Document *pDoc = NULL);
00212 void SaveWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00220 void OpenWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00227 void SaveGcp (std::string const &filename, gcp::Document* pDoc);
00234 void OpenGcp (std::string const &filename, gcp::Document* pDoc);
00239 xmlDocPtr GetXmlDoc () {return XmlDoc;}
00243 void OnSaveAsImage ();
00247 bool HaveGhemical () {return m_Have_Ghemical;}
00251 bool HaveInChI () {return m_Have_InChI;}
00255 int GetDocsNumber () {return m_Docs.size ();}
00261 void Zoom (double zoom);
00307 void AddActions (GtkRadioActionEntry const *entries, int nb, char const *ui_description, IconDesc const *icons);
00315 void RegisterToolbar (char const *name, int index);
00321 void OnToolChanged (GtkAction *current);
00328 void AddTarget (Target *target);
00335 void DeleteTarget (Target *target);
00342 void NotifyIconification (bool iconified);
00350 void NotifyFocus (bool has_focus, Target *target = NULL);
00354 void CloseAll ();
00358 std::list<std::string> &GetSupportedMimeTypes () {return m_SupportedMimeTypes;}
00359 #ifdef HAVE_GO_CONF_SYNC
00360
00367 void OnConfigChanged (GOConfNode *node, gchar const *name);
00368 #else
00369
00377 void OnConfigChanged (GConfClient *client, guint cnxn_id, GConfEntry *entry);
00378 #endif
00379
00383 std::list<std::string> &GetExtensions(std::string &mime_type);
00384
00389 void OnThemeNamesChanged ();
00390
00396 void AddMenuCallback (BuildMenuCb cb);
00397
00404 void BuildMenu (GtkUIManager *manager);
00405
00413 void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00414
00421 void AddOptions (GOptionContext *context);
00422
00427 gcu::Document *CreateNewDocument ();
00428
00429
00437 virtual void OnFileNew (char const *Theme = NULL) = 0;
00438
00439 protected:
00444 void InitTools();
00449 void BuildTools () throw (std::runtime_error);
00455 void ShowTools (bool visible);
00456
00457 private:
00458 void TestSupportedType (char const *mime_type);
00459 void AddMimeType (std::list<std::string> &l, std::string const& mime_type);
00460
00461 protected:
00465 gcp::Document *m_pActiveDoc;
00469 Target *m_pActiveTarget;
00473 unsigned m_NumWindow;
00474
00475 private:
00476 int m_CurZ;
00477 std::map <std::string, GtkWidget*> ToolItems;
00478 std::map <std::string, GtkWidget*> Toolbars;
00479 std::map <std::string, Tool*> m_Tools;
00480 Tool* m_pActiveTool;
00481 static bool m_bInit;
00482 static bool m_Have_Ghemical;
00483 static bool m_Have_InChI;
00484 xmlDocPtr XmlDoc;
00485 GtkIconFactory *IconFactory;
00486 std::list<char const*> UiDescs;
00487 GtkRadioActionEntry* RadioActions;
00488 int m_entries;
00489 std::map<int, std::string> ToolbarNames;
00490 unsigned m_NumDoc;
00491 std::set<Target*> m_Targets;
00492 int visible_windows;
00493 std::list<std::string> m_SupportedMimeTypes;
00494 std::list<std::string> m_WriteableMimeTypes;
00495 #ifdef HAVE_GO_CONF_SYNC
00496 GOConfNode *m_ConfNode;
00497 #else
00498 GConfClient *m_ConfClient;
00499 #endif
00500 guint m_NotificationId;
00501 gcu::Object *m_Dummy;
00502 std::list<BuildMenuCb> m_MenuCbs;
00503 std::list<option_data> m_Options;
00504
00505 GCU_RO_POINTER_PROP (GtkStyle, Style)
00506 };
00507
00508 }
00509
00510 #endif //GCHEMPAINT_APPLICATION_H