2 * controlpanel-applet.c.c - Source for Azimuth's control panel applet
3 * Copyright (C) 2010 Collabora
4 * @author Alban Crequy <alban.crequy@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <gconf/gconf-client.h>
24 #include <hildon/hildon.h>
25 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
27 #include "azimuth-gconf.h"
29 static GtkWidget* button_enabled = NULL;
30 static GtkWidget* button_blur = NULL;
31 static GtkWidget* button_start_gps = NULL;
32 static GConfClient *gconf_client;
35 enabled_toggled (HildonCheckButton *button, gpointer user_data)
39 active = hildon_check_button_get_active (button);
42 gtk_widget_set_sensitive (button_blur, TRUE);
43 gtk_widget_set_sensitive (button_start_gps, TRUE);
47 gtk_widget_set_sensitive (button_blur, FALSE);
48 gtk_widget_set_sensitive (button_start_gps, FALSE);
53 azimuth_create_check_button (const gchar *text,
55 const gchar *gconf_key)
60 b = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT |
61 HILDON_SIZE_AUTO_WIDTH);
62 gtk_button_set_label (GTK_BUTTON (b), text);
64 g_signal_connect (b, "toggled", cb, NULL);
65 checked = gconf_client_get_bool (gconf_client, gconf_key,
67 hildon_check_button_set_active (HILDON_CHECK_BUTTON (b), checked);
73 create_main_dialog (gpointer window, osso_context_t *osso)
78 dialog = g_object_new (GTK_TYPE_DIALOG,
79 "transient-for", GTK_WINDOW (window),
80 "destroy-with-parent", TRUE,
82 "has-separator", FALSE,
85 gtk_window_set_title (GTK_WINDOW (dialog),
86 "Publish position to contacts");
88 bSave = gtk_dialog_add_button (GTK_DIALOG (dialog),
89 dgettext ("hildon-libs", "wdgt_bd_save"),
92 button_blur = azimuth_create_check_button (
93 "Truncate your position", NULL, AZIMUTH_GCONF_KEY_BLUR);
94 button_start_gps = azimuth_create_check_button (
95 "Start GPS (drains battery)", NULL, AZIMUTH_GCONF_KEY_START_GPS);
97 button_enabled = azimuth_create_check_button (
98 "Publish position when GPS is running", G_CALLBACK (enabled_toggled),
99 AZIMUTH_GCONF_KEY_ENABLED);
100 enabled_toggled (HILDON_CHECK_BUTTON (button_enabled), NULL);
102 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), button_enabled,
104 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), button_blur,
106 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), button_start_gps,
109 gtk_widget_show_all (dialog);
121 enabled = hildon_check_button_get_active (HILDON_CHECK_BUTTON (
123 blur = hildon_check_button_get_active (HILDON_CHECK_BUTTON (
125 start_gps = hildon_check_button_get_active (HILDON_CHECK_BUTTON (
128 gconf_client_set_bool (gconf_client, AZIMUTH_GCONF_KEY_ENABLED, enabled,
130 gconf_client_set_bool (gconf_client, AZIMUTH_GCONF_KEY_BLUR, blur,
132 gconf_client_set_bool (gconf_client, AZIMUTH_GCONF_KEY_START_GPS, start_gps,
137 execute (osso_context_t *osso, gpointer data,
138 gboolean user_activated)
143 gconf_client = gconf_client_get_default ();
145 dialog = create_main_dialog (data, osso);
147 ret = gtk_dialog_run (GTK_DIALOG (dialog));
149 if (ret == GTK_RESPONSE_OK)
152 gtk_widget_destroy (dialog);
154 g_object_unref (gconf_client);