[gnome-builder/wip/chergert/layout] editor: wire up new-document action



commit 2dc499c1992178ae20f78e9165d0238fc8ef08d5
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jun 27 16:35:10 2017 -0700

    editor: wire up new-document action
    
    We can bring this back, but we still need to hookup the editor part
    that will auto-display the new buffer.

 libide/editor/ide-editor-perspective-actions.c |   62 ++++++++++++++++++++++++
 libide/editor/ide-editor-perspective.c         |    3 +
 libide/editor/ide-editor-private.h             |    8 ++-
 libide/editor/ide-editor-workbench-addin.c     |    2 +-
 libide/meson.build                             |    1 +
 5 files changed, 72 insertions(+), 4 deletions(-)
---
diff --git a/libide/editor/ide-editor-perspective-actions.c b/libide/editor/ide-editor-perspective-actions.c
new file mode 100644
index 0000000..4af5cd2
--- /dev/null
+++ b/libide/editor/ide-editor-perspective-actions.c
@@ -0,0 +1,62 @@
+/* ide-editor-perspective-actions.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-editor-perspective-actions"
+
+#include "buffers/ide-buffer-manager.h"
+#include "editor/ide-editor-private.h"
+#include "util/ide-gtk.h"
+
+static void
+ide_editor_perspective_actions_new_document (GSimpleAction *action,
+                                             GVariant      *variant,
+                                             gpointer       user_data)
+{
+  IdeEditorPerspective *self = user_data;
+  IdeWorkbench *workbench;
+  IdeContext *context;
+  IdeBufferManager *bufmgr;
+  IdeBuffer *buffer;
+
+  g_assert (G_IS_SIMPLE_ACTION (action));
+  g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
+
+  workbench = ide_widget_get_workbench (GTK_WIDGET (self));
+  context = ide_workbench_get_context (workbench);
+  bufmgr = ide_context_get_buffer_manager (context);
+  buffer = ide_buffer_manager_create_temporary_buffer (bufmgr);
+
+  g_clear_object (&buffer);
+}
+
+static const GActionEntry editor_actions[] = {
+  { "new-document", ide_editor_perspective_actions_new_document },
+};
+
+void
+_ide_editor_perspective_init_actions (IdeEditorPerspective *self)
+{
+  g_autoptr(GSimpleActionGroup) group = NULL;
+
+  group = g_simple_action_group_new ();
+  g_action_map_add_action_entries (G_ACTION_MAP (group),
+                                   editor_actions,
+                                   G_N_ELEMENTS (editor_actions),
+                                   self);
+  gtk_widget_insert_action_group (GTK_WIDGET (self), "editor", G_ACTION_GROUP (group));
+}
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index 839467d..394bce6 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -21,6 +21,7 @@
 #include <glib/gi18n.h>
 
 #include "editor/ide-editor-perspective.h"
+#include "editor/ide-editor-private.h"
 #include "editor/ide-editor-view.h"
 #include "workbench/ide-perspective.h"
 
@@ -50,6 +51,8 @@ static void
 ide_editor_perspective_init (IdeEditorPerspective *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
+
+  _ide_editor_perspective_init_actions (self);
 }
 
 /**
diff --git a/libide/editor/ide-editor-private.h b/libide/editor/ide-editor-private.h
index 3be19b7..02a572a 100644
--- a/libide/editor/ide-editor-private.h
+++ b/libide/editor/ide-editor-private.h
@@ -18,12 +18,14 @@
 
 #pragma once
 
+#include "ide-editor-perspective.h"
 #include "ide-editor-view.h"
 
 G_BEGIN_DECLS
 
-void _ide_editor_view_init_actions   (IdeEditorView *self);
-void _ide_editor_view_init_settings  (IdeEditorView *self);
-void _ide_editor_view_init_shortcuts (IdeEditorView *self);
+void _ide_editor_view_init_actions        (IdeEditorView        *self);
+void _ide_editor_view_init_settings       (IdeEditorView        *self);
+void _ide_editor_view_init_shortcuts      (IdeEditorView        *self);
+void _ide_editor_perspective_init_actions (IdeEditorPerspective *self);
 
 G_END_DECLS
diff --git a/libide/editor/ide-editor-workbench-addin.c b/libide/editor/ide-editor-workbench-addin.c
index 54c38eb..7c8b7b8 100644
--- a/libide/editor/ide-editor-workbench-addin.c
+++ b/libide/editor/ide-editor-workbench-addin.c
@@ -92,7 +92,7 @@ ide_editor_workbench_addin_load (IdeWorkbenchAddin *addin,
   header = ide_workbench_get_headerbar (workbench);
 
   self->new_document_button = g_object_new (GTK_TYPE_BUTTON,
-                                            "action-name", "perspective.new-file",
+                                            "action-name", "editor.new-document",
                                             "child", g_object_new (GTK_TYPE_IMAGE,
                                                                    "visible", TRUE,
                                                                    "icon-name", "document-new-symbolic",
diff --git a/libide/meson.build b/libide/meson.build
index fb14de0..a70c32f 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -290,6 +290,7 @@ libide_public_sources = [
   'doap/ide-doap-person.c',
   'doap/ide-doap.c',
   'editor/ide-editor-perspective.c',
+  'editor/ide-editor-perspective-actions.c',
   'editor/ide-editor-view-addin.c',
   'editor/ide-editor-view.c',
   'files/ide-file-settings.c',


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