# 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 using namespace std;
    00038
    00039 namespace gcu {
    00040
    00041 class Document;
    00042 class Dialog;
    00043
    00047 class Application: public DialogOwner
    00048 {
    00049 friend class Document;
    00050 friend class Dialog;
    00051 public:
    00063         Application (string name, string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
    00064         virtual ~Application ();
    00065
    00074         void OnHelp (string s = "");
    00078         bool HasHelp ();
    00082         string &GetName () {return Name;}
    00083
    00087         virtual GtkWindow * GetWindow () {return NULL;}
    00088
    00102         virtual bool FileProcess (const gchar* filename, const gchar* mime_type, bool bSave, GtkWindow *window, Document *pDoc = NULL)
    00103                 {return false;}
    00104
    00108         char const* GetCurDir () {return CurDir;}
    00109
    00113         void SetCurDir (char const* dir);
    00114
    00120         void ShowURI (string& uri);
    00121
    00127         void OnBug (char *uri = (char*) PACKAGE_BUGREPORT)
    00128                 {string s (uri); ShowURI (s);}
    00129
    00134         void OnWeb (char *uri = (char*) "http://gchemutils.nongnu.org/")
    00135                 {string s (uri); ShowURI (s);}
    00136
    00143         void OnMail (char *MailAddress = (char*) "mailto:gchemutils-main@nongnu.org");
    00144
    00148         bool HasMailAgent () {return MailAgent.length () > 0;}
    00149
    00153         bool HasWebBrowser () {return WebBrowser.length () > 0;}
    00154
    00159         GtkWidget *GetImageResolutionWidget ();
    00160
    00165         GtkWidget *GetImageSizeWidget ();
    00166
    00170         map<string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
    00171
    00181         char const *GetPixbufTypeName (string& filename, char const *mime_type);
    00182
    00183 protected:
    00184
    00190         virtual void NoMoreDocsEvent () {gtk_main_quit ();}
    00191
    00192 private:
    00193         void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
    00194         void RemoveDocument (Document *Doc);
    00195
    00196 private:
    00197         string Name;
    00198         string HelpName;
    00199         string HelpBrowser;
    00200         string HelpFilename;
    00201         char *CurDir;
    00202         string WebBrowser;
    00203         string MailAgent;
    00204
    00205 protected:
    00209         map<string, GdkPixbufFormat*> m_SupportedPixbufFormats;
    00210
    00217 GCU_PROT_PROP (set <Document*>, Docs)
    00221 GCU_RO_PROP (unsigned, ScreenResolution)
    00234 GCU_PROP (unsigned, ImageResolution)
    00247 GCU_PROP (unsigned, ImageWidth)
    00260 GCU_PROP (unsigned, ImageHeight)
    00264 GCU_RO_PROP (GtkRecentManager*, RecentManager)
    00265 };
    00266
    00267 }       // namespace gcu
    00268
    00269 #endif // GCU_APPLICATION_H