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>
10 #include "maemo-tweaks-types.h"
11 #include "libmaemo-tweaks-section/maemo-tweaks-section.h"
12 #include "maemo-tweaks-module-manager.h"
14 static gboolean save_ret;
16 GtkWidget *create_dialog (GtkWindow *parent)
20 dialog = gtk_dialog_new_with_buttons
23 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
33 void _save (MaemoTweaksSection *section, gboolean *requires_restart)
35 save_ret &= maemo_tweaks_section_save (section, requires_restart);
38 osso_return_t execute (osso_context_t *osso, gpointer data,
39 gboolean user_activated)
46 MaemoTweaksModuleManager *manager;
49 GList *sections = NULL;
51 gboolean requires_restart = FALSE;
53 manager = g_object_new (MAEMO_TWEAKS_TYPE_MODULE_MANAGER,
54 "module-path", MODULES_DIR,
57 section_types = g_type_children (MAEMO_TWEAKS_TYPE_SECTION, &n_sections);
59 dialog = create_dialog (GTK_WINDOW (data));
60 panarea = hildon_pannable_area_new ();
61 box = gtk_vbox_new (FALSE, 0);
63 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (panarea),
65 g_object_set (G_OBJECT (panarea), "height-request", 350, NULL);
67 for (i = 0; i < n_sections; i++)
69 MaemoTweaksSection *section;
70 MaemoTweaksSectionClass *klass;
72 klass = g_type_class_ref (section_types[i]);
73 section = maemo_tweaks_section_new (section_types[i]);
75 sections = g_list_prepend (sections, section);
76 gtk_box_pack_start (GTK_BOX (box),
77 gtk_label_new (section->name),
79 gtk_box_pack_start (GTK_BOX (box),
80 maemo_tweaks_section_get_widget (section),
83 g_type_class_unref (klass);
86 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), panarea,
88 gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
93 response = gtk_dialog_run (GTK_DIALOG (dialog));
94 if (response == GTK_RESPONSE_OK)
96 /* Save all settings */
97 g_list_foreach (sections, (GFunc) _save, &requires_restart);
103 gtk_widget_destroy (GTK_WIDGET (dialog));
104 g_object_unref (manager);
107 g_list_foreach (sections, (GFunc) g_object_unref, NULL);
108 g_list_free (sections);
111 if (requires_restart)
115 note = hildon_note_new_information
116 (GTK_WINDOW (data), "Some of the settings you have changed"
117 " will take effect only after you restart your device.");
118 gtk_dialog_run (GTK_DIALOG (note));
119 gtk_widget_destroy (note);