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