[gnome-control-center/wip/feborges/new-printers-panel: 17/21] printers: use panel-wide page for empty-state



commit a3376b9fd8ed77101617d78c194be6a2ff330bac
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Jun 8 16:20:47 2016 +0200

    printers: use panel-wide page for empty-state
    
    Instead of having the empty-state and no-cups-page states displayed
    as tabs of the printer notebook, go for panel-wide pages, which
    better highlight these states and doesn't unnecessarily shows the
    empty printers list.
    
    This change is also part of the effort of the panel redesign,
    according to the mockups at
    https://wiki.gnome.org/Design/SystemSettings/Printers

 panels/printers/cc-printers-panel.c |   22 +---
 panels/printers/printers.ui         |  229 ++++++++++++++++-------------------
 2 files changed, 112 insertions(+), 139 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index fe1e618..2ec88b8 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -732,9 +732,8 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
       priv->dests != NULL)
     {
       widget = (GtkWidget*)
-        gtk_builder_get_object (priv->builder, "notebook");
-      if (gtk_notebook_get_current_page (GTK_NOTEBOOK (widget)) >= NOTEBOOK_NO_PRINTERS_PAGE)
-        gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), NOTEBOOK_INFO_PAGE);
+        gtk_builder_get_object (priv->builder, "main-vbox");
+      gtk_stack_set_visible_child_name (GTK_STACK (widget), "printers-list");
 
       for (i = 0; i < priv->dests[id].num_options; i++)
         {
@@ -1035,9 +1034,8 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
               printer_model = g_strdup (priv->new_printer_make_and_model);
 
               widget = (GtkWidget*)
-                gtk_builder_get_object (priv->builder, "notebook");
-              if (gtk_notebook_get_current_page (GTK_NOTEBOOK (widget)) >= NOTEBOOK_NO_PRINTERS_PAGE)
-                gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), NOTEBOOK_INFO_PAGE);
+                gtk_builder_get_object (priv->builder, "main-vbox");
+              gtk_stack_set_visible_child_name (GTK_STACK (widget), "printers-list");
             }
         }
 
@@ -1142,9 +1140,9 @@ set_current_page (GObject      *source_object,
   g_object_unref (source_object);
 
   if (success)
-    gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), NOTEBOOK_NO_PRINTERS_PAGE);
+    gtk_stack_set_visible_child_name (GTK_STACK (widget), "empty-state");
   else
-    gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), NOTEBOOK_NO_CUPS_PAGE);
+    gtk_stack_set_visible_child_name (GTK_STACK (widget), "no-cups-page");
 }
 
 static void
@@ -1218,7 +1216,7 @@ actualize_printers_list_cb (GObject      *source_object,
   if (priv->num_dests == 0 && !priv->new_printer_name)
     {
       widget = (GtkWidget*)
-        gtk_builder_get_object (priv->builder, "notebook");
+        gtk_builder_get_object (priv->builder, "main-vbox");
 
       pp_cups_connection_test_async (g_object_ref (cups), set_current_page, widget);
 
@@ -2663,7 +2661,6 @@ update_sensitivity (gpointer user_data)
   gboolean                 already_present_local;
   GList                   *iter;
   gchar                   *current_printer_name = NULL;
-  gchar                   *no_printer_label;
   gint                     i;
 
   priv = PRINTERS_PANEL_PRIVATE (self);
@@ -2745,11 +2742,6 @@ update_sensitivity (gpointer user_data)
   widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "printer-add-button2");
   gtk_widget_set_sensitive (widget, local_server && is_authorized && !no_cups && !priv->new_printer_name);
 
-  widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "no-printer-label");
-  no_printer_label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>", _("No printers"));
-  gtk_label_set_markup (GTK_LABEL (widget), no_printer_label);
-  g_free (no_printer_label);
-
   widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "printer-remove-button");
   gtk_widget_set_sensitive (widget, already_present_local && printer_selected && !no_cups);
 
diff --git a/panels/printers/printers.ui b/panels/printers/printers.ui
index f27efca..f887115 100644
--- a/panels/printers/printers.ui
+++ b/panels/printers/printers.ui
@@ -2,10 +2,7 @@
 <interface>
   <requires lib="gtk+" version="3.12"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkBox" id="main-vbox">
-    <property name="border_width">10</property>
-    <property name="orientation">vertical</property>
-    <property name="spacing">10</property>
+  <object class="GtkStack" id="main-vbox">
     <property name="margin-start">6</property>
     <property name="margin-end">6</property>
     <property name="margin-top">6</property>
@@ -13,7 +10,8 @@
     <child>
       <object class="GtkBox" id="hbox1">
         <property name="visible">True</property>
-        <property name="spacing">10</property>
+        <property name="spacing">20</property>
+        <property name="border_width">10</property>
         <child>
           <object class="GtkBox" id="vbox4">
             <property name="visible">True</property>
@@ -536,123 +534,108 @@
                 <property name="tab_fill">False</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkBox" id="hbuttonbox2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">10</property>
-                <property name="orientation">vertical</property>
-                <property name="valign">center</property>
-                <child>
-                  <object class="GtkImage" id="no-printer-image">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="valign">start</property>
-                    <property name="pixel_size">64</property>
-                    <property name="icon_name">printer-symbolic</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="no-printer-label">
-                    <property name="visible">True</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkButton" id="printer-add-button2">
-                    <property name="label" translatable="yes" comments="Translators: This button adds new 
printer.">Add a Printer</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="halign">center</property>
-                    <property name="relief">normal</property>
-                    <style>
-                      <class name="suggested-action"/>
-                    </style>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label21">
-                <property name="visible">True</property>
-                <property name="label">No printers</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkBox" id="vbox7">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">20</property>
-                <property name="orientation">vertical</property>
-                <child>
-                  <object class="GtkLabel" id="no-cups-label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="yalign">1</property>
-                    <property name="label" translatable="yes" comments="Translators: The CUPS server is not 
running (we can not connect to it).">Sorry! The system printing service
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="name">printers-list</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">10</property>
+        <property name="orientation">vertical</property>
+        <property name="valign">center</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="valign">start</property>
+            <property name="pixel_size">72</property>
+            <property name="icon_name">printer-symbolic</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">No printers</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+              <attribute name="scale" value="1.2"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="printer-add-button2">
+            <property name="label" translatable="yes" comments="Translators: This button adds new 
printer.">Add a Printer</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="halign">center</property>
+            <property name="relief">normal</property>
+            <style>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="name">empty-state</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">20</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="yalign">1</property>
+            <property name="label" translatable="yes" comments="Translators: The CUPS server is not running 
(we can not connect to it).">Sorry! The system printing service
 doesn't seem to be available.</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkImage" id="image1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="valign">start</property>
-                    <property name="pixel_size">64</property>
-                    <property name="icon_name">computer-fail</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label9">
-                <property name="visible">True</property>
-                <property name="label">No cups</property>
-              </object>
-              <packing>
-                <property name="position">2</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="valign">start</property>
+            <property name="pixel_size">64</property>
+            <property name="icon_name">computer-fail</property>
           </object>
           <packing>
             <property name="expand">True</property>
@@ -662,9 +645,7 @@ doesn't seem to be available.</property>
         </child>
       </object>
       <packing>
-        <property name="expand">True</property>
-        <property name="fill">True</property>
-        <property name="position">0</property>
+        <property name="name">no-cups-page</property>
       </packing>
     </child>
   </object>


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