[gnome-calendar/calendar-editor] source-dialog: implement changing the default source
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/calendar-editor] source-dialog: implement changing the default source
- Date: Mon, 9 Feb 2015 18:43:35 +0000 (UTC)
commit 8df30011f0cd310b6c3a9f172ae8d2dfe5b469c2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Feb 9 16:43:27 2015 -0200
source-dialog: implement changing the default source
data/ui/source-dialog.ui | 1 +
src/gcal-source-dialog.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index 84bea98..0545232 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -71,6 +71,7 @@
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
+ <signal name="notify::active" handler="default_check_toggled" object="GcalSourceDialog"
swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index ce8deb7..4341eff 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -37,6 +37,7 @@ typedef struct
/* flags */
gint mode : 1;
ESource *source;
+ ESource *old_default_source;
GBinding *title_bind;
/* manager */
@@ -57,6 +58,10 @@ static void action_widget_activated (GtkWidget *w
static void color_set (GtkColorButton *button,
gpointer user_data);
+static void default_check_toggled (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data);
+
static gboolean description_label_link_activated (GtkWidget *widget,
gchar *uri,
gpointer user_data);
@@ -93,6 +98,8 @@ action_widget_activated (GtkWidget *widget,
response = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "response"));
+ priv->old_default_source = NULL;
+
gtk_dialog_response (GTK_DIALOG (user_data), response);
}
@@ -111,6 +118,36 @@ color_set (GtkColorButton *button,
e_source_selectable_set_color (extension, gdk_rgba_to_string (&color));
}
+static void
+default_check_toggled (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+
+ /* Retrieve the current default source */
+ if (priv->old_default_source == NULL)
+ {
+ priv->old_default_source = gcal_manager_get_default_source (priv->manager);
+ g_object_unref (priv->old_default_source);
+ }
+
+ /**
+ * Keeps toggling between the
+ * current source and the previous
+ * default source.
+ */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object)))
+ {
+ gcal_manager_set_default_source (priv->manager, priv->source);
+ }
+ else
+ {
+ gcal_manager_set_default_source (priv->manager, priv->old_default_source);
+ }
+}
+
+
/**
* description_label_link_activated:
*
@@ -243,6 +280,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
gtk_widget_class_bind_template_callback (widget_class, action_widget_activated);
gtk_widget_class_bind_template_callback (widget_class, color_set);
+ gtk_widget_class_bind_template_callback (widget_class, default_check_toggled);
gtk_widget_class_bind_template_callback (widget_class, description_label_link_activated);
gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]