gcu/application.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gcu/application.h
00006  *
00007  * Copyright (C) 2005-2007 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 #include <goffice/app/go-conf.h>
00034 #endif
00035 #include <gtk/gtkmain.h>
00036 #include <gtk/gtkwindow.h>
00037 #include <gtk/gtkrecentmanager.h>
00038 #include <gcu/macros.h>
00039 
00040 namespace gcu {
00041 
00042 class Document;
00043 class Dialog;
00044 
00045 #define GCU_CONF_DIR "gchemutils"
00046 
00050 class Application: public DialogOwner
00051 {
00052 friend class Document;
00053 friend class Dialog;
00054 public:
00066         Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00067         virtual ~Application ();
00068 
00077         void OnHelp (std::string s = "");
00081         bool HasHelp ();
00085         std::string &GetName () {return Name;}
00086 
00090         virtual GtkWindow * GetWindow () {return NULL;}
00091 
00105         virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00106                 {return false;}
00107 
00111         char const* GetCurDir () {return CurDir.c_str ();}
00112 
00116         void SetCurDir (char const* dir);
00117 
00121         void SetCurDir (std::string const &dir);
00122 
00128         void ShowURI (std::string& uri);
00129 
00135         void OnBug (char const *uri = PACKAGE_BUGREPORT)
00136                 {std::string s (uri); ShowURI (s);}
00137 
00142         void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00143                 {std::string s (uri); ShowURI (s);}
00144 
00151         void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00152 
00156         bool HasMailAgent () {return MailAgent.length () > 0;}
00157 
00161         bool HasWebBrowser () {return WebBrowser.length () > 0;}
00162 
00167         GtkWidget *GetImageResolutionWidget ();
00168 
00173         GtkWidget *GetImageSizeWidget ();
00174 
00178         std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00179 
00189         char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00190         bool Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00191         bool Save (std::string const &uri, const gchar *mime_type, Document* Doc);
00192         virtual Document *CreateNewDocument () {return NULL;}
00193 #ifdef HAVE_GO_CONF_SYNC
00194         static GOConfNode *GetConfDir ();
00195 #endif
00196 
00197 protected:
00198 
00204         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00205 
00206 private:
00207         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00208         void RemoveDocument (Document *Doc);
00209 
00210 private:
00211         std::string Name;
00212         std::string HelpName;
00213         std::string HelpBrowser;
00214         std::string HelpFilename;
00215         std::string CurDir;
00216         std::string WebBrowser;
00217         std::string MailAgent;
00218 #ifdef HAVE_GO_CONF_SYNC
00219         static GOConfNode *m_ConfDir;
00220 #endif
00221 
00222 protected:
00226         std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;       
00227 
00234 GCU_PROT_PROP (std::set <Document*>, Docs)
00238 GCU_RO_PROP (unsigned, ScreenResolution)
00251 GCU_PROP (unsigned, ImageResolution)
00264 GCU_PROP (unsigned, ImageWidth)
00277 GCU_PROP (unsigned, ImageHeight)
00281 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00282 };
00283 
00284 }       // namespace gcu
00285 
00286 #endif // GCU_APPLICATION_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6