summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-02-28 19:23:23 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-03-04 15:19:21 +0000
commit0d82613258b1171b0d19e873740ad8c7a477286f (patch)
treef5e5011bb10b564184a8ba73723a4a303ed5c0c5
parentfc1f83597d57c748d90bbff068e2fd6e97284674 (diff)
downloadgnome-control-center-0d82613258b1171b0d19e873740ad8c7a477286f.tar.gz
wacom: Bring back empty state view
This went mistakenly missing in the recent UI updates. Since this panel is still accessible through search despite tablet availability, we should have a proper empty state view when moving to the panel with no tablets available. Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1684
-rw-r--r--panels/wacom/cc-wacom-panel.c18
-rw-r--r--panels/wacom/cc-wacom-panel.ui52
2 files changed, 50 insertions, 20 deletions
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 0c808c24b..05592f3ea 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -49,6 +49,9 @@ struct _CcWacomPanel
GtkWidget *scrollable;
GtkWidget *tablets;
GtkWidget *styli;
+ GtkWidget *initial_state_stack;
+ GtkWidget *panel_view;
+ GtkWidget *panel_empty_state;
GHashTable *devices; /* key=GsdDevice, value=CcWacomDevice */
GHashTable *pages; /* key=CcWacomDevice, value=GtkWidget */
GHashTable *stylus_pages; /* key=CcWacomTool, value=GtkWidget */
@@ -349,6 +352,15 @@ update_test_button (CcWacomPanel *self)
}
static void
+update_initial_state (CcWacomPanel *self)
+{
+ gtk_stack_set_visible_child (GTK_STACK (self->initial_state_stack),
+ g_hash_table_size (self->devices) == 0 ?
+ self->panel_empty_state :
+ self->panel_view);
+}
+
+static void
update_highlighted_stylus (CcWacomPanel *panel,
CcWacomTool *stylus)
{
@@ -520,6 +532,9 @@ cc_wacom_panel_class_init (CcWacomPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, test_draw_area);
gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, tablets);
gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, styli);
+ gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, initial_state_stack);
+ gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, panel_empty_state);
+ gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, panel_view);
gtk_widget_class_bind_template_child (widget_class, CcWacomPanel, vadjustment);
}
@@ -582,6 +597,7 @@ device_removed_cb (CcWacomPanel *self,
g_hash_table_remove (self->devices, gsd_device);
check_remove_stylus_pages (self);
update_test_button (self);
+ update_initial_state (self);
}
static void
@@ -590,6 +606,7 @@ device_added_cb (CcWacomPanel *self,
{
add_known_device (self, device);
update_test_button (self);
+ update_initial_state (self);
}
void
@@ -663,6 +680,7 @@ cc_wacom_panel_init (CcWacomPanel *self)
add_known_device (self, l->data);
update_test_button (self);
+ update_initial_state (self);
}
GDBusProxy *
diff --git a/panels/wacom/cc-wacom-panel.ui b/panels/wacom/cc-wacom-panel.ui
index 28a9d79b6..77e7e16a9 100644
--- a/panels/wacom/cc-wacom-panel.ui
+++ b/panels/wacom/cc-wacom-panel.ui
@@ -15,34 +15,46 @@
</child>
<child type="content">
- <object class="GtkScrolledWindow">
- <property name="hscrollbar-policy">never</property>
- <property name="vadjustment">vadjustment</property>
+ <object class="GtkStack" id="initial_state_stack">
+ <property name="transition_duration">0</property>
<child>
- <object class="AdwClamp" id="scrollable">
- <property name="margin_top">32</property>
- <property name="margin_bottom">32</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
-
+ <object class="GtkScrolledWindow" id="panel_view">
+ <property name="hscrollbar-policy">never</property>
+ <property name="vadjustment">vadjustment</property>
<child>
- <object class="GtkBox">
- <property name="spacing">48</property>
- <property name="orientation">vertical</property>
+ <object class="AdwClamp" id="scrollable">
+ <property name="margin_top">32</property>
+ <property name="margin_bottom">32</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+
<child>
- <object class="GtkBox" id="tablets">
- <property name="orientation">vertical</property>
+ <object class="GtkBox">
<property name="spacing">48</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="styli">
<property name="orientation">vertical</property>
- <property name="spacing">48</property>
- </object>
+ <child>
+ <object class="GtkBox" id="tablets">
+ <property name="orientation">vertical</property>
+ <property name="spacing">48</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="styli">
+ <property name="orientation">vertical</property>
+ <property name="spacing">48</property>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwStatusPage" id="panel_empty_state">
+ <property name="icon-name">input-tablet-symbolic</property>
+ <property name="title" translatable="yes">No tablet detected</property>
+ <property name="description" translatable="yes">Please plug in or turn on your Wacom tablet.</property>
</object>
</child>
</object>