[gnome-calendar] time-selector: don't access dconf multiple times for the same key
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] time-selector: don't access dconf multiple times for the same key
- Date: Sat, 3 Jan 2015 17:31:40 +0000 (UTC)
commit c10ba6b22807075aad36e548810ee62a684f479b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jan 3 15:31:05 2015 -0200
time-selector: don't access dconf multiple times for the same key
Instead of accessing 3 times the same key, use the cached version and save up some time.
src/gcal-edit-dialog.c | 3 +++
src/gcal-time-selector.c | 38 +++++++++++++++++---------------------
src/gcal-time-selector.h | 3 +++
3 files changed, 23 insertions(+), 21 deletions(-)
---
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index 06d02d2..6c919ff 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -779,6 +779,9 @@ gcal_edit_dialog_new (gboolean format_24h)
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
priv->format_24h = format_24h;
+ gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (priv->start_time_selector), format_24h);
+ gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (priv->end_time_selector), format_24h);
+
return dialog;
}
diff --git a/src/gcal-time-selector.c b/src/gcal-time-selector.c
index cf96a30..ba0e7f7 100644
--- a/src/gcal-time-selector.c
+++ b/src/gcal-time-selector.c
@@ -127,6 +127,23 @@ period_changed (GtkComboBox *combo,
g_signal_emit (user_data, signals[MODIFIED], 0);
}
+void
+gcal_time_selector_set_time_format (GcalTimeSelector *selector,
+ gboolean format_24h)
+{
+ GcalTimeSelectorPrivate *priv;
+
+ priv = gcal_time_selector_get_instance_private (selector);
+
+ priv->format_24h = format_24h;
+ gtk_widget_set_visible (priv->period_combo, !format_24h);
+
+ if (format_24h)
+ gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->hour_spin)), 23.0);
+ else
+ gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->hour_spin)), 11.0);
+}
+
static void
time_changed (GtkAdjustment *adjustment,
gpointer user_data)
@@ -175,29 +192,8 @@ gcal_time_selector_init (GcalTimeSelector *self)
static void
gcal_time_selector_constructed (GObject *object)
{
- GcalTimeSelectorPrivate *priv;
-
- GSettings *settings;
- gchar *clock_format;
-
- priv = gcal_time_selector_get_instance_private (GCAL_TIME_SELECTOR (object));
-
/* chaining up */
G_OBJECT_CLASS (gcal_time_selector_parent_class)->constructed (object);
-
- /* 24h setting */
- settings = g_settings_new ("org.gnome.desktop.interface");
- clock_format = g_settings_get_string (settings, "clock-format");
- priv->format_24h = (g_strcmp0 (clock_format, "24h") == 0);
-
- g_free (clock_format);
- g_object_unref (settings);
-
- /* maximum of 11 for 12h format */
- if (! priv->format_24h)
- {
- gtk_adjustment_set_upper (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->hour_spin)), 11.0);
- }
}
/* Public API */
diff --git a/src/gcal-time-selector.h b/src/gcal-time-selector.h
index 262fd14..af0369f 100644
--- a/src/gcal-time-selector.h
+++ b/src/gcal-time-selector.h
@@ -55,6 +55,9 @@ GType gcal_time_selector_get_type (void);
GtkWidget* gcal_time_selector_new (void);
+void gcal_time_selector_set_time_format (GcalTimeSelector *selector,
+ gboolean format_24h);
+
void gcal_time_selector_set_time (GcalTimeSelector *selector,
gint hours,
gint minutes);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]