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>
9 #include "maemo-tweaks-types.h"
10 #include "libmaemo-tweaks-section/maemo-tweaks-section.h"
11 #include "maemo-tweaks-module-manager.h"
13 static gboolean save_ret;
15 GtkWidget *create_dialog (GtkWindow *parent)
19 dialog = gtk_dialog_new_with_buttons
22 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
32 void _save (MaemoTweaksSection *section, gboolean *requires_restart)
34 save_ret &= maemo_tweaks_section_save (section, requires_restart);
37 osso_return_t execute (osso_context_t *osso, gpointer data,
38 gboolean user_activated)
43 MaemoTweaksModuleManager *manager;
46 GList *sections = NULL;
48 gboolean requires_restart = FALSE;
50 manager = g_object_new (MAEMO_TWEAKS_TYPE_MODULE_MANAGER,
51 "module-path", MODULES_DIR,
54 section_types = g_type_children (MAEMO_TWEAKS_TYPE_SECTION, &n_sections);
56 dialog = create_dialog (GTK_WINDOW (data));
58 for (i = 0; i < n_sections; i++)
60 MaemoTweaksSection *section;
61 MaemoTweaksSectionClass *klass;
63 klass = g_type_class_ref (section_types[i]);
64 section = maemo_tweaks_section_new (section_types[i]);
66 sections = g_list_prepend (sections, section);
67 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
68 maemo_tweaks_section_get_widget (section),
71 g_type_class_unref (klass);
74 gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
79 response = gtk_dialog_run (GTK_DIALOG (dialog));
80 if (response == GTK_RESPONSE_OK)
82 /* Save all settings */
83 g_list_foreach (sections, (GFunc) _save, &requires_restart);
89 gtk_widget_destroy (GTK_WIDGET (dialog));
90 g_object_unref (manager);
93 g_list_foreach (sections, (GFunc) g_object_unref, NULL);
94 g_list_free (sections);
101 note = hildon_note_new_information
102 (GTK_WINDOW (data), "Some of the settings you have changed"
103 " will take effect only after you restart your device.");
104 gtk_dialog_run (GTK_DIALOG (note));
105 gtk_widget_destroy (note);