[gnome-control-center/wip/feborges/new-addprinter-dialog: 38/44] printers: Allow dismissing authentication in "Add New Printer" dialog



commit d60644750a629cd1adbfd5eefbaef78de1b85cc0
Author: Felipe Borges <felipeborges gnome org>
Date:   Sat Nov 12 18:04:18 2016 +0100

    printers: Allow dismissing authentication in "Add New Printer" dialog
    
    Introduce a "go-back" button allowing to get back to the list of
    printers when the user is exposed to the authentication form in
    the "Add New Printer" dialog.
    
    This is a redesign based on the newest mockups available at
    https://wiki.gnome.org/Design/SystemSettings/Printers#Guidelines
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760783

 panels/printers/new-printer-dialog.ui   |   37 ++++++++++++++++++++++++++----
 panels/printers/pp-new-printer-dialog.c |   16 +++++++++++++
 2 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/panels/printers/new-printer-dialog.ui b/panels/printers/new-printer-dialog.ui
index 1219362..bf583a7 100644
--- a/panels/printers/new-printer-dialog.ui
+++ b/panels/printers/new-printer-dialog.ui
@@ -37,17 +37,44 @@
         <property name="visible">True</property>
         <property name="show-close-button">False</property>
         <child>
-          <object class="GtkButton" id="new-printer-cancel-button">
-            <property name="label" translatable="yes">_Cancel</property>
+          <object class="GtkStack" id="headerbar-topleft-buttons">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="use_underline">True</property>
+            <property name="valign">center</property>
+            <child>
+              <object class="GtkButton" id="new-printer-cancel-button">
+                <property name="label" translatable="yes">_Cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="name">addprinter-page</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="go-back-button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="halign">start</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="icon-name">go-previous-symbolic</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="name">authentication-page</property>
+              </packing>
+            </child>
           </object>
         </child>
         <child>
           <object class="GtkStack" id="headerbar-topright-buttons">
             <property name="visible">True</property>
+            <property name="valign">center</property>
             <child>
               <object class="GtkButton" id="new-printer-add-button">
                 <property name="label" translatable="yes">_Add</property>
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 9c43600..bc44858 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -344,6 +344,9 @@ go_to_page (PpNewPrinterDialog *dialog,
 
   stack = GTK_STACK (WID ("headerbar-topright-buttons"));
   gtk_stack_set_visible_child_name (stack, page);
+
+  stack = GTK_STACK (WID ("headerbar-topleft-buttons"));
+  gtk_stack_set_visible_child_name (stack, page);
 }
 
 static gchar *
@@ -420,6 +423,18 @@ auth_entries_changed (GtkEditable *editable,
 }
 
 static void
+on_go_back_button_clicked (GtkButton *button,
+                           gpointer   user_data)
+{
+  PpNewPrinterDialog        *dialog = PP_NEW_PRINTER_DIALOG (user_data);
+  PpNewPrinterDialogPrivate *priv = dialog->priv;
+
+  pp_samba_set_auth_info (priv->samba_host, NULL, NULL);
+
+  go_to_page (dialog, ADDPRINTER_PAGE);
+}
+
+static void
 authenticate_samba_server (GtkButton *button,
                            gpointer   user_data)
 {
@@ -519,6 +534,7 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
   /* Authentication form widgets */
   g_signal_connect (WID ("username-entry"), "changed", G_CALLBACK (auth_entries_changed), dialog);
   g_signal_connect (WID ("password-entry"), "changed", G_CALLBACK (auth_entries_changed), dialog);
+  g_signal_connect (WID ("go-back-button"), "clicked", G_CALLBACK (on_go_back_button_clicked), dialog);
 
   /* Set junctions */
   widget = WID ("scrolledwindow1");


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