gcu/application.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gcu/application.h
00006  *
00007  * Copyright (C) 2005-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 GCU_APPLICATION_H
00026 #define GCU_APPLICATION_H
00027 
00028 #include "dialog-owner.h"
00029 #include <map>
00030 #include <set>
00031 #include <string>
00032 #ifdef HAVE_GO_CONF_SYNC
00033 #   ifdef GOFFICE_HAS_GLOBAL_HEADER
00034 #      include <goffice/goffice.h>
00035 #   else
00036 #      include <goffice/app/go-conf.h>
00037 #   endif
00038 #endif
00039 #include <gtk/gtkmain.h>
00040 #include <gtk/gtkwindow.h>
00041 #include <gtk/gtkrecentmanager.h>
00042 #include <gcu/macros.h>
00043 
00045 namespace gcu {
00046 
00047 class Document;
00048 class Dialog;
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 (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, 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         bool Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00204 
00214         bool Save (std::string const &uri, const gchar *mime_type, Document* Doc);
00215 
00220         virtual Document *CreateNewDocument () {return NULL;}
00221 
00222 #ifdef HAVE_GO_CONF_SYNC
00223 
00228         static GOConfNode *GetConfDir ();
00229 #endif
00230 
00231 protected:
00232 
00238         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00239 
00240 private:
00241         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00242         void RemoveDocument (Document *Doc);
00243 
00244 private:
00245         std::string Name;
00246         std::string HelpName;
00247         std::string HelpBrowser;
00248         std::string HelpFilename;
00249         std::string CurDir;
00250 #ifdef HAVE_GO_CONF_SYNC
00251         static GOConfNode *m_ConfDir;
00252 #endif
00253 
00254 protected:
00258         std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;       
00259 
00266 GCU_PROT_PROP (std::set <Document*>, Docs)
00270 GCU_RO_PROP (unsigned, ScreenResolution)
00284 GCU_PROP (unsigned, ImageResolution)
00298 GCU_PROP (unsigned, ImageWidth)
00312 GCU_PROP (unsigned, ImageHeight)
00316 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00317 };
00318 
00319 }       // namespace gcu
00320 
00321 #endif // GCU_APPLICATION_H

Generated on Mon Aug 31 20:43:14 2009 for The Gnome Chemistry Utils by  doxygen 1.6.1