[gnome-builder/wip/libide-merge] add toggle sidebar action
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] add toggle sidebar action
- Date: Sun, 22 Mar 2015 09:25:34 +0000 (UTC)
commit ea5a99c12c4884da9cbbaffcdd3969cec3cee74f
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 22 01:30:54 2015 -0700
add toggle sidebar action
data/keybindings/vim.css | 1 +
data/ui/gb-editor-workspace.ui | 5 ++-
src/editor/gb-editor-workspace-actions.c | 46 ++++++++++++++++++++++++++++++
src/editor/gb-editor-workspace-private.h | 2 +
src/editor/gb-editor-workspace.c | 2 +
5 files changed, 54 insertions(+), 2 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index d2b206f..a3a4328 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -97,6 +97,7 @@
bind "F4" { "action" ("view", "find-other-file", "") };
bind "F6" { "action" ("view", "preview", "") };
+ bind "F9" { "action" ("workspace", "toggle-sidebar", "") };
}
@binding-set builder-vim-source-view-normal-with-count
diff --git a/data/ui/gb-editor-workspace.ui b/data/ui/gb-editor-workspace.ui
index 3c43355..f8e3bdf 100644
--- a/data/ui/gb-editor-workspace.ui
+++ b/data/ui/gb-editor-workspace.ui
@@ -3,12 +3,12 @@
<!-- interface-requires gtk+ 3.15 -->
<template class="GbEditorWorkspace" parent="GbWorkspace">
<child>
- <object class="GtkPaned">
+ <object class="GtkPaned" id="project_paned">
<property name="orientation">horizontal</property>
<property name="position">250</property>
<property name="visible">true</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="project_sidebar">
<property name="vexpand">true</property>
<property name="orientation">vertical</property>
<property name="visible">true</property>
@@ -27,6 +27,7 @@
<property name="visible">true</property>
<style>
<class name="dim-label"/>
+ <class name="flat"/>
</style>
</object>
</child>
diff --git a/src/editor/gb-editor-workspace-actions.c b/src/editor/gb-editor-workspace-actions.c
index 82f688b..6141358 100644
--- a/src/editor/gb-editor-workspace-actions.c
+++ b/src/editor/gb-editor-workspace-actions.c
@@ -16,9 +16,55 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <ide.h>
+
#include "gb-editor-workspace-actions.h"
+#include "gb-editor-workspace-private.h"
+
+#define ANIMATION_DURATION_MSEC 250
+
+static void
+gb_editor_workspace_actions_toggle_sidebar (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GbEditorWorkspace *self = user_data;
+
+ if (gtk_widget_get_visible (GTK_WIDGET (self->project_sidebar)))
+ {
+ ide_object_animate_full (self->project_paned,
+ IDE_ANIMATION_EASE_IN_CUBIC,
+ ANIMATION_DURATION_MSEC,
+ NULL,
+ (GDestroyNotify)gtk_widget_hide,
+ self->project_sidebar,
+ "position", 0,
+ NULL);
+ }
+ else
+ {
+ gtk_paned_set_position (self->project_paned, 0);
+ gtk_widget_show (GTK_WIDGET (self->project_sidebar));
+ ide_object_animate (self->project_paned,
+ IDE_ANIMATION_EASE_IN_CUBIC,
+ ANIMATION_DURATION_MSEC,
+ NULL,
+ "position", 250,
+ NULL);
+ }
+}
+
+static const GActionEntry GbEditorWorkspaceActions[] = {
+ { "toggle-sidebar", gb_editor_workspace_actions_toggle_sidebar },
+};
void
gb_editor_workspace_actions_init (GbEditorWorkspace *self)
{
+ g_autoptr(GSimpleActionGroup) group = NULL;
+
+ group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (group), GbEditorWorkspaceActions,
+ G_N_ELEMENTS (GbEditorWorkspaceActions), self);
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "workspace", G_ACTION_GROUP (group));
}
diff --git a/src/editor/gb-editor-workspace-private.h b/src/editor/gb-editor-workspace-private.h
index 82d2e84..c0df98f 100644
--- a/src/editor/gb-editor-workspace-private.h
+++ b/src/editor/gb-editor-workspace-private.h
@@ -29,6 +29,8 @@ struct _GbEditorWorkspace
{
GbWorkspace parent_instance;
+ GtkPaned *project_paned;
+ GtkBox *project_sidebar;
GbTree *project_tree;
GbTreeBuilder *project_tree_builder;
GbViewGrid *view_grid;
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index b6c80e9..e778de9 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -165,6 +165,8 @@ gb_editor_workspace_class_init (GbEditorWorkspaceClass *klass)
GB_WIDGET_CLASS_TEMPLATE (klass, "gb-editor-workspace.ui");
+ GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_paned);
+ GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_sidebar);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_tree);
GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, view_grid);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]