[gnome-todo] task-lists-workspace: Reintroduce split headerbars
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] task-lists-workspace: Reintroduce split headerbars
- Date: Thu, 16 Sep 2021 17:52:22 +0000 (UTC)
commit 7e8ca5ce4246a422e7d4430a661fe3948aab825d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Sep 14 19:02:00 2021 -0300
task-lists-workspace: Reintroduce split headerbars
Now that the task lists workspace handles the headerbar, it is
possible to reintroduce split headerbars decently.
.../gtd-task-lists-workspace.c | 29 +++----
.../gtd-task-lists-workspace.ui | 94 ++++++++++++----------
2 files changed, 68 insertions(+), 55 deletions(-)
---
diff --git a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
index 58566183..24d3c66e 100644
--- a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
+++ b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.c
@@ -36,14 +36,16 @@ struct _GtdTaskListsWorkspace
GtkBox parent;
GtkWidget *back_button;
+ GtkWidget *content_box;
GtkMenuButton *gear_menu_button;
+ AdwLeaflet *leaflet;
GtkWidget *new_list_button;
GtkBox *panel_box_end;
GtkBox *panel_box_start;
GtkMenuButton *primary_menu_button;
GtkStack *stack;
GtdSidebar *sidebar;
- GtkWidget *toggle_sidebar_button;
+ GtkWidget *sidebar_box;
GtdPanel *active_panel;
GtdPanel *task_list_panel;
@@ -175,6 +177,7 @@ on_action_activate_panel_activated_cb (GSimpleAction *simple,
gtd_panel_activate (panel, panel_parameters);
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (panel));
+ adw_leaflet_set_visible_child (self->leaflet, self->content_box);
}
static void
@@ -192,6 +195,13 @@ on_action_toggle_archive_activated_cb (GSimpleAction *simple,
gtd_sidebar_set_archive_visible (self->sidebar, archive_visible);
}
+static void
+on_back_sidebar_button_clicked_cb (GtkButton *button,
+ GtdTaskListsWorkspace *self)
+{
+ adw_leaflet_set_visible_child (self->leaflet, self->sidebar_box);
+}
+
static void
on_back_button_clicked_cb (GtkButton *button,
GtdTaskListsWorkspace *self)
@@ -365,15 +375,9 @@ static void
gtd_task_lists_workspace_constructed (GObject *object)
{
GtdTaskListsWorkspace *self = (GtdTaskListsWorkspace *)object;
- GtdManager *manager;
-
- self = GTD_TASK_LISTS_WORKSPACE (object);
G_OBJECT_CLASS (gtd_task_lists_workspace_parent_class)->constructed (object);
- /* Add plugins' header widgets, and setup for new plugins */
- manager = gtd_manager_get_default ();
-
/* Add loaded panels */
self->panels_set = peas_extension_set_new (peas_engine_get_default (),
GTD_TYPE_PANEL,
@@ -385,12 +389,6 @@ gtd_task_lists_workspace_constructed (GObject *object)
g_signal_connect (self->panels_set, "extension-added", G_CALLBACK (on_panel_added_cb), self);
g_signal_connect (self->panels_set, "extension-removed", G_CALLBACK (on_panel_removed_cb), self);
-
- g_settings_bind (gtd_manager_get_settings (manager),
- "sidebar-revealed",
- self->toggle_sidebar_button,
- "active",
- G_SETTINGS_BIND_DEFAULT);
}
static void
@@ -486,16 +484,19 @@ gtd_task_lists_workspace_class_init (GtdTaskListsWorkspaceClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/todo/plugins/task-lists-workspace/gtd-task-lists-workspace.ui");
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, back_button);
+ gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, content_box);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, gear_menu_button);
+ gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, leaflet);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, new_list_button);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, panel_box_end);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, panel_box_start);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, primary_menu_button);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, sidebar);
+ gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, sidebar_box);
gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, stack);
- gtk_widget_class_bind_template_child (widget_class, GtdTaskListsWorkspace, toggle_sidebar_button);
gtk_widget_class_bind_template_callback (widget_class, on_back_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_back_sidebar_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_stack_visible_child_cb);
}
diff --git a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui
b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui
index f3d0678d..dc99fe33 100644
--- a/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui
+++ b/src/plugins/task-lists-workspace/gtd-task-lists-workspace.ui
@@ -4,19 +4,23 @@
<!-- Main leaflet -->
<child>
- <object class="AdwLeaflet" id="content_box">
+ <object class="AdwLeaflet" id="leaflet">
<property name="can-swipe-back">true</property>
<property name="width-request">360</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="sidebar_box">
<property name="orientation">vertical</property>
- <property name="hexpand">true</property>
+ <property name="hexpand">False</property>
+ <style>
+ <class name="sidebar"/>
+ </style>
<child>
- <object class="AdwHeaderBar" id="headerbar">
+ <object class="AdwHeaderBar" id="start_headerbar">
<property name="hexpand">1</property>
- <property name="show-end-title-buttons">1</property>
+ <property name="show-start-title-buttons">True</property>
+ <property name="show-end-title-buttons" bind-source="leaflet" bind-property="folded"
bind-flags="sync-create" />
<!-- New List -->
<child>
@@ -40,11 +44,44 @@
</object>
</child>
+ <child type="end">
+ <object class="GtkMenuButton" id="primary_menu_button">
+ <property name="icon-name">open-menu-symbolic</property>
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ <child>
+ <object class="GtdSidebar" id="sidebar">
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkBox" id="content_box">
+ <property name="orientation">vertical</property>
+ <property name="hexpand">true</property>
+
+ <child>
+ <object class="AdwHeaderBar" id="headerbar">
+ <property name="hexpand">1</property>
+ <property name="show-start-title-buttons" bind-source="leaflet" bind-property="folded"
bind-flags="sync-create" />
+ <property name="show-end-title-buttons">True</property>
+
<child>
- <object class="GtkToggleButton" id="toggle_sidebar_button">
+ <object class="GtkButton" id="back_sidebar_button">
+ <property name="visible" bind-source="leaflet" bind-property="folded"
bind-flags="sync-create" />
<property name="can_focus">1</property>
- <property name="icon-name">builder-view-left-pane-symbolic</property>
- <property name="active" bind-source="flap" bind-property="reveal-flap"
bind-flags="sync-create|bidirectional"/>
+ <property name="receives_default">1</property>
+ <property name="halign">start</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <signal name="clicked" handler="on_back_sidebar_button_clicked_cb"
object="GtdTaskListsWorkspace" swapped="no" />
</object>
</child>
@@ -60,12 +97,6 @@
</object>
</child>
- <child type="end">
- <object class="GtkMenuButton" id="primary_menu_button">
- <property name="icon-name">open-menu-symbolic</property>
- </object>
- </child>
-
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="can_focus">1</property>
@@ -82,36 +113,17 @@
</object>
</child>
+ <!-- Panels Stack -->
<child>
- <object class="AdwFlap" id="flap">
+ <object class="GtkStack" id="stack">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
- <property name="modal">true</property>
- <property name="swipe-to-open">true</property>
- <property name="swipe-to-close">true</property>
-
- <!-- Sidebar -->
- <property name="flap">
- <object class="GtdSidebar" id="sidebar">
- <property name="can_focus">False</property>
- <property name="vexpand">True</property>
- </object>
- </property>
-
- <!-- Panels Stack -->
- <property name="content">
- <object class="GtkStack" id="stack">
- <property name="hexpand">true</property>
- <property name="vexpand">true</property>
- <property name="transition_duration">250</property>
- <property name="transition_type">crossfade</property>
- <signal name="notify::visible-child" handler="on_stack_visible_child_cb"
object="GtdTaskListsWorkspace" swapped="yes"/>
- <style>
- <class name="background"/>
- </style>
- </object>
- </property>
-
+ <property name="transition_duration">250</property>
+ <property name="transition_type">crossfade</property>
+ <signal name="notify::visible-child" handler="on_stack_visible_child_cb"
object="GtdTaskListsWorkspace" swapped="yes"/>
+ <style>
+ <class name="background"/>
+ </style>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]