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-2009 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 "structs.h"
00030 #include <map>
00031 #include <set>
00032 #include <string>
00033 #include <gcu/macros.h>
00034 
00036 namespace gcu {
00037 
00038 class Document;
00039 class Dialog;
00040 
00041 #define GCU_CONF_DIR "gchemutils"
00042 
00046 class Application: virtual public DialogOwner
00047 {
00048 friend class Document;
00049 friend class Dialog;
00050 public:
00062         Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
00066         virtual ~Application ();
00067 
00076         void OnHelp (std::string s = "");
00080         bool HasHelp ();
00084         std::string &GetName () {return Name;}
00085 
00089         virtual GtkWindow * GetWindow () {return NULL;}
00090 
00104         virtual bool FileProcess (G_GNUC_UNUSED const gchar* filename, G_GNUC_UNUSED const gchar* mime_type, G_GNUC_UNUSED bool bSave, G_GNUC_UNUSED GtkWindow *window, G_GNUC_UNUSED Document *pDoc = NULL)
00105                 {return false;}
00106 
00110         char const* GetCurDir () {return CurDir.c_str ();}
00111 
00115         void SetCurDir (char const* dir);
00116 
00120         void SetCurDir (std::string const &dir);
00121 
00127         void ShowURI (std::string& uri);
00128 
00134         void OnBug (char const *uri = PACKAGE_BUGREPORT)
00135                 {std::string s (uri); ShowURI (s);}
00136 
00141         void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
00142                 {std::string s (uri); ShowURI (s);}
00143 
00150         void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
00151 
00155         void OnLiveAssistance ();
00156 
00161         GtkWidget *GetImageResolutionWidget ();
00162 
00167         GtkWidget *GetImageSizeWidget ();
00168 
00172         std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
00173 
00183         char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
00184 
00194         ContentType Load (std::string const &uri, const gchar *mime_type, Document* Doc);
00195 
00206         bool Save (std::string const &uri, const gchar *mime_type, Document const *Doc, ContentType type);
00207 
00212         virtual Document *CreateNewDocument () {return NULL;}
00213 
00218         static GOConfNode *GetConfDir ();
00219 
00220         std::string const &GetIconName () {return IconName;}
00221 
00222 protected:
00223 
00229         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
00230 
00231 private:
00232         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
00233         void RemoveDocument (Document *Doc);
00234 
00235 private:
00236         std::string Name;
00237         std::string HelpName;
00238         std::string HelpBrowser;
00239         std::string HelpFilename;
00240         std::string CurDir;
00241         std::string IconName;
00242         static GOConfNode *m_ConfDir;
00243 
00244 protected:
00248         std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;       
00249 
00256 GCU_PROT_PROP (std::set <Document*>, Docs)
00260 GCU_RO_PROP (unsigned, ScreenResolution)
00274 GCU_PROP (unsigned, ImageResolution)
00288 GCU_PROP (unsigned, ImageWidth)
00302 GCU_PROP (unsigned, ImageHeight)
00314 GCU_PROP (bool, TransparentBackground)
00318 GCU_RO_PROP (GtkRecentManager*, RecentManager)
00319 };
00320 
00321 }       // namespace gcu
00322 
00323 #endif // GCU_APPLICATION_H

Generated on Thu Jun 25 13:24:19 2009 for The Gnome Chemistry Utils by  doxygen 1.5.9