[gnome-builder] workbench: add close-tab action.



commit 3de507bfd402cd2a50070aa8846a30b6d3e1b3e5
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 9 23:07:07 2014 -0700

    workbench: add close-tab action.

 src/editor/gb-editor-workspace.c      |   16 ++++++++++++++++
 src/resources/gtk/menus.ui            |    4 ++--
 src/resources/keybindings/default.ini |    3 ++-
 src/workbench/gb-workbench-actions.c  |    3 ++-
 4 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index ba22e37..2a51b84 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -72,6 +72,21 @@ on_new_tab_activate (GSimpleAction *action,
 }
 
 static void
+on_close_tab_activate (GSimpleAction *action,
+                       GVariant      *parameter,
+                       gpointer       user_data)
+{
+  GbEditorWorkspace *workspace = user_data;
+  GbTab *tab;
+
+  g_return_if_fail (GB_IS_EDITOR_WORKSPACE (workspace));
+
+  tab = gb_multi_notebook_get_active_tab (workspace->priv->multi_notebook);
+  if (tab)
+    gb_tab_close (tab);
+}
+
+static void
 on_find_activate (GSimpleAction *action,
                   GVariant      *parameter,
                   gpointer       user_data)
@@ -294,6 +309,7 @@ static void
 gb_editor_workspace_init (GbEditorWorkspace *workspace)
 {
   static const GActionEntry action_entries[] = {
+    { "close-tab", on_close_tab_activate },
     { "find", on_find_activate },
     { "go-to-end", on_go_to_end_activate },
     { "go-to-start", on_go_to_start_activate },
diff --git a/src/resources/gtk/menus.ui b/src/resources/gtk/menus.ui
index dcd8ce3..05827bf 100644
--- a/src/resources/gtk/menus.ui
+++ b/src/resources/gtk/menus.ui
@@ -84,11 +84,11 @@
       <attribute name="id">close-section</attribute>
       <item>
         <attribute name="label" translatable="yes">_Close All</attribute>
-        <attribute name="action">win.close-all</attribute>
+        <attribute name="action">workbench.close-all</attribute>
       </item>
       <item>
         <attribute name="label" translatable="yes">_Close</attribute>
-        <attribute name="action">win.close</attribute>
+        <attribute name="action">workbench.close-tab</attribute>
       </item>
     </section>
   </menu>
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index 1a4eab5..d5bb8ed 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -1,6 +1,7 @@
 [workbench]
-new-tab = <Control><Shift>T
+close-tab = <Control>W
 find = <Control>F
+new-tab = <Control><Shift>T
 
 [editor]
 go-to-end = <Control>Page_Down
diff --git a/src/workbench/gb-workbench-actions.c b/src/workbench/gb-workbench-actions.c
index b652744..e221dc0 100644
--- a/src/workbench/gb-workbench-actions.c
+++ b/src/workbench/gb-workbench-actions.c
@@ -175,8 +175,9 @@ gb_workbench_actions_constructed (GObject *object)
 {
    GbWorkbenchActions *actions = (GbWorkbenchActions *)object;
    static const GActionEntry action_entries[] = {
-      { "new-tab", proxy_action },
+      { "close-tab", proxy_action },
       { "find", proxy_action },
+      { "new-tab", proxy_action },
    };
 
    g_assert (GB_IS_WORKBENCH_ACTIONS (actions));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]