printers: Store PpPrinterEntry instances for individual manipulation

We were actualizing the whole printers collection everytime
something should change.

These patch introduces a HashTable keyed by the unique printer.name,
which allows us to access individual instances of PpPrinterEntry.

https://bugzilla.gnome.org/show_bug.cgi?id=779079
This commit is contained in:
Felipe Borges 2017-02-24 10:57:47 +01:00
parent 5302047ff1
commit 89ff6a610e

View file

@ -99,6 +99,8 @@ struct _CcPrintersPanelPrivate
gchar *renamed_printer_name;
GHashTable *printer_entries;
gpointer dummy;
};
@ -218,6 +220,8 @@ cc_printers_panel_dispose (GObject *object)
priv->get_all_ppds_cancellable = NULL;
}
g_clear_pointer (&priv->printer_entries, g_hash_table_destroy);
G_OBJECT_CLASS (cc_printers_panel_parent_class)->dispose (object);
}
@ -594,6 +598,8 @@ add_printer_entry (CcPrintersPanel *self,
gtk_box_pack_start (GTK_BOX (content), GTK_WIDGET (printer_entry), FALSE, TRUE, 5);
gtk_widget_show_all (content);
g_hash_table_insert (priv->printer_entries, g_strdup (printer.name), printer_entry);
}
static void
@ -938,6 +944,11 @@ cc_printers_panel_init (CcPrintersPanel *self)
priv->all_ppds_list = NULL;
priv->printer_entries = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
NULL);
builder_result = gtk_builder_add_objects_from_resource (priv->builder,
"/org/gnome/control-center/printers/printers.ui",
objects, &error);