[gnome-control-center/gsoc2011/location: 6/10] [location] hook up the 24hr switch with the system settings
- From: StÃphane Maniaci <maniacis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gsoc2011/location: 6/10] [location] hook up the 24hr switch with the system settings
- Date: Fri, 8 Jul 2011 16:39:39 +0000 (UTC)
commit c38fc46243a3275f3fa4e0e7287fab3aa42798ba
Author: StÃphane Maniaci <stephane maniaci gmail com>
Date: Thu Jul 7 23:17:40 2011 +0200
[location] hook up the 24hr switch with the system settings
panels/location/cc-location-panel.c | 46 +++++++++++++++++++++++++++++++++++
panels/location/data/bg.png | Bin 213448 -> 172256 bytes
panels/location/location.ui | 4 +-
3 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/panels/location/cc-location-panel.c b/panels/location/cc-location-panel.c
index 45cbd11..f825b88 100644
--- a/panels/location/cc-location-panel.c
+++ b/panels/location/cc-location-panel.c
@@ -21,6 +21,11 @@
#include "cc-location-panel.h"
+#include <gdesktop-enums.h>
+
+#define CLOCK_SCHEMA "org.gnome.desktop.interface"
+#define CLOCK_FORMAT_KEY "clock-format"
+
G_DEFINE_DYNAMIC_TYPE (CcLocationPanel, cc_location_panel, CC_TYPE_PANEL)
#define LOCATION_PANEL_PRIVATE(o) \
@@ -31,10 +36,37 @@ G_DEFINE_DYNAMIC_TYPE (CcLocationPanel, cc_location_panel, CC_TYPE_PANEL)
struct _CcLocationPanelPrivate
{
GtkBuilder *builder;
+ GSettings *settings;
+ GDesktopClockFormat clock_format;
/* that's where private vars go I guess */
};
static void
+_on_24hr_time_switch (GObject *gobject,
+ GParamSpec *pspec,
+ CcLocationPanel *self)
+{
+ CcLocationPanelPrivate *priv = self->priv;
+ GDesktopClockFormat value;
+
+ //g_signal_handlers_block_by_func (priv->settings, clock_settings_changed_cb,
+ // panel);
+
+ if (gtk_switch_get_active (GTK_SWITCH (WID ("24h_time_switch"))))
+ value = G_DESKTOP_CLOCK_FORMAT_24H;
+ else
+ value = G_DESKTOP_CLOCK_FORMAT_12H;
+
+ g_settings_set_enum (priv->settings, CLOCK_FORMAT_KEY, value);
+ priv->clock_format = value;
+
+ /* update_time (panel); */
+
+ /* g_signal_handlers_unblock_by_func (priv->settings, clock_settings_changed_cb, */
+ /* panel); */
+}
+
+static void
cc_location_panel_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -65,6 +97,11 @@ cc_location_panel_dispose (GObject *object)
{
CcLocationPanelPrivate *priv = CC_LOCATION_PANEL (object)->priv;
G_OBJECT_CLASS (cc_location_panel_parent_class)->dispose (object);
+
+ if (priv->settings) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
}
static void
@@ -100,6 +137,7 @@ cc_location_panel_init (CcLocationPanel *self)
GtkStyleContext *context;
self->priv = LOCATION_PANEL_PRIVATE (self);
+ self->priv->settings = g_settings_new (CLOCK_SCHEMA);
self->priv->builder = gtk_builder_new ();
error = NULL;
@@ -123,8 +161,16 @@ cc_location_panel_init (CcLocationPanel *self)
gtk_style_context_add_class (context, "inline-toolbar");
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+ widget = WID ("24h_time_switch");
+ gtk_switch_set_active (GTK_SWITCH (widget),
+ g_settings_get_enum (self->priv->settings, CLOCK_FORMAT_KEY) ==
+ G_DESKTOP_CLOCK_FORMAT_24H);
+ g_signal_connect (widget, "notify::active",
+ G_CALLBACK (_on_24hr_time_switch), self);
+
widget = WID ("location-vbox");
gtk_widget_reparent (widget, (GtkWidget *) self);
+
}
void
diff --git a/panels/location/data/bg.png b/panels/location/data/bg.png
index c04b7fd..43f5f83 100644
Binary files a/panels/location/data/bg.png and b/panels/location/data/bg.png differ
diff --git a/panels/location/location.ui b/panels/location/location.ui
index 338e628..9baadce 100644
--- a/panels/location/location.ui
+++ b/panels/location/location.ui
@@ -130,7 +130,7 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Use AM format</property>
+ <property name="label" translatable="yes">Use 24-hour time</property>
</object>
<packing>
<property name="expand">False</property>
@@ -140,7 +140,7 @@
</packing>
</child>
<child>
- <object class="GtkSwitch" id="switch1">
+ <object class="GtkSwitch" id="24h_time_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]