The Gnome Chemistry Utils  0.12.11
gcu/application.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gcu/application.h
6  *
7  * Copyright (C) 2005-2010 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_APPLICATION_H
26 #define GCU_APPLICATION_H
27 
28 #include "dialog-owner.h"
29 #include "structs.h"
30 #include <list>
31 #include <map>
32 #include <set>
33 #include <string>
34 #include <gcu/macros.h>
35 
37 namespace gcu {
38 
39 class Document;
40 class Dialog;
41 struct option_data;
42 
46 typedef enum {
63 } WindowState;
64 
65 #define GCU_CONF_DIR "gchemutils"
66 
70 class Application: virtual public DialogOwner
71 {
72 friend class Document;
73 friend class Dialog;
74 friend class ApplicationPrivate;
75 public:
87  Application (std::string name, std::string datadir = DATADIR, char const *help_name = NULL, char const *icon_name = NULL);
91  virtual ~Application ();
92 
101  void OnHelp (std::string s = "");
105  bool HasHelp ();
109  std::string &GetName () {return Name;}
110 
114  virtual GtkWindow * GetWindow () {return NULL;}
115 
129  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)
130  {return false;}
131 
135  char const* GetCurDir () {return CurDir.c_str ();}
136 
140  void SetCurDir (char const* dir);
141 
145  void SetCurDir (std::string const &dir);
146 
152  void ShowURI (std::string& uri);
153 
159  void OnBug (char const *uri = PACKAGE_BUGREPORT)
160  {std::string s (uri); ShowURI (s);}
161 
166  void OnWeb (char const *uri = "http://gchemutils.nongnu.org/")
167  {std::string s (uri); ShowURI (s);}
168 
175  void OnMail (char const *MailAddress = "mailto:gchemutils-main@nongnu.org");
176 
180  void OnLiveAssistance ();
181 
186  GtkWidget *GetImageResolutionWidget ();
187 
192  GtkWidget *GetImageSizeWidget ();
193 
197  std::map<std::string, GdkPixbufFormat*> &GetSupportedPixbufFormats () {return m_SupportedPixbufFormats;}
198 
208  char const *GetPixbufTypeName (std::string& filename, char const *mime_type);
209 
219  ContentType Load (std::string const &uri, const gchar *mime_type, Document* Doc);
220 
231  bool Save (std::string const &uri, const gchar *mime_type, Document const *Doc, ContentType type);
232 
237  virtual Document *CreateNewDocument () {return NULL;}
238 
243  static GOConfNode *GetConfDir ();
244 
249  std::string const &GetIconName () {return IconName;}
250 
258  void RegisterOptions (GOptionEntry const *entries, char const *translation_domain = GETTEXT_PACKAGE);
259 
266  void AddOptions (GOptionContext *context);
270  static WindowState GetDefaultWindowState () {return DefaultWindowState;}
276 
277 protected:
278 
284  virtual void NoMoreDocsEvent () {gtk_main_quit ();}
285 
286 private:
287  void AddDocument (Document *Doc) {m_Docs.insert (Doc);}
288  void RemoveDocument (Document *Doc);
289 
290 private:
291  std::string Name;
292  std::string HelpName;
293  std::string HelpBrowser;
294  std::string HelpFilename;
295  std::string CurDir;
296  std::string IconName;
297  static GOConfNode *m_ConfDir;
298  std::list<option_data> m_Options;
299  static WindowState DefaultWindowState;
300 
301 protected:
305  std::map<std::string, GdkPixbufFormat*> m_SupportedPixbufFormats;
306 
313 GCU_PROT_PROP (std::set <Document*>, Docs)
317 GCU_RO_PROP (unsigned, ScreenResolution)
331 GCU_PROP (unsigned, ImageResolution)
345 GCU_PROP (unsigned, ImageWidth)
359 GCU_PROP (unsigned, ImageHeight)
371 GCU_PROP (bool, TransparentBackground)
375 GCU_RO_PROP (GtkRecentManager*, RecentManager)
376 };
377 
378 } // namespace gcu
379 
380 #endif // GCU_APPLICATION_H