[gnome-builder/wip/chergert/layout] editor: wire up properties to view menu



commit a96847f707c67450e809cf844f4fbc8ac58e3cf8
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jul 12 18:15:06 2017 -0700

    editor: wire up properties to view menu
    
    We still need a proper way to dismiss the panel, but this
    handles ensuring the panel can be made visible.

 data/gtk/menus.ui                       |    1 +
 libide/editor/ide-editor-perspective.c  |   11 +++++++++++
 libide/editor/ide-editor-private.h      |   18 ++++++++++--------
 libide/editor/ide-editor-view-actions.c |   17 +++++++++++++++++
 4 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index afec72a..5c6bfdf 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -321,6 +321,7 @@
       <attribute name="after">editor-document-section</attribute>
       <item>
         <attribute name="label" translatable="yes">Document Preferences</attribute>
+        <attribute name="action">editor-view.properties</attribute>
       </item>
     </section>
     <section id="editor-document-save-section">
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index e11b135..f86c798 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -659,3 +659,14 @@ perspective_iface_init (IdePerspectiveInterface *iface)
   iface->views_foreach = ide_editor_perspective_views_foreach;
   iface->set_fullscreen = ide_editor_perspective_set_fullscreen;
 }
+
+void
+_ide_editor_perspective_show_properties (IdeEditorPerspective *self,
+                                         IdeEditorView        *view)
+{
+  g_return_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self));
+  g_return_if_fail (!view || IDE_IS_EDITOR_VIEW (view));
+
+  ide_editor_properties_set_view (self->properties, view);
+  g_object_set (self, "right-visible", view != NULL, NULL);
+}
diff --git a/libide/editor/ide-editor-private.h b/libide/editor/ide-editor-private.h
index 8e6b693..bb869f3 100644
--- a/libide/editor/ide-editor-private.h
+++ b/libide/editor/ide-editor-private.h
@@ -61,13 +61,15 @@ struct _IdeEditorView
   guint                    show_map : 1;
 };
 
-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_update_actions        (IdeEditorView        *self);
-void _ide_editor_sidebar_set_open_pages     (IdeEditorSidebar     *self,
-                                             GListModel           *open_pages);
-void _ide_editor_perspective_init_actions   (IdeEditorPerspective *self);
-void _ide_editor_perspective_init_shortcuts (IdeEditorPerspective *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_view_update_actions         (IdeEditorView        *self);
+void _ide_editor_sidebar_set_open_pages      (IdeEditorSidebar     *self,
+                                              GListModel           *open_pages);
+void _ide_editor_perspective_show_properties (IdeEditorPerspective *self,
+                                              IdeEditorView        *view);
+void _ide_editor_perspective_init_actions    (IdeEditorPerspective *self);
+void _ide_editor_perspective_init_shortcuts  (IdeEditorPerspective *self);
 
 G_END_DECLS
diff --git a/libide/editor/ide-editor-view-actions.c b/libide/editor/ide-editor-view-actions.c
index 792bae4..7648c19 100644
--- a/libide/editor/ide-editor-view-actions.c
+++ b/libide/editor/ide-editor-view-actions.c
@@ -24,7 +24,9 @@
 #include "files/ide-file-settings.h"
 #include "buffers/ide-buffer.h"
 #include "buffers/ide-buffer-manager.h"
+#include "editor/ide-editor-perspective.h"
 #include "editor/ide-editor-private.h"
+#include "layout/ide-layout-transient-sidebar.h"
 #include "editor/ide-editor-print-operation.h"
 #include "util/ide-progress.h"
 #include "vcs/ide-vcs.h"
@@ -483,6 +485,20 @@ ide_editor_view_actions_move_previous_search_result (GSimpleAction *action,
   ide_editor_view_move_previous_search_result (user_data);
 }
 
+static void
+ide_editor_view_actions_properties (GSimpleAction *action,
+                                    GVariant      *variant,
+                                    gpointer       user_data)
+{
+  IdeEditorView *self = user_data;
+  GtkWidget *editor;
+
+  g_assert (IDE_IS_EDITOR_VIEW (self));
+
+  editor = gtk_widget_get_ancestor (GTK_WIDGET (self), IDE_TYPE_EDITOR_PERSPECTIVE);
+  _ide_editor_perspective_show_properties (IDE_EDITOR_PERSPECTIVE (editor), self);
+}
+
 static const GActionEntry editor_view_entries[] = {
   { "find", ide_editor_view_actions_find },
   { "find-replace", ide_editor_view_actions_find_replace },
@@ -491,6 +507,7 @@ static const GActionEntry editor_view_entries[] = {
   { "move-next-search-result", ide_editor_view_actions_move_next_search_result },
   { "move-previous-error", ide_editor_view_actions_move_previous_error },
   { "move-previous-search-result", ide_editor_view_actions_move_previous_search_result },
+  { "properties", ide_editor_view_actions_properties },
   { "print", ide_editor_view_actions_print },
   { "reload", ide_editor_view_actions_reload },
   { "save", ide_editor_view_actions_save },


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