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 <set>
00029 #include <string>
00030 #include <gtk/gtkmain.h>
00031 #include <gtk/gtkwindow.h>
00032 
00033 using namespace std;
00034 
00035 namespace gcu {
00036 
00037 class Document;
00038 
00042 class Application
00043 {
00044 public:
00056         Application (string name, string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00057         virtual ~Application ();
00058 
00067         void OnHelp (string s = "");
00071         bool HasHelp ();
00075         string &GetName () {return Name;}
00076 
00080         virtual GtkWindow * GetWindow () {return NULL;}
00081 
00095         virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00096                 {return false;}
00097 
00101         char const* GetCurDir () {return CurDir;}
00102 
00106         void SetCurDir (char const* dir);
00107         void ShowURI (string& uri);
00108         void OnBug (char *uri = PACKAGE_BUGREPORT)
00109                 {string s (uri); ShowURI (s);}
00110         void OnWeb (char *uri = "http://gchemutils.nongnu.org/")
00111                 {string s (uri); ShowURI (s);}
00112         void OnMail (char *MailAddress = "mailto:gchemutils-main@nongnu.org");
00113         bool HasMailAgent () {return MailAgent.length () > 0;}
00114         bool HasWebBrowser () {return WebBrowser.length () > 0;}
00115         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00116         void RemoveDocument (Document *Doc) {m_Docs.erase (Doc); if (m_Docs.size () == 0) NoMoreDocsEvent ();}
00117         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00118         
00119 private:
00120         string Name;
00121         string HelpBrowser;
00122         string HelpFilename;
00123         char *CurDir;
00124 
00125 protected:
00126         string WebBrowser;
00127         string MailAgent;
00128         set <Document*> m_Docs;
00129 };
00130 
00131 }       // namespace gcu
00132 
00133 #endif // GCU_APPLICATION_H

Generated on Tue Aug 15 10:47:35 2006 for The Gnome Chemistry Utils by  doxygen 1.4.7