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/macros.h>
00031 #include <gcu/object.h>
00032 #ifdef HAVE_GO_CONF_SYNC
00033 #include <goffice/app/go-conf.h>
00034 #else
00035 #include <gconf/gconf-client.h>
00036 #endif
00037 #include <set>
00038 #include <string>
00039 #include <map>
00040 #include <list>
00041
00049 namespace gcp {
00050
00055 typedef struct
00056 {
00060 char const *name;
00064 unsigned char const *data_24;
00065 } IconDesc;
00066
00067 class Target;
00068 class NewFileDlg;
00069 class Tool;
00070 class Document;
00071 struct option_data;
00072 typedef void (*BuildMenuCb) (GtkUIManager *UIManager);
00073
00080 class Application: public gcu::Application
00081 {
00082 public:
00086 Application ();
00090 virtual ~Application ();
00091
00103 void ActivateTool (const std::string& toolname, bool activate);
00104
00119 void ActivateWindowsActionWidget (const char *path, bool activate);
00123 virtual void ClearStatus ();
00129 virtual void SetStatusText (const char* text);
00134 virtual GtkWindow* GetWindow () = 0;
00138 Tool* GetActiveTool () {return m_pActiveTool;}
00142 gcp::Document* GetActiveDocument () {return m_pActiveDoc;}
00148 void SetActiveDocument (gcp::Document* pDoc) {m_pActiveDoc = pDoc;}
00153 Tool* GetTool (const std::string& name) {return m_Tools[name];}
00161 void SetTool (const std::string& toolname, Tool* tool) {m_Tools[toolname] = tool;}
00166 GtkWidget* GetToolItem(const std::string& name) {return ToolItems[name];}
00174 void SetToolItem (const std::string& name, GtkWidget* w) {ToolItems[name] = w;}
00180 void SetCurZ (int Z) {m_CurZ = Z;}
00184 int GetCurZ () {return m_CurZ;}
00188 void OnSaveAs ();
00200 bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, gcu::Document *pDoc = NULL);
00208 void SaveWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00216 void OpenWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00223 void SaveGcp (std::string const &filename, gcp::Document* pDoc);
00230 void OpenGcp (std::string const &filename, gcp::Document* pDoc);
00235 xmlDocPtr GetXmlDoc () {return XmlDoc;}
00239 void OnSaveAsImage ();
00243 bool HaveGhemical () {return m_Have_Ghemical;}
00247 bool HaveInChI () {return m_Have_InChI;}
00251 int GetDocsNumber () {return m_Docs.size ();}
00257 void Zoom (double zoom);
00303 void AddActions (GtkRadioActionEntry const *entries, int nb, char const *ui_description, IconDesc const *icons);
00311 void RegisterToolbar (char const *name, int index);
00317 void OnToolChanged (GtkAction *current);
00324 void AddTarget (Target *target);
00331 void DeleteTarget (Target *target);
00338 void NotifyIconification (bool iconified);
00346 void NotifyFocus (bool has_focus, Target *target = NULL);
00350 void CloseAll ();
00354 std::list<std::string> &GetSupportedMimeTypes () {return m_SupportedMimeTypes;}
00355 #ifdef HAVE_GO_CONF_SYNC
00356
00363 void OnConfigChanged (GOConfNode *node, gchar const *name);
00364 #else
00365
00373 void OnConfigChanged (GConfClient *client, guint cnxn_id, GConfEntry *entry);
00374 #endif
00375
00379 std::list<std::string> &GetExtensions(std::string &mime_type);
00380
00385 void OnThemeNamesChanged ();
00386
00392 void AddMenuCallback (BuildMenuCb cb);
00393
00400 void BuildMenu (GtkUIManager *manager);
00401
00409 void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00410
00417 void AddOptions (GOptionContext *context);
00418
00423 gcu::Document *CreateNewDocument ();
00424
00425
00433 virtual void OnFileNew (char const *Theme = NULL) = 0;
00434
00435 protected:
00440 void InitTools();
00445 void BuildTools ();
00451 void ShowTools (bool visible);
00452
00453 private:
00454 void TestSupportedType (char const *mime_type);
00455 void AddMimeType (std::list<std::string> &l, std::string const& mime_type);
00456
00457 protected:
00461 gcp::Document *m_pActiveDoc;
00465 Target *m_pActiveTarget;
00469 unsigned m_NumWindow;
00470
00471 private:
00472 int m_CurZ;
00473 std::map <std::string, GtkWidget*> ToolItems;
00474 std::map <std::string, GtkWidget*> Toolbars;
00475 std::map <std::string, Tool*> m_Tools;
00476 Tool* m_pActiveTool;
00477 static bool m_bInit;
00478 static bool m_Have_Ghemical;
00479 static bool m_Have_InChI;
00480 xmlDocPtr XmlDoc;
00481 GtkIconFactory *IconFactory;
00482 std::list<char const*> UiDescs;
00483 GtkRadioActionEntry* RadioActions;
00484 int m_entries;
00485 std::map<int, std::string> ToolbarNames;
00486 unsigned m_NumDoc;
00487 std::set<Target*> m_Targets;
00488 int visible_windows;
00489 std::list<std::string> m_SupportedMimeTypes;
00490 std::list<std::string> m_WriteableMimeTypes;
00491 #ifdef HAVE_GO_CONF_SYNC
00492 GOConfNode *m_ConfNode;
00493 #else
00494 GConfClient *m_ConfClient;
00495 #endif
00496 guint m_NotificationId;
00497 gcu::Object *m_Dummy;
00498 std::list<BuildMenuCb> m_MenuCbs;
00499 std::list<option_data> m_Options;
00500
00501 GCU_RO_POINTER_PROP (GtkStyle, Style)
00502 };
00503
00504 }
00505
00506 #endif //GCHEMPAINT_APPLICATION_H