[gnome-control-center/gbsneto/panel-headerbar-cleanup: 14/14] window: Install action to navigate main leaflet
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/panel-headerbar-cleanup: 14/14] window: Install action to navigate main leaflet
- Date: Wed, 19 Jan 2022 22:43:21 +0000 (UTC)
commit 5dba261637d8dd31db4800dde3fe7e4bf87348b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jan 19 19:39:04 2022 -0300
window: Install action to navigate main leaflet
This allows implementing the back button of panel titlebars
trivially, which is also done in this commit.
panels/display/cc-display-panel.ui | 2 ++
panels/network/cc-wifi-panel.ui | 2 ++
shell/cc-panel.ui | 2 ++
shell/cc-window.c | 13 +++++++++++++
4 files changed, 19 insertions(+)
---
diff --git a/panels/display/cc-display-panel.ui b/panels/display/cc-display-panel.ui
index 6ddc407e0..0d44917db 100644
--- a/panels/display/cc-display-panel.ui
+++ b/panels/display/cc-display-panel.ui
@@ -72,6 +72,8 @@
<object class="GtkButton">
<property name="visible" bind-source="CcDisplayPanel" bind-property="folded"
bind-flags="default|sync-create" />
<property name="icon-name">go-previous-symbolic</property>
+ <property name="action-name">window.navigate</property>
+ <property name="action-target">0</property> <!-- 0:
ADW_NAVIGATION_DIRECTION_BACK -->
<style>
<class name="flat" />
</style>
diff --git a/panels/network/cc-wifi-panel.ui b/panels/network/cc-wifi-panel.ui
index e1533ccd4..312a396fa 100644
--- a/panels/network/cc-wifi-panel.ui
+++ b/panels/network/cc-wifi-panel.ui
@@ -10,6 +10,8 @@
<object class="GtkButton">
<property name="visible" bind-source="CcWifiPanel" bind-property="folded"
bind-flags="default|sync-create" />
<property name="icon-name">go-previous-symbolic</property>
+ <property name="action-name">window.navigate</property>
+ <property name="action-target">0</property> <!-- 0: ADW_NAVIGATION_DIRECTION_BACK -->
<style>
<class name="flat" />
</style>
diff --git a/shell/cc-panel.ui b/shell/cc-panel.ui
index 34d08f679..cf2932442 100644
--- a/shell/cc-panel.ui
+++ b/shell/cc-panel.ui
@@ -18,6 +18,8 @@
<object class="GtkButton">
<property name="visible" bind-source="CcPanel" bind-property="folded"
bind-flags="default|sync-create" />
<property name="icon-name">go-previous-symbolic</property>
+ <property name="action-name">window.navigate</property>
+ <property name="action-target">0</property> <!-- 0: ADW_NAVIGATION_DIRECTION_BACK -->
<style>
<class name="flat" />
</style>
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 589f5a45a..633139e5f 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -480,6 +480,17 @@ switch_to_previous_panel (CcWindow *self)
}
/* Callbacks */
+
+static void
+navigate_action_cb (GtkWidget *widget,
+ const gchar *action_name,
+ GVariant *parameter)
+{
+ CcWindow *self = CC_WINDOW (widget);
+
+ adw_leaflet_navigate (self->main_leaflet, g_variant_get_int32 (parameter));
+}
+
static void
on_main_leaflet_folded_changed_cb (CcWindow *self)
{
@@ -811,6 +822,8 @@ cc_window_class_init (CcWindowClass *klass)
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_w, GDK_CONTROL_MASK, "window.close", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_W, GDK_CONTROL_MASK, "window.close", NULL);
+ gtk_widget_class_install_action (widget_class, "window.navigate", "i", navigate_action_cb);
+
g_type_ensure (CC_TYPE_PANEL_LIST);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]