summaryrefslogtreecommitdiff
path: root/panels/printers/cc-printers-panel.c
diff options
context:
space:
mode:
authorFelipe Borges <felipeborges@gnome.org>2017-05-16 13:37:25 +0200
committerFelipe Borges <felipeborges@gnome.org>2017-05-29 17:49:11 +0200
commit6dcf057a53ceccc3e1fbb91fd62ad7bfab9426e9 (patch)
treeae1e24b2b2fb43c4082f80293a12426733ade84e /panels/printers/cc-printers-panel.c
parent00bfa2dc13067b4ba7f2820e6e5029f01bf09e6f (diff)
downloadgnome-control-center-6dcf057a53ceccc3e1fbb91fd62ad7bfab9426e9.tar.gz
printers: Scroll view to show newly added Printer
In scenarios with a long list of printers, it might be difficult to find a newly added printer. This patch make the view scroll to the allocated position of the printer entry. https://bugzilla.gnome.org/show_bug.cgi?id=779506
Diffstat (limited to 'panels/printers/cc-printers-panel.c')
-rw-r--r--panels/printers/cc-printers-panel.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index a9504c649..d8a9f51c1 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -874,13 +874,16 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
{
CcPrintersPanelPrivate *priv;
CcPrintersPanel *self = (CcPrintersPanel*) user_data;
+ GtkScrolledWindow *scrolled_window;
+ GtkAllocation allocation;
+ GtkAdjustment *adjustment;
+ GtkWidget *printer_entry;
priv = PRINTERS_PANEL_PRIVATE (self);
if (priv->pp_new_printer_dialog)
g_clear_object (&priv->pp_new_printer_dialog);
- g_clear_pointer (&priv->new_printer_name, g_free);
g_clear_pointer (&priv->new_printer_location, g_free);
g_clear_pointer (&priv->new_printer_make_and_model, g_free);
@@ -902,6 +905,19 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
}
actualize_printers_list (self);
+
+ /* Scroll the view to show the newly added printer-entry. */
+ scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (priv->builder,
+ "scrolled-window"));
+ adjustment = gtk_scrolled_window_get_vadjustment (scrolled_window);
+
+ printer_entry = GTK_WIDGET (g_hash_table_lookup (priv->printer_entries,
+ priv->new_printer_name));
+ gtk_widget_get_allocation (printer_entry, &allocation);
+ g_clear_pointer (&priv->new_printer_name, g_free);
+
+ gtk_adjustment_set_value (adjustment,
+ allocation.y - gtk_widget_get_margin_top (printer_entry));
}
static void