[gnome-control-center] printers: Scroll view to show newly added Printer
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Scroll view to show newly added Printer
- Date: Mon, 29 May 2017 15:49:42 +0000 (UTC)
commit 6dcf057a53ceccc3e1fbb91fd62ad7bfab9426e9
Author: Felipe Borges <felipeborges gnome org>
Date: Tue May 16 13:37:25 2017 +0200
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
panels/printers/cc-printers-panel.c | 18 +++++++++++++++++-
panels/printers/printers.ui | 2 +-
2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index a9504c6..d8a9f51 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
diff --git a/panels/printers/printers.ui b/panels/printers/printers.ui
index 9dcf0cb..71aa758 100644
--- a/panels/printers/printers.ui
+++ b/panels/printers/printers.ui
@@ -126,7 +126,7 @@
</object>
</child>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkScrolledWindow" id="scrolled-window">
<property name="visible">True</property>
<property name="hscrollbar-policy">GTK_POLICY_NEVER</property>
<property name="min-content-height">490</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]