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.
This commit is contained in:
@@ -779,6 +779,9 @@ gcal_edit_dialog_new (gboolean format_24h)
|
|||||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||||
priv->format_24h = format_24h;
|
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;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-21
@@ -127,6 +127,23 @@ period_changed (GtkComboBox *combo,
|
|||||||
g_signal_emit (user_data, signals[MODIFIED], 0);
|
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
|
static void
|
||||||
time_changed (GtkAdjustment *adjustment,
|
time_changed (GtkAdjustment *adjustment,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -175,29 +192,8 @@ gcal_time_selector_init (GcalTimeSelector *self)
|
|||||||
static void
|
static void
|
||||||
gcal_time_selector_constructed (GObject *object)
|
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 */
|
/* chaining up */
|
||||||
G_OBJECT_CLASS (gcal_time_selector_parent_class)->constructed (object);
|
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 */
|
/* Public API */
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ GType gcal_time_selector_get_type (void);
|
|||||||
|
|
||||||
GtkWidget* gcal_time_selector_new (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,
|
void gcal_time_selector_set_time (GcalTimeSelector *selector,
|
||||||
gint hours,
|
gint hours,
|
||||||
gint minutes);
|
gint minutes);
|
||||||
|
|||||||
Reference in New Issue
Block a user