[gnome-screenshot/wip/exalm/cleanups] dialog: Pass GtkApplication explicitly



commit 06d2ee4f54cbe9566a2200c1e5622a3fddac3e24
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Apr 3 09:49:57 2020 +0500

    dialog: Pass GtkApplication explicitly
    
    Don't rely on g_application_get_default().

 src/screenshot-application.c |  3 ++-
 src/screenshot-dialog.c      | 10 ++++++----
 src/screenshot-dialog.h      |  5 +++--
 3 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/screenshot-application.c b/src/screenshot-application.c
index 820bc55..96829a5 100644
--- a/src/screenshot-application.c
+++ b/src/screenshot-application.c
@@ -439,7 +439,8 @@ build_filename_ready_cb (GObject *source,
 
   if (screenshot_config->interactive)
     {
-      self->priv->dialog = screenshot_dialog_new (self->priv->screenshot,
+      self->priv->dialog = screenshot_dialog_new (GTK_APPLICATION (self),
+                                                  self->priv->screenshot,
                                                   self->priv->save_uri);
       g_signal_connect_object (self->priv->dialog, "save", G_CALLBACK (save_clicked_cb), self, 0);
       g_signal_connect_object (self->priv->dialog, "copy", G_CALLBACK (copy_clicked_cb), self, 0);
diff --git a/src/screenshot-dialog.c b/src/screenshot-dialog.c
index 684152e..b7c2b89 100644
--- a/src/screenshot-dialog.c
+++ b/src/screenshot-dialog.c
@@ -248,8 +248,9 @@ screenshot_dialog_init (ScreenshotDialog *self)
 }
 
 ScreenshotDialog *
-screenshot_dialog_new (GdkPixbuf *screenshot,
-                       char      *initial_uri)
+screenshot_dialog_new (GtkApplication *app,
+                       GdkPixbuf      *screenshot,
+                       char           *initial_uri)
 {
   g_autoptr(GFile) tmp_file = NULL, parent_file = NULL;
   g_autofree gchar *current_folder = NULL, *current_name = NULL;
@@ -263,11 +264,12 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
   current_name = g_file_get_basename (tmp_file);
   current_folder = g_file_get_uri (parent_file);
 
-  self = g_object_new (SCREENSHOT_TYPE_DIALOG, NULL);
+  self = g_object_new (SCREENSHOT_TYPE_DIALOG,
+                       "application", app,
+                       NULL);
 
   self->screenshot = screenshot;
 
-  gtk_window_set_application (GTK_WINDOW (self), GTK_APPLICATION (g_application_get_default ()));
   gtk_widget_realize (GTK_WIDGET (self));
 
   gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (self->save_widget), current_folder);
diff --git a/src/screenshot-dialog.h b/src/screenshot-dialog.h
index 51b425f..7419154 100644
--- a/src/screenshot-dialog.h
+++ b/src/screenshot-dialog.h
@@ -27,8 +27,9 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (ScreenshotDialog, screenshot_dialog, SCREENSHOT, DIALOG, GtkApplicationWindow)
 
-ScreenshotDialog *screenshot_dialog_new          (GdkPixbuf *screenshot,
-                                                  char      *initial_uri);
+ScreenshotDialog *screenshot_dialog_new          (GtkApplication *app,
+                                                  GdkPixbuf      *screenshot,
+                                                  char           *initial_uri);
 
 char             *screenshot_dialog_get_uri      (ScreenshotDialog *dialog);
 char             *screenshot_dialog_get_folder   (ScreenshotDialog *dialog);


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