[gnome-text-editor] prefs: cleanup dialog creation



commit 45ccc500c425df642738ed85a274ca2203a8248d
Author: Christian Hergert <chergert redhat com>
Date:   Wed Feb 2 11:24:03 2022 -0800

    prefs: cleanup dialog creation
    
    We shouldn't be using g_object_set() for things like this from the
    init function of the window.

 src/editor-preferences-dialog-private.h | 3 ++-
 src/editor-preferences-dialog.c         | 8 +++-----
 src/editor-window-actions.c             | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/editor-preferences-dialog-private.h b/src/editor-preferences-dialog-private.h
index 16aba2a..0991352 100644
--- a/src/editor-preferences-dialog-private.h
+++ b/src/editor-preferences-dialog-private.h
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EditorPreferencesDialog, editor_preferences_dialog, EDITOR, PREFERENCES_DIALOG, 
AdwPreferencesWindow)
 
-GtkWidget *editor_preferences_dialog_new (EditorWindow *transient_for);
+GtkWidget *editor_preferences_dialog_new (EditorApplication *application,
+                                          EditorWindow      *transient_for);
 
 G_END_DECLS
diff --git a/src/editor-preferences-dialog.c b/src/editor-preferences-dialog.c
index f8edd38..9034314 100644
--- a/src/editor-preferences-dialog.c
+++ b/src/editor-preferences-dialog.c
@@ -435,10 +435,6 @@ editor_preferences_dialog_init (EditorPreferencesDialog *self)
   gtk_widget_add_css_class (GTK_WIDGET (self), "devel");
 #endif
 
-  g_object_set (self,
-                "application", g_application_get_default (),
-                NULL);
-
   style_context = gtk_widget_get_style_context (GTK_WIDGET (self->source_view));
   self->css_provider = gtk_css_provider_new ();
   gtk_style_context_add_provider (style_context,
@@ -496,11 +492,13 @@ editor_preferences_dialog_init (EditorPreferencesDialog *self)
 }
 
 GtkWidget *
-editor_preferences_dialog_new (EditorWindow *transient_for)
+editor_preferences_dialog_new (EditorApplication *application,
+                               EditorWindow      *transient_for)
 {
   g_return_val_if_fail (EDITOR_IS_WINDOW (transient_for), NULL);
 
   return g_object_new (EDITOR_TYPE_PREFERENCES_DIALOG,
+                       "application", application,
                        "transient-for", transient_for,
                        NULL);
 }
diff --git a/src/editor-window-actions.c b/src/editor-window-actions.c
index afa34b1..d319aee 100644
--- a/src/editor-window-actions.c
+++ b/src/editor-window-actions.c
@@ -565,7 +565,7 @@ editor_window_actions_show_preferences_cb (GtkWidget  *widget,
 
   g_assert (EDITOR_IS_WINDOW (self));
 
-  dialog = editor_preferences_dialog_new (self);
+  dialog = editor_preferences_dialog_new (EDITOR_APPLICATION_DEFAULT, self);
   gtk_window_present (GTK_WINDOW (dialog));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]