[gnome-calendar] source-dialog: properly save the source when the dialog is closed
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] source-dialog: properly save the source when the dialog is closed
- Date: Mon, 25 May 2015 16:48:46 +0000 (UTC)
commit cba97f8719bd81601fad0e774807e5c1ef510fa7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Feb 9 17:06:02 2015 -0200
source-dialog: properly save the source when the dialog is closed
data/ui/source-dialog.ui | 1 +
src/gcal-source-dialog.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index 0545232..6d79042 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -10,6 +10,7 @@
<property name="width_request">450</property>
<property name="default_width">550</property>
<property name="default_height">500</property>
+ <signal name="response" handler="response_signal" object="GcalSourceDialog" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="vbox">
<property name="can_focus">False</property>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 4341eff..e68f02f 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -70,6 +70,10 @@ static void name_entry_text_changed (GObject *ob
GParamSpec *pspec,
gpointer user_data);
+static void response_signal (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data);
+
G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG)
enum {
@@ -100,6 +104,9 @@ action_widget_activated (GtkWidget *widget,
priv->old_default_source = NULL;
+ /* save the source */
+ gcal_manager_save_source (priv->manager, priv->source);
+
gtk_dialog_response (GTK_DIALOG (user_data), response);
}
@@ -189,6 +196,28 @@ name_entry_text_changed (GObject *object,
e_source_set_display_name (priv->source, gtk_entry_get_text (GTK_ENTRY (priv->name_entry)));
}
+/**
+ * response_signal:
+ *
+ * Save the source when the dialog
+ * is close.
+ *
+ * Returns:
+ */
+static void
+response_signal (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (dialog)->priv;
+
+ /* save the source */
+ if (priv->mode == GCAL_SOURCE_DIALOG_MODE_EDIT || response_id == GTK_RESPONSE_APPLY)
+ {
+ gcal_manager_save_source (priv->manager, priv->source);
+ }
+}
+
GcalSourceDialog *
gcal_source_dialog_new (void)
{
@@ -283,6 +312,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
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);
+ gtk_widget_class_bind_template_callback (widget_class, response_signal);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]