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 #include <gtk/gtkmain.h>
00033 #include <gtk/gtkwindow.h>
00034 #include <gtk/gtkrecentmanager.h>
00035 #include <gcu/macros.h>
00036 
00037 namespace gcu {
00038 
00039 class Document;
00040 class Dialog;
00041 
00045 class Application: public DialogOwner
00046 {
00047 friend class Document;
00048 friend class Dialog;
00049 public:
00061         Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00062         virtual ~Application ();
00063 
00072         void OnHelp (std::string s = "");
00076         bool HasHelp ();
00080         std::string &GetName () {return Name;}
00081 
00085         virtual GtkWindow * GetWindow () {return NULL;}
00086 
00100         virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
00101                 {return false;}
00102 
00106         char const* GetCurDir () {return CurDir.c_str ();}
00107 
00111         void SetCurDir (char const* dir);
00112 
00116         void SetCurDir (std::string const &dir);
00117 
00123         void ShowURI (std::string& uri);
00124 
00130         void OnBug (char const *uri = PACKAGE_BUGREPORT)
00131                 {std::string s (uri); ShowURI (s);}
00132 
00137         void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00138                 {std::string s (uri); ShowURI (s);}
00139 
00146         void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00147 
00151         bool HasMailAgent () {return MailAgent.length () > 0;}
00152 
00156         bool HasWebBrowser () {return WebBrowser.length () > 0;}
00157 
00162         GtkWidget *GetImageResolutionWidget ();
00163 
00168         GtkWidget *GetImageSizeWidget ();
00169 
00173         std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00174 
00184         char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00185 
00186 protected:
00187 
00193         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00194 
00195 private:
00196         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00197         void RemoveDocument (Document *Doc);
00198 
00199 private:
00200         std::string Name;
00201         std::string HelpName;
00202         std::string HelpBrowser;
00203         std::string HelpFilename;
00204         std::string CurDir;
00205         std::string WebBrowser;
00206         std::string MailAgent;
00207 
00208 protected:
00212         std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;       
00213 
00220 GCU_PROT_PROP (std::set <Document*>, Docs)
00224 GCU_RO_PROP (unsigned, ScreenResolution)
00237 GCU_PROP (unsigned, ImageResolution)
00250 GCU_PROP (unsigned, ImageWidth)
00263 GCU_PROP (unsigned, ImageHeight)
00267 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00268 };
00269 
00270 }       // namespace gcu
00271 
00272 #endif // GCU_APPLICATION_H

Generated on Thu Dec 20 11:20:45 2007 for The Gnome Chemistry Utils by  doxygen 1.5.4