f274aa16704a9f68e33e8c05984ac73b8e7a43fa
[tweakr] / modules / maemo-tweaks-desktop.c
1 /*
2  * vim:ts=4:sw=4:et:cindent:cino=(0
3  */ 
4
5 #include <config.h>
6
7 #include <gtk/gtk.h>
8 #include <hildon/hildon-picker-button.h>
9 #include <hildon/hildon-touch-selector.h>
10
11 #include "libmaemo-tweaks-section/maemo-tweaks-section.h"
12 #include "libmaemo-tweaks-section/maemo-tweaks-module.h"
13
14
15 #define MAEMO_TWEAKS_TYPE_DESKTOP_SECTION \
16         (maemo_tweaks_desktop_section_type)
17 #define MAEMO_TWEAKS_DESKTOP_SECTION(obj) \
18         (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
19         MAEMO_TWEAKS_TYPE_DESKTOP_SECTION, \
20         MaemoTweaksDesktopSection))
21 #define MAEMO_TWEAKS_DESKTOP_SECTION_CLASS(k) \
22         (G_TYPE_CHECK_CLASS_CAST((k), \
23         MAEMO_TWEAKS_TYPE_DESKTOP_SECTION, \
24         MaemoTweaksDesktopSectionClass))
25 #define MAEMO_TWEAKS_IS_DESKTOP_SECTION(obj) \
26         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
27         MAEMO_TWEAKS_TYPE_DESKTOP_SECTION))
28
29
30 typedef struct _MaemoTweaksDesktopSection MaemoTweaksDesktopSection;
31 typedef struct _MaemoTweaksDesktopSectionClass
32                MaemoTweaksDesktopSectionClass;
33
34 struct _MaemoTweaksDesktopSection
35 {
36     MaemoTweaksSection parent_instance;
37 };
38
39 struct _MaemoTweaksDesktopSectionClass
40 {
41     MaemoTweaksSectionClass parent_class;
42 };
43
44
45 static GType maemo_tweaks_desktop_section_get_type (GTypeModule *module);
46 static void maemo_tweaks_desktop_section_class_init
47     (MaemoTweaksDesktopSectionClass *class);
48 static void maemo_tweaks_desktop_section_init
49     (MaemoTweaksDesktopSection *section);
50
51 static void maemo_tweaks_desktop_section_build (MaemoTweaksSection *section);
52
53 static GType maemo_tweaks_desktop_section_type = 0;
54 static MaemoTweaksSectionClass *
55     maemo_tweaks_desktop_section_parent_class = NULL;
56
57
58 G_MODULE_EXPORT void
59 maemo_tweaks_module_load (MaemoTweaksModule *module)
60 {
61     maemo_tweaks_desktop_section_get_type (G_TYPE_MODULE (module));
62 }
63
64 G_MODULE_EXPORT void
65 maemo_tweaks_module_unload (MaemoTweaksModule *module)
66 {
67 }
68
69 static GType
70 maemo_tweaks_desktop_section_get_type (GTypeModule *module)
71 {
72     if (!maemo_tweaks_desktop_section_type)
73     {
74         static const GTypeInfo section_info =
75         {
76             sizeof (MaemoTweaksDesktopSectionClass),
77             (GBaseInitFunc) NULL,
78             (GBaseFinalizeFunc) NULL,
79             (GClassInitFunc) maemo_tweaks_desktop_section_class_init,
80             NULL,           /* class_finalize */
81             NULL,           /* class_data     */
82             sizeof (MaemoTweaksDesktopSection),
83             0,              /* n_preallocs    */
84             (GInstanceInitFunc) maemo_tweaks_desktop_section_init
85         };
86
87         maemo_tweaks_desktop_section_type =
88             g_type_module_register_type (module, MAEMO_TWEAKS_TYPE_SECTION,
89                                          "MaemoTweaksDesktopSection",
90                                          &section_info, 0);
91     }
92
93     return maemo_tweaks_desktop_section_type;
94 }
95
96 static void
97 maemo_tweaks_desktop_section_class_init
98     (MaemoTweaksDesktopSectionClass *klass)
99 {
100     MaemoTweaksSectionClass *section_class =
101         MAEMO_TWEAKS_SECTION_CLASS (klass);
102
103     maemo_tweaks_desktop_section_parent_class =
104         g_type_class_peek_parent (klass);
105
106     section_class->name   = "_Desktop";
107     section_class->build = maemo_tweaks_desktop_section_build;
108 }
109
110 static void
111 maemo_tweaks_desktop_section_init (MaemoTweaksDesktopSection *section)
112 {
113 }
114
115 GtkWidget * _build_snap_to_grid (void)
116 {
117     const gchar *options[] = {"Default", "Small grid", "Large grid", NULL};
118     gint i = 0;
119     GtkWidget *button, *selector;
120
121     selector = hildon_touch_selector_new_text ();
122     while (options[i] && options[i] != '\0')
123     {
124         hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
125                                            options [i++]);
126     }
127
128     button = hildon_picker_button_new (HILDON_SIZE_AUTO,
129                                        HILDON_BUTTON_ARRANGEMENT_VERTICAL);
130
131     hildon_button_set_title (HILDON_BUTTON (button),
132                              "Snap desktop icons to grid");
133
134     hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
135                                        HILDON_TOUCH_SELECTOR (selector));
136
137     gtk_widget_show (button);
138     return button;
139 }
140
141 static void
142 maemo_tweaks_desktop_section_build (MaemoTweaksSection *section)
143 {
144 }
145