From: Salvatore Iovene Date: Wed, 9 Dec 2009 05:44:52 +0000 (+0200) Subject: Introduce 'requires restart.' X-Git-Tag: 0.0.1~1^2~13 X-Git-Url: https://vcs.maemo.org/git/?p=tweakr;a=commitdiff_plain;h=0fdcf3c81081175a78c2ef0b6301863ff8c05ec2 Introduce 'requires restart.' --- diff --git a/libmaemo-tweaks-section/maemo-tweaks-section.c b/libmaemo-tweaks-section/maemo-tweaks-section.c index 1f87b2c..336b16b 100644 --- a/libmaemo-tweaks-section/maemo-tweaks-section.c +++ b/libmaemo-tweaks-section/maemo-tweaks-section.c @@ -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", diff --git a/libmaemo-tweaks-section/maemo-tweaks-section.h b/libmaemo-tweaks-section/maemo-tweaks-section.h index 5652e6e..0e14daf 100644 --- a/libmaemo-tweaks-section/maemo-tweaks-section.h +++ b/libmaemo-tweaks-section/maemo-tweaks-section.h @@ -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 diff --git a/maemo-tweaks.c b/maemo-tweaks.c index 7f0b0c6..9679937 100644 --- a/maemo-tweaks.c +++ b/maemo-tweaks.c @@ -4,6 +4,7 @@ #include #include +#include #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; } diff --git a/modules/maemo-tweaks-desktop.c b/modules/maemo-tweaks-desktop.c index 541c852..5dbb4d5 100644 --- a/modules/maemo-tweaks-desktop.c +++ b/modules/maemo-tweaks-desktop.c @@ -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; diff --git a/modules/maemo-tweaks-mce.c b/modules/maemo-tweaks-mce.c index 7b313c5..f3e139a 100644 --- a/modules/maemo-tweaks-mce.c +++ b/modules/maemo-tweaks-mce.c @@ -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));