printers: Show empty-state after removal of the last printer
Check whether the currently removed printer was last. Also check whether there are other printer being removed by CUPS right now (their amount is still part of self->num_dests). Do this check also in actualize_printers_list_cb() to catch corner cases from timing point of view. This will handle them with some delay if they show up. When undone, just check whether the number of printers is higher than 0 and show the printers-list page. Fixes #2023
This commit is contained in:
parent
c965de1eb4
commit
5ceabcb5c7
1 changed files with 15 additions and 1 deletions
|
@ -127,6 +127,9 @@ static void actualize_printers_list (CcPrintersPanel *self);
|
|||
static void update_sensitivity (gpointer user_data);
|
||||
static void detach_from_cups_notifier (gpointer data);
|
||||
static void free_dests (CcPrintersPanel *self);
|
||||
static void set_current_page (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data);
|
||||
|
||||
static void
|
||||
execute_action (CcPrintersPanel *self,
|
||||
|
@ -619,6 +622,12 @@ on_printer_deletion_undone (CcPrintersPanel *self)
|
|||
gtk_list_box_invalidate_filter (GTK_LIST_BOX (widget));
|
||||
|
||||
g_clear_handle_id (&self->remove_printer_timeout_id, g_source_remove);
|
||||
|
||||
if (self->num_dests > 0)
|
||||
{
|
||||
widget = (GtkWidget *) gtk_builder_get_object (self->builder, "main-vbox");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (widget), "printers-list");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -687,6 +696,9 @@ on_printer_deleted (CcPrintersPanel *self,
|
|||
gtk_revealer_set_reveal_child (self->notification, TRUE);
|
||||
|
||||
self->remove_printer_timeout_id = g_timeout_add_seconds (10, G_SOURCE_FUNC (on_remove_printer_timeout), self);
|
||||
|
||||
if (self->num_dests == 1 + g_list_length (self->deleted_printers))
|
||||
pp_cups_connection_test_async (self->cups, NULL, set_current_page, self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -817,7 +829,9 @@ actualize_printers_list_cb (GObject *source_object,
|
|||
g_free (cups_dests);
|
||||
|
||||
widget = (GtkWidget*) gtk_builder_get_object (self->builder, "main-vbox");
|
||||
if (self->num_dests == 0 && !self->new_printer_name)
|
||||
if ((self->num_dests == 0 && self->new_printer_name == NULL) ||
|
||||
(self->num_dests == 1 + g_list_length (self->deleted_printers) &&
|
||||
self->deleted_printer_name != NULL))
|
||||
pp_cups_connection_test_async (PP_CUPS (source_object), NULL, set_current_page, self);
|
||||
else
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (widget), "printers-list");
|
||||
|
|
Loading…
Add table
Reference in a new issue