application.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gcu/application.h
00006  *
00007  * Copyright (C) 2005-2006 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 <map>
00029 #include <set>
00030 #include <string>
00031 #include <gtk/gtkmain.h>
00032 #include <gtk/gtkwindow.h>
00033 #include <gtk/gtkrecentmanager.h>
00034 #include <gcu/macros.h>
00035 
00036 using namespace std;
00037 
00038 namespace gcu {
00039 
00040 class Document;
00041 
00045 class Application
00046 {
00047 public:
00059         Application (string name, string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00060         virtual ~Application ();
00061 
00070         void OnHelp (string s = "");
00074         bool HasHelp ();
00078         string &GetName () {return Name;}
00079 
00083         virtual GtkWindow * GetWindow () {return NULL;}
00084 
00098         virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00099                 {return false;}
00100 
00104         char const* GetCurDir () {return CurDir;}
00105 
00109         void SetCurDir (char const* dir);
00110         void ShowURI (string& uri);
00111         void OnBug (char *uri = PACKAGE_BUGREPORT)
00112                 {string s (uri); ShowURI (s);}
00113         void OnWeb (char *uri = "http://gchemutils.nongnu.org/")
00114                 {string s (uri); ShowURI (s);}
00115         void OnMail (char *MailAddress = "mailto:gchemutils-main@nongnu.org");
00116         bool HasMailAgent () {return MailAgent.length () > 0;}
00117         bool HasWebBrowser () {return WebBrowser.length () > 0;}
00118         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00119         void RemoveDocument (Document *Doc) {m_Docs.erase (Doc); if (m_Docs.size () == 0) NoMoreDocsEvent ();}
00120         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00121         GtkWidget *GetImageResolutionWidget ();
00122         map<string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00123         char const *GetPixbufTypeName (string& filename, char const *mime_type);
00124 
00125 private:
00126         string Name;
00127         string HelpBrowser;
00128         string HelpFilename;
00129         char *CurDir;
00130 
00131 protected:
00132         string WebBrowser;
00133         string MailAgent;
00134         set <Document*> m_Docs;
00135         map<string, GdkPixbufFormat*> m_SupportedPixbufFormats;
00136 
00137 GCU_RO_PROP (unsigned, ScreenResolution);
00138 GCU_PROP (unsigned, ImageResolution);
00139 GCU_RO_PROP (GtkRecentManager*, RecentManager);
00140 };
00141 
00142 }       // namespace gcu
00143 
00144 #endif // GCU_APPLICATION_H

Generated on Sun Nov 26 11:43:07 2006 for The Gnome Chemistry Utils by  doxygen 1.5.1