Style the buttons correctly.
[tweakr] / modules / maemo-tweaks-mce.c
index 2b244c3..4a83f86 100644 (file)
@@ -7,6 +7,7 @@
 #include <gtk/gtk.h>
 #include <hildon/hildon-picker-button.h>
 #include <hildon/hildon-touch-selector.h>
+#include <hildon/hildon-note.h>
 
 #include "libmaemo-tweaks-section/maemo-tweaks-section.h"
 #include "libmaemo-tweaks-section/maemo-tweaks-module.h"
@@ -110,7 +111,8 @@ static void maemo_tweaks_mce_section_init
     (MaemoTweaksMceSection *section);
 static void maemo_tweaks_mce_section_dispose (GObject *obj);
 
-static void _save (MaemoTweaksSection *section, gboolean *requires_restart);
+static gboolean _save (MaemoTweaksSection *section,
+                       gboolean *requires_restart);
 
 static GType maemo_tweaks_mce_section_type = 0;
 static MaemoTweaksSectionClass *
@@ -193,6 +195,7 @@ GtkWidget * _build_short_power_key (MaemoTweaksMceSection *section)
 
     button = hildon_picker_button_new (HILDON_SIZE_AUTO,
                                        HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
                              "Power key: short press");
@@ -221,6 +224,7 @@ GtkWidget * _build_long_power_key (MaemoTweaksMceSection *section)
 
     button = hildon_picker_button_new (HILDON_SIZE_AUTO,
                                        HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
                              "Power key: long press");
@@ -249,6 +253,7 @@ GtkWidget * _build_double_power_key (MaemoTweaksMceSection *section)
 
     button = hildon_picker_button_new (HILDON_SIZE_AUTO,
                                        HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    hildon_gtk_widget_set_theme_size (button, HILDON_SIZE_FINGER_HEIGHT);
 
     hildon_button_set_title (HILDON_BUTTON (button),
                              "Power key: double press");
@@ -326,13 +331,14 @@ maemo_tweaks_mce_section_init (MaemoTweaksMceSection *section)
     section->value_changed = FALSE;
 
     iface = MAEMO_TWEAKS_SECTION (section);
+    iface->name = "Mce";
     iface->widget = gtk_vbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (iface->widget), section->short_power_key,
-                        TRUE, TRUE, 0);
+                        FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (iface->widget), section->long_power_key,
-                        TRUE, TRUE, 0);
+                        FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (iface->widget), section->double_power_key,
-                        TRUE, TRUE, 0);
+                        FALSE, FALSE, 0);
 }
 
 static void
@@ -349,16 +355,15 @@ maemo_tweaks_mce_section_dispose (GObject *obj)
         (obj);
 }
 
-static void _save (MaemoTweaksSection *section, gboolean *requires_restart)
+static gboolean _save (MaemoTweaksSection *section,
+                       gboolean *requires_restart)
 {
     gchar *argv[5];
     gint short_active, long_active, double_active;
     gint i;
 
     if (!MAEMO_TWEAKS_MCE_SECTION (section)->value_changed)
-        return;
-
-    *requires_restart = TRUE;
+        return TRUE;
 
     short_active = hildon_picker_button_get_active
         (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_MCE_SECTION
@@ -372,6 +377,26 @@ static void _save (MaemoTweaksSection *section, gboolean *requires_restart)
         (HILDON_PICKER_BUTTON (MAEMO_TWEAKS_MCE_SECTION
                                (section)->double_power_key));
 
+    if (short_active  == SHORT_POWER_KEY_DISABLED &&
+        long_active   == LONG_POWER_KEY_DISABLED  &&
+        double_active == DOUBLE_POWER_KEY_DISABLED)
+    {
+        GtkWidget *note;
+        gint retcode;
+
+        note = hildon_note_new_confirmation
+            (NULL, "Setting all Power Key options to \"Disabled\" means "
+             "that the only way to turn the device off is the removal of "
+             "the battery. Do you want to continue?");
+        retcode = gtk_dialog_run (GTK_DIALOG (note));
+        gtk_widget_destroy (note);
+
+        if (retcode == GTK_RESPONSE_CANCEL)
+            return FALSE;
+    }
+
+    *requires_restart = TRUE;
+
     argv[0] = g_strdup ("/usr/bin/maemo-tweaks-mce-save");
     argv[1] = g_strdup_printf ("%s", spk[short_active].value);
     argv[2] = g_strdup_printf ("%s", lpk[long_active].value);
@@ -384,5 +409,7 @@ static void _save (MaemoTweaksSection *section, gboolean *requires_restart)
 
     for (i = 0; i < (sizeof (argv) / sizeof (gchar *)) - 1; i++)
         g_free (argv[i]);
+
+    return TRUE;
 }