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 "tweakr-types.h"
12 #include "libtweakr-section/tweakr-section.h"
13 #include "tweakr-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 (TweakrSection *section, gboolean *requires_restart)
36 save_ret &= tweakr_section_save (section, requires_restart);
39 osso_return_t execute (osso_context_t *osso, gpointer data,
40 gboolean user_activated)
47 TweakrModuleManager *manager;
50 GList *sections = NULL;
52 gboolean requires_restart = FALSE;
54 manager = g_object_new (TWEAKR_TYPE_MODULE_MANAGER,
55 "module-path", MODULES_DIR,
58 section_types = g_type_children (TWEAKR_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 TweakrSection *section;
71 TweakrSectionClass *klass;
74 klass = g_type_class_ref (section_types[i]);
75 section = tweakr_section_new (section_types[i]);
77 sections = g_list_prepend (sections, section);
78 frame = gtk_frame_new (section->name);
80 gtk_box_pack_start (GTK_BOX (box),
83 gtk_container_add (GTK_CONTAINER (frame),
84 tweakr_section_get_widget (section));
86 g_type_class_unref (klass);
89 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), panarea,
91 gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
96 response = gtk_dialog_run (GTK_DIALOG (dialog));
97 if (response == GTK_RESPONSE_OK)
99 /* Save all settings */
100 g_list_foreach (sections, (GFunc) _save, &requires_restart);
106 gtk_widget_destroy (GTK_WIDGET (dialog));
107 g_object_unref (manager);
110 g_list_foreach (sections, (GFunc) g_object_unref, NULL);
111 g_list_free (sections);
114 if (requires_restart)
118 note = hildon_note_new_information
119 (GTK_WINDOW (data), "Some of the settings you have changed"
120 " will take effect only after you restart your device.");
121 gtk_dialog_run (GTK_DIALOG (note));
122 gtk_widget_destroy (note);