Played with BasicItemFactory:
[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 #if 0
75 class SettingsDialogChoiceEntry : public SettingsDialogEntry {
76 public:
77   SettingsDialogChoiceEntry(GConfIntegerOption& option, const std::string& name);
78
79   virtual const std::string& text(int index) const = 0;
80   virtual int numberOfChoices() const = 0;
81   virtual int initialValue() const = 0;
82
83   void updateValue();
84   GtkWidget *getWidget() const { return myWidget; }
85
86 private:
87   GtkWidget *myWidget;
88 };
89
90 class SettingsDialogIconSizeEntry : public SettingsDialogChoiceEntry
91 #endif
92
93 class SettingsDialogIconSizeEntry : public SettingsDialogEntry {
94 public:
95   SettingsDialogIconSizeEntry(GConfIntegerOption& option, const std::string& name);
96
97   void updateValue();
98
99   GtkWidget *getWidget() const { return myWidget; }
100
101 private:
102   GtkWidget *myWidget;
103 };
104
105 #endif
106
107 // vim:ts=2:sw=2:et