From d8d39a2d39af06e511a4a7092ee7be98c1a724c8 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 29 Apr 2010 18:50:35 +0100 Subject: [PATCH] Add an 'enabled' check button in the control panel applet --- src/controlpanel-applet.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/controlpanel-applet.c b/src/controlpanel-applet.c index 71496a8..3905d35 100644 --- a/src/controlpanel-applet.c +++ b/src/controlpanel-applet.c @@ -20,14 +20,35 @@ #include #include +#include #include #include +#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; } - -- 1.7.9.5