Add an 'enabled' check button in the control panel applet
authorAlban Crequy <alban.crequy@collabora.co.uk>
Thu, 29 Apr 2010 17:50:35 +0000 (18:50 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Sun, 2 May 2010 11:00:49 +0000 (13:00 +0200)
src/controlpanel-applet.c

index 71496a8..3905d35 100644 (file)
 
 #include <libintl.h>
 #include <libosso.h>
+#include <gconf/gconf-client.h>
 #include <hildon/hildon.h>
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
 
+#include "azimuth-gconf.h"
+
+static GtkWidget* button_enabled = NULL;
+static GConfClient *gconf_client;
+
+static void
+enabled_toggled (HildonCheckButton *button, gpointer user_data)
+{
+  gboolean active;
+
+  active = hildon_check_button_get_active (button);
+  if (active)
+    /* TODO: unblur other widgets */
+    g_debug ("Publishing position is enabled");
+  else
+    /* TODO: blur other widgets */
+    g_debug ("Publishing position is disabled");
+}
+
 static GtkWidget*
 create_main_dialog (gpointer window, osso_context_t *osso)
 {
   GtkWidget *dialog;
   GtkWidget *bSave;
+  gboolean enabled;
 
   dialog = g_object_new (GTK_TYPE_DIALOG,
       "transient-for", GTK_WINDOW (window),
@@ -43,11 +64,36 @@ create_main_dialog (gpointer window, osso_context_t *osso)
       dgettext ("hildon-libs", "wdgt_bd_save"),
       GTK_RESPONSE_OK);
 
+  button_enabled = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT |
+      HILDON_SIZE_AUTO_WIDTH);
+  gtk_button_set_label (GTK_BUTTON (button_enabled),
+      "Enable Position Publishing");
+  g_signal_connect (button_enabled, "toggled", G_CALLBACK (enabled_toggled),
+      NULL);
+  enabled = gconf_client_get_bool (gconf_client, AZIMUTH_GCONF_KEY_ENABLED,
+      NULL);
+  hildon_check_button_set_active (HILDON_CHECK_BUTTON (button_enabled),
+      enabled);
+
+  gtk_box_pack_end (GTK_BOX (GTK_DIALOG(dialog)->vbox), button_enabled, FALSE,
+      FALSE, 0);
+
   gtk_widget_show_all (dialog);
 
   return dialog;
 }
 
+static void
+save (void)
+{
+  gboolean enabled;
+
+  enabled = hildon_check_button_get_active (HILDON_CHECK_BUTTON (
+        button_enabled));
+  gconf_client_set_bool (gconf_client, AZIMUTH_GCONF_KEY_ENABLED, enabled,
+      NULL);
+}
+
 osso_return_t
 execute (osso_context_t *osso, gpointer data,
     gboolean user_activated)
@@ -55,13 +101,19 @@ execute (osso_context_t *osso, gpointer data,
   GtkWidget *dialog;
   gint ret;
 
+  gconf_client = gconf_client_get_default ();
+
   dialog = create_main_dialog (data, osso);
 
   ret = gtk_dialog_run (GTK_DIALOG (dialog));
 
+  if (ret == GTK_RESPONSE_OK)
+    save ();
+
   gtk_widget_destroy (dialog);
 
+  g_object_unref (gconf_client);
+  gconf_client = NULL;
 
   return OSSO_OK;
 }
-