2 * vim:ts=4:sw=4:et:cindent:cino=(0
5 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
7 #include <hildon/hildon-note.h>
8 #include <hildon/hildon-pannable-area.h>
9 #include <hildon/hildon-defines.h>
11 #include "maemo-tweaks-types.h"
12 #include "libmaemo-tweaks-section/maemo-tweaks-section.h"
13 #include "maemo-tweaks-module-manager.h"
15 static gboolean save_ret;
17 GtkWidget *create_dialog (GtkWindow *parent)
21 dialog = gtk_dialog_new_with_buttons
24 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
34 void _save (MaemoTweaksSection *section, gboolean *requires_restart)
36 save_ret &= maemo_tweaks_section_save (section, requires_restart);
39 osso_return_t execute (osso_context_t *osso, gpointer data,
40 gboolean user_activated)
47 MaemoTweaksModuleManager *manager;
50 GList *sections = NULL;
52 gboolean requires_restart = FALSE;
54 manager = g_object_new (MAEMO_TWEAKS_TYPE_MODULE_MANAGER,
55 "module-path", MODULES_DIR,
58 section_types = g_type_children (MAEMO_TWEAKS_TYPE_SECTION, &n_sections);
60 dialog = create_dialog (GTK_WINDOW (data));
61 panarea = hildon_pannable_area_new ();
62 box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
64 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (panarea),
66 g_object_set (G_OBJECT (panarea), "height-request", 350, NULL);
68 for (i = 0; i < n_sections; i++)
70 MaemoTweaksSection *section;
71 MaemoTweaksSectionClass *klass;
73 klass = g_type_class_ref (section_types[i]);
74 section = maemo_tweaks_section_new (section_types[i]);
76 sections = g_list_prepend (sections, section);
77 gtk_box_pack_start (GTK_BOX (box),
78 gtk_label_new (section->name),
80 gtk_box_pack_start (GTK_BOX (box),
81 maemo_tweaks_section_get_widget (section),
84 g_type_class_unref (klass);
87 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), panarea,
89 gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
94 response = gtk_dialog_run (GTK_DIALOG (dialog));
95 if (response == GTK_RESPONSE_OK)
97 /* Save all settings */
98 g_list_foreach (sections, (GFunc) _save, &requires_restart);
104 gtk_widget_destroy (GTK_WIDGET (dialog));
105 g_object_unref (manager);
108 g_list_foreach (sections, (GFunc) g_object_unref, NULL);
109 g_list_free (sections);
112 if (requires_restart)
116 note = hildon_note_new_information
117 (GTK_WINDOW (data), "Some of the settings you have changed"
118 " will take effect only after you restart your device.");
119 gtk_dialog_run (GTK_DIALOG (note));
120 gtk_widget_destroy (note);