5f13bd97439d8a3c727db5d263c76289f5e5913e
[simple-launcher] / dialog-entry.h
1 // This file is a part of Simple Launcher
2 //
3 // Copyright (C) 2006, 2007, Mikhail Sobolev
4 //
5 // Simple Launcher is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License version 2 as published by
7 // the Free Software Foundation.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12 // more details.
13 //
14 // You should have received a copy of the GNU General Public License along with
15 // this program; if not, write to the Free Software Foundation, Inc., 51
16 // Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 #ifndef _DIALOG_ENTRY_H_
19 #define _DIALOG_ENTRY_H_
20
21 #include <gtk/gtkwidget.h>
22
23 #include <hildon-widgets/hildon-number-editor.h>
24
25 #include "gconf-wrapper.h"
26
27 class SettingsDialogEntry {
28 public:
29         virtual ~SettingsDialogEntry() {}
30
31   const std::string& name() const { return myName; }
32   virtual GtkWidget *getWidget() const = 0;
33
34   virtual void updateValue() = 0;
35
36 protected:
37         SettingsDialogEntry(GConfOption& option, const std::string& name): myOption(option), myName(name) {}
38
39 protected:
40         GConfOption& myOption;
41         const std::string myName;
42 };
43
44 class SettingsDialogStringEntry : public SettingsDialogEntry {
45 public:
46   SettingsDialogStringEntry(GConfStringOption& option, const std::string& name): SettingsDialogEntry(option, name) {}
47
48   void updateValue();
49   GtkWidget *getWidget() const;
50 };
51
52 class SettingsDialogBooleanEntry : public SettingsDialogEntry {
53 public:
54   SettingsDialogBooleanEntry(GConfBooleanOption& option, const std::string& name);
55
56   void updateValue();
57   GtkWidget *getWidget() const { return myWidget; }
58
59 private:
60   GtkWidget *myWidget;
61 };
62
63 class SettingsDialogIntegerEntry : public SettingsDialogEntry {
64 public:
65   SettingsDialogIntegerEntry(GConfIntegerOption& option, const std::string& name, int minValue, int maxValue);
66
67   void updateValue();
68   GtkWidget *getWidget() const { return GTK_WIDGET(mySpinBox); }
69
70 private:
71   HildonNumberEditor *mySpinBox;
72 };
73
74 class SettingsDialogChoiceEntry : public SettingsDialogEntry {
75 public:
76   SettingsDialogChoiceEntry(GConfIntegerOption& option, const std::string& name);
77
78   virtual const std::string& text(int index) const = 0;
79   virtual int numberOfChoices() const = 0;
80   virtual int initialValue() const = 0;
81
82   void updateValue();
83   GtkWidget *getWidget() const { return myWidget; }
84
85 private:
86   GtkWidget *myWidget;
87 };
88
89 class SettingsDialogIconSizeEntry : public SettingsDialogChoiceEntry {
90   SettingsDialogIconSizeEntry(GConfIntegerOption& option, const std::string& name): SettingsDialogChoiceEntry(option, name) {}
91
92   const std::string& text(int index) const;
93   int numberOfChoices() const;
94   int initialValue() const;
95 };
96
97 #endif
98
99 // vim:ts=2:sw=2:et