2 * vim:ts=4:sw=4:et:cindent:cino=(0
6 #include <glib/gi18n-lib.h>
8 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
10 #include <hildon/hildon-note.h>
11 #include <hildon/hildon-pannable-area.h>
12 #include <hildon/hildon-defines.h>
14 #include "tweakr-types.h"
15 #include "libtweakr-section/tweakr-section.h"
16 #include "tweakr-module-manager.h"
18 static gboolean save_ret;
20 GtkWidget *create_dialog (GtkWindow *parent)
24 dialog = gtk_dialog_new_with_buttons
27 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
37 void _save (TweakrSection *section, gboolean *requires_restart)
39 save_ret &= tweakr_section_save (section, requires_restart);
42 osso_return_t execute (osso_context_t *osso, gpointer data,
43 gboolean user_activated)
50 TweakrModuleManager *manager;
53 GList *sections = NULL;
55 gboolean requires_restart = FALSE;
57 manager = g_object_new (TWEAKR_TYPE_MODULE_MANAGER,
58 "module-path", MODULES_DIR,
61 section_types = g_type_children (TWEAKR_TYPE_SECTION, &n_sections);
63 dialog = create_dialog (GTK_WINDOW (data));
64 panarea = hildon_pannable_area_new ();
65 box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
67 hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (panarea),
69 g_object_set (G_OBJECT (panarea), "height-request", 350, NULL);
71 for (i = 0; i < n_sections; i++)
73 TweakrSection *section;
74 TweakrSectionClass *klass;
77 klass = g_type_class_ref (section_types[i]);
78 section = tweakr_section_new (section_types[i]);
80 sections = g_list_prepend (sections, section);
81 frame = gtk_frame_new (section->name);
83 gtk_box_pack_start (GTK_BOX (box),
86 gtk_container_add (GTK_CONTAINER (frame),
87 tweakr_section_get_widget (section));
89 g_type_class_unref (klass);
92 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), panarea,
94 gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
99 response = gtk_dialog_run (GTK_DIALOG (dialog));
100 if (response == GTK_RESPONSE_OK)
102 /* Save all settings */
103 g_list_foreach (sections, (GFunc) _save, &requires_restart);
109 gtk_widget_destroy (GTK_WIDGET (dialog));
110 g_object_unref (manager);
113 g_list_foreach (sections, (GFunc) g_object_unref, NULL);
114 g_list_free (sections);
117 if (requires_restart)
121 note = hildon_note_new_information
123 _("Some of the settings you have changed "
124 "will take effect only after you restart your device."));
125 gtk_dialog_run (GTK_DIALOG (note));
126 gtk_widget_destroy (note);