Introduce 'requires restart.'
authorSalvatore Iovene <salvatore@iovene.com>
Wed, 9 Dec 2009 05:44:52 +0000 (07:44 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Wed, 9 Dec 2009 05:44:52 +0000 (07:44 +0200)
libmaemo-tweaks-section/maemo-tweaks-section.c
libmaemo-tweaks-section/maemo-tweaks-section.h
maemo-tweaks.c
modules/maemo-tweaks-desktop.c
modules/maemo-tweaks-mce.c

index 1f87b2c..336b16b 100644 (file)
@@ -39,12 +39,14 @@ maemo_tweaks_section_get_widget (MaemoTweaksSection *section)
 }
 
 void
-maemo_tweaks_section_save (MaemoTweaksSection *section)
+maemo_tweaks_section_save (MaemoTweaksSection *section,
+                           gboolean *requires_restart)
 {
     g_return_if_fail (MAEMO_TWEAKS_IS_SECTION (section));
 
     if (MAEMO_TWEAKS_SECTION_GET_CLASS (section)->save)
-        MAEMO_TWEAKS_SECTION_GET_CLASS (section)->save (section);
+        MAEMO_TWEAKS_SECTION_GET_CLASS (section)->save (section,
+                                                        requires_restart);
     else
         g_warning ("%s: section class %s doesn't implement "
                    "MaemoTweaksSection::filter ()\n",
index 5652e6e..0e14daf 100644 (file)
@@ -44,7 +44,7 @@ struct _MaemoTweaksSectionClass
 
     const gchar *name;
 
-    void (*save) (MaemoTweaksSection *section);
+    void (*save) (MaemoTweaksSection *section, gboolean *requires_restart);
 };
 
 
@@ -53,7 +53,8 @@ GType maemo_tweaks_section_get_type (void) G_GNUC_CONST;
 MaemoTweaksSection * maemo_tweaks_section_new (GType type);
 
 GtkWidget * maemo_tweaks_section_get_widget (MaemoTweaksSection *section);
-void maemo_tweaks_section_save (MaemoTweaksSection *section);
+void maemo_tweaks_section_save (MaemoTweaksSection *section,
+                                gboolean *requires_restart);
 
 G_END_DECLS
 
index 7f0b0c6..9679937 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
 #include <gtk/gtk.h>
+#include <hildon/hildon-note.h>
 
 #include "maemo-tweaks-types.h"
 #include "libmaemo-tweaks-section/maemo-tweaks-section.h"
@@ -37,6 +38,7 @@ osso_return_t execute (osso_context_t *osso, gpointer data,
     guint n_sections;
     GList *sections = NULL;
     gint i;
+    gboolean requires_restart = FALSE;
 
     manager = g_object_new (MAEMO_TWEAKS_TYPE_MODULE_MANAGER,
                             "module-path", MODULES_DIR,
@@ -67,10 +69,10 @@ osso_return_t execute (osso_context_t *osso, gpointer data,
     if (response == GTK_RESPONSE_OK)
     {
         /* Save all settings */
-        g_list_foreach (sections, (GFunc) maemo_tweaks_section_save, NULL);
+        g_list_foreach (sections, (GFunc) maemo_tweaks_section_save,
+                        &requires_restart);
     }
 
-
     gtk_widget_destroy (GTK_WIDGET (dialog));
     g_object_unref (manager);
     if (sections)
@@ -79,6 +81,17 @@ osso_return_t execute (osso_context_t *osso, gpointer data,
         g_list_free (sections);
     }
 
+    if (requires_restart)
+    {
+        GtkWidget *note;
+
+        note = hildon_note_new_information
+            (GTK_WINDOW (data), "Some of the settings you have changed"
+             " will take effect only after you restart your device.");
+        gtk_dialog_run (GTK_DIALOG (note));
+        gtk_widget_destroy (note);
+    }
+
     return OSSO_OK;
 }
 
index 541c852..5dbb4d5 100644 (file)
@@ -72,7 +72,7 @@ static void maemo_tweaks_desktop_section_init
     (MaemoTweaksDesktopSection *section);
 static void maemo_tweaks_desktop_section_dispose (GObject *obj);
 
-static void _save (MaemoTweaksSection *section);
+static void _save (MaemoTweaksSection *section, gboolean *requires_restart);
 
 static GType maemo_tweaks_desktop_section_type = 0;
 static MaemoTweaksSectionClass *
@@ -219,7 +219,7 @@ maemo_tweaks_desktop_section_dispose (GObject *obj)
 }
 
 
-static void _save (MaemoTweaksSection *section)
+static void _save (MaemoTweaksSection *section, gboolean *requires_restart)
 {
     gchar *argv[3];
     gint active;
index 7b313c5..f3e139a 100644 (file)
@@ -56,6 +56,8 @@ struct _MaemoTweaksMceSection
 
     GKeyFile *ini;
     GtkWidget *short_power_key;
+
+    guint value_changed : 1;
 };
 
 struct _MaemoTweaksMceSectionClass
@@ -71,7 +73,7 @@ static void maemo_tweaks_mce_section_init
     (MaemoTweaksMceSection *section);
 static void maemo_tweaks_mce_section_dispose (GObject *obj);
 
-static void _save (MaemoTweaksSection *section);
+static void _save (MaemoTweaksSection *section, gboolean *requires_restart);
 
 static GType maemo_tweaks_mce_section_type = 0;
 static MaemoTweaksSectionClass *
@@ -133,7 +135,14 @@ maemo_tweaks_mce_section_class_init
     object_class->dispose = maemo_tweaks_mce_section_dispose;
 }
 
-GtkWidget * _build_short_power_key (void)
+static void _value_changed (HildonPickerButton *b, gpointer user_data)
+{
+    MaemoTweaksMceSection *section = MAEMO_TWEAKS_MCE_SECTION (user_data);
+
+    section->value_changed = TRUE;
+}
+
+GtkWidget * _build_short_power_key (MaemoTweaksMceSection *section)
 {
     gint i;
     GtkWidget *button, *selector;
@@ -154,6 +163,9 @@ GtkWidget * _build_short_power_key (void)
     hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
                                        HILDON_TOUCH_SELECTOR (selector));
 
+    g_signal_connect (G_OBJECT (button), "value-changed",
+                      G_CALLBACK (_value_changed), section);
+
     gtk_widget_show (button);
     return button;
 }
@@ -165,7 +177,7 @@ maemo_tweaks_mce_section_init (MaemoTweaksMceSection *section)
     gchar *short_power_key_value;
     gint i;
 
-    section->short_power_key = _build_short_power_key ();
+    section->short_power_key = _build_short_power_key (section);
 
     section->ini = g_key_file_new ();
 
@@ -189,6 +201,7 @@ maemo_tweaks_mce_section_init (MaemoTweaksMceSection *section)
         }
     }
 
+    section->value_changed = FALSE;
 
     iface = MAEMO_TWEAKS_SECTION (section);
     iface->widget = gtk_vbox_new (FALSE, 0);
@@ -211,11 +224,16 @@ maemo_tweaks_mce_section_dispose (GObject *obj)
 }
 
 
-static void _save (MaemoTweaksSection *section)
+static void _save (MaemoTweaksSection *section, gboolean *requires_restart)
 {
     gchar *argv[3];
     gint active;
 
+    if (!MAEMO_TWEAKS_MCE_SECTION (section)->value_changed)
+        return;
+
+    *requires_restart = TRUE;
+
     active = hildon_picker_button_get_active
         (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_MCE_SECTION
                                (section)->short_power_key));