gcp/application.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * application.h 
00006  *
00007  * Copyright (C) 2004-2008 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
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 #include <goffice/app/go-conf.h>
00033 #else
00034 #include <gconf/gconf-client.h>
00035 #endif
00036 #include <set>
00037 #include <string>
00038 #include <map>
00039 #include <list>
00040 
00048 namespace gcp {
00049 
00054 typedef struct
00055 {
00059         char const *name;
00063         unsigned char const *data_24;
00064 } IconDesc;
00065 
00066 class Target;
00067 class NewFileDlg;
00068 class Tool;
00069 class Document;
00070 struct option_data;
00071 typedef void (*BuildMenuCb) (GtkUIManager *UIManager);
00072 
00079 class Application: public gcu::Application
00080 {
00081 public:
00085         Application ();
00089         virtual ~Application ();
00090 
00102         void ActivateTool (const std::string& toolname, bool activate);
00103 
00118         void ActivateWindowsActionWidget (const char *path, bool activate);
00122         virtual void ClearStatus ();
00128         virtual void SetStatusText (const char* text);
00133         virtual GtkWindow* GetWindow () = 0;
00137         Tool* GetActiveTool () {return m_pActiveTool;}
00141         gcp::Document* GetActiveDocument () {return m_pActiveDoc;}
00147         void SetActiveDocument (gcp::Document* pDoc) {m_pActiveDoc = pDoc;}
00152         Tool* GetTool (const std::string& name) {return m_Tools[name];}
00160         void SetTool (const std::string& toolname, Tool* tool) {m_Tools[toolname] = tool;}
00165         GtkWidget* GetToolItem(const std::string& name) {return ToolItems[name];}
00173         void SetToolItem (const std::string& name, GtkWidget* w) {ToolItems[name] = w;}
00179         void SetCurZ (int Z) {m_CurZ = Z;}
00183         int GetCurZ () {return m_CurZ;}
00187         void OnSaveAs ();
00199         bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, gcu::Document *pDoc = NULL);
00207         void SaveWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00215         void OpenWithBabel (std::string const &filename, const gchar *mime_type, gcp::Document* pDoc);
00222         void SaveGcp (std::string const &filename, gcp::Document* pDoc);
00229         void OpenGcp (std::string const &filename, gcp::Document* pDoc);
00234         xmlDocPtr GetXmlDoc () {return XmlDoc;}
00238         void OnSaveAsImage ();
00242         bool HaveGhemical () {return m_Have_Ghemical;}
00246         bool HaveInChI () {return m_Have_InChI;}
00250         int GetDocsNumber () {return m_Docs.size ();}
00256         void Zoom (double zoom);
00302         void AddActions (GtkRadioActionEntry const *entries, int nb, char const *ui_description, IconDesc const *icons);
00310         void RegisterToolbar (char const *name, int index);
00316         void OnToolChanged (GtkAction *current);
00323         void AddTarget (Target *target);
00330         void DeleteTarget (Target *target);
00337         void NotifyIconification (bool iconified);
00345         void NotifyFocus (bool has_focus, Target *target = NULL);
00349         void CloseAll ();
00353         std::list<std::string> &GetSupportedMimeTypes () {return m_SupportedMimeTypes;}
00354 #ifdef HAVE_GO_CONF_SYNC
00355 
00362         void OnConfigChanged (GOConfNode *node, gchar const *name);
00363 #else
00364 
00372         void OnConfigChanged (GConfClient *client, guint cnxn_id, GConfEntry *entry);
00373 #endif
00374 
00378         std::list<std::string> &GetExtensions(std::string &mime_type);
00379 
00384         void OnThemeNamesChanged ();
00385 
00391         void AddMenuCallback (BuildMenuCb cb);
00392 
00399         void BuildMenu (GtkUIManager *manager);
00400 
00408         void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
00409 
00416         void AddOptions (GOptionContext *context);
00417 
00422         gcu::Document *CreateNewDocument ();
00423 
00424         // virtual menus actions:
00432         virtual void OnFileNew (char const *Theme = NULL) = 0;
00433 
00434 protected:
00439         void InitTools();
00444         void BuildTools ();
00450         void ShowTools (bool visible);
00451 
00452 private:
00453         void TestSupportedType (char const *mime_type);
00454         void AddMimeType (std::list<std::string> &l, std::string const& mime_type);
00455 
00456 protected:
00460         gcp::Document *m_pActiveDoc;
00464         Target *m_pActiveTarget;
00468         unsigned m_NumWindow; //used for new files (Untitled%d)
00469 
00470 private:
00471         int m_CurZ;
00472         std::map <std::string, GtkWidget*> ToolItems;
00473         std::map <std::string, GtkWidget*> Toolbars;
00474         std::map <std::string, Tool*> m_Tools;
00475         Tool* m_pActiveTool;
00476         static bool m_bInit;
00477         static bool m_Have_Ghemical;
00478         static bool m_Have_InChI;
00479         xmlDocPtr XmlDoc;
00480         GtkIconFactory *IconFactory;
00481         std::list<char const*> UiDescs;
00482         GtkRadioActionEntry* RadioActions;
00483         int m_entries;
00484         std::map<int, std::string> ToolbarNames;
00485         unsigned m_NumDoc; //used to build the name of the action associated with the menu
00486         std::set<Target*> m_Targets;
00487         int visible_windows;
00488         std::list<std::string> m_SupportedMimeTypes;
00489         std::list<std::string> m_WriteableMimeTypes;
00490 #ifdef HAVE_GO_CONF_SYNC
00491         GOConfNode *m_ConfNode;
00492 #else
00493         GConfClient *m_ConfClient;
00494 #endif
00495         guint m_NotificationId;
00496         gcu::Object *m_Dummy;
00497         std::list<BuildMenuCb> m_MenuCbs;
00498         std::list<option_data> m_Options;
00499 
00500 GCU_RO_POINTER_PROP     (GtkStyle, Style)
00501 };
00502 
00503 }       // namespace gcp
00504 
00505 #endif //GCHEMPAINT_APPLICATION_H

Generated on Mon Jan 5 20:27:52 2009 for The Gnome Chemistry Utils by  doxygen 1.5.6