[gnome-control-center/wip/carlosg/issue-315: 7/7] wacom: Always try to add the stylus page UI on proximity



commit a4cc9d35b910ef0f0f44721581698cb3269afa53
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 20 13:31:59 2018 +0100

    wacom: Always try to add the stylus page UI on proximity
    
    This used to be done only if the stylus was "brand new", because pages for
    previously known styli are added when the tablet is detected/plugged. There
    are however situations where this may break: eg. the stylus was previously
    known through a tablet that is not plugged ATM. The tool is however "not
    new" so no UI is added for it.
    
    We should try to add the stylus invariably on proximity, add_stylus_page()
    ensures there is only one page per tool anyway.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/315

 panels/wacom/cc-wacom-panel.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 34cd11248..72c8c46a0 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -346,6 +346,7 @@ update_current_tool (CcWacomPanel  *panel,
        CcWacomTool *stylus;
        GsdDevice *gsd_device;
        guint64 serial, id;
+       gboolean added;
 
        if (!tool)
                return;
@@ -375,8 +376,6 @@ update_current_tool (CcWacomPanel  *panel,
                                                 wacom_device, serial);
 
        if (!stylus) {
-               gboolean added;
-
                id = gdk_device_tool_get_hardware_id (tool);
 
                /* The wacom driver sends a hw id of 0x2 for stylus and 0xa
@@ -395,24 +394,24 @@ update_current_tool (CcWacomPanel  *panel,
                stylus = cc_wacom_tool_new (serial, id, wacom_device);
                if (!stylus)
                        return;
+        }
 
-               added = add_stylus (panel, stylus);
+       added = add_stylus (panel, stylus);
 
-               if (added) {
-                       if (panel->stylus_notebook ==
-                           gtk_stack_get_visible_child (GTK_STACK (panel->stack))) {
-                               GtkWidget *widget;
-                               gint page;
+       if (added) {
+               if (panel->stylus_notebook ==
+                   gtk_stack_get_visible_child (GTK_STACK (panel->stack))) {
+                       GtkWidget *widget;
+                       gint page;
 
-                               widget = g_hash_table_lookup (panel->stylus_pages, stylus);
-                               page = gtk_notebook_page_num (GTK_NOTEBOOK (panel->stylus_notebook), widget);
-                               gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->stylus_notebook), page);
-                       } else {
-                               gtk_container_child_set (GTK_CONTAINER (panel->stack),
-                                                        panel->stylus_notebook,
-                                                        "needs-attention", TRUE,
-                                                        NULL);
-                       }
+                       widget = g_hash_table_lookup (panel->stylus_pages, stylus);
+                       page = gtk_notebook_page_num (GTK_NOTEBOOK (panel->stylus_notebook), widget);
+                       gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->stylus_notebook), page);
+               } else {
+                       gtk_container_child_set (GTK_CONTAINER (panel->stack),
+                                                panel->stylus_notebook,
+                                                "needs-attention", TRUE,
+                                                NULL);
                }
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]