[gnome-calendar] source-dialog: emit the response signal when an action button is activated
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] source-dialog: emit the response signal when an action button is activated
- Date: Mon, 25 May 2015 16:46:54 +0000 (UTC)
commit 00e48dca820713ab8624373b94651f8023f50fc5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Feb 9 13:22:19 2015 -0200
source-dialog: emit the response signal when an action button is activated
data/ui/source-dialog.ui | 2 ++
src/gcal-source-dialog.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index e8570a2..0f79c9d 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -247,6 +247,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="action_widget_activated" object="GcalSourceDialog" swapped="no"/>
</object>
</child>
<child>
@@ -255,6 +256,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <signal name="clicked" handler="action_widget_activated" object="GcalSourceDialog" swapped="no"/>
</object>
<packing>
<property name="pack_type">end</property>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 27c2f75..ec1ec92 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -40,6 +40,9 @@ struct _GcalSourceDialog
GcalSourceDialogPrivate *priv;
};
+static void action_widget_activated (GtkWidget *widget,
+ gpointer user_data);
+
G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG)
enum {
@@ -49,6 +52,28 @@ enum {
static GParamSpec *gParamSpecs [LAST_PROP];
+/**
+ * action_widget_activated:
+ * @widget: the button which emited the signal.
+ * @user_data: a { link GcalSourceDialog} instance.
+ *
+ * Emit a response when action buttons
+ * are clicked.
+ *
+ * Returns:
+ */
+static void
+action_widget_activated (GtkWidget *widget,
+ gpointer user_data)
+{
+ GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+ gint response;
+
+ response = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "response"));
+
+ gtk_dialog_response (GTK_DIALOG (user_data), response);
+}
+
GcalSourceDialog *
gcal_source_dialog_new (void)
{
@@ -63,6 +88,13 @@ gcal_source_dialog_constructed (GObject *object)
G_OBJECT_CLASS (gcal_source_dialog_parent_class)->constructed (object);
+ /* widget responses */
+ gtk_dialog_set_default_response (GTK_DIALOG (object), GTK_RESPONSE_CANCEL);
+
+ g_object_set_data (G_OBJECT (priv->add_button), "response", GINT_TO_POINTER (GTK_RESPONSE_APPLY));
+ g_object_set_data (G_OBJECT (priv->cancel_button), "response", GINT_TO_POINTER (GTK_RESPONSE_CANCEL));
+
+ /* setup titlebar */
gtk_window_set_titlebar (GTK_WINDOW (object), priv->headerbar);
}
@@ -125,6 +157,8 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, cancel_button);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, headerbar);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, stack);
+
+ gtk_widget_class_bind_template_callback (widget_class, action_widget_activated);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]