Blame SOURCES/printers-Update-entries.patch

cbd954
--- gnome-control-center-3.28.2/panels/printers/cc-printers-panel.c
cbd954
+++ gnome-control-center-3.28.2/panels/printers/cc-printers-panel.c
cbd954
@@ -105,6 +105,8 @@ struct _CcPrintersPanelPrivate
cbd954
   gchar    *renamed_printer_name;
cbd954
   gchar    *old_printer_name;
cbd954
   gchar    *deleted_printer_name;
cbd954
+  GList    *deleted_printers;
cbd954
+  GObject  *reference;
cbd954
 
cbd954
   GHashTable *printer_entries;
cbd954
   gboolean    entries_filled;
cbd954
@@ -267,18 +269,40 @@ printer_removed_cb (GObject      *source
cbd954
                     GAsyncResult *result,
cbd954
                     gpointer      user_data)
cbd954
 {
cbd954
-  GError *error = NULL;
cbd954
+  PpPrinter *printer = PP_PRINTER (source_object);
cbd954
+  g_autoptr(GError) error = NULL;
cbd954
+  g_autofree gchar *printer_name = NULL;
cbd954
 
cbd954
-  pp_printer_delete_finish (PP_PRINTER (source_object), result, &error);
cbd954
-  g_object_unref (source_object);
cbd954
+  g_object_get (printer, "printer-name", &printer_name, NULL);
cbd954
+  pp_printer_delete_finish (printer, result, &error);
cbd954
 
cbd954
-  if (error != NULL)
cbd954
+  if (user_data != NULL)
cbd954
     {
cbd954
-      g_warning ("Printer could not be deleted: %s", error->message);
cbd954
-      g_error_free (error);
cbd954
+      g_autoptr(GObject) reference = G_OBJECT (user_data);
cbd954
+
cbd954
+      if (g_object_get_data (reference, "self") != NULL)
cbd954
+        {
cbd954
+          CcPrintersPanel *self = CC_PRINTERS_PANEL (g_object_get_data (reference, "self"));
cbd954
+          CcPrintersPanelPrivate *priv = self->priv;
cbd954
+          GList           *iter;
cbd954
+
cbd954
+          for (iter = priv->deleted_printers; iter != NULL; iter = iter->next)
cbd954
+            {
cbd954
+              if (g_strcmp0 (iter->data, printer_name) == 0)
cbd954
+                {
cbd954
+                  g_free (iter->data);
cbd954
+                  priv->deleted_printers = g_list_delete_link (priv->deleted_printers, iter);
cbd954
+                  break;
cbd954
+                }
cbd954
+            }
cbd954
+        }
cbd954
     }
cbd954
+
cbd954
+  if (error != NULL)
cbd954
+    g_warning ("Printer could not be deleted: %s", error->message);
cbd954
 }
cbd954
 
cbd954
+
cbd954
 static void
cbd954
 cc_printers_panel_dispose (GObject *object)
cbd954
 {
cbd954
@@ -368,6 +392,12 @@ cc_printers_panel_dispose (GObject *obje
cbd954
 
cbd954
   g_clear_pointer (&priv->printer_entries, g_hash_table_destroy);
cbd954
 
cbd954
+  g_list_free_full (priv->deleted_printers, g_free);
cbd954
+  priv->deleted_printers = NULL;
cbd954
+  if (priv->reference != NULL)
cbd954
+    g_object_set_data (priv->reference, "self", NULL);
cbd954
+  g_clear_object (&priv->reference);
cbd954
+
cbd954
   G_OBJECT_CLASS (cc_printers_panel_parent_class)->dispose (object);
cbd954
 }
cbd954
 
cbd954
@@ -740,13 +770,16 @@ on_printer_deletion_undone (GtkButton *b
cbd954
 {
cbd954
   CcPrintersPanelPrivate *priv;
cbd954
   CcPrintersPanel        *self = (CcPrintersPanel*) user_data;
cbd954
+  GtkWidget              *widget;
cbd954
 
cbd954
   priv = PRINTERS_PANEL_PRIVATE (self);
cbd954
 
cbd954
   gtk_revealer_set_reveal_child (priv->notification, FALSE);
cbd954
 
cbd954
   g_clear_pointer (&priv->deleted_printer_name, g_free);
cbd954
-  actualize_printers_list (self);
cbd954
+
cbd954
+  widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "content");
cbd954
+  gtk_list_box_invalidate_filter (GTK_LIST_BOX (widget));
cbd954
 
cbd954
   cancel_notification_timeout (self);
cbd954
 }
cbd954
@@ -768,9 +801,11 @@ on_notification_dismissed (GtkButton *bu
cbd954
       pp_printer_delete_async (printer,
cbd954
                                NULL,
cbd954
                                printer_removed_cb,
cbd954
-                               NULL);
cbd954
+                               g_object_ref (priv->reference));
cbd954
 
cbd954
-      g_clear_pointer (&priv->deleted_printer_name, g_free);
cbd954
+      priv->deleted_printers = g_list_prepend (priv->deleted_printers, priv->deleted_printer_name);
cbd954
+      priv->deleted_printer_name = NULL;
cbd954
+      g_object_unref (printer);
cbd954
     }
cbd954
 
cbd954
   gtk_revealer_set_reveal_child (priv->notification, FALSE);
cbd954
@@ -793,8 +828,7 @@ on_printer_deleted (PpPrinterEntry *prin
cbd954
   GtkLabel               *label;
cbd954
   gchar                  *notification_message;
cbd954
   gchar                  *printer_name;
cbd954
-
cbd954
-  gtk_widget_hide (GTK_WIDGET (printer_entry));
cbd954
+  GtkWidget              *widget;
cbd954
 
cbd954
   priv = PRINTERS_PANEL_PRIVATE (self);
cbd954
 
cbd954
@@ -816,6 +850,9 @@ on_printer_deleted (PpPrinterEntry *prin
cbd954
   priv->deleted_printer_name = g_strdup (printer_name);
cbd954
   g_free (printer_name);
cbd954
 
cbd954
+  widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "content");
cbd954
+  gtk_list_box_invalidate_filter (GTK_LIST_BOX (widget));
cbd954
+
cbd954
   gtk_revealer_set_reveal_child (priv->notification, TRUE);
cbd954
 
cbd954
   priv->remove_printer_timeout_id = g_timeout_add_seconds (10, on_remove_printer_timeout, self);
cbd954
@@ -910,6 +947,36 @@ set_current_page (GObject      *source_o
cbd954
 }
cbd954
 
cbd954
 static void
cbd954
+destroy_nonexisting_entries (PpPrinterEntry *entry,
cbd954
+                             gpointer        user_data)
cbd954
+{
cbd954
+  CcPrintersPanelPrivate *priv;
cbd954
+  CcPrintersPanel        *self = (CcPrintersPanel *) user_data;
cbd954
+  g_autofree gchar       *printer_name = NULL;
cbd954
+  gboolean                exists = FALSE;
cbd954
+  gint                    i;
cbd954
+
cbd954
+  priv = PRINTERS_PANEL_PRIVATE (self);
cbd954
+
cbd954
+  g_object_get (G_OBJECT (entry), "printer-name", &printer_name, NULL);
cbd954
+
cbd954
+  for (i = 0; i < priv->num_dests; i++)
cbd954
+    {
cbd954
+      if (g_strcmp0 (priv->dests[i].name, printer_name) == 0)
cbd954
+        {
cbd954
+          exists = TRUE;
cbd954
+          break;
cbd954
+        }
cbd954
+    }
cbd954
+
cbd954
+  if (!exists)
cbd954
+    {
cbd954
+      gtk_widget_destroy (GTK_WIDGET (entry));
cbd954
+      g_hash_table_remove (priv->printer_entries, printer_name);
cbd954
+    }
cbd954
+}
cbd954
+
cbd954
+static void
cbd954
 actualize_printers_list_cb (GObject      *source_object,
cbd954
                             GAsyncResult *result,
cbd954
                             gpointer      user_data)
cbd954
@@ -920,6 +987,7 @@ actualize_printers_list_cb (GObject
cbd954
   PpCups                 *cups = PP_CUPS (source_object);
cbd954
   PpCupsDests            *cups_dests;
cbd954
   gboolean                new_printer_available = FALSE;
cbd954
+  gpointer                item;
cbd954
   GError                 *error = NULL;
cbd954
   int                     i;
cbd954
 
cbd954
@@ -950,7 +1018,7 @@ actualize_printers_list_cb (GObject
cbd954
     gtk_stack_set_visible_child_name (GTK_STACK (widget), "printers-list");
cbd954
 
cbd954
   widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "content");
cbd954
-  gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_destroy, NULL);
cbd954
+  gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) destroy_nonexisting_entries, self);
cbd954
 
cbd954
   for (i = 0; i < priv->num_dests; i++)
cbd954
     {
cbd954
@@ -961,13 +1029,14 @@ actualize_printers_list_cb (GObject
cbd954
 
cbd954
   for (i = 0; i < priv->num_dests; i++)
cbd954
     {
cbd954
-      if (g_strcmp0 (priv->dests[i].name, priv->deleted_printer_name) == 0)
cbd954
-          continue;
cbd954
-
cbd954
       if (new_printer_available && g_strcmp0 (priv->dests[i].name, priv->old_printer_name) == 0)
cbd954
           continue;
cbd954
 
cbd954
-      add_printer_entry (self, priv->dests[i]);
cbd954
+      item = g_hash_table_lookup (priv->printer_entries, priv->dests[i].name);
cbd954
+      if (item != NULL)
cbd954
+        pp_printer_entry_update (PP_PRINTER_ENTRY (item), priv->dests[i], priv->is_authorized);
cbd954
+      else
cbd954
+        add_printer_entry (self, priv->dests[i]);
cbd954
     }
cbd954
 
cbd954
   if (!priv->entries_filled)
cbd954
@@ -983,6 +1052,30 @@ actualize_printers_list_cb (GObject
cbd954
     }
cbd954
 
cbd954
   update_sensitivity (user_data);
cbd954
+
cbd954
+  if (priv->new_printer_name != NULL)
cbd954
+    {
cbd954
+      GtkScrolledWindow      *scrolled_window;
cbd954
+      GtkAllocation           allocation;
cbd954
+      GtkAdjustment          *adjustment;
cbd954
+      GtkWidget              *printer_entry;
cbd954
+
cbd954
+      /* Scroll the view to show the newly added printer-entry. */
cbd954
+      scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (priv->builder,
cbd954
+                                                                     "scrolled-window"));
cbd954
+      adjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
cbd954
+
cbd954
+      printer_entry = GTK_WIDGET (g_hash_table_lookup (priv->printer_entries,
cbd954
+                                                       priv->new_printer_name));
cbd954
+      if (printer_entry != NULL)
cbd954
+        {
cbd954
+          gtk_widget_get_allocation (printer_entry, &allocation);
cbd954
+          g_clear_pointer (&priv->new_printer_name, g_free);
cbd954
+
cbd954
+          gtk_adjustment_set_value (adjustment,
cbd954
+                                    allocation.y - gtk_widget_get_margin_top (printer_entry));
cbd954
+        }
cbd954
+    }
cbd954
 }
cbd954
 
cbd954
 static void
cbd954
@@ -1028,10 +1121,6 @@ new_printer_dialog_response_cb (PpNewPri
cbd954
 {
cbd954
   CcPrintersPanelPrivate *priv;
cbd954
   CcPrintersPanel        *self = (CcPrintersPanel*) user_data;
cbd954
-  GtkScrolledWindow      *scrolled_window;
cbd954
-  GtkAllocation           allocation;
cbd954
-  GtkAdjustment          *adjustment;
cbd954
-  GtkWidget              *printer_entry;
cbd954
 
cbd954
   priv = PRINTERS_PANEL_PRIVATE (self);
cbd954
 
cbd954
@@ -1059,22 +1148,6 @@ new_printer_dialog_response_cb (PpNewPri
cbd954
     }
cbd954
 
cbd954
   actualize_printers_list (self);
cbd954
-
cbd954
-  if (priv->new_printer_name == NULL)
cbd954
-    return;
cbd954
-
cbd954
-  /* Scroll the view to show the newly added printer-entry. */
cbd954
-  scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (priv->builder,
cbd954
-                                                                 "scrolled-window"));
cbd954
-  adjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
cbd954
-
cbd954
-  printer_entry = GTK_WIDGET (g_hash_table_lookup (priv->printer_entries,
cbd954
-                                                   priv->new_printer_name));
cbd954
-  gtk_widget_get_allocation (printer_entry, &allocation);
cbd954
-  g_clear_pointer (&priv->new_printer_name, g_free);
cbd954
-
cbd954
-  gtk_adjustment_set_value (adjustment,
cbd954
-                            allocation.y - gtk_widget_get_margin_top (printer_entry));
cbd954
 }
cbd954
 
cbd954
 static void
cbd954
@@ -1288,11 +1361,17 @@ filter_function (GtkListBoxRow *row,
cbd954
   CcPrintersPanel        *self = (CcPrintersPanel*) user_data;
cbd954
   GtkWidget              *search_entry;
cbd954
   gboolean                retval;
cbd954
-  gchar                  *search;
cbd954
-  gchar                  *name;
cbd954
-  gchar                  *location;
cbd954
-  gchar                  *printer_name;
cbd954
-  gchar                  *printer_location;
cbd954
+  g_autofree gchar       *search = NULL;
cbd954
+  g_autofree gchar       *name = NULL;
cbd954
+  g_autofree gchar       *location = NULL;
cbd954
+  g_autofree gchar       *printer_name = NULL;
cbd954
+  g_autofree gchar       *printer_location = NULL;
cbd954
+  GList                  *iter;
cbd954
+
cbd954
+  g_object_get (G_OBJECT (row),
cbd954
+                "printer-name", &printer_name,
cbd954
+                "printer-location", &printer_location,
cbd954
+                NULL);
cbd954
 
cbd954
   priv = PRINTERS_PANEL_PRIVATE (self);
cbd954
 
cbd954
@@ -1300,31 +1379,72 @@ filter_function (GtkListBoxRow *row,
cbd954
     gtk_builder_get_object (priv->builder, "search-entry");
cbd954
 
cbd954
   if (gtk_entry_get_text_length (GTK_ENTRY (search_entry)) == 0)
cbd954
-    return TRUE;
cbd954
+    {
cbd954
+      retval = TRUE;
cbd954
+    }
cbd954
+  else
cbd954
+    {
cbd954
+      name = cc_util_normalize_casefold_and_unaccent (printer_name);
cbd954
+      location = cc_util_normalize_casefold_and_unaccent (printer_location);
cbd954
 
cbd954
-  g_object_get (G_OBJECT (row),
cbd954
-                "printer-name", &printer_name,
cbd954
-                "printer-location", &printer_location,
cbd954
-                NULL);
cbd954
+      search = cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (search_entry)));
cbd954
 
cbd954
-  name = cc_util_normalize_casefold_and_unaccent (printer_name);
cbd954
-  location = cc_util_normalize_casefold_and_unaccent (printer_location);
cbd954
+      retval = strstr (name, search) != NULL;
cbd954
+      if (location != NULL)
cbd954
+          retval = retval || (strstr (location, search) != NULL);
cbd954
+    }
cbd954
 
cbd954
-  g_free (printer_name);
cbd954
-  g_free (printer_location);
cbd954
+  if (priv->deleted_printer_name != NULL &&
cbd954
+      g_strcmp0 (priv->deleted_printer_name, printer_name) == 0)
cbd954
+    {
cbd954
+      retval = FALSE;
cbd954
+    }
cbd954
 
cbd954
-  search = cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (search_entry)));
cbd954
+  if (priv->deleted_printers != NULL)
cbd954
+    {
cbd954
+      for (iter = priv->deleted_printers; iter != NULL; iter = iter->next)
cbd954
+        {
cbd954
+          if (g_strcmp0 (iter->data, printer_name) == 0)
cbd954
+            {
cbd954
+              retval = FALSE;
cbd954
+              break;
cbd954
+            }
cbd954
+        }
cbd954
+    }
cbd954
 
cbd954
+  return retval;
cbd954
+}
cbd954
 
cbd954
-  retval = strstr (name, search) != NULL;
cbd954
-  if (location != NULL)
cbd954
-      retval = retval || (strstr (location, search) != NULL);
cbd954
+static gint
cbd954
+sort_function (GtkListBoxRow *row1,
cbd954
+               GtkListBoxRow *row2,
cbd954
+               gpointer       user_data)
cbd954
+{
cbd954
+  g_autofree gchar *printer_name1 = NULL;
cbd954
+  g_autofree gchar *printer_name2 = NULL;
cbd954
 
cbd954
-  g_free (search);
cbd954
-  g_free (name);
cbd954
-  g_free (location);
cbd954
+  g_object_get (G_OBJECT (row1),
cbd954
+                "printer-name", &printer_name1,
cbd954
+                NULL);
cbd954
 
cbd954
-  return retval;
cbd954
+  g_object_get (G_OBJECT (row2),
cbd954
+                "printer-name", &printer_name2,
cbd954
+                NULL);
cbd954
+
cbd954
+  if (printer_name1 != NULL)
cbd954
+    {
cbd954
+      if (printer_name2 != NULL)
cbd954
+        return g_ascii_strcasecmp (printer_name1, printer_name2);
cbd954
+      else
cbd954
+        return 1;
cbd954
+    }
cbd954
+  else
cbd954
+    {
cbd954
+      if (printer_name2 != NULL)
cbd954
+        return -1;
cbd954
+      else
cbd954
+        return 0;
cbd954
+    }
cbd954
 }
cbd954
 
cbd954
 static void
cbd954
@@ -1364,6 +1484,8 @@ cc_printers_panel_init (CcPrintersPanel
cbd954
   priv->renamed_printer_name = NULL;
cbd954
   priv->old_printer_name = NULL;
cbd954
   priv->deleted_printer_name = NULL;
cbd954
+  priv->deleted_printers = NULL;
cbd954
+  priv->reference = g_object_new (G_TYPE_OBJECT, NULL);
cbd954
 
cbd954
   priv->permission = NULL;
cbd954
   priv->lockdown_settings = NULL;
cbd954
@@ -1380,6 +1502,8 @@ cc_printers_panel_init (CcPrintersPanel
cbd954
   priv->actualize_printers_list_cancellable = g_cancellable_new ();
cbd954
   priv->cups_status_check_cancellable = g_cancellable_new ();
cbd954
 
cbd954
+  g_object_set_data_full (priv->reference, "self", self, NULL);
cbd954
+
cbd954
   builder_result = gtk_builder_add_objects_from_resource (priv->builder,
cbd954
                                                           "/org/gnome/control-center/printers/printers.ui",
cbd954
                                                           objects, &error);
cbd954
@@ -1430,6 +1554,10 @@ cc_printers_panel_init (CcPrintersPanel
cbd954
                             "search-changed",
cbd954
                             G_CALLBACK (gtk_list_box_invalidate_filter),
cbd954
                             widget);
cbd954
+  gtk_list_box_set_sort_func (GTK_LIST_BOX (widget),
cbd954
+                              sort_function,
cbd954
+                              NULL,
cbd954
+                              NULL);
cbd954
 
cbd954
   priv->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
cbd954
   if (priv->lockdown_settings)
cbd954
--- gnome-control-center-3.28.2/panels/printers/pp-printer-entry.c
cbd954
+++ gnome-control-center-3.28.2/panels/printers/pp-printer-entry.c
cbd954
@@ -45,7 +45,6 @@ struct _PpPrinterEntry
cbd954
 {
cbd954
   GtkListBoxRow parent;
cbd954
 
cbd954
-  gchar    *printer_uri;
cbd954
   gchar    *printer_name;
cbd954
   gchar    *ppd_file_name;
cbd954
   int       num_jobs;
cbd954
@@ -156,10 +155,27 @@ pp_printer_entry_set_property (GObject
cbd954
     }
cbd954
 }
cbd954
 
cbd954
+static InkLevelData *
cbd954
+ink_level_data_new (void)
cbd954
+{
cbd954
+  return g_slice_new0 (InkLevelData);
cbd954
+}
cbd954
+
cbd954
+static void
cbd954
+ink_level_data_free (InkLevelData *data)
cbd954
+{
cbd954
+  g_clear_pointer (&data->marker_names, g_free);
cbd954
+  g_clear_pointer (&data->marker_levels, g_free);
cbd954
+  g_clear_pointer (&data->marker_colors, g_free);
cbd954
+  g_clear_pointer (&data->marker_types, g_free);
cbd954
+  g_slice_free (InkLevelData, data);
cbd954
+}
cbd954
+
cbd954
 static void
cbd954
 pp_printer_entry_init (PpPrinterEntry *self)
cbd954
 {
cbd954
   gtk_widget_init_template (GTK_WIDGET (self));
cbd954
+  self->inklevel = ink_level_data_new ();
cbd954
 }
cbd954
 
cbd954
 typedef struct {
cbd954
@@ -260,9 +276,8 @@ tone_down_color (GdkRGBA *color,
cbd954
 }
cbd954
 
cbd954
 static gboolean
cbd954
-supply_levels_draw_cb (GtkWidget      *widget,
cbd954
-                       cairo_t        *cr,
cbd954
-                       PpPrinterEntry *self)
cbd954
+supply_levels_draw_cb (PpPrinterEntry *self,
cbd954
+                       cairo_t        *cr)
cbd954
 {
cbd954
   GtkStyleContext        *context;
cbd954
   gboolean                is_empty = TRUE;
cbd954
@@ -271,10 +286,10 @@ supply_levels_draw_cb (GtkWidget      *w
cbd954
   gint                    height;
cbd954
   int                     i;
cbd954
 
cbd954
-  context = gtk_widget_get_style_context (widget);
cbd954
+  context = gtk_widget_get_style_context (GTK_WIDGET (self->supply_drawing_area));
cbd954
 
cbd954
-  width = gtk_widget_get_allocated_width (widget);
cbd954
-  height = gtk_widget_get_allocated_height (widget);
cbd954
+  width = gtk_widget_get_allocated_width (GTK_WIDGET (self->supply_drawing_area));
cbd954
+  height = gtk_widget_get_allocated_height (GTK_WIDGET (self->supply_drawing_area));
cbd954
 
cbd954
   gtk_render_background (context, cr, 0, 0, width, height);
cbd954
 
cbd954
@@ -376,13 +391,13 @@ supply_levels_draw_cb (GtkWidget      *w
cbd954
 
cbd954
     if (tooltip_text)
cbd954
       {
cbd954
-        gtk_widget_set_tooltip_text (widget, tooltip_text);
cbd954
+        gtk_widget_set_tooltip_text (GTK_WIDGET (self->supply_drawing_area), tooltip_text);
cbd954
         g_free (tooltip_text);
cbd954
       }
cbd954
     else
cbd954
       {
cbd954
-        gtk_widget_set_tooltip_text (widget, NULL);
cbd954
-        gtk_widget_set_has_tooltip (widget, FALSE);
cbd954
+        gtk_widget_set_tooltip_text (GTK_WIDGET (self->supply_drawing_area), NULL);
cbd954
+        gtk_widget_set_has_tooltip (GTK_WIDGET (self->supply_drawing_area), FALSE);
cbd954
       }
cbd954
     }
cbd954
 
cbd954
@@ -727,11 +742,34 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
                       gboolean     is_authorized)
cbd954
 {
cbd954
   PpPrinterEntry *self;
cbd954
+
cbd954
+  self = g_object_new (PP_PRINTER_ENTRY_TYPE, "printer-name", printer.name, NULL);
cbd954
+
cbd954
+  self->clean_command = pp_maintenance_command_new (self->printer_name,
cbd954
+                                                    "Clean",
cbd954
+                                                    "all",
cbd954
+                                                    /* Translators: Name of job which makes printer to clean its heads */
cbd954
+                                                    _("Clean print heads"));
cbd954
+  check_clean_heads_maintenance_command (self);
cbd954
+
cbd954
+  g_signal_connect_object (self->supply_drawing_area, "draw", G_CALLBACK (supply_levels_draw_cb), self, G_CONNECT_SWAPPED);
cbd954
+
cbd954
+  pp_printer_entry_update (self, printer, is_authorized);
cbd954
+
cbd954
+  return self;
cbd954
+}
cbd954
+
cbd954
+void
cbd954
+pp_printer_entry_update (PpPrinterEntry *self,
cbd954
+                         cups_dest_t     printer,
cbd954
+                         gboolean        is_authorized)
cbd954
+{
cbd954
   cups_ptype_t    printer_type = 0;
cbd954
-  gboolean        is_accepting_jobs;
cbd954
+  gboolean        is_accepting_jobs = TRUE;
cbd954
   gboolean        ink_supply_is_empty;
cbd954
   gchar          *instance;
cbd954
   gchar          *printer_uri = NULL;
cbd954
+  const gchar    *device_uri = NULL;
cbd954
   gchar          *location = NULL;
cbd954
   gchar          *printer_icon_name = NULL;
cbd954
   gchar          *default_icon_name = NULL;
cbd954
@@ -798,10 +836,6 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
       N_("The optical photo conductor is no longer functioning")
cbd954
     };
cbd954
 
cbd954
-  self = g_object_new (PP_PRINTER_ENTRY_TYPE, "printer-name", printer.name, NULL);
cbd954
-
cbd954
-  self->inklevel = g_slice_new0 (InkLevelData);
cbd954
-
cbd954
   if (printer.instance)
cbd954
     {
cbd954
       instance = g_strdup_printf ("%s / %s", printer.name, printer.instance);
cbd954
@@ -816,7 +850,7 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
   for (i = 0; i < printer.num_options; i++)
cbd954
     {
cbd954
       if (g_strcmp0 (printer.options[i].name, "device-uri") == 0)
cbd954
-        self->printer_uri = printer.options[i].value;
cbd954
+        device_uri = printer.options[i].value;
cbd954
       else if (g_strcmp0 (printer.options[i].name, "printer-uri-supported") == 0)
cbd954
         printer_uri = printer.options[i].value;
cbd954
       else if (g_strcmp0 (printer.options[i].name, "printer-type") == 0)
cbd954
@@ -826,13 +860,25 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
       else if (g_strcmp0 (printer.options[i].name, "printer-state-reasons") == 0)
cbd954
         reason = printer.options[i].value;
cbd954
       else if (g_strcmp0 (printer.options[i].name, "marker-names") == 0)
cbd954
-        self->inklevel->marker_names = g_strcompress (printer.options[i].value);
cbd954
+        {
cbd954
+          g_free (self->inklevel->marker_names);
cbd954
+          self->inklevel->marker_names = g_strcompress (printer.options[i].value);
cbd954
+        }
cbd954
       else if (g_strcmp0 (printer.options[i].name, "marker-levels") == 0)
cbd954
-        self->inklevel->marker_levels = g_strdup (printer.options[i].value);
cbd954
+        {
cbd954
+          g_free (self->inklevel->marker_levels);
cbd954
+          self->inklevel->marker_levels = g_strdup (printer.options[i].value);
cbd954
+        }
cbd954
       else if (g_strcmp0 (printer.options[i].name, "marker-colors") == 0)
cbd954
-        self->inklevel->marker_colors = g_strdup (printer.options[i].value);
cbd954
+        {
cbd954
+          g_free (self->inklevel->marker_colors);
cbd954
+          self->inklevel->marker_colors = g_strdup (printer.options[i].value);
cbd954
+        }
cbd954
       else if (g_strcmp0 (printer.options[i].name, "marker-types") == 0)
cbd954
-        self->inklevel->marker_types = g_strdup (printer.options[i].value);
cbd954
+        {
cbd954
+          g_free (self->inklevel->marker_types);
cbd954
+          self->inklevel->marker_types = g_strdup (printer.options[i].value);
cbd954
+        }
cbd954
       else if (g_strcmp0 (printer.options[i].name, "printer-make-and-model") == 0)
cbd954
         printer_make_and_model = printer.options[i].value;
cbd954
       else if (g_strcmp0 (printer.options[i].name, "printer-state") == 0)
cbd954
@@ -896,6 +942,11 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
       gtk_label_set_label (self->error_status, status);
cbd954
       gtk_widget_set_visible (GTK_WIDGET (self->printer_error), TRUE);
cbd954
     }
cbd954
+  else
cbd954
+    {
cbd954
+      gtk_label_set_label (self->error_status, "");
cbd954
+      gtk_widget_set_visible (GTK_WIDGET (self->printer_error), FALSE);
cbd954
+    }
cbd954
 
cbd954
   switch (self->printer_state)
cbd954
     {
cbd954
@@ -921,7 +972,7 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
         break;
cbd954
     }
cbd954
 
cbd954
-  if (printer_is_local (printer_type, self->printer_uri))
cbd954
+  if (printer_is_local (printer_type, device_uri))
cbd954
     printer_icon_name = g_strdup ("printer");
cbd954
   else
cbd954
     printer_icon_name = g_strdup ("printer-network");
cbd954
@@ -931,14 +982,8 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
   self->is_accepting_jobs = is_accepting_jobs;
cbd954
   self->is_authorized = is_authorized;
cbd954
 
cbd954
-  self->printer_hostname = printer_get_hostname (printer_type, self->printer_uri, printer_uri);
cbd954
-
cbd954
-  self->clean_command = pp_maintenance_command_new (self->printer_name,
cbd954
-                                                    "Clean",
cbd954
-                                                    "all",
cbd954
-                                                    /* Translators: Name of job which makes printer to clean its heads */
cbd954
-                                                    _("Clean print heads"));
cbd954
-  check_clean_heads_maintenance_command (self);
cbd954
+  g_free (self->printer_hostname);
cbd954
+  self->printer_hostname = printer_get_hostname (printer_type, device_uri, printer_uri);
cbd954
 
cbd954
   gtk_image_set_from_icon_name (self->printer_icon, printer_icon_name, GTK_ICON_SIZE_DIALOG);
cbd954
   gtk_label_set_text (self->printer_status, printer_status);
cbd954
@@ -970,7 +1015,6 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
       gtk_label_set_text (self->printer_location_address_label, location);
cbd954
     }
cbd954
 
cbd954
-  g_signal_connect (self->supply_drawing_area, "draw", G_CALLBACK (supply_levels_draw_cb), self);
cbd954
   ink_supply_is_empty = supply_level_is_empty (self);
cbd954
   gtk_widget_set_visible (GTK_WIDGET (self->printer_inklevel_label), !ink_supply_is_empty);
cbd954
   gtk_widget_set_visible (GTK_WIDGET (self->supply_frame), !ink_supply_is_empty);
cbd954
@@ -983,8 +1027,6 @@ pp_printer_entry_new (cups_dest_t  print
cbd954
   g_free (instance);
cbd954
   g_free (printer_icon_name);
cbd954
   g_free (default_icon_name);
cbd954
-
cbd954
-  return self;
cbd954
 }
cbd954
 
cbd954
 static void
cbd954
@@ -1008,6 +1050,7 @@ pp_printer_entry_dispose (GObject *objec
cbd954
   g_clear_pointer (&self->printer_location, g_free);
cbd954
   g_clear_pointer (&self->printer_make_and_model, g_free);
cbd954
   g_clear_pointer (&self->printer_hostname, g_free);
cbd954
+  g_clear_pointer (&self->inklevel, ink_level_data_free);
cbd954
 
cbd954
   if (self->get_jobs_cancellable != NULL)
cbd954
     {
cbd954
--- gnome-control-center-3.28.2/panels/printers/pp-printer-entry.h
cbd954
+++ gnome-control-center-3.28.2/panels/printers/pp-printer-entry.h
cbd954
@@ -42,4 +42,8 @@ void            pp_printer_entry_show_jo
cbd954
 
cbd954
 void            pp_printer_entry_authenticate_jobs (PpPrinterEntry *self);
cbd954
 
cbd954
+void            pp_printer_entry_update (PpPrinterEntry *self,
cbd954
+                                         cups_dest_t     printer,
cbd954
+                                         gboolean        is_authorized);
cbd954
+
cbd954
 #endif /* PP_PRINTER_ENTRY_H */