[gedit] File choosers: call ::create_gtk_file_chooser vfunc in ::constructed
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] File choosers: call ::create_gtk_file_chooser vfunc in ::constructed
- Date: Sat, 13 Jun 2020 21:05:32 +0000 (UTC)
commit e414f9e7960065eefedad5a8e04277142a11e03f
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Jun 12 10:34:59 2020 +0200
File choosers: call ::create_gtk_file_chooser vfunc in ::constructed
Not in init(), because apparently in init() the Class struct is not
fully initialized.
gedit/gedit-file-chooser-open.c | 52 ++++++++++++++++++++++++--------------
gedit/gedit-file-chooser.c | 56 +++++++++++++++++++++++++----------------
2 files changed, 67 insertions(+), 41 deletions(-)
---
diff --git a/gedit/gedit-file-chooser-open.c b/gedit/gedit-file-chooser-open.c
index bb1ffb364..b9f28b6cc 100644
--- a/gedit/gedit-file-chooser-open.c
+++ b/gedit/gedit-file-chooser-open.c
@@ -41,23 +41,6 @@ get_gtk_file_chooser (GeditFileChooserOpen *chooser)
return _gedit_file_chooser_get_gtk_file_chooser (GEDIT_FILE_CHOOSER (chooser));
}
-static void
-_gedit_file_chooser_open_class_init (GeditFileChooserOpenClass *klass)
-{
- /*
- * 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
response_cb (GtkFileChooser *gtk_chooser,
gint response_id,
@@ -70,11 +53,15 @@ response_cb (GtkFileChooser *gtk_chooser,
}
static void
-_gedit_file_chooser_open_init (GeditFileChooserOpen *chooser)
+_gedit_file_chooser_open_constructed (GObject *object)
{
+ GeditFileChooserOpen *chooser = GEDIT_FILE_CHOOSER_OPEN (object);
GtkFileChooser *gtk_chooser;
- chooser->priv = _gedit_file_chooser_open_get_instance_private (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);
@@ -85,6 +72,33 @@ _gedit_file_chooser_open_init (GeditFileChooserOpen *chooser)
chooser);
}
+static void
+_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
+_gedit_file_chooser_open_init (GeditFileChooserOpen *chooser)
+{
+ chooser->priv = _gedit_file_chooser_open_get_instance_private (chooser);
+}
+
GeditFileChooserOpen *
_gedit_file_chooser_open_new (void)
{
diff --git a/gedit/gedit-file-chooser.c b/gedit/gedit-file-chooser.c
index 309d06f47..ba9064008 100644
--- a/gedit/gedit-file-chooser.c
+++ b/gedit/gedit-file-chooser.c
@@ -553,24 +553,6 @@ setup_filters (GeditFileChooser *chooser)
NULL);
}
-static void
-_gedit_file_chooser_dispose (GObject *object)
-{
- GeditFileChooser *chooser = GEDIT_FILE_CHOOSER (object);
-
- g_clear_object (&chooser->priv->gtk_chooser);
-
- G_OBJECT_CLASS (_gedit_file_chooser_parent_class)->dispose (object);
-}
-
-static void
-_gedit_file_chooser_class_init (GeditFileChooserClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = _gedit_file_chooser_dispose;
-}
-
/* Set the dialog as modal. It's a workaround for this bug:
* https://gitlab.gnome.org/GNOME/gtk/issues/2824
* "GtkNativeDialog: non-modal and gtk_native_dialog_show(), doesn't present the
@@ -598,22 +580,52 @@ set_modal (GeditFileChooser *chooser)
}
static void
-_gedit_file_chooser_init (GeditFileChooser *chooser)
+_gedit_file_chooser_constructed (GObject *object)
{
- GeditFileChooserClass *klass;
+ GeditFileChooser *chooser = GEDIT_FILE_CHOOSER (object);
+ GeditFileChooserClass *klass = GEDIT_FILE_CHOOSER_GET_CLASS (chooser);
- chooser->priv = _gedit_file_chooser_get_instance_private (chooser);
+ if (G_OBJECT_CLASS (_gedit_file_chooser_parent_class)->constructed != NULL)
+ {
+ G_OBJECT_CLASS (_gedit_file_chooser_parent_class)->constructed (object);
+ }
- klass = GEDIT_FILE_CHOOSER_GET_CLASS (chooser);
if (klass->create_gtk_file_chooser != NULL)
{
+ g_return_if_fail (chooser->priv->gtk_chooser == NULL);
chooser->priv->gtk_chooser = klass->create_gtk_file_chooser (chooser);
+
setup_filters (chooser);
set_modal (chooser);
gtk_file_chooser_set_local_only (chooser->priv->gtk_chooser, FALSE);
}
}
+static void
+_gedit_file_chooser_dispose (GObject *object)
+{
+ GeditFileChooser *chooser = GEDIT_FILE_CHOOSER (object);
+
+ g_clear_object (&chooser->priv->gtk_chooser);
+
+ G_OBJECT_CLASS (_gedit_file_chooser_parent_class)->dispose (object);
+}
+
+static void
+_gedit_file_chooser_class_init (GeditFileChooserClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = _gedit_file_chooser_constructed;
+ object_class->dispose = _gedit_file_chooser_dispose;
+}
+
+static void
+_gedit_file_chooser_init (GeditFileChooser *chooser)
+{
+ chooser->priv = _gedit_file_chooser_get_instance_private (chooser);
+}
+
GeditFileChooser *
_gedit_file_chooser_new (void)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]