diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-11-16 17:18:15 +0100 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2021-11-18 14:57:22 +0000 |
commit | a93a023229b91ea471977c6e4f3ca3ae4f3847a4 (patch) | |
tree | 3240a52e5ab85da0242ceaefa5603837d40b8cac | |
parent | d47b9be08a62804823867cca4061ace9945a9690 (diff) | |
download | gnome-control-center-a93a023229b91ea471977c6e4f3ca3ae4f3847a4.tar.gz |
wacom: Split off notebook switching for detected stylus
This will reduce code duplication for mocking styli.
-rw-r--r-- | panels/wacom/cc-wacom-panel.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c index 17404c1bd..643955c3a 100644 --- a/panels/wacom/cc-wacom-panel.c +++ b/panels/wacom/cc-wacom-panel.c @@ -331,6 +331,26 @@ update_test_button (CcWacomPanel *self) } static void +update_stylus_notebook (CcWacomPanel *panel, + CcWacomTool *stylus) +{ + 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); + } +} + +static void update_current_tool (CcWacomPanel *panel, GdkDevice *device, GdkDeviceTool *tool) @@ -392,22 +412,8 @@ update_current_tool (CcWacomPanel *panel, added = add_stylus (panel, stylus); - 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); - } - } + if (added) + update_stylus_notebook (panel, stylus); cc_tablet_tool_map_add_relation (panel->tablet_tool_map, wacom_device, stylus); |