[gnome-builder/document-manager] GbEditorView: implement toggle-split action
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/document-manager] GbEditorView: implement toggle-split action
- Date: Tue, 9 Dec 2014 00:10:36 +0000 (UTC)
commit 93a59593353128d8614afd051acda448bfb61498
Author: Christian Hergert <christian hergert me>
Date: Mon Dec 8 16:10:30 2014 -0800
GbEditorView: implement toggle-split action
src/editor/gb-editor-view.c | 59 +++++++++++++++++++++++++++++++++
src/editor/gb-editor-workspace.c | 16 ---------
src/resources/keybindings/default.ini | 4 ++-
src/resources/ui/gb-editor-view.ui | 1 +
4 files changed, 63 insertions(+), 17 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index 5772acb..cb301fe 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -56,10 +56,16 @@ static void
gb_editor_view_connect (GbEditorView *view,
GbEditorDocument *document)
{
+ GtkWidget *child2;
+
g_return_if_fail (GB_IS_EDITOR_VIEW (view));
g_return_if_fail (GB_IS_EDITOR_DOCUMENT (document));
gb_editor_frame_set_document (view->priv->frame, document);
+
+ child2 = gtk_paned_get_child2 (view->priv->paned);
+ if (GB_IS_EDITOR_FRAME (child2))
+ gb_editor_frame_set_document (GB_EDITOR_FRAME (child2), document);
}
static void
@@ -110,6 +116,47 @@ gb_editor_view_set_document (GbEditorView *view,
}
static void
+gb_editor_view_toggle_split (GbEditorView *view)
+{
+ GbEditorViewPrivate *priv;
+ GtkWidget *child2;
+
+ g_return_if_fail (GB_IS_EDITOR_VIEW (view));
+
+ priv = view->priv;
+
+ if ((child2 = gtk_paned_get_child2 (priv->paned)))
+ {
+ gtk_widget_destroy (child2);
+ gtk_widget_grab_focus (GTK_WIDGET (priv->frame));
+ }
+ else
+ {
+ child2 = g_object_new (GB_TYPE_EDITOR_FRAME,
+ "document", view->priv->document,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add_with_properties (GTK_CONTAINER (priv->paned), child2,
+ "shrink", TRUE,
+ "resize", TRUE,
+ NULL);
+ gtk_widget_grab_focus (child2);
+ }
+}
+
+static void
+gb_editor_view_toggle_split_activate (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GbEditorView *view = user_data;
+
+ g_return_if_fail (GB_IS_EDITOR_VIEW (view));
+
+ gb_editor_view_toggle_split (view);
+}
+
+static void
gb_editor_view_grab_focus (GtkWidget *widget)
{
GbEditorView *view = (GbEditorView *)widget;
@@ -201,7 +248,19 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
static void
gb_editor_view_init (GbEditorView *self)
{
+ const GActionEntry entries[] = {
+ { "toggle-split", gb_editor_view_toggle_split_activate },
+ };
+ GSimpleActionGroup *actions;
+
self->priv = gb_editor_view_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
+
+ actions = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (actions), entries,
+ G_N_ELEMENTS (entries), self);
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "editor-view",
+ G_ACTION_GROUP (actions));
+ g_object_unref (actions);
}
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 939da10..0cc77cc 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -88,21 +88,6 @@ save_as_tab (GSimpleAction *action,
}
static void
-toggle_split_tab (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
-#if 0
- GbEditorWorkspace *workspace = user_data;
- GbTab *tab;
-
- tab = gb_tab_grid_get_active (workspace->priv->tab_grid);
- if (GB_IS_EDITOR_TAB (tab))
- gb_editor_tab_toggle_split (GB_EDITOR_TAB (tab));
-#endif
-}
-
-static void
find_tab (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -417,7 +402,6 @@ gb_editor_workspace_init (GbEditorWorkspace *workspace)
{ "open", open_tab },
{ "save", save_tab },
{ "save-as", save_as_tab },
- { "toggle-split", toggle_split_tab },
{ "find", find_tab },
{ "reformat", reformat_tab },
{ "preview", preview_tab },
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index ae285e7..dd4df37 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -25,13 +25,15 @@ reformat = <Control><Shift>R
save = <Control>S
save-as = <Control><Shift>S
preview = <Control><Alt>P
-toggle-split = <Control><Shift>J
switch-pane = <Control><Shift>K
[editor-frame]
scroll-up = <Control>Y
scroll-down = <Control>E
+[editor-view]
+toggle-split = <Control><Shift>J
+
[stack]
close = <Control>W
focus-search = <Control>J
diff --git a/src/resources/ui/gb-editor-view.ui b/src/resources/ui/gb-editor-view.ui
index ff47a36..31db980 100644
--- a/src/resources/ui/gb-editor-view.ui
+++ b/src/resources/ui/gb-editor-view.ui
@@ -11,6 +11,7 @@
<child>
<object class="GtkToggleButton" id="split_button">
<property name="visible">true</property>
+ <property name="action_name">editor-view.toggle-split</property>
<style>
<class name="image-button"/>
<class name="tab-control-first"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]