[gnome-todo] window: Add a sidebar revealer and button
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] window: Add a sidebar revealer and button
- Date: Mon, 27 Apr 2020 03:37:19 +0000 (UTC)
commit f636fad382c17ed5a60e4901397203cb9fc20419
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Apr 26 23:43:28 2020 -0300
window: Add a sidebar revealer and button
The icon is a courtesy of Sam Hewitt and GNOME Builder.
.../actions/builder-view-left-pane-symbolic.svg | 6 ++++++
data/icons/icons.gresource.xml | 1 +
data/org.gnome.todo.gschema.xml | 5 +++++
src/gtd-window.c | 24 +++++++++++++++-------
src/gtd-window.ui | 22 +++++++++++++++++---
5 files changed, 48 insertions(+), 10 deletions(-)
---
diff --git a/data/icons/hicolor/symbolic/actions/builder-view-left-pane-symbolic.svg
b/data/icons/hicolor/symbolic/actions/builder-view-left-pane-symbolic.svg
new file mode 100644
index 0000000..b0b8449
--- /dev/null
+++ b/data/icons/hicolor/symbolic/actions/builder-view-left-pane-symbolic.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
+ <g color="#000" fill="#2e3436">
+ <path d="M15.012 1h-14v14h14zm-1 1v12h-12V2z"
style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none"
font-weight="400" font-family="sans-serif" white-space="normal" overflow="visible"/>
+ <path d="M5.014 2.95v10.032H2.98V2.95z" style="marker:none" overflow="visible"/>
+ </g>
+</svg>
diff --git a/data/icons/icons.gresource.xml b/data/icons/icons.gresource.xml
index 5313abe..6a9b7d1 100644
--- a/data/icons/icons.gresource.xml
+++ b/data/icons/icons.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<!-- Icons -->
<gresource prefix="/org/gnome/todo/icons">
+ <file preprocess="xml-stripblanks"
alias="scalable/actions/builder-view-left-pane-symbolic.svg">hicolor/symbolic/actions/builder-view-left-pane-symbolic.svg</file>
<file preprocess="xml-stripblanks"
alias="scalable/actions/drag-handle-symbolic.svg">hicolor/symbolic/actions/drag-handle-symbolic.svg</file>
<file preprocess="xml-stripblanks"
alias="scalable/actions/mail-inbox-symbolic.svg">hicolor/symbolic/actions/mail-inbox-symbolic.svg</file>
<file preprocess="xml-stripblanks"
alias="scalable/actions/view-tasks-all-symbolic.svg">hicolor/symbolic/actions/view-tasks-all-symbolic.svg</file>
diff --git a/data/org.gnome.todo.gschema.xml b/data/org.gnome.todo.gschema.xml
index ebe4953..efe9018 100644
--- a/data/org.gnome.todo.gschema.xml
+++ b/data/org.gnome.todo.gschema.xml
@@ -31,5 +31,10 @@
<summary>The current list selector</summary>
<description>The current list selector. Can be “grid” or “list”.</description>
</key>
+ <key name="sidebar-revealed" type="b">
+ <default>true</default>
+ <summary>Sidebar revealed</summary>
+ <description>Whether the sidebar is revealed or not</description>
+ </key>
</schema>
</schemalist>
diff --git a/src/gtd-window.c b/src/gtd-window.c
index 438354d..628b4e6 100644
--- a/src/gtd-window.c
+++ b/src/gtd-window.c
@@ -1,6 +1,6 @@
/* gtd-window.c
*
- * Copyright (C) 2015 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ * Copyright (C) 2015-2020 Georges Basile Stavracas Neto <georges stavracas gmail com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -73,6 +73,7 @@ struct _GtdWindow
GtkWidget *extension_box_start;
GtkWidget *panel_box_end;
GtkWidget *panel_box_start;
+ GtkWidget *toggle_sidebar_button;
GtdPanel *active_panel;
GtdPanel *task_list_panel;
@@ -523,6 +524,7 @@ gtd_window_constructed (GObject *object)
g_autoptr (GList) l = NULL;
GtdPluginManager *plugin_manager;
GtkApplication *app;
+ GtdManager *manager;
GtdWindow *self;
GMenu *menu;
@@ -539,7 +541,8 @@ gtd_window_constructed (GObject *object)
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (self->gear_menu_button), G_MENU_MODEL (menu));
/* Add plugins' header widgets, and setup for new plugins */
- plugin_manager = gtd_manager_get_plugin_manager (gtd_manager_get_default ());
+ manager = gtd_manager_get_default ();
+ plugin_manager = gtd_manager_get_plugin_manager (manager);
plugins = gtd_plugin_manager_get_loaded_plugins (plugin_manager);
for (l = plugins; l; l = l->next)
@@ -549,16 +552,22 @@ gtd_window_constructed (GObject *object)
g_signal_connect_swapped (plugin_manager, "plugin-unloaded", G_CALLBACK (on_plugin_unloaded_cb), self);
/* Add loaded panels */
- lists = gtd_manager_get_panels (gtd_manager_get_default ());
+ lists = gtd_manager_get_panels (manager);
for (l = lists; l; l = l->next)
on_panel_added_cb (NULL, l->data, self);
- g_signal_connect (gtd_manager_get_default (), "panel-added", G_CALLBACK (on_panel_added_cb), self);
- g_signal_connect (gtd_manager_get_default (), "panel-removed", G_CALLBACK (on_panel_removed_cb), self);
+ g_signal_connect (manager, "panel-added", G_CALLBACK (on_panel_added_cb), self);
+ g_signal_connect (manager, "panel-removed", G_CALLBACK (on_panel_removed_cb), self);
- g_signal_connect (gtd_manager_get_default (), "show-error-message", G_CALLBACK (on_show_error_message_cb),
self);
- g_signal_connect (gtd_manager_get_default (), "show-notification", G_CALLBACK (on_show_notification_cb),
self);
+ g_signal_connect (manager, "show-error-message", G_CALLBACK (on_show_error_message_cb), self);
+ g_signal_connect (manager, "show-notification", G_CALLBACK (on_show_notification_cb), self);
+
+ g_settings_bind (gtd_manager_get_settings (manager),
+ "sidebar-revealed",
+ self->toggle_sidebar_button,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
}
static void
@@ -639,6 +648,7 @@ gtd_window_class_init (GtdWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtdWindow, new_list_button);
gtk_widget_class_bind_template_child (widget_class, GtdWindow, sidebar);
gtk_widget_class_bind_template_child (widget_class, GtdWindow, stack);
+ gtk_widget_class_bind_template_child (widget_class, GtdWindow, toggle_sidebar_button);
gtk_widget_class_bind_template_child (widget_class, GtdWindow, extension_box_end);
gtk_widget_class_bind_template_child (widget_class, GtdWindow, extension_box_start);
diff --git a/src/gtd-window.ui b/src/gtd-window.ui
index 1b2bed3..72e5781 100644
--- a/src/gtd-window.ui
+++ b/src/gtd-window.ui
@@ -18,12 +18,22 @@
</child>
<child>
<object class="GtkBox">
+
+ <!-- Sidebar -->
<child>
- <object class="GtdSidebar" id="sidebar">
- <property name="can_focus">False</property>
- <property name="vexpand">True</property>
+ <object class="GtkRevealer" id="sidebar_revealer">
+ <property name="transition-type">slide-left</property>
+ <property name="reveal-child" bind-source="toggle_sidebar_button" bind-property="active"
bind-flags="default" />
+ <child>
+ <object class="GtdSidebar" id="sidebar">
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
</object>
</child>
+
+ <!-- Main Stack -->
<child>
<object class="GtkStack" id="stack">
<property name="hexpand">true</property>
@@ -66,6 +76,12 @@
<property name="icon-name">go-previous-symbolic</property>
</object>
</child>
+ <child>
+ <object class="GtkToggleButton" id="toggle_sidebar_button">
+ <property name="can_focus">1</property>
+ <property name="icon-name">builder-view-left-pane-symbolic</property>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="panel_box_start">
<property name="spacing">6</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]