root/trunk/src/Config.h

Revision 200, 3.7 kB (checked in by jordi, 2 years ago)

Added the option to save a copy of the currently loaded document.

Line 
1// ePDFView - A lightweight PDF Viewer.
2// Copyright (C) 2006 Emma's Software.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18#if !defined (__CONFIG_H__)
19#define __CONFIG_H__
20
21namespace ePDFView
22{
23    ///
24    /// @class Config
25    /// @brief Configuration.
26    ///
27    /// The configuration class tries to follow the singleton patter but with
28    /// a variation: the application can destroy the created instance by
29    /// calling Config::destroy(). This, along with the Config::loadFile()
30    /// function, are used almost only for testing.
31    ///
32    class Config
33    {
34        public:
35            static void destroy (void);
36            static Config &getConfig (void);
37            static void loadFile (gboolean load);
38
39            ~Config (void);
40
41            gchar *getExternalBrowserCommandLine (void);
42            gchar *getOpenFileFolder (void);
43            gchar *getSaveFileFolder (void);
44            gint getWindowHeight (void);
45            gint getWindowWidth (void);
46            gint getWindowX (void);
47            gint getWindowY (void);
48            gboolean showStatusbar (void);
49            gboolean showToolbar (void);
50            gboolean zoomToFit (void);
51            gboolean zoomToWidth (void);
52            void save(void);
53            void setExternalBrowserCommandLine (const gchar *commandLine);
54            void setOpenFileFolder (const gchar *folder);
55            void setSaveFileFolder (const gchar *folder);
56            void setShowStatusbar (gboolean show);
57            void setShowToolbar (gboolean show);
58            void setWindowSize (gint width, gint height);
59            void setWindowPos (gint x, gint y);
60            void setZoomToFit (gboolean active);
61            void setZoomToWidth (gboolean active);
62
63        protected:
64            /// The configuration values.
65            GKeyFile *m_Values;
66           
67            Config (void);
68
69            ///
70            /// @brief Constructs a Config object as a copy of another.
71            ///
72            /// This is defined as protected to prevent instantiate
73            /// a new Config object besides the one created when calling
74            /// Config::getConfig().
75            ///
76            /// @param config The Config object to copy.
77            ///
78            Config (Config &config) { }
79
80            /// The global configuration object that is returned by
81            /// ePDFView::Config::getConfig() function.
82            static Config *m_Config;
83            /// This is for test only purposes. If this variables is
84            /// set to false, the Config class doesn't load
85            /// the configuration values from the file and doesn't save
86            /// it when destroyed.
87            static gboolean m_LoadFile;
88
89            gboolean getBoolean (const gchar *group, const gchar *key,
90                                 gboolean defaultValue);
91            gint getInteger (const gchar *group, const gchar *key,
92                             gint defaultValue);
93            gchar *getString (const gchar *group, const gchar *key,
94                              const gchar *defaultValue);
95    };
96}
97
98#endif // !__CONFIG_H__
Note: See TracBrowser for help on using the browser.