[gnome-control-center] Return a PpNewPrinter instead of PpPrintDevice, use gtk_show_all



commit 16aa95bdc8c542529c7166465fa56ab1a92de207
Author: Brandon Nielsen <nielsenb jetfuse net>
Date:   Tue Jul 13 14:43:12 2021 -0500

    Return a PpNewPrinter instead of PpPrintDevice, use gtk_show_all
    
    pp_new_printer_dialog_get_new_print_device is replaced with
    pp_new_printer_dialog_get_new_printer which returns a PpNewPrinter.
    
    gtk_show_all is used instead of gtk_dialog_run for PpNewPrinterDialog
    and PpPPDSelectionDialog.
    
    This is in response to feedback:
    https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/930#note_1202114

 panels/printers/cc-printers-panel.c     | 38 +++++++--------------------------
 panels/printers/pp-details-dialog.c     |  2 +-
 panels/printers/pp-new-printer-dialog.c | 37 ++++++++++++++++++++++++++------
 panels/printers/pp-new-printer-dialog.h |  3 ++-
 4 files changed, 41 insertions(+), 39 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index a0dd86f39..60e471455 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -45,8 +45,6 @@
 #include "cc-permission-infobar.h"
 #include "cc-util.h"
 
-#include <gdk/gdkx.h>
-
 #define RENEW_INTERVAL        500
 #define SUBSCRIPTION_DURATION 600
 
@@ -944,38 +942,18 @@ new_printer_dialog_response_cb (GtkDialog *_dialog,
 {
   CcPrintersPanel         *self = (CcPrintersPanel*) user_data;
   PpNewPrinterDialog      *pp_new_printer_dialog =  PP_NEW_PRINTER_DIALOG (_dialog);
-  g_autoptr(PpPrintDevice) new_device = NULL;
   g_autoptr(PpNewPrinter)  new_printer = NULL;
-  guint                    window_id = 0;
 
   if (response_id == GTK_RESPONSE_OK) {
-    new_device = pp_new_printer_dialog_get_new_print_device (pp_new_printer_dialog);
-    self->new_printer_name = g_strdup (pp_print_device_get_device_name (new_device));
+    new_printer = pp_new_printer_dialog_get_new_printer (pp_new_printer_dialog);
+    g_object_get(G_OBJECT (new_printer), "name", &self->new_printer_name, NULL);
+
     actualize_printers_list (self);
 
-    window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (gtk_window_get_transient_for 
(GTK_WINDOW (pp_new_printer_dialog)))));
-
-    new_printer = pp_new_printer_new ();
-    g_object_set (new_printer,
-                  "name", pp_print_device_get_device_name (new_device),
-                  "original-name", pp_print_device_get_device_original_name (new_device),
-                  "device-uri", pp_print_device_get_device_uri (new_device),
-                  "device-id", pp_print_device_get_device_id (new_device),
-                  "ppd-name", pp_print_device_get_device_ppd (new_device),
-                  "ppd-file-name", pp_print_device_get_device_ppd (new_device),
-                  "info", pp_print_device_get_device_info (new_device),
-                  "location", pp_print_device_get_device_location (new_device),
-                  "make-and-model", pp_print_device_get_device_make_and_model (new_device),
-                  "host-name", pp_print_device_get_host_name (new_device),
-                  "host-port", pp_print_device_get_host_port (new_device),
-                  "is-network-device", pp_print_device_is_network_device (new_device),
-                  "window-id", window_id,
-                  NULL);
-
-      pp_new_printer_add_async (new_printer,
-                                cc_panel_get_cancellable (CC_PANEL (self)),
-                                printer_add_async_cb,
-                                self);
+    pp_new_printer_add_async (new_printer,
+                              cc_panel_get_cancellable (CC_PANEL (self)),
+                              printer_add_async_cb,
+                              self);
   }
 
   gtk_widget_destroy (GTK_WIDGET (pp_new_printer_dialog));
@@ -995,7 +973,7 @@ printer_add_cb (CcPrintersPanel *self)
   gtk_window_set_transient_for (GTK_WINDOW (self->pp_new_printer_dialog),
                                             GTK_WINDOW (toplevel));
 
-  gtk_dialog_run (GTK_DIALOG (self->pp_new_printer_dialog));
+  gtk_widget_show_all (self->pp_new_printer_dialog);
 }
 
 static void
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index d6b13c8f3..100ed9c29 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -219,7 +219,7 @@ select_ppd_in_dialog (PpDetailsDialog *self)
         gtk_window_set_transient_for (GTK_WINDOW (self->pp_ppd_selection_dialog),
                                       GTK_WINDOW (self));
 
-        gtk_dialog_run (GTK_DIALOG (self->pp_ppd_selection_dialog));
+        gtk_widget_show_all (self->pp_ppd_selection_dialog);
     }
 }
 
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 424945909..c4247b102 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -29,11 +29,12 @@
 #include <gtk/gtk.h>
 
 #include "pp-new-printer-dialog.h"
-#include "pp-ppd-selection-dialog.h"
-#include "pp-utils.h"
-#include "pp-host.h"
 #include "pp-cups.h"
+#include "pp-host.h"
+#include "pp-new-printer.h"
+#include "pp-ppd-selection-dialog.h"
 #include "pp-samba.h"
+#include "pp-utils.h"
 
 #if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
 #define HAVE_CUPS_1_6 1
@@ -1754,7 +1755,7 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *self,
                                             GTK_WINDOW (self));
 
               //New device will be set at return from ppd selection
-              gtk_dialog_run (GTK_DIALOG (self->ppd_selection_dialog));
+              gtk_widget_show_all (self->ppd_selection_dialog);
             }
           else
             {
@@ -1914,8 +1915,30 @@ pp_new_printer_dialog_set_ppd_list (PpNewPrinterDialog *self,
     pp_ppd_selection_dialog_set_ppd_list (self->ppd_selection_dialog, self->list);
 }
 
-PpPrintDevice *
-pp_new_printer_dialog_get_new_print_device (PpNewPrinterDialog *self)
+PpNewPrinter *
+pp_new_printer_dialog_get_new_printer (PpNewPrinterDialog *self)
 {
-  return pp_print_device_copy (self->new_device);
+  PpNewPrinter *new_printer = NULL;
+  guint         window_id = 0;
+
+  window_id = (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (gtk_window_get_transient_for 
(GTK_WINDOW (self)))));
+
+  new_printer = pp_new_printer_new ();
+  g_object_set (new_printer,
+                "name", pp_print_device_get_device_name (self->new_device),
+                "original-name", pp_print_device_get_device_original_name (self->new_device),
+                "device-uri", pp_print_device_get_device_uri (self->new_device),
+                "device-id", pp_print_device_get_device_id (self->new_device),
+                "ppd-name", pp_print_device_get_device_ppd (self->new_device),
+                "ppd-file-name", pp_print_device_get_device_ppd (self->new_device),
+                "info", pp_print_device_get_device_info (self->new_device),
+                "location", pp_print_device_get_device_location (self->new_device),
+                "make-and-model", pp_print_device_get_device_make_and_model (self->new_device),
+                "host-name", pp_print_device_get_host_name (self->new_device),
+                "host-port", pp_print_device_get_host_port (self->new_device),
+                "is-network-device", pp_print_device_is_network_device (self->new_device),
+                "window-id", window_id,
+                NULL);
+
+  return new_printer;
 }
diff --git a/panels/printers/pp-new-printer-dialog.h b/panels/printers/pp-new-printer-dialog.h
index 50a3665f7..78ac68d56 100644
--- a/panels/printers/pp-new-printer-dialog.h
+++ b/panels/printers/pp-new-printer-dialog.h
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <gtk/gtk.h>
+#include "pp-new-printer.h"
 #include "pp-utils.h"
 
 G_BEGIN_DECLS
@@ -32,6 +33,6 @@ PpNewPrinterDialog *pp_new_printer_dialog_new                  (PPDList
                                                                 gpointer              user_data);
 void                pp_new_printer_dialog_set_ppd_list         (PpNewPrinterDialog *dialog,
                                                                 PPDList            *list);
-PpPrintDevice      *pp_new_printer_dialog_get_new_print_device (PpNewPrinterDialog *dialog);
+PpNewPrinter       *pp_new_printer_dialog_get_new_printer (PpNewPrinterDialog *dialog);
 
 G_END_DECLS


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