BasicItem:
[simple-launcher] / dialog-entry.cc
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 #include <gtk/gtkcheckbutton.h>
19 #include <gtk/gtkcombobox.h>
20
21 #include "dialog-entry.h"
22
23 SettingsDialogBooleanEntry::SettingsDialogBooleanEntry(GConfBooleanOption& option, const std::string& name): SettingsDialogEntry(option, name) {
24         myWidget = gtk_check_button_new();
25
26         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(myWidget), option.value());
27 }
28
29 void SettingsDialogBooleanEntry::updateValue() {
30         ((GConfBooleanOption&)myOption).setValue(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(myWidget)));
31 }
32
33 SettingsDialogIntegerEntry::SettingsDialogIntegerEntry(GConfIntegerOption& option, const std::string& name, int minValue, int maxValue): SettingsDialogEntry(option, name) {
34         mySpinBox = HILDON_NUMBER_EDITOR(hildon_number_editor_new(minValue, maxValue));
35         hildon_number_editor_set_value(mySpinBox, option.value());
36 }
37
38 void SettingsDialogIntegerEntry::updateValue() {
39         ((GConfIntegerOption&)myOption).setValue(hildon_number_editor_get_value(mySpinBox));
40 }
41
42 #if 0
43 SettingsDialogChoiceEntry::SettingsDialogChoiceEntry(GConfIntegerOption& option, const std::string& name): SettingsDialogEntry(option, name) {
44         myWidget = gtk_combo_box_new_text();
45 }
46 #endif
47
48 ///
49
50 static struct {
51         int value;
52         const char *name;
53 } IconSizes[] = {
54         { 26, "Extra Small (26)" },
55         { 32, "Small (32)" },
56         { 48, "Medium (48)" },
57         { 54, "Large (54)" },
58         { 64, "Extra Large (64)" },
59         { -1, NULL }
60 };
61
62 SettingsDialogIconSizeEntry::SettingsDialogIconSizeEntry(GConfIntegerOption& option, const std::string& name): SettingsDialogEntry(option, name) {
63         myWidget = gtk_combo_box_new_text();
64
65         int active = -1;
66
67         for (int i = 0; IconSizes[i].value != -1; ++i) {
68                 gtk_combo_box_append_text(GTK_COMBO_BOX(myWidget), IconSizes[i].name);
69
70                 if (IconSizes[i].value == option.value()) {
71                         active = i;
72                 }
73         }
74
75         if (active != -1) {
76                 gtk_combo_box_set_active(GTK_COMBO_BOX(myWidget), active);
77         }
78 }
79
80 void SettingsDialogIconSizeEntry::updateValue() {
81         gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(myWidget));
82
83         if (index != -1) {
84                 ((GConfIntegerOption&)myOption).setValue(IconSizes[index].value);
85         }
86 }
87
88 ///