[gedit] File choosers: move the ::done signal down the class hierarchy
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] File choosers: move the ::done signal down the class hierarchy
- Date: Sat, 13 Jun 2020 21:05:37 +0000 (UTC)
commit 103b67fc2d5777c8c731c6afeb3848d0f81daf7e
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Jun 12 11:23:49 2020 +0200
File choosers: move the ::done signal down the class hierarchy
gedit/gedit-file-chooser-open.c | 41 +----------------------------------------
gedit/gedit-file-chooser.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 40 deletions(-)
---
diff --git a/gedit/gedit-file-chooser-open.c b/gedit/gedit-file-chooser-open.c
index b9f28b6cc..2b9d5bf5a 100644
--- a/gedit/gedit-file-chooser-open.c
+++ b/gedit/gedit-file-chooser-open.c
@@ -25,14 +25,6 @@ struct _GeditFileChooserOpenPrivate
gint something;
};
-enum
-{
- SIGNAL_DONE,
- N_SIGNALS
-};
-
-static guint signals[N_SIGNALS];
-
G_DEFINE_TYPE_WITH_PRIVATE (GeditFileChooserOpen, _gedit_file_chooser_open, GEDIT_TYPE_FILE_CHOOSER)
static GtkFileChooser *
@@ -41,35 +33,17 @@ get_gtk_file_chooser (GeditFileChooserOpen *chooser)
return _gedit_file_chooser_get_gtk_file_chooser (GEDIT_FILE_CHOOSER (chooser));
}
-static void
-response_cb (GtkFileChooser *gtk_chooser,
- gint response_id,
- GeditFileChooserOpen *chooser)
-{
- gboolean accept;
-
- accept = response_id == GTK_RESPONSE_ACCEPT;
- g_signal_emit (chooser, signals[SIGNAL_DONE], 0, accept);
-}
-
static void
_gedit_file_chooser_open_constructed (GObject *object)
{
GeditFileChooserOpen *chooser = GEDIT_FILE_CHOOSER_OPEN (object);
- GtkFileChooser *gtk_chooser;
if (G_OBJECT_CLASS (_gedit_file_chooser_open_parent_class)->constructed != NULL)
{
G_OBJECT_CLASS (_gedit_file_chooser_open_parent_class)->constructed (object);
}
- gtk_chooser = get_gtk_file_chooser (chooser);
- gtk_file_chooser_set_select_multiple (gtk_chooser, TRUE);
-
- g_signal_connect (gtk_chooser,
- "response",
- G_CALLBACK (response_cb),
- chooser);
+ gtk_file_chooser_set_select_multiple (get_gtk_file_chooser (chooser), TRUE);
}
static void
@@ -78,19 +52,6 @@ _gedit_file_chooser_open_class_init (GeditFileChooserOpenClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = _gedit_file_chooser_open_constructed;
-
- /*
- * GeditFileChooserOpen::done:
- * @chooser: the #GeditFileChooserOpen emitting the signal.
- * @accept: whether the response code is %GTK_RESPONSE_ACCEPT.
- */
- signals[SIGNAL_DONE] =
- g_signal_new ("done",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1, G_TYPE_BOOLEAN);
}
static void
diff --git a/gedit/gedit-file-chooser.c b/gedit/gedit-file-chooser.c
index ba9064008..ccc0ce0b6 100644
--- a/gedit/gedit-file-chooser.c
+++ b/gedit/gedit-file-chooser.c
@@ -29,6 +29,14 @@ struct _GeditFileChooserPrivate
GtkFileChooser *gtk_chooser;
};
+enum
+{
+ SIGNAL_DONE,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS];
+
G_DEFINE_TYPE_WITH_PRIVATE (GeditFileChooser, _gedit_file_chooser, G_TYPE_OBJECT)
#define ALL_FILES _("All Files")
@@ -579,6 +587,17 @@ set_modal (GeditFileChooser *chooser)
}
}
+static void
+response_cb (GtkFileChooser *gtk_chooser,
+ gint response_id,
+ GeditFileChooser *chooser)
+{
+ gboolean accept;
+
+ accept = response_id == GTK_RESPONSE_ACCEPT;
+ g_signal_emit (chooser, signals[SIGNAL_DONE], 0, accept);
+}
+
static void
_gedit_file_chooser_constructed (GObject *object)
{
@@ -598,6 +617,12 @@ _gedit_file_chooser_constructed (GObject *object)
setup_filters (chooser);
set_modal (chooser);
gtk_file_chooser_set_local_only (chooser->priv->gtk_chooser, FALSE);
+
+ g_signal_connect_object (chooser->priv->gtk_chooser,
+ "response",
+ G_CALLBACK (response_cb),
+ chooser,
+ 0);
}
}
@@ -618,6 +643,19 @@ _gedit_file_chooser_class_init (GeditFileChooserClass *klass)
object_class->constructed = _gedit_file_chooser_constructed;
object_class->dispose = _gedit_file_chooser_dispose;
+
+ /*
+ * GeditFileChooser::done:
+ * @chooser: the #GeditFileChooser emitting the signal.
+ * @accept: whether the response code is %GTK_RESPONSE_ACCEPT.
+ */
+ signals[SIGNAL_DONE] =
+ g_signal_new ("done",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1, G_TYPE_BOOLEAN);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]