[gnome-control-center/gnome-3-26] printer: Don't show the supply level bar by default



commit 5ac6a0da687a0980d83af79e9cff4531edb1bc80
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Nov 21 15:16:53 2017 +0100

    printer: Don't show the supply level bar by default
    
    We were checking for the ink supply level at the callback of the
    supply bar "draw" signal. This way we were making the the widget
    visible, causing it to allocate vertical space even when it isn't
    desired.
    
    Now we check for the supply level before setting the visiblity of
    the supply level widget.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790667

 panels/printers/pp-printer-entry.c |   16 ++++++++++++++--
 panels/printers/printer-entry.ui   |    2 --
 2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/panels/printers/pp-printer-entry.c b/panels/printers/pp-printer-entry.c
index ba704b9..6aa202a 100644
--- a/panels/printers/pp-printer-entry.c
+++ b/panels/printers/pp-printer-entry.c
@@ -227,6 +227,15 @@ sanitize_printer_model (gchar *printer_make_and_model)
   return g_strdup (printer_model);
 }
 
+static gboolean
+supply_level_is_empty (PpPrinterEntry *self)
+{
+    return !((self->inklevel->marker_levels != NULL) &&
+             (self->inklevel->marker_colors != NULL) &&
+             (self->inklevel->marker_names != NULL) &&
+             (self->inklevel->marker_types != NULL));
+}
+
 /* To tone down the colors in the supply level bar
  * we shade them by darkening the hue.
  *
@@ -267,8 +276,7 @@ supply_levels_draw_cb (GtkWidget      *widget,
 
   gtk_render_background (context, cr, 0, 0, width, height);
 
-  if (self->inklevel->marker_levels && self->inklevel->marker_colors &&
-      self->inklevel->marker_names && self->inklevel->marker_types)
+  if (!supply_level_is_empty (self))
     {
       GSList   *markers = NULL;
       GSList   *tmp_list = NULL;
@@ -694,6 +702,7 @@ pp_printer_entry_new (cups_dest_t  printer,
   PpPrinterEntry *self;
   cups_ptype_t    printer_type = 0;
   gboolean        is_accepting_jobs;
+  gboolean        ink_supply_is_empty;
   gchar          *instance;
   gchar          *printer_uri = NULL;
   gchar          *location = NULL;
@@ -935,6 +944,9 @@ pp_printer_entry_new (cups_dest_t  printer,
     }
 
   g_signal_connect (self->supply_drawing_area, "draw", G_CALLBACK (supply_levels_draw_cb), self);
+  ink_supply_is_empty = supply_level_is_empty (self);
+  gtk_widget_set_visible (GTK_WIDGET (self->printer_inklevel_label), !ink_supply_is_empty);
+  gtk_widget_set_visible (GTK_WIDGET (self->supply_frame), !ink_supply_is_empty);
 
   pp_printer_entry_update_jobs_count (self);
 
diff --git a/panels/printers/printer-entry.ui b/panels/printers/printer-entry.ui
index 5ac2eb1..c72b90a 100644
--- a/panels/printers/printer-entry.ui
+++ b/panels/printers/printer-entry.ui
@@ -248,7 +248,6 @@
 
             <child>
               <object class="GtkLabel" id="printer_inklevel_label">
-                <property name="visible">True</property>
                 <property name="label" translatable="yes">Ink Level</property>
                 <property name="halign">end</property>
                 <property name="xalign">1</property>
@@ -264,7 +263,6 @@
 
             <child>
               <object class="GtkFrame" id="supply_frame">
-                <property name="visible">True</property>
                 <property name="valign">center</property>
                 <property name="halign">start</property>
                 <property name="height_request">18</property>


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