[gnome-builder] more wip on redesign
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] more wip on redesign
- Date: Wed, 19 Jul 2017 11:00:33 +0000 (UTC)
commit 889f3c9508b4d88e3ca737ead3ce8342e835a6ee
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 27 12:41:35 2017 -0700
more wip on redesign
libide/editor/ide-editor-frame-actions.c | 488 --------
libide/editor/ide-editor-frame-actions.h | 30 -
libide/editor/ide-editor-frame-private.h | 67 -
libide/editor/ide-editor-frame.c | 1281 --------------------
libide/editor/ide-editor-frame.h | 40 -
libide/editor/ide-editor-frame.ui | 407 -------
libide/editor/ide-editor-layout-stack-addin.c | 128 --
libide/editor/ide-editor-layout-stack-addin.h | 34 -
libide/editor/ide-editor-layout-stack-controls.c | 328 -----
libide/editor/ide-editor-layout-stack-controls.h | 59 -
libide/editor/ide-editor-layout-stack-controls.ui | 117 --
libide/editor/ide-editor-map-bin.c | 251 ----
libide/editor/ide-editor-map-bin.h | 32 -
libide/editor/ide-editor-perspective.c | 973 +--------------
libide/editor/ide-editor-perspective.h | 34 +-
libide/editor/ide-editor-perspective.ui | 65 +-
libide/editor/ide-editor-plugin.c | 4 -
libide/editor/ide-editor-print-operation.c | 8 +-
...-editor-view-actions.h => ide-editor-private.h} | 14 +-
libide/editor/ide-editor-tweak-widget.c | 186 ---
libide/editor/ide-editor-tweak-widget.ui | 203 ---
libide/editor/ide-editor-view-actions.c | 781 +------------
libide/editor/ide-editor-view-addin-private.h | 39 -
libide/editor/ide-editor-view-addin.c | 22 -
libide/editor/ide-editor-view-addin.h | 18 +-
libide/editor/ide-editor-view-private.h | 53 -
libide/editor/ide-editor-view-settings.c | 117 ++
...-tweak-widget.h => ide-editor-view-shortcuts.c} | 27 +-
libide/editor/ide-editor-view.c | 930 +++------------
libide/editor/ide-editor-view.h | 13 +-
libide/editor/ide-editor-view.ui | 90 +--
libide/editor/ide-editor-workbench-addin.c | 1 +
libide/layout/ide-layout-stack-actions.c | 3 +
libide/libide.gresource.xml | 5 +-
libide/meson.build | 41 +-
.../{editor => spellcheck}/ide-editor-spell-dict.c | 0
.../{editor => spellcheck}/ide-editor-spell-dict.h | 0
.../ide-editor-spell-language-popover.c | 0
.../ide-editor-spell-language-popover.h | 0
.../ide-editor-spell-navigator.c | 0
.../ide-editor-spell-navigator.h | 0
.../ide-editor-spell-utils.c | 0
.../ide-editor-spell-utils.h | 0
.../ide-editor-spell-widget.c | 8 +-
.../ide-editor-spell-widget.h | 0
.../ide-editor-spell-widget.ui | 0
46 files changed, 398 insertions(+), 6499 deletions(-)
---
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index 0c7053a..42c44d6 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -1,6 +1,6 @@
/* ide-editor-perspective.c
*
- * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ * 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
@@ -18,384 +18,47 @@
#define G_LOG_DOMAIN "ide-editor-perspective"
-#include <dazzle.h>
-#include <glib/gi18n.h>
-
-#include "ide-context.h"
-#include "ide-debug.h"
-
-#include "buffers/ide-buffer-manager.h"
-#include "buffers/ide-buffer.h"
-#include "editor/ide-editor-perspective.h"
-#include "editor/ide-editor-spell-widget.h"
-#include "editor/ide-editor-view.h"
-#include "layout/ide-layout-grid.h"
-#include "layout/ide-layout-pane.h"
-#include "util/ide-gtk.h"
-#include "workbench/ide-workbench.h"
-#include "workbench/ide-workbench-header-bar.h"
-
-#define OVERLAY_REVEAL_DURATION 300
+#include "ide-editor-perspective.h"
struct _IdeEditorPerspective
{
- DzlDockOverlay parent_instance;
+ IdeLayout parent_instance;
- GtkWidget *active_view;
- IdeLayout *layout;
- IdeLayoutGrid *grid;
- GSimpleActionGroup *actions;
-
- DzlSignalGroup *buffer_manager_signals;
-
- gint right_pane_position;
- guint spellchecker_opened : 1;
+ IdeLayoutGrid *grid;
};
-typedef struct
-{
- IdeEditorPerspective *self;
- IdeSourceLocation *location;
-} FocusLocation;
-
-static void ide_perspective_iface_init (IdePerspectiveInterface *iface);
-static void ide_editor_perspective_add (GtkContainer *container,
- GtkWidget *widget);
-static void ide_editor_perspective_focus_location_full (IdeEditorPerspective *self,
- IdeSourceLocation *location,
- gboolean open_if_not_found);
-
-G_DEFINE_TYPE_EXTENDED (IdeEditorPerspective, ide_editor_perspective, DZL_TYPE_DOCK_OVERLAY, 0,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, ide_perspective_iface_init))
-
enum {
PROP_0,
- PROP_ACTIVE_VIEW,
- LAST_PROP
-};
-
-static GParamSpec *properties [LAST_PROP];
-
-enum {
- VIEW_ADDED,
- VIEW_REMOVED,
- LAST_SIGNAL
+ N_PROPS
};
-static guint signals [LAST_SIGNAL];
-
-static void
-set_reveal_child_without_transition (DzlDockRevealer *revealer,
- gboolean reveal)
-{
- DzlDockRevealerTransitionType type;
-
- g_assert (DZL_IS_DOCK_REVEALER (revealer));
-
- type = dzl_dock_revealer_get_transition_type (revealer);
- dzl_dock_revealer_set_transition_type (revealer, DZL_DOCK_REVEALER_TRANSITION_TYPE_NONE);
- dzl_dock_revealer_set_reveal_child (revealer, reveal);
- dzl_dock_revealer_set_transition_type (revealer, type);
-}
-
-static void
-ide_editor_perspective_restore_panel_state (IdeEditorPerspective *self)
-{
- g_autoptr(GSettings) settings = NULL;
- GtkWidget *pane;
- gboolean reveal;
- guint position;
+G_DEFINE_TYPE (IdeEditorPerspective, ide_editor_perspective, IDE_TYPE_LAYOUT)
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
-
- settings = g_settings_new ("org.gnome.builder.workbench");
-
- pane = dzl_dock_bin_get_left_edge (DZL_DOCK_BIN (self->layout));
- reveal = g_settings_get_boolean (settings, "left-visible");
- position = g_settings_get_int (settings, "left-position");
- dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
- set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
-
- pane = dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self->layout));
- reveal = g_settings_get_boolean (settings, "right-visible");
- position = g_settings_get_int (settings, "right-position");
- dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
- set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
-
- pane = dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self->layout));
- reveal = g_settings_get_boolean (settings, "bottom-visible");
- position = g_settings_get_int (settings, "bottom-position");
- dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
- set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
-}
-
-static void
-ide_editor_perspective_save_panel_state (IdeEditorPerspective *self)
-{
- g_autoptr(GSettings) settings = NULL;
- GtkWidget *pane;
- gboolean reveal;
- guint position;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
-
- settings = g_settings_new ("org.gnome.builder.workbench");
-
- pane = dzl_dock_bin_get_left_edge (DZL_DOCK_BIN (self->layout));
- position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
- reveal = dzl_dock_revealer_get_reveal_child (DZL_DOCK_REVEALER (pane));
- g_settings_set_boolean (settings, "left-visible", reveal);
- g_settings_set_int (settings, "left-position", position);
-
- pane = dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self->layout));
- position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
- reveal = dzl_dock_revealer_get_reveal_child (DZL_DOCK_REVEALER (pane));
- g_settings_set_boolean (settings, "right-visible", reveal);
- g_settings_set_int (settings, "right-position", position);
-
- pane = dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self->layout));
- position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
- reveal = dzl_dock_revealer_get_reveal_child (DZL_DOCK_REVEALER (pane));
- g_settings_set_boolean (settings, "bottom-visible", reveal);
- g_settings_set_int (settings, "bottom-position", position);
-}
-
-static void
-ide_editor_perspective_context_set (GtkWidget *widget,
- IdeContext *context)
-{
- IdeEditorPerspective *self = (IdeEditorPerspective *)widget;
- IdeBufferManager *buffer_manager = NULL;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (!context || IDE_IS_CONTEXT (context));
-
- if (context != NULL)
- buffer_manager = ide_context_get_buffer_manager (context);
-
- dzl_signal_group_set_target (self->buffer_manager_signals, buffer_manager);
-}
+static GParamSpec *properties [N_PROPS];
static void
-ide_editor_perspective_load_buffer (IdeEditorPerspective *self,
- IdeBuffer *buffer,
- gboolean create_new_view,
- IdeBufferManager *buffer_manager)
-{
- IdeEditorView *view;
- GtkWidget *stack;
- IdeWorkbench *workbench;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (IDE_IS_BUFFER (buffer));
- g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
-
- /*
- * We only want to create a new view when the buffer is originally
- * created, not when it's reloaded.
- */
- if (!create_new_view)
- {
- ide_buffer_manager_set_focus_buffer (buffer_manager, buffer);
- return;
- }
-
- IDE_TRACE_MSG ("Loading %s", ide_buffer_get_title (buffer));
-
- view = g_object_new (IDE_TYPE_EDITOR_VIEW,
- "document", buffer,
- "visible", TRUE,
- NULL);
-
- stack = ide_layout_grid_get_last_focus (self->grid);
-
- ide_editor_perspective_add (GTK_CONTAINER (self), GTK_WIDGET (view));
-
- workbench = ide_widget_get_workbench (GTK_WIDGET (stack));
- ide_workbench_focus (workbench, GTK_WIDGET (view));
-}
-
-static void
-ide_editor_perspective_locate_buffer (GtkWidget *view,
- gpointer user_data)
-{
- IdeBuffer **buffer = user_data;
-
- g_assert (IDE_IS_LAYOUT_VIEW (view));
- g_assert (buffer != NULL);
- g_assert (!*buffer || IDE_IS_BUFFER (*buffer));
-
- if (!*buffer)
- return;
-
- if (IDE_IS_EDITOR_VIEW (view))
- {
- if (*buffer == ide_editor_view_get_document (IDE_EDITOR_VIEW (view)))
- {
- GtkWidget *stack;
-
- stack = gtk_widget_get_ancestor (view, IDE_TYPE_LAYOUT_STACK);
-
- if (stack != NULL)
- {
- IdeWorkbench *workbench;
-
- ide_layout_stack_set_active_view (IDE_LAYOUT_STACK (stack), view);
- *buffer = NULL;
-
- workbench = ide_widget_get_workbench (GTK_WIDGET (stack));
- ide_workbench_focus (workbench, GTK_WIDGET (view));
- }
- }
- }
-}
-
-void
-ide_editor_perspective_focus_buffer_in_current_stack (IdeEditorPerspective *self,
- IdeBuffer *buffer)
-{
- GtkWidget *focus_stack;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (IDE_IS_BUFFER (buffer));
-
- focus_stack = ide_layout_grid_get_last_focus (self->grid);
- g_assert (!focus_stack || IDE_IS_LAYOUT_STACK (focus_stack));
-
- if (focus_stack != NULL)
- {
- IdeBuffer *search_buffer = buffer;
- GtkWidget *view;
-
- ide_layout_stack_foreach_view (IDE_LAYOUT_STACK (focus_stack),
- ide_editor_perspective_locate_buffer,
- &search_buffer);
-
- if (search_buffer != NULL)
- {
- view = g_object_new (IDE_TYPE_EDITOR_VIEW,
- "document", buffer,
- "visible", TRUE,
- NULL);
- ide_editor_perspective_add (GTK_CONTAINER (self), view);
- }
- }
-}
-
-static void
-ide_editor_perspective_notify_focus_buffer (IdeEditorPerspective *self,
- GParamSpec *pspec,
- IdeBufferManager *buffer_manager)
-{
- IdeBuffer *buffer;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
-
- buffer = ide_buffer_manager_get_focus_buffer (buffer_manager);
- if (buffer == NULL)
- return;
-
- ide_layout_grid_foreach_view (self->grid,
- ide_editor_perspective_locate_buffer,
- &buffer);
-}
-
-static void
-new_file_activate (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorPerspective *self = user_data;
- IdeWorkbench *workbench;
- IdeContext *context;
- IdeBufferManager *bufmgr;
- IdeBuffer *buffer;
-
- 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 void
-ide_editor_perspective_finalize (GObject *object)
-{
- IdeEditorPerspective *self = (IdeEditorPerspective *)object;
-
- g_clear_object (&self->buffer_manager_signals);
-
- G_OBJECT_CLASS (ide_editor_perspective_parent_class)->finalize (object);
-}
-
-static void
-ide_editor_perspective_view_destroyed (IdeEditorPerspective *self,
- IdeLayoutView *view)
-{
- IDE_ENTRY;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (IDE_IS_LAYOUT_VIEW (view));
-
- g_signal_emit (self, signals [VIEW_REMOVED], 0, view);
-
- IDE_EXIT;
-}
-
-static void
-ide_editor_perspective_add (GtkContainer *container,
- GtkWidget *widget)
+ide_editor_perspective_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- IdeEditorPerspective *self = (IdeEditorPerspective *)container;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (GTK_IS_WIDGET (widget));
-
- if (IDE_IS_LAYOUT_VIEW (widget))
+ switch (prop_id)
{
- gtk_container_add (GTK_CONTAINER (self->grid), widget);
- g_signal_connect_object (widget,
- "destroy",
- G_CALLBACK (ide_editor_perspective_view_destroyed),
- self,
- G_CONNECT_SWAPPED);
- g_signal_emit (self, signals [VIEW_ADDED], 0, widget);
- return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
-
- GTK_CONTAINER_CLASS (ide_editor_perspective_parent_class)->add (container, widget);
}
static void
-ide_editor_perspective_grab_focus (GtkWidget *widget)
+ide_editor_perspective_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- IdeEditorPerspective *self = (IdeEditorPerspective *)widget;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
-
- gtk_widget_grab_focus (GTK_WIDGET (self->grid));
-}
-
-static void
-ide_editor_perspective_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- IdeEditorPerspective *self = IDE_EDITOR_PERSPECTIVE (object);
-
switch (prop_id)
{
- case PROP_ACTIVE_VIEW:
- g_value_set_object (value, ide_editor_perspective_get_active_view (self));
- break;
-
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -404,612 +67,34 @@ ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->get_property = ide_editor_perspective_get_property;
- object_class->finalize = ide_editor_perspective_finalize;
-
- widget_class->grab_focus = ide_editor_perspective_grab_focus;
-
- container_class->add = ide_editor_perspective_add;
+ object_class->set_property = ide_editor_perspective_set_property;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-editor-perspective.ui");
- gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, layout);
- gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, actions);
gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, grid);
-
- properties [PROP_ACTIVE_VIEW] =
- g_param_spec_object ("active-view",
- "Active View",
- "Active View",
- GTK_TYPE_WIDGET,
- (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_properties (object_class, LAST_PROP, properties);
-
- signals[VIEW_ADDED] =
- g_signal_new ("view-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_WIDGET);
-
- signals[VIEW_REMOVED] =
- g_signal_new ("view-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_WIDGET);
-}
-
-static void
-ide_editor_perspective_active_view_notify_cb (IdeEditorPerspective *self,
- GParamSpec *pspec,
- IdeLayout *layout)
-{
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (IDE_IS_LAYOUT (layout));
-
- self->active_view = ide_layout_get_active_view (layout);
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ACTIVE_VIEW]);
}
static void
ide_editor_perspective_init (IdeEditorPerspective *self)
{
- static const gchar *proxy_actions[] = {
- "bottom-visible",
- "left-visible",
- "right-visible",
- NULL
- };
- static const GActionEntry entries[] = {
- { "new-file", new_file_activate },
- };
-
- GActionGroup *actions;
- guint i;
-
- self->buffer_manager_signals = dzl_signal_group_new (IDE_TYPE_BUFFER_MANAGER);
-
- dzl_signal_group_connect_object (self->buffer_manager_signals,
- "load-buffer",
- G_CALLBACK (ide_editor_perspective_load_buffer),
- self,
- G_CONNECT_SWAPPED);
-
- dzl_signal_group_connect_object (self->buffer_manager_signals,
- "notify::focus-buffer",
- G_CALLBACK (ide_editor_perspective_notify_focus_buffer),
- self,
- G_CONNECT_SWAPPED);
-
- gtk_widget_init_template (GTK_WIDGET (self));
-
- g_action_map_add_action_entries (G_ACTION_MAP (self->actions), entries,
- G_N_ELEMENTS (entries), self);
-
- /* Ensure panels are created up front */
- (void)ide_editor_perspective_get_left_edge (self);
- (void)ide_editor_perspective_get_bottom_edge (self);
- (void)ide_editor_perspective_get_right_edge (self);
-
- actions = gtk_widget_get_action_group (GTK_WIDGET (self->layout), "dockbin");
-
- for (i = 0; proxy_actions[i]; i++)
- {
- GAction *action;
-
- action = g_action_map_lookup_action (G_ACTION_MAP (actions), proxy_actions[i]);
- g_action_map_add_action (G_ACTION_MAP (self->actions), action);
- }
-
- ide_widget_set_context_handler (GTK_WIDGET (self),
- ide_editor_perspective_context_set);
-
- g_signal_connect_swapped (self->layout,
- "notify::active-view",
- G_CALLBACK (ide_editor_perspective_active_view_notify_cb),
- self);
-
- ide_editor_perspective_active_view_notify_cb (self, NULL, self->layout);
-}
-
-static gchar *
-ide_editor_perspective_get_title (IdePerspective *perspective)
-{
- return g_strdup (_("Editor"));
-}
-
-static gchar *
-ide_editor_perspective_get_icon_name (IdePerspective *perspective)
-{
- return g_strdup ("builder-editor-symbolic");
-}
-
-static gchar *
-ide_editor_perspective_get_id (IdePerspective *perspective)
-{
- return g_strdup ("editor");
-}
-
-static void
-ide_editor_perspective_views_foreach (IdePerspective *perspective,
- GtkCallback callback,
- gpointer user_data)
-{
- IdeEditorPerspective *self = (IdeEditorPerspective *)perspective;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
-
- ide_layout_grid_foreach_view (self->grid, callback, user_data);
-}
-
-static GActionGroup *
-ide_editor_perspective_get_actions (IdePerspective *perspective)
-{
- IdeEditorPerspective *self = (IdeEditorPerspective *)perspective;
-
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return g_object_ref (self->actions);
-}
-
-static gboolean
-ide_editor_perspective_agree_to_shutdown (IdePerspective *perspective)
-{
- IdeEditorPerspective *self = (IdeEditorPerspective *)perspective;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
-
- ide_editor_perspective_save_panel_state (self);
-
- return TRUE;
-}
-
-static void
-ide_editor_perspective_restore_state (IdePerspective *perspective)
-{
- IdeEditorPerspective *self = (IdeEditorPerspective *)perspective;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
-
- ide_editor_perspective_restore_panel_state (self);
-}
-
-static gchar *
-ide_editor_perspective_get_accelerator (IdePerspective *perspective)
-{
- return g_strdup ("<alt>1");
-}
-
-static void
-ide_perspective_iface_init (IdePerspectiveInterface *iface)
-{
- iface->agree_to_shutdown = ide_editor_perspective_agree_to_shutdown;
- iface->get_actions = ide_editor_perspective_get_actions;
- iface->get_icon_name = ide_editor_perspective_get_icon_name;
- iface->get_id = ide_editor_perspective_get_id;
- iface->get_title = ide_editor_perspective_get_title;
- iface->views_foreach = ide_editor_perspective_views_foreach;
- iface->get_accelerator = ide_editor_perspective_get_accelerator;
- iface->restore_state = ide_editor_perspective_restore_state;
-}
-
-static void
-ide_editor_perspective_find_source_location (GtkWidget *widget,
- gpointer user_data)
-{
- struct {
- IdeFile *file;
- IdeEditorView *view;
- } *lookup = user_data;
- IdeBuffer *buffer;
- IdeFile *file;
-
- g_return_if_fail (IDE_IS_LAYOUT_VIEW (widget));
-
- if (lookup->view != NULL)
- return;
-
- if (!IDE_IS_EDITOR_VIEW (widget))
- return;
-
- buffer = ide_editor_view_get_document (IDE_EDITOR_VIEW (widget));
- file = ide_buffer_get_file (buffer);
-
- if (ide_file_equal (file, lookup->file))
- lookup->view = IDE_EDITOR_VIEW (widget);
-}
-
-static void
-ide_editor_perspective_focus_location_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- IdeBufferManager *bufmgr = (IdeBufferManager *)object;
- FocusLocation *state = user_data;
- GError *error = NULL;
-
- g_assert (IDE_IS_BUFFER_MANAGER (bufmgr));
- g_assert (state != NULL);
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (state->self));
- g_assert (state->location != NULL);
-
- if (!ide_buffer_manager_load_file_finish (bufmgr, result, &error))
- {
- /* TODO: display warning breifly to the user in the frame? */
- g_warning ("%s", error->message);
- g_clear_error (&error);
- goto cleanup;
- }
-
- /* try again now that we have loaded */
- ide_editor_perspective_focus_location_full (state->self, state->location, FALSE);
-
-cleanup:
- g_object_unref (state->self);
- ide_source_location_unref (state->location);
- g_slice_free (FocusLocation, state);
-}
-
-static void
-ide_editor_perspective_focus_location_full (IdeEditorPerspective *self,
- IdeSourceLocation *location,
- gboolean open_if_not_found)
-{
- struct {
- IdeFile *file;
- IdeEditorView *view;
- } lookup = { 0 };
- GtkWidget *stack;
-
- g_return_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_return_if_fail (location != NULL);
-
- lookup.file = ide_source_location_get_file (location);
- lookup.view = NULL;
-
- if (lookup.file == NULL)
- {
- g_warning ("IdeSourceLocation does not contain a file");
- return;
- }
-
- ide_perspective_views_foreach (IDE_PERSPECTIVE (self),
- ide_editor_perspective_find_source_location,
- &lookup);
-
- if (!open_if_not_found && lookup.view == NULL)
- return;
-
- if (lookup.view == NULL)
- {
- FocusLocation *state;
- IdeBufferManager *bufmgr;
- IdeWorkbench *workbench;
- IdeContext *context;
-
- workbench = ide_widget_get_workbench (GTK_WIDGET (self));
- context = ide_workbench_get_context (workbench);
- bufmgr = ide_context_get_buffer_manager (context);
-
- state = g_slice_new0 (FocusLocation);
- state->self = g_object_ref (self);
- state->location = ide_source_location_ref (location);
-
- ide_buffer_manager_load_file_async (bufmgr,
- lookup.file,
- FALSE,
- IDE_WORKBENCH_OPEN_FLAGS_NONE,
- NULL,
- NULL,
- ide_editor_perspective_focus_location_cb,
- state);
- return;
- }
-
- stack = gtk_widget_get_ancestor (GTK_WIDGET (lookup.view), IDE_TYPE_LAYOUT_STACK);
- ide_layout_stack_set_active_view (IDE_LAYOUT_STACK (stack), GTK_WIDGET (lookup.view));
- ide_layout_view_navigate_to (IDE_LAYOUT_VIEW (lookup.view), location);
- gtk_widget_grab_focus (GTK_WIDGET (lookup.view));
-}
-
-void
-ide_editor_perspective_focus_location (IdeEditorPerspective *self,
- IdeSourceLocation *location)
-{
- ide_editor_perspective_focus_location_full (self, location, TRUE);
}
/**
- * ide_editor_perspective_get_layout:
- * @self: A #IdeEditorPerspective
+ * ide_editor_perspective_get_grid:
+ * @self: a #IdeEditorPerspective
*
- * Gets the #IdeLayout widget for the editor perspective.
+ * Gets the grid for the perspective. This is the area containing
+ * grid columns, stacks, and views.
*
- * Returns: (transfer none) (nullable): A #IdeLayout or %NULL.
- */
-IdeLayout *
-ide_editor_perspective_get_layout (IdeEditorPerspective *self)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return self->layout;
-}
-
-/**
- * ide_editor_perspective_get_active_view:
+ * Returns: (transfer none): An #IdeLayoutGrid.
*
- * Returns: (transfer none) (nullable): An #IdeLayoutView or %NULL.
+ * Since: 3.26
*/
-GtkWidget *
-ide_editor_perspective_get_active_view (IdeEditorPerspective *self)
+IdeLayoutGrid *
+ide_editor_perspective_get_grid (IdeEditorPerspective *self)
{
-
g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
- return self->active_view;
-}
-
-/**
- * ide_editor_perspective_get_center_widget:
- * @self: A #IdeEditorPerspective
- *
- * Gets the center widget for the editor perspective.
- *
- * Returns: (transfer none) (nullable): A #GtkWidget or %NULL.
- */
-GtkWidget *
-ide_editor_perspective_get_center_widget (IdeEditorPerspective *self)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return dzl_dock_bin_get_center_widget (DZL_DOCK_BIN (self->layout));
-}
-
-/**
- * ide_editor_perspective_get_top_edge:
- * Returns: (transfer none): A #GtkWidget
- */
-GtkWidget *
-ide_editor_perspective_get_top_edge (IdeEditorPerspective *self)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return dzl_dock_bin_get_top_edge (DZL_DOCK_BIN (self->layout));
-}
-
-/**
- * ide_editor_perspective_get_left_edge:
- * Returns: (transfer none): A #GtkWidget
- */
-GtkWidget *
-ide_editor_perspective_get_left_edge (IdeEditorPerspective *self)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return dzl_dock_bin_get_left_edge (DZL_DOCK_BIN (self->layout));
-}
-
-/**
- * ide_editor_perspective_get_bottom_edge:
- * Returns: (transfer none): A #GtkWidget
- */
-GtkWidget *
-ide_editor_perspective_get_bottom_edge (IdeEditorPerspective *self)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self->layout));
-}
-
-/**
- * ide_editor_perspective_get_right_edge:
- * Returns: (transfer none): A #GtkWidget
- */
-GtkWidget *
-ide_editor_perspective_get_right_edge (IdeEditorPerspective *self)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self->layout));
-}
-
-/**
- * ide_editor_perspective_get_overlay_edge:
- * self: an #IdeEditorPerspective.
- * position: a #GtkPositionType.
- *
- * Returns: (transfer none): A #DzlDockOverlayEdge
- */
-DzlDockOverlayEdge *
-ide_editor_perspective_get_overlay_edge (IdeEditorPerspective *self,
- GtkPositionType position)
-{
- g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self), NULL);
-
- return dzl_dock_overlay_get_edge (DZL_DOCK_OVERLAY (self), position);
-}
-
-static GtkOrientation
-get_orientation_from_position_type (GtkPositionType position_type)
-{
- if (position_type == GTK_POS_LEFT || position_type == GTK_POS_RIGHT)
- return GTK_ORIENTATION_HORIZONTAL;
- else
- return GTK_ORIENTATION_VERTICAL;
-}
-
-/* Triggered at the start of the animation */
-static void
-overlay_child_reveal_notify_cb (IdeEditorPerspective *self,
- GParamSpec *pspec,
- DzlDockOverlayEdge *edge)
-{
- IdeLayoutPane *pane;
- gboolean reveal;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (DZL_IS_DOCK_OVERLAY_EDGE (edge));
-
- gtk_container_child_get (GTK_CONTAINER (self), GTK_WIDGET (edge),
- "reveal", &reveal,
- NULL);
-
- if (!reveal && self->spellchecker_opened)
- {
- g_signal_handlers_disconnect_by_func (edge,
- overlay_child_reveal_notify_cb,
- self);
-
- pane = IDE_LAYOUT_PANE (dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self->layout)));
- dzl_dock_revealer_animate_to_position (DZL_DOCK_REVEALER (pane),
- self->right_pane_position,
- OVERLAY_REVEAL_DURATION);
- }
-}
-
-/* Triggered at the end of the animation */
-static void
-overlay_child_revealed_notify_cb (IdeEditorPerspective *self,
- GParamSpec *pspec,
- DzlDockOverlayEdge *edge)
-{
- GtkWidget *child;
- gboolean revealed;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (DZL_IS_DOCK_OVERLAY_EDGE (edge));
-
- gtk_container_child_get (GTK_CONTAINER (self), GTK_WIDGET (edge),
- "revealed", &revealed,
- NULL);
-
- if (!revealed && self->spellchecker_opened)
- {
- g_signal_handlers_disconnect_by_func (edge,
- overlay_child_revealed_notify_cb,
- self);
-
- child = gtk_bin_get_child (GTK_BIN (edge));
- g_assert (child != NULL);
- gtk_container_remove (GTK_CONTAINER (edge), child);
- self->spellchecker_opened = FALSE;
- }
- else if (revealed)
- self->spellchecker_opened = TRUE;
-}
-
-static void
-show_spell_checker (IdeEditorPerspective *self,
- DzlDockOverlayEdge *overlay_edge,
- IdeLayoutPane *pane)
-{
- GtkOrientation pane_orientation;
- GtkPositionType pane_position_type;
- GtkOrientation overlay_orientation;
- GtkPositionType overlay_position_type;
- gint overlay_size;
-
- g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_assert (gtk_bin_get_child (GTK_BIN (overlay_edge)) != NULL);
-
- pane_position_type = dzl_dock_bin_edge_get_edge (DZL_DOCK_BIN_EDGE (pane));
- overlay_position_type = dzl_dock_overlay_edge_get_edge (overlay_edge);
-
- pane_orientation = get_orientation_from_position_type (pane_position_type);
- overlay_orientation = get_orientation_from_position_type (overlay_position_type);
-
- g_assert (pane_orientation == overlay_orientation);
-
- if (dzl_dock_revealer_get_position_set (DZL_DOCK_REVEALER (pane)))
- self->right_pane_position = dzl_dock_revealer_get_position (DZL_DOCK_REVEALER (pane));
- else
- {
- if (overlay_orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_preferred_width (GTK_WIDGET (pane), NULL, &self->right_pane_position);
- else
- gtk_widget_get_preferred_height (GTK_WIDGET (pane), NULL, &self->right_pane_position);
- }
-
- if (overlay_orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_preferred_width (GTK_WIDGET (overlay_edge), NULL, &overlay_size);
- else
- gtk_widget_get_preferred_height (GTK_WIDGET (overlay_edge), NULL, &overlay_size);
-
- g_signal_connect_object (overlay_edge,
- "child-notify::reveal",
- G_CALLBACK (overlay_child_reveal_notify_cb),
- self,
- G_CONNECT_SWAPPED);
- g_signal_connect_object (overlay_edge,
- "child-notify::revealed",
- G_CALLBACK (overlay_child_revealed_notify_cb),
- self,
- G_CONNECT_SWAPPED);
-
- dzl_dock_revealer_animate_to_position (DZL_DOCK_REVEALER (pane),
- overlay_size,
- OVERLAY_REVEAL_DURATION);
- gtk_container_child_set (GTK_CONTAINER (self), GTK_WIDGET (overlay_edge),
- "reveal", TRUE,
- NULL);
-}
-
-static GtkWidget *
-create_spellchecker_widget (IdeSourceView *source_view)
-{
- GtkWidget *spellchecker_widget;
- GtkWidget *scroll_window;
- GtkWidget *spell_widget;
-
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
-
- spellchecker_widget = g_object_new (GTK_TYPE_BOX,
- "visible", TRUE,
- "expand", TRUE,
- NULL);
- scroll_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
- "visible", TRUE,
- "expand", TRUE,
- "propagate-natural-width", TRUE,
- NULL);
- spell_widget = ide_editor_spell_widget_new (source_view);
- gtk_box_pack_start (GTK_BOX (spellchecker_widget), scroll_window, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (scroll_window), spell_widget);
- gtk_widget_show_all (spellchecker_widget);
-
- return spellchecker_widget;
-}
-
-void
-ide_editor_perspective_show_spellchecker (IdeEditorPerspective *self,
- IdeSourceView *source_view)
-{
- GtkWidget *spellchecker_widget;
- DzlDockOverlayEdge *overlay_edge;
- IdeLayoutPane *pane;
-
- g_return_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self));
- g_return_if_fail (IDE_IS_SOURCE_VIEW (source_view));
-
- if (!self->spellchecker_opened)
- {
- self->spellchecker_opened = TRUE;
- spellchecker_widget = create_spellchecker_widget (source_view);
-
- dzl_overlay_add_child (DZL_DOCK_OVERLAY (self), spellchecker_widget, "right");
- overlay_edge = ide_editor_perspective_get_overlay_edge (self, GTK_POS_RIGHT);
- gtk_widget_set_child_visible (GTK_WIDGET (overlay_edge), TRUE);
-
- pane = IDE_LAYOUT_PANE (dzl_dock_bin_get_right_edge (DZL_DOCK_BIN (self->layout)));
- show_spell_checker (self, overlay_edge, pane);
- }
+ return self->grid;
}
diff --git a/libide/editor/ide-editor-perspective.h b/libide/editor/ide-editor-perspective.h
index 3af0dd5..7e2dcb5 100644
--- a/libide/editor/ide-editor-perspective.h
+++ b/libide/editor/ide-editor-perspective.h
@@ -1,6 +1,6 @@
/* ide-editor-perspective.h
*
- * Copyright (C) 2015 Christian Hergert <chergert redhat com>
+ * 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
@@ -16,41 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IDE_EDITOR_PERSPECTIVE_H
-#define IDE_EDITOR_PERSPECTIVE_H
+#pragma once
-#include <dazzle.h>
-#include <gtk/gtk.h>
-
-#include "diagnostics/ide-source-location.h"
#include "layout/ide-layout.h"
-#include "sourceview/ide-source-view.h"
-#include "workbench/ide-perspective.h"
+#include "layout/ide-layout-grid.h"
G_BEGIN_DECLS
#define IDE_TYPE_EDITOR_PERSPECTIVE (ide_editor_perspective_get_type())
-G_DECLARE_FINAL_TYPE (IdeEditorPerspective, ide_editor_perspective, IDE, EDITOR_PERSPECTIVE, DzlDockOverlay)
-
-void ide_editor_perspective_focus_location (IdeEditorPerspective *self,
- IdeSourceLocation
*location);
-void ide_editor_perspective_focus_buffer_in_current_stack (IdeEditorPerspective *self,
- IdeBuffer *buffer);
-GtkWidget *ide_editor_perspective_get_active_view (IdeEditorPerspective *self);
-IdeLayout *ide_editor_perspective_get_layout (IdeEditorPerspective *self);
+G_DECLARE_FINAL_TYPE (IdeEditorPerspective, ide_editor_perspective, IDE, EDITOR_PERSPECTIVE, IdeLayout)
-GtkWidget *ide_editor_perspective_get_center_widget (IdeEditorPerspective *self);
-GtkWidget *ide_editor_perspective_get_top_edge (IdeEditorPerspective *self);
-GtkWidget *ide_editor_perspective_get_left_edge (IdeEditorPerspective *self);
-GtkWidget *ide_editor_perspective_get_bottom_edge (IdeEditorPerspective *self);
-GtkWidget *ide_editor_perspective_get_right_edge (IdeEditorPerspective *self);
+IdeLayoutGrid *ide_editor_perspective_get_grid (IdeEditorPerspective *self);
-DzlDockOverlayEdge *ide_editor_perspective_get_overlay_edge (IdeEditorPerspective *self,
- GtkPositionType
position);
-
-void ide_editor_perspective_show_spellchecker (IdeEditorPerspective *self,
- IdeSourceView
*source_view);
G_END_DECLS
-
-#endif /* IDE_EDITOR_PERSPECTIVE_H */
diff --git a/libide/editor/ide-editor-perspective.ui b/libide/editor/ide-editor-perspective.ui
index 6b0c3ec..9601352 100644
--- a/libide/editor/ide-editor-perspective.ui
+++ b/libide/editor/ide-editor-perspective.ui
@@ -1,71 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.18 -->
- <template class="IdeEditorPerspective" parent="DzlDockOverlay">
+ <template class="IdeEditorPerspective" parent="IdeLayout">
<child>
- <object class="IdeLayout" id="layout">
+ <object class="IdeLayoutGrid" id="grid">
<property name="visible">true</property>
- <child type="center">
- <object class="GtkStack" id="content_stack">
- <property name="visible">true</property>
- <child>
- <object class="GtkBox">
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkImage">
- <property name="icon-name">text-editor-symbolic</property>
- <property name="pixel-size">128</property>
- <property name="visible">true</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">No open files</property>
- <property name="visible">true</property>
- <style>
- <class name="dim-label"/>
- </style>
- <attributes>
- <attribute name="scale" value="2.0"/>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label" translatable="yes">Try opening a file by typing in the search box
at the top</property>
- <property name="wrap">true</property>
- <property name="visible">true</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">empty_state</property>
- </packing>
- </child>
- <child>
- <object class="IdeLayoutGrid" id="grid">
- <property name="visible">true</property>
- </object>
- <packing>
- <property name="name">grid</property>
- </packing>
- </child>
- </object>
- </child>
</object>
</child>
</template>
- <object class="GSimpleActionGroup" id="actions">
- </object>
</interface>
diff --git a/libide/editor/ide-editor-plugin.c b/libide/editor/ide-editor-plugin.c
index e47b6d8..59d2d7b 100644
--- a/libide/editor/ide-editor-plugin.c
+++ b/libide/editor/ide-editor-plugin.c
@@ -21,7 +21,6 @@
#include <libpeas/peas.h>
#include "editor/ide-editor-workbench-addin.h"
-#include "editor/ide-editor-layout-stack-addin.h"
void
ide_editor_register_types (PeasObjectModule *module)
@@ -29,7 +28,4 @@ ide_editor_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_WORKBENCH_ADDIN,
IDE_TYPE_EDITOR_WORKBENCH_ADDIN);
- peas_object_module_register_extension_type (module,
- IDE_TYPE_LAYOUT_STACK_ADDIN,
- IDE_TYPE_EDITOR_LAYOUT_STACK_ADDIN);
}
diff --git a/libide/editor/ide-editor-print-operation.c b/libide/editor/ide-editor-print-operation.c
index 3743107..47a995c 100644
--- a/libide/editor/ide-editor-print-operation.c
+++ b/libide/editor/ide-editor-print-operation.c
@@ -114,7 +114,7 @@ ide_editor_print_operation_begin_print (GtkPrintOperation *operation,
static gboolean
ide_editor_print_operation_paginate (GtkPrintOperation *operation,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
IdeEditorPrintOperation *self = IDE_EDITOR_PRINT_OPERATION (operation);
gboolean finished;
@@ -134,8 +134,8 @@ ide_editor_print_operation_paginate (GtkPrintOperation *operation,
static void
ide_editor_print_operation_draw_page (GtkPrintOperation *operation,
- GtkPrintContext *context,
- gint page_nr)
+ GtkPrintContext *context,
+ gint page_nr)
{
IdeEditorPrintOperation *self = IDE_EDITOR_PRINT_OPERATION (operation);
@@ -144,7 +144,7 @@ ide_editor_print_operation_draw_page (GtkPrintOperation *operation,
static void
ide_editor_print_operation_end_print (GtkPrintOperation *operation,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
IdeEditorPrintOperation *self = IDE_EDITOR_PRINT_OPERATION (operation);
diff --git a/libide/editor/ide-editor-view-actions.h b/libide/editor/ide-editor-private.h
similarity index 69%
rename from libide/editor/ide-editor-view-actions.h
rename to libide/editor/ide-editor-private.h
index daab752..3be19b7 100644
--- a/libide/editor/ide-editor-view-actions.h
+++ b/libide/editor/ide-editor-private.h
@@ -1,6 +1,6 @@
-/* ide-editor-view-actions.h
+/* ide-editor-private.h
*
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * 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
@@ -16,16 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IDE_EDITOR_VIEW_ACTIONS_H
-#define IDE_EDITOR_VIEW_ACTIONS_H
+#pragma once
#include "ide-editor-view.h"
G_BEGIN_DECLS
-void ide_editor_view_actions_init (IdeEditorView *self);
-void ide_editor_view_actions_update (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);
G_END_DECLS
-
-#endif /* IDE_EDITOR_VIEW_ACTIONS_H */
diff --git a/libide/editor/ide-editor-view-actions.c b/libide/editor/ide-editor-view-actions.c
index 7f23a3b..052d414 100644
--- a/libide/editor/ide-editor-view-actions.c
+++ b/libide/editor/ide-editor-view-actions.c
@@ -1,6 +1,6 @@
/* ide-editor-view-actions.c
*
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * 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
@@ -16,783 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define G_LOG_DOMAIN "ide-editor-view"
+#define G_LOG_DOMAIN "ide-editor-view-actions"
-#include <dazzle.h>
-#include <glib/gi18n.h>
-#include <string.h>
-
-#include "buffers/ide-buffer.h"
-#include "buffers/ide-buffer-manager.h"
-#include "files/ide-file.h"
-#include "files/ide-file-settings.h"
-#include "editor/ide-editor-frame-private.h"
-#include "editor/ide-editor-print-operation.h"
-#include "editor/ide-editor-view-actions.h"
-#include "editor/ide-editor-view-private.h"
-#include "editor/ide-editor-view.h"
-#include "projects/ide-project.h"
-#include "sourceview/ide-source-view.h"
-#include "util/ide-gtk.h"
-#include "util/ide-progress.h"
-#include "vcs/ide-vcs.h"
-#include "workbench/ide-workbench.h"
-
-static void
-ide_editor_view_actions_source_view_notify (IdeSourceView *source_view,
- GParamSpec *pspec,
- GActionMap *actions)
-{
- g_autoptr(GVariant) param = NULL;
- GtkSourceView *gsv;
- GAction *action = NULL;
-
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
- g_assert (pspec != NULL);
- g_assert (G_IS_ACTION_MAP (actions));
-
- gsv = GTK_SOURCE_VIEW (source_view);
-
- if (g_str_equal (pspec->name, "show-line-numbers"))
- {
- gboolean show_line_numbers;
-
- action = g_action_map_lookup_action (actions, "show-line-numbers");
- show_line_numbers = gtk_source_view_get_show_line_numbers (gsv);
- param = g_variant_new_boolean (show_line_numbers);
- }
- else if (g_str_equal (pspec->name, "show-right-margin"))
- {
- gboolean show_right_margin;
-
- action = g_action_map_lookup_action (actions, "show-right-margin");
- show_right_margin = gtk_source_view_get_show_right_margin (gsv);
- param = g_variant_new_boolean (show_right_margin);
- }
- else if (g_str_equal (pspec->name, "highlight-current-line"))
- {
- gboolean highlight_current_line;
-
- action = g_action_map_lookup_action (actions, "highlight-current-line");
- g_object_get (gsv, "highlight-current-line", &highlight_current_line, NULL);
- param = g_variant_new_boolean (highlight_current_line);
- }
- else if (g_str_equal (pspec->name, "auto-indent"))
- {
- gboolean auto_indent;
-
- action = g_action_map_lookup_action (actions, "auto-indent");
- g_object_get (source_view, "auto-indent", &auto_indent, NULL);
- param = g_variant_new_boolean (auto_indent);
- }
- else if (g_str_equal (pspec->name, "tab-width"))
- {
- guint tab_width;
-
- action = g_action_map_lookup_action (actions, "tab-width");
- g_object_get (source_view, "tab-width", &tab_width, NULL);
- param = g_variant_new_int32 (tab_width);
- }
- else if (g_str_equal (pspec->name, "insert-spaces-instead-of-tabs"))
- {
- gboolean use_spaces;
-
- action = g_action_map_lookup_action (actions, "use-spaces");
- g_object_get (source_view, "insert-spaces-instead-of-tabs", &use_spaces, NULL);
- param = g_variant_new_boolean (use_spaces);
- }
- else if (g_str_equal (pspec->name, "smart-backspace"))
- {
- gboolean smart_backspace;
-
- action = g_action_map_lookup_action (actions, "smart-backspace");
- g_object_get (source_view, "smart-backspace", &smart_backspace, NULL);
- param = g_variant_new_boolean (smart_backspace);
- }
-
- if (action && param)
- {
- g_simple_action_set_state (G_SIMPLE_ACTION (action), param);
- param = NULL;
- }
-}
-
-static void
-ide_editor_view_actions_language (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- GtkSourceLanguageManager *manager;
- GtkSourceLanguage *language;
- GtkSourceBuffer *buffer;
- const gchar *name;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- manager = gtk_source_language_manager_get_default ();
- name = g_variant_get_string (variant, NULL);
- buffer = GTK_SOURCE_BUFFER (self->document);
-
- if (name != NULL)
- {
- language = gtk_source_language_manager_get_language (manager, name);
- gtk_source_buffer_set_language (buffer, language);
- ide_editor_view_actions_update (self);
- }
-}
-
-#define STATE_HANDLER_BOOLEAN(name,propname) \
-static void \
-ide_editor_view_actions_##name (GSimpleAction *action, \
- GVariant *variant, \
- gpointer user_data) \
-{ \
- IdeEditorView *self = user_data; \
- gboolean val; \
- \
- g_assert (IDE_IS_EDITOR_VIEW (self)); \
- \
- val = g_variant_get_boolean (variant); \
- g_object_set (self->frame1->source_view, propname, val, NULL); \
- if (self->frame2) \
- g_object_set (self->frame2->source_view, propname, val, NULL); \
-}
-
-#define STATE_HANDLER_INT(name,propname) \
-static void \
-ide_editor_view_actions_##name (GSimpleAction *action, \
- GVariant *variant, \
- gpointer user_data) \
-{ \
- IdeEditorView *self = user_data; \
- gint val; \
- \
- g_assert (IDE_IS_EDITOR_VIEW (self)); \
- \
- val = g_variant_get_int32 (variant); \
- g_object_set (self->frame1->source_view, propname, val, NULL); \
- if (self->frame2) \
- g_object_set (self->frame2->source_view, propname, val, NULL); \
-}
-
-STATE_HANDLER_BOOLEAN (auto_indent, "auto-indent")
-STATE_HANDLER_BOOLEAN (show_line_numbers, "show-line-numbers")
-STATE_HANDLER_BOOLEAN (show_right_margin, "show-right-margin")
-STATE_HANDLER_BOOLEAN (highlight_current_line, "highlight-current-line")
-STATE_HANDLER_BOOLEAN (use_spaces, "insert-spaces-instead-of-tabs")
-STATE_HANDLER_BOOLEAN (smart_backspace, "smart-backspace")
-STATE_HANDLER_INT (tab_width, "tab-width")
-
-static void
-save_file_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- IdeBufferManager *buffer_manager = (IdeBufferManager *)object;
- g_autoptr(IdeEditorView) self = user_data;
- GError *error = NULL;
-
- if (!ide_buffer_manager_save_file_finish (buffer_manager, result, &error))
- {
- /* info bar */
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- if (self->progress_bar)
- dzl_gtk_widget_hide_with_fade (GTK_WIDGET (self->progress_bar));
-}
-
-static void
-ide_editor_view_actions__save_temp_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeBufferManager *buffer_manager = (IdeBufferManager *)object;
- GError *error = NULL;
-
- if (!ide_buffer_manager_save_file_finish (buffer_manager, result, &error))
- {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- g_object_unref (self);
-}
-
-static void
-save_temp_response (GtkWidget *widget,
- gint response,
- gpointer user_data)
-{
- g_autoptr(IdeEditorView) self = user_data;
- g_autoptr(GFile) target = NULL;
- g_autoptr(IdeProgress) progress = NULL;
- GtkFileChooser *chooser = (GtkFileChooser *)widget;
-
- g_assert (GTK_IS_FILE_CHOOSER (chooser));
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- switch (response)
- {
- case GTK_RESPONSE_OK:
- target = gtk_file_chooser_get_file (chooser);
- break;
-
- case GTK_RESPONSE_CANCEL:
- default:
- break;
- }
-
- if (target != NULL)
- {
- IdeBufferManager *buffer_manager;
- IdeContext *context;
- IdeProject *project;
- IdeBuffer *buffer = IDE_BUFFER (self->document);
- g_autoptr(IdeFile) file = NULL;
-
- context = ide_buffer_get_context (buffer);
- project = ide_context_get_project (context);
- buffer_manager = ide_context_get_buffer_manager (context);
- file = ide_project_get_project_file (project, target);
-
- ide_buffer_manager_save_file_async (buffer_manager,
- buffer,
- file,
- &progress,
- NULL,
- ide_editor_view_actions__save_temp_cb,
- g_object_ref (self));
- }
-
- gtk_widget_destroy (widget);
-}
-
-static void
-ide_editor_view_actions_save (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeContext *context;
- IdeBufferManager *buffer_manager;
- IdeFile *file;
- IdeProgress *progress = NULL;
- IdeVcs *vcs;
- GFile *workdir;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- file = ide_buffer_get_file (IDE_BUFFER (self->document));
- context = ide_buffer_get_context (IDE_BUFFER (self->document));
- buffer_manager = ide_context_get_buffer_manager (context);
- vcs = ide_context_get_vcs (context);
- workdir = ide_vcs_get_working_directory (vcs);
-
- if (ide_file_get_is_temporary (file))
- {
- GtkDialog *dialog;
- GtkWidget *toplevel;
- GtkWidget *suggested;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
- "action", GTK_FILE_CHOOSER_ACTION_SAVE,
- "do-overwrite-confirmation", TRUE,
- "local-only", FALSE,
- "modal", TRUE,
- "select-multiple", FALSE,
- "show-hidden", FALSE,
- "transient-for", toplevel,
- "title", _("Save Document"),
- NULL);
-
- gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), workdir, NULL);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Cancel"), GTK_RESPONSE_CANCEL,
- _("Save"), GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- suggested = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_style_context_add_class (gtk_widget_get_style_context (suggested),
- GTK_STYLE_CLASS_SUGGESTED_ACTION);
-
- g_signal_connect (dialog, "response", G_CALLBACK (save_temp_response), g_object_ref (self));
-
- gtk_window_present (GTK_WINDOW (dialog));
-
- return;
- }
-
- ide_buffer_manager_save_file_async (buffer_manager,
- IDE_BUFFER (self->document),
- file,
- &progress,
- NULL,
- save_file_cb,
- g_object_ref (self));
- g_object_bind_property (progress, "fraction", self->progress_bar, "fraction",
- G_BINDING_SYNC_CREATE);
- gtk_widget_show (GTK_WIDGET (self->progress_bar));
- g_clear_object (&progress);
-}
-
-static void
-ide_editor_view_actions__save_as_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeBufferManager *buffer_manager = (IdeBufferManager *)object;
- GError *error = NULL;
-
- if (!ide_buffer_manager_save_file_finish (buffer_manager, result, &error))
- {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- g_object_unref (self);
-}
-
-static void
-save_as_response (GtkWidget *widget,
- gint response,
- gpointer user_data)
-{
- g_autoptr(IdeEditorView) self = user_data;
- g_autoptr(GFile) target = NULL;
- g_autoptr(IdeProgress) progress = NULL;
- GtkFileChooser *chooser = (GtkFileChooser *)widget;
-
- g_assert (GTK_IS_FILE_CHOOSER (chooser));
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- switch (response)
- {
- case GTK_RESPONSE_OK:
- target = gtk_file_chooser_get_file (chooser);
- break;
-
- case GTK_RESPONSE_CANCEL:
- default:
- break;
- }
-
- if (target != NULL)
- {
- IdeBufferManager *buffer_manager;
- IdeContext *context;
- IdeProject *project;
- IdeBuffer *buffer = IDE_BUFFER (self->document);
- g_autoptr(IdeFile) file = NULL;
-
- context = ide_buffer_get_context (buffer);
- project = ide_context_get_project (context);
- buffer_manager = ide_context_get_buffer_manager (context);
- file = ide_project_get_project_file (project, target);
-
- ide_buffer_manager_save_file_async (buffer_manager,
- buffer,
- file,
- &progress,
- NULL,
- ide_editor_view_actions__save_as_cb,
- g_object_ref (self));
- }
-
- gtk_widget_destroy (widget);
-}
-
-static void
-ide_editor_view_actions_save_as (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeBuffer *buffer;
- GtkWidget *suggested;
- GtkWidget *toplevel;
- GtkWidget *dialog;
- IdeFile *file;
- GFile *gfile;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
- "action", GTK_FILE_CHOOSER_ACTION_SAVE,
- "do-overwrite-confirmation", TRUE,
- "local-only", FALSE,
- "modal", TRUE,
- "select-multiple", FALSE,
- "show-hidden", FALSE,
- "transient-for", toplevel,
- "title", _("Save Document As"),
- NULL);
-
- buffer = IDE_BUFFER (self->document);
- file = ide_buffer_get_file (buffer);
- gfile = ide_file_get_file (file);
-
- if (gfile != NULL)
- gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), gfile, NULL);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Cancel"), GTK_RESPONSE_CANCEL,
- _("Save"), GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- suggested = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_style_context_add_class (gtk_widget_get_style_context (suggested),
- GTK_STYLE_CLASS_SUGGESTED_ACTION);
-
- g_signal_connect (dialog, "response", G_CALLBACK (save_as_response), g_object_ref (self));
-
- gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static gboolean
-set_split_view (gpointer data)
-{
- g_autoptr(IdeEditorView) self = data;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- ide_layout_view_set_split_view (IDE_LAYOUT_VIEW (self), (self->frame2 == NULL));
-
- return G_SOURCE_REMOVE;
-}
-
-static void
-ide_editor_view_actions_toggle_split (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- g_timeout_add (0, set_split_view, g_object_ref (self));
-}
-
-static void
-ide_editor_view_actions_close (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- /* just close our current frame if we have split view */
- if (self->frame2 != NULL)
- {
- /* todo: swap frame1/frame2 if frame2 was last focused. */
- g_timeout_add (0, set_split_view, g_object_ref (self));
- }
- else
- {
- dzl_gtk_widget_action (GTK_WIDGET (self), "view-stack", "close", NULL);
- }
-}
-
-static void
-find_other_file_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- g_autoptr(IdeEditorView) self = user_data;
- g_autoptr(IdeFile) ret = NULL;
- IdeFile *file = (IdeFile *)object;
-
- ret = ide_file_find_other_finish (file, result, NULL);
-
- if (ret != NULL)
- {
- IdeWorkbench *workbench;
- GFile *gfile;
-
- gfile = ide_file_get_file (ret);
- workbench = ide_widget_get_workbench (GTK_WIDGET (self));
- ide_workbench_open_files_async (workbench, &gfile, 1, "editor", IDE_WORKBENCH_OPEN_FLAGS_NONE, NULL,
NULL, NULL);
- }
-}
-
-static void
-ide_editor_view_actions_find_other_file (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeFile *file;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- file = ide_buffer_get_file (IDE_BUFFER (self->document));
- ide_file_find_other_async (file, NULL, find_other_file_cb, g_object_ref (self));
-}
-
-static void
-ide_editor_view_actions_reload_buffer_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- IdeBufferManager *buffer_manager = (IdeBufferManager *)object;
- g_autoptr(IdeEditorView) self = user_data;
- g_autoptr(GError) error = NULL;
- g_autoptr(IdeBuffer) buffer = NULL;
-
- g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- gtk_revealer_set_reveal_child (self->modified_revealer, FALSE);
-
- if (!(buffer = ide_buffer_manager_load_file_finish (buffer_manager, result, &error)))
- {
- g_warning ("%s", error->message);
- }
- else
- {
- g_signal_emit_by_name (self->frame1->source_view, "movement",
- IDE_SOURCE_VIEW_MOVEMENT_FIRST_LINE, FALSE, TRUE,
- FALSE);
- if (self->frame2 != NULL)
- g_signal_emit_by_name (self->frame2->source_view, "movement",
- IDE_SOURCE_VIEW_MOVEMENT_FIRST_LINE, FALSE, TRUE,
- FALSE);
- }
-
- dzl_gtk_widget_hide_with_fade (GTK_WIDGET (self->progress_bar));
-}
-
-static void
-ide_editor_view_actions_reload_buffer (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeContext *context;
- IdeBufferManager *buffer_manager;
- IdeFile *file;
- g_autoptr(IdeProgress) progress = NULL;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- context = ide_buffer_get_context (IDE_BUFFER (self->document));
- file = ide_buffer_get_file (IDE_BUFFER (self->document));
-
- buffer_manager = ide_context_get_buffer_manager (context);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->progress_bar), 0.0);
- gtk_widget_show (GTK_WIDGET (self->progress_bar));
-
- ide_buffer_manager_load_file_async (buffer_manager,
- file,
- TRUE,
- IDE_WORKBENCH_OPEN_FLAGS_NONE,
- &progress,
- NULL,
- ide_editor_view_actions_reload_buffer_cb,
- g_object_ref (self));
-
- g_object_bind_property (progress, "fraction", self->progress_bar, "fraction",
- G_BINDING_SYNC_CREATE);
-}
-
-static void
-handle_print_result (IdeEditorView *self,
- GtkPrintOperation *operation,
- GtkPrintOperationResult result)
-{
- if (result == GTK_PRINT_OPERATION_RESULT_ERROR)
- {
- GError *error = NULL;
-
- gtk_print_operation_get_error (operation, &error);
-
- /* info bar */
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-}
-
-static void
-print_done (GtkPrintOperation *operation,
- GtkPrintOperationResult result,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
-
- handle_print_result (self, operation, result);
-
- g_object_unref (operation);
- g_object_unref (self);
-}
-
-static void
-ide_editor_view_actions_print (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- GtkWidget *toplevel;
- g_autoptr(IdeEditorPrintOperation) operation;
- GtkPrintOperationResult result;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
-
- operation = ide_editor_print_operation_new (self->frame1->source_view);
-
- /* keep a ref until "done" is emitted */
- g_object_ref (operation);
-
- g_signal_connect_after (operation, "done", G_CALLBACK (print_done), g_object_ref (self));
-
- result = gtk_print_operation_run (GTK_PRINT_OPERATION (operation),
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
- GTK_WINDOW (toplevel),
- NULL);
-
- handle_print_result (self, GTK_PRINT_OPERATION (operation), result);
-}
-
-static void
-activate_spellcheck_cb (GtkWidget *widget,
- IdeEditorView *self)
-{
- IdeEditorView *editor_view = (IdeEditorView *)widget;
- IdeSourceView *original_view;
- IdeSourceView *dst_view;
- GtkTextBuffer *original_buffer;
- GtkTextBuffer *dst_buffer;
- GActionGroup *group;
- GAction *action;
- GVariant *state;
- gboolean spellcheck_state;
-
- if (editor_view == self)
- return;
-
- original_view = self->frame1->source_view;
- original_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (original_view));
- dst_view = editor_view->frame1->source_view;
- dst_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dst_view));
-
- if (original_buffer == dst_buffer)
- {
- spellcheck_state = ide_source_view_get_spell_checking (original_view);
- state = g_variant_new_boolean (spellcheck_state);
-
- if (NULL != (group = gtk_widget_get_action_group (GTK_WIDGET (editor_view), "view")) &&
- NULL != (action = g_action_map_lookup_action (G_ACTION_MAP (group), "spellchecking")))
- {
- g_simple_action_set_state (G_SIMPLE_ACTION (action), state);
- ide_source_view_set_spell_checking (dst_view, spellcheck_state);
-
- if (editor_view->frame2)
- {
- dst_view = ide_editor_frame_get_source_view (editor_view->frame2);
- ide_source_view_set_spell_checking (dst_view, spellcheck_state);
- }
- }
- }
-}
-
-static void
-ide_editor_view_actions_spellchecking (GSimpleAction *action,
- GVariant *state,
- gpointer user_data)
-{
- IdeEditorView *self = user_data;
- IdeWorkbench *workbench;
- IdePerspective *editor;
- IdeSourceView *source_view;
- gboolean action_state;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (state != NULL);
- g_assert (g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN));
-
- g_simple_action_set_state (action, state);
- action_state = g_variant_get_boolean (state);
-
- source_view = ide_editor_frame_get_source_view (self->frame1);
- ide_source_view_set_spell_checking (source_view, action_state);
-
- if (self->frame2)
- {
- source_view = ide_editor_frame_get_source_view (self->frame2);
- ide_source_view_set_spell_checking (source_view, action_state);
- }
-
- workbench = ide_widget_get_workbench (GTK_WIDGET (self));
- editor = ide_workbench_get_perspective_by_name (workbench, "editor");
- ide_perspective_views_foreach (IDE_PERSPECTIVE (editor), (GtkCallback)activate_spellcheck_cb, self);
-}
-
-static GActionEntry IdeEditorViewActions[] = {
- { "auto-indent", NULL, NULL, "false", ide_editor_view_actions_auto_indent },
- { "close", ide_editor_view_actions_close },
- { "find-other-file", ide_editor_view_actions_find_other_file },
- { "highlight-current-line", NULL, NULL, "false", ide_editor_view_actions_highlight_current_line },
- { "language", NULL, "s", "''", ide_editor_view_actions_language },
- { "reload-buffer", ide_editor_view_actions_reload_buffer },
- { "save", ide_editor_view_actions_save },
- { "save-as", ide_editor_view_actions_save_as },
- { "print", ide_editor_view_actions_print },
- { "show-line-numbers", NULL, NULL, "false", ide_editor_view_actions_show_line_numbers },
- { "show-right-margin", NULL, NULL, "false", ide_editor_view_actions_show_right_margin },
- { "smart-backspace", NULL, NULL, "false", ide_editor_view_actions_smart_backspace },
- { "spellchecking", NULL, NULL, "false", ide_editor_view_actions_spellchecking },
- { "tab-width", NULL, "i", "8", ide_editor_view_actions_tab_width },
- { "toggle-split", ide_editor_view_actions_toggle_split },
- { "use-spaces", NULL, "b", "false", ide_editor_view_actions_use_spaces },
-};
+#include "ide-editor-private.h"
void
-ide_editor_view_actions_init (IdeEditorView *self)
+_ide_editor_view_init_actions (IdeEditorView *self)
{
- g_autoptr(GSimpleActionGroup) group = NULL;
-
- group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorViewActions,
- G_N_ELEMENTS (IdeEditorViewActions), self);
-
- gtk_widget_insert_action_group (GTK_WIDGET (self), "view", G_ACTION_GROUP (group));
-
-#define WATCH_PROPERTY(name) \
- G_STMT_START { \
- g_signal_connect (self->frame1->source_view, \
- "notify::"name, \
- G_CALLBACK (ide_editor_view_actions_source_view_notify), \
- group); \
- g_object_notify (G_OBJECT (self->frame1->source_view), name); \
- } G_STMT_END
-
- WATCH_PROPERTY ("auto-indent");
- WATCH_PROPERTY ("highlight-current-line");
- WATCH_PROPERTY ("insert-spaces-instead-of-tabs");
- WATCH_PROPERTY ("show-line-numbers");
- WATCH_PROPERTY ("show-right-margin");
- WATCH_PROPERTY ("smart-backspace");
- WATCH_PROPERTY ("tab-width");
-
-#undef WATCH_PROPERTY
-}
-
-void
-ide_editor_view_actions_update (IdeEditorView *self)
-{
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- /* Currently a no-op */
+ g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
}
diff --git a/libide/editor/ide-editor-view-addin.c b/libide/editor/ide-editor-view-addin.c
index 024f60d..9ac4bae 100644
--- a/libide/editor/ide-editor-view-addin.c
+++ b/libide/editor/ide-editor-view-addin.c
@@ -56,25 +56,3 @@ ide_editor_view_addin_language_changed (IdeEditorViewAddin *self,
if (IDE_EDITOR_VIEW_ADDIN_GET_IFACE (self)->language_changed)
IDE_EDITOR_VIEW_ADDIN_GET_IFACE (self)->language_changed (self, language_id);
}
-
-void
-ide_editor_view_addin_load_source_view (IdeEditorViewAddin *self,
- IdeSourceView *source_view)
-{
- g_return_if_fail (IDE_IS_EDITOR_VIEW_ADDIN (self));
- g_return_if_fail (IDE_IS_SOURCE_VIEW (source_view));
-
- if (IDE_EDITOR_VIEW_ADDIN_GET_IFACE (self)->load_source_view)
- IDE_EDITOR_VIEW_ADDIN_GET_IFACE (self)->load_source_view (self, source_view);
-}
-
-void
-ide_editor_view_addin_unload_source_view (IdeEditorViewAddin *self,
- IdeSourceView *source_view)
-{
- g_return_if_fail (IDE_IS_EDITOR_VIEW_ADDIN (self));
- g_return_if_fail (IDE_IS_SOURCE_VIEW (source_view));
-
- if (IDE_EDITOR_VIEW_ADDIN_GET_IFACE (self)->unload_source_view)
- IDE_EDITOR_VIEW_ADDIN_GET_IFACE (self)->unload_source_view (self, source_view);
-}
diff --git a/libide/editor/ide-editor-view-addin.h b/libide/editor/ide-editor-view-addin.h
index 5593dfa..0498381 100644
--- a/libide/editor/ide-editor-view-addin.h
+++ b/libide/editor/ide-editor-view-addin.h
@@ -1,6 +1,6 @@
/* ide-editor-view-addin.h
*
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * Copyright (C) 2015-2017 Christian Hergert <christian hergert me>
*
* 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
@@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IDE_EDITOR_VIEW_ADDIN_H
-#define IDE_EDITOR_VIEW_ADDIN_H
+#pragma once
#include "ide-editor-view.h"
@@ -37,12 +36,13 @@ struct _IdeEditorViewAddinInterface
IdeEditorView *view);
void (*language_changed) (IdeEditorViewAddin *self,
const gchar *language_id);
- void (*load_source_view) (IdeEditorViewAddin *self,
- IdeSourceView *source_view);
- void (*unload_source_view) (IdeEditorViewAddin *self,
- IdeSourceView *source_view);
};
-G_END_DECLS
+void ide_editor_view_addin_load (IdeEditorViewAddin *self,
+ IdeEditorView *view);
+void ide_editor_view_addin_unload (IdeEditorViewAddin *self,
+ IdeEditorView *view);
+void ide_editor_view_addin_language_changed (IdeEditorViewAddin *self,
+ const gchar *language_id);
-#endif /* IDE_EDITOR_VIEW_ADDIN_H */
+G_END_DECLS
diff --git a/libide/editor/ide-editor-view-settings.c b/libide/editor/ide-editor-view-settings.c
new file mode 100644
index 0000000..9eb39f3
--- /dev/null
+++ b/libide/editor/ide-editor-view-settings.c
@@ -0,0 +1,117 @@
+/* ide-editor-view-settings.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-view-settings"
+
+#include "ide-editor-private.h"
+
+static GSettings *editor_settings;
+
+static gboolean
+get_smart_home_end (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ if (g_variant_get_boolean (variant))
+ g_value_set_enum (value, GTK_SOURCE_SMART_HOME_END_BEFORE);
+ else
+ g_value_set_enum (value, GTK_SOURCE_SMART_HOME_END_DISABLED);
+ return TRUE;
+}
+
+static gboolean
+get_wrap_mode (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ if (g_variant_get_boolean (variant))
+ g_value_set_enum (value, GTK_WRAP_WORD);
+ else
+ g_value_set_enum (value, GTK_WRAP_NONE);
+ return TRUE;
+}
+
+void
+_ide_editor_view_init_settings (IdeEditorView *self)
+{
+ IdeSourceView *source_view;
+ IdeBuffer *buffer;
+
+ g_assert (IDE_IS_EDITOR_VIEW (self));
+ g_assert (!editor_settings || G_IS_SETTINGS (editor_settings));
+
+ if (editor_settings == NULL)
+ editor_settings = g_settings_new ("org.gnome.builder.editor");
+
+ source_view = ide_editor_view_get_source_view (self);
+ buffer = ide_editor_view_get_buffer (self);
+
+ g_settings_bind (editor_settings, "highlight-current-line",
+ source_view, "highlight-current-line",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "highlight-matching-brackets",
+ buffer, "highlight-matching-brackets",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "show-line-changes",
+ source_view, "show-line-changes",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "show-line-numbers",
+ source_view, "show-line-numbers",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "smart-backspace",
+ source_view, "smart-backspace",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind_with_mapping (editor_settings, "smart-home-end",
+ source_view, "smart-home-end",
+ G_SETTINGS_BIND_GET,
+ get_smart_home_end, NULL, NULL, NULL);
+
+ g_settings_bind (editor_settings, "font-name",
+ source_view, "font-name",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "overscroll",
+ source_view, "overscroll",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "scroll-offset",
+ source_view, "scroll-offset",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "show-grid-lines",
+ source_view, "show-grid-lines",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind_with_mapping (editor_settings, "wrap-text",
+ source_view, "wrap-mode",
+ G_SETTINGS_BIND_GET,
+ get_wrap_mode, NULL, NULL, NULL);
+
+ g_settings_bind (editor_settings, "show-map",
+ self, "show-map",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (editor_settings, "auto-hide-map",
+ self, "auto-hide-map",
+ G_SETTINGS_BIND_GET);
+}
diff --git a/libide/editor/ide-editor-tweak-widget.h b/libide/editor/ide-editor-view-shortcuts.c
similarity index 52%
rename from libide/editor/ide-editor-tweak-widget.h
rename to libide/editor/ide-editor-view-shortcuts.c
index b90c3e1..49f9598 100644
--- a/libide/editor/ide-editor-tweak-widget.h
+++ b/libide/editor/ide-editor-view-shortcuts.c
@@ -1,6 +1,6 @@
-/* ide-editor-tweak-widget.h
+/* ide-editor-view-shortcuts.c
*
- * Copyright (C) 2014 Christian Hergert <christian hergert me>
+ * 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
@@ -16,17 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IDE_EDITOR_TWEAK_WIDGET_H
-#define IDE_EDITOR_TWEAK_WIDGET_H
+#include "config.h"
-#include <gtk/gtk.h>
+#include <dazzle.h>
-G_BEGIN_DECLS
+#include "ide-editor-private.h"
-#define IDE_TYPE_EDITOR_TWEAK_WIDGET (ide_editor_tweak_widget_get_type())
+static DzlShortcutEntry editor_view_shortcuts[] = {
+};
-G_DECLARE_FINAL_TYPE (IdeEditorTweakWidget, ide_editor_tweak_widget, IDE, EDITOR_TWEAK_WIDGET, GtkBin)
+void
+_ide_editor_view_init_shortcuts (IdeEditorView *self)
+{
+ g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
-G_END_DECLS
-
-#endif /* IDE_EDITOR_TWEAK_WIDGET_H */
+ dzl_shortcut_manager_add_shortcut_entries (NULL,
+ editor_view_shortcuts,
+ G_N_ELEMENTS (editor_view_shortcuts),
+ GETTEXT_PACKAGE);
+}
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index c173358..831d7bf 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -1,6 +1,6 @@
/* ide-editor-view.c
*
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * 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
@@ -19,723 +19,200 @@
#define G_LOG_DOMAIN "ide-editor-view"
#include <dazzle.h>
-#include <glib/gi18n.h>
-#include <glib/gprintf.h>
-
-#include "ide-debug.h"
-#include "ide-macros.h"
-
-#include "buffers/ide-buffer-manager.h"
-#include "diagnostics/ide-source-location.h"
-#include "editor/ide-editor-frame-private.h"
-#include "editor/ide-editor-view-actions.h"
-#include "editor/ide-editor-view-addin.h"
-#include "editor/ide-editor-view.h"
-#include "editor/ide-editor-view-addin-private.h"
-#include "editor/ide-editor-view-private.h"
-#include "workbench/ide-workbench.h"
+#include <libpeas/peas.h>
-G_DEFINE_TYPE (IdeEditorView, ide_editor_view, IDE_TYPE_LAYOUT_VIEW)
-
-enum {
- PROP_0,
- PROP_DOCUMENT,
- LAST_PROP
-};
-
-enum {
- REQUEST_DOCUMENTATION,
- LAST_SIGNAL
-};
-
-static GParamSpec *properties [LAST_PROP];
-static guint signals [LAST_SIGNAL];
+#include "ide-editor-private.h"
+#include "ide-editor-view.h"
+#include "ide-editor-view-addin.h"
-static IdeEditorFrame *
-ide_editor_view_get_last_focused (IdeEditorView *self)
+struct _IdeEditorView
{
- g_assert (self->last_focused_frame != NULL);
-
- return self->last_focused_frame;
-}
-
-static void
-ide_editor_view_navigate_to (IdeLayoutView *view,
- IdeSourceLocation *location)
-{
- IdeEditorView *self = (IdeEditorView *)view;
- IdeEditorFrame *frame;
- GtkTextMark *insert;
- GtkTextBuffer *buffer;
- GtkTextIter iter;
- guint line;
- guint line_offset;
-
- IDE_ENTRY;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (location != NULL);
-
- frame = ide_editor_view_get_last_focused (self);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->source_view));
-
- line = ide_source_location_get_line (location);
- line_offset = ide_source_location_get_line_offset (location);
-
- gtk_text_buffer_get_iter_at_line (buffer, &iter, line);
- for (; line_offset; line_offset--)
- if (gtk_text_iter_ends_line (&iter) || !gtk_text_iter_forward_char (&iter))
- break;
+ IdeLayoutView parent_instance;
- gtk_text_buffer_select_range (buffer, &iter, &iter);
+ PeasExtensionSet *addins;
- insert = gtk_text_buffer_get_insert (buffer);
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (frame->source_view), insert, 0.0, TRUE, 1.0, 0.5);
+ IdeBuffer *buffer;
+ DzlBindingGroup *buffer_bindings;
+ DzlSignalGroup *buffer_signals;
- g_signal_emit_by_name (frame->source_view, "save-insert-mark");
-
- IDE_EXIT;
-}
-
-static gboolean
-ide_editor_view_get_modified (IdeLayoutView *view)
-{
- IdeEditorView *self = (IdeEditorView *)view;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
+ GtkOverlay *overlay;
+ IdeSourceView *source_view;
+ GtkScrolledWindow *scroller;
+};
- return gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (self->document));
-}
+enum {
+ PROP_0,
+ PROP_BUFFER,
+ N_PROPS
+};
-static void
-ide_editor_view__buffer_modified_changed (IdeEditorView *self,
- GParamSpec *pspec,
- GtkTextBuffer *buffer)
-{
- g_assert (IDE_IS_EDITOR_VIEW (self));
+G_DEFINE_TYPE (IdeEditorView, ide_editor_view, IDE_TYPE_LAYOUT_VIEW)
- g_object_notify (G_OBJECT (self), "modified");
-}
+static GParamSpec *properties [N_PROPS];
static void
-force_scroll_to_top (IdeSourceView *source_view)
+ide_editor_view_buffer_modified_changed (IdeEditorView *self,
+ GtkSourceBuffer *buffer)
{
- GtkAdjustment *vadj;
- GtkAdjustment *hadj;
- gdouble lower;
-
- /*
- * FIXME:
- *
- * See the comment in ide_editor_view__buffer_changed_on_volume()
- */
-
- vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (source_view));
- hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (source_view));
-
- lower = gtk_adjustment_get_lower (vadj);
- gtk_adjustment_set_value (vadj, lower);
-
- lower = gtk_adjustment_get_lower (hadj);
- gtk_adjustment_set_value (hadj, lower);
-}
-
-static gboolean
-no_really_scroll_to_the_top (gpointer data)
-{
- g_autoptr(IdeEditorView) self = data;
-
- force_scroll_to_top (self->frame1->source_view);
- if (self->frame2 != NULL)
- force_scroll_to_top (self->frame2->source_view);
-
- return G_SOURCE_REMOVE;
-}
+ gboolean modified;
-static void
-ide_editor_view__buffer_changed_on_volume (IdeEditorView *self,
- GParamSpec *pspec,
- IdeBuffer *buffer)
-{
g_assert (IDE_IS_EDITOR_VIEW (self));
g_assert (IDE_IS_BUFFER (buffer));
- if (ide_buffer_get_changed_on_volume (buffer))
- gtk_revealer_set_reveal_child (self->modified_revealer, TRUE);
- else if (gtk_revealer_get_reveal_child (self->modified_revealer))
- {
- GtkTextIter iter;
-
- gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &iter);
- gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &iter, &iter);
-
- /*
- * FIXME:
- *
- * Without this delay, I see a condition with split view where the
- * non-focused split will just render blank. Well that isn't totally
- * correct, it renders empty gutters and proper line grid background. But
- * no textual content. And the adjustment is way out of sync. Even
- * changing the adjustment manually doesn't help. So whatever, I'll
- * insert a short delay and we'll pick up after the textview has
- * stablized.
- */
- g_timeout_add (10, no_really_scroll_to_the_top, g_object_ref (self));
-
- gtk_revealer_set_reveal_child (self->modified_revealer, FALSE);
- }
-}
+ modified = gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (buffer));
-static gchar *
-ide_editor_view_get_special_title (IdeLayoutView *view)
-{
- g_assert (IDE_IS_EDITOR_VIEW (view));
-
- return g_strdup (IDE_EDITOR_VIEW (view)->title);
+ ide_layout_view_set_modified (IDE_LAYOUT_VIEW (self), modified);
}
static void
-ide_editor_view__buffer_notify_title (IdeEditorView *self,
- GParamSpec *pspec,
- IdeBuffer *buffer)
-{
- const gchar *title;
- gchar **parts;
- gboolean needs_prefix;
- gchar *str;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (IDE_IS_BUFFER (buffer));
-
- g_free (self->title);
-
- title = ide_buffer_get_title (buffer);
-
- if (title == NULL)
- {
- /* translators: this shouldn't ever happen */
- self->title = g_strdup ("untitled");
- return;
- }
-
- if ((needs_prefix = (title [0] == G_DIR_SEPARATOR)))
- title++;
-
- parts = g_strsplit (title, G_DIR_SEPARATOR_S, 0);
- str = g_strjoinv (" "G_DIR_SEPARATOR_S" ", parts);
-
- if (needs_prefix)
- {
- self->title = g_strdup_printf (G_DIR_SEPARATOR_S" %s", str);
- g_free (str);
- }
- else
- {
- self->title = str;
- }
-
- g_strfreev (parts);
-
- g_object_notify (G_OBJECT (self), "title");
-}
-
-static void
-notify_language_foreach (PeasExtensionSet *set,
- PeasPluginInfo *plugin_info,
- PeasExtension *exten,
- gpointer user_data)
+ide_editor_view_buffer_notify_language_cb (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ PeasExtension *exten,
+ gpointer user_data)
{
const gchar *language_id = user_data;
- ide_editor_view_addin_language_changed (IDE_EDITOR_VIEW_ADDIN (exten), language_id);
-}
-
-static void
-ide_editor_view__buffer_notify_language (IdeEditorView *self,
- GParamSpec *pspec,
- IdeBuffer *document)
-{
- g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (IDE_IS_BUFFER (document));
-
- if (self->extensions != NULL)
- {
- GtkSourceLanguage *language;
- const gchar *language_id;
-
- language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (document));
- language_id = language ? gtk_source_language_get_id (language) : NULL;
+ g_assert (PEAS_IS_EXTENSION_SET (set));
+ g_assert (plugin_info != NULL);
+ g_assert (IDE_IS_EDITOR_VIEW_ADDIN (exten));
- peas_extension_set_foreach (self->extensions,
- notify_language_foreach,
- (gchar *)language_id);
- }
+ ide_editor_view_addin_language_changed (IDE_EDITOR_VIEW_ADDIN (exten), language_id);
}
static void
-ide_editor_view_set_document (IdeEditorView *self,
- IdeBuffer *document)
+ide_editor_view_buffer_notify_language (IdeEditorView *self,
+ GParamSpec *pspec,
+ GtkSourceBuffer *buffer)
{
- g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
- g_return_if_fail (IDE_IS_BUFFER (document));
-
- if (g_set_object (&self->document, document))
- {
- if (self->frame1)
- ide_editor_frame_set_document (self->frame1, document);
-
- if (self->frame2)
- ide_editor_frame_set_document (self->frame2, document);
-
- g_settings_bind (self->settings, "style-scheme-name",
- document, "style-scheme-name",
- G_SETTINGS_BIND_GET);
- g_settings_bind (self->settings, "highlight-matching-brackets",
- document, "highlight-matching-brackets",
- G_SETTINGS_BIND_GET);
-
- g_signal_connect_object (document,
- "modified-changed",
- G_CALLBACK (ide_editor_view__buffer_modified_changed),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (document,
- "notify::title",
- G_CALLBACK (ide_editor_view__buffer_notify_title),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (document,
- "notify::language",
- G_CALLBACK (ide_editor_view__buffer_notify_language),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (document,
- "notify::changed-on-volume",
- G_CALLBACK (ide_editor_view__buffer_changed_on_volume),
- self,
- G_CONNECT_SWAPPED);
-
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DOCUMENT]);
-
- ide_editor_view__buffer_notify_language (self, NULL, document);
- ide_editor_view__buffer_notify_title (self, NULL, IDE_BUFFER (document));
-
- ide_editor_view_actions_update (self);
- }
-}
-
-static IdeLayoutView *
-ide_editor_view_create_split (IdeLayoutView *view,
- GFile *file)
-{
- IdeEditorView *self = (IdeEditorView *)view;
- IdeLayoutView *ret;
- IdeBuffer *buffer;
- IdeContext *context;
- IdeBufferManager *buf_mgr;
- IdeSourceView *source_view;
- IdeSourceView *split_source_view;
- GActionGroup *group;
- GAction *action;
- GVariant *state = NULL;
- gboolean spellcheck_state;
+ GtkSourceLanguage *language;
+ const gchar *language_id = NULL;
g_assert (IDE_IS_EDITOR_VIEW (self));
+ g_assert (IDE_IS_BUFFER (buffer));
- if (file == NULL)
- {
- buffer = self->document;
- }
- else
- {
- context = ide_buffer_get_context (self->document);
- buf_mgr = ide_context_get_buffer_manager (context);
- buffer = ide_buffer_manager_find_buffer (buf_mgr, file);
- if (buffer == NULL)
- {
- g_warning ("Failed to find buffer for file '%s'", g_file_get_path (file));
- buffer = self->document;
- }
- }
-
- ret = g_object_new (IDE_TYPE_EDITOR_VIEW,
- "document", buffer,
- "visible", TRUE,
- NULL);
-
- source_view = self->frame1->source_view;
- spellcheck_state = ide_source_view_get_spell_checking (source_view);
+ if (self->addins == NULL)
+ return;
- split_source_view = ((IdeEditorView *)ret)->frame1->source_view;
- ide_source_view_set_spell_checking (split_source_view, spellcheck_state);
+ if (NULL != (language = gtk_source_buffer_get_language (buffer)))
+ language_id = gtk_source_language_get_id (language);
- if (NULL != (group = gtk_widget_get_action_group (GTK_WIDGET (ret), "view")) &&
- NULL != (action = g_action_map_lookup_action (G_ACTION_MAP (group), "spellchecking")))
- {
- state = g_variant_new_boolean (spellcheck_state);
- g_simple_action_set_state (G_SIMPLE_ACTION (action), state);
- }
-
- return ret;
+ peas_extension_set_foreach (self->addins,
+ ide_editor_view_buffer_notify_language_cb,
+ (gpointer)language_id);
}
static void
-ide_editor_view_grab_focus (GtkWidget *widget)
+ide_editor_view_bind_signals (IdeEditorView *self,
+ GtkSourceBuffer *buffer,
+ DzlSignalGroup *buffer_signals)
{
- IdeEditorView *self = (IdeEditorView *)widget;
-
g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (IDE_IS_EDITOR_FRAME (self->last_focused_frame));
+ g_assert (IDE_IS_BUFFER (buffer));
+ g_assert (DZL_IS_SIGNAL_GROUP (buffer_signals));
- gtk_widget_grab_focus (GTK_WIDGET (self->last_focused_frame->source_view));
+ ide_editor_view_buffer_modified_changed (self, buffer);
+ ide_editor_view_buffer_notify_language (self, NULL, buffer);
}
static void
-ide_editor_view_request_documentation (IdeEditorView *self,
- IdeSourceView *source_view)
+ide_editor_view_set_buffer (IdeEditorView *self,
+ IdeBuffer *buffer)
{
- g_autofree gchar *word = NULL;
- IdeBuffer *buffer;
- GtkTextMark *mark;
- GtkTextIter iter;
-
g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
-
- buffer = IDE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (source_view)));
- mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer));
- gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &iter, mark);
+ g_assert (!buffer || IDE_IS_BUFFER (buffer));
- word = ide_buffer_get_word_at_iter (buffer, &iter);
-
- g_signal_emit (self, signals [REQUEST_DOCUMENTATION], 0, word);
+ if (g_set_object (&self->buffer, buffer))
+ dzl_signal_group_set_target (self->buffer_signals, buffer);
}
-static void
-ide_editor_view__focused_frame_weak_notify (gpointer data,
- GObject *object)
+static IdeLayoutView *
+ide_editor_view_create_split_view (IdeLayoutView *view)
{
- IdeEditorView *self = data;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- self->last_focused_frame = self->frame1;
-}
+ IdeEditorView *self = (IdeEditorView *)view;
-static gboolean
-ide_editor_view__focus_in_event (IdeEditorView *self,
- GdkEvent *event,
- IdeSourceView *source_view)
-{
g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
-
- if (self->last_focused_frame && self->last_focused_frame->source_view == source_view)
- return FALSE;
- if (self->frame2 && self->frame2->source_view == source_view)
- {
- self->last_focused_frame = self->frame2;
- g_object_weak_ref (G_OBJECT (self->frame2), ide_editor_view__focused_frame_weak_notify, self);
- }
- else
- {
- g_object_weak_unref (G_OBJECT (self->frame2), ide_editor_view__focused_frame_weak_notify, self);
- self->last_focused_frame = self->frame1;
- }
-
- return FALSE;
+ return g_object_new (IDE_TYPE_EDITOR_VIEW,
+ "buffer", self->buffer,
+ "visible", TRUE,
+ NULL);
}
static void
-addin_load_source_view (PeasExtensionSet *set,
- PeasPluginInfo *plugin_info,
- PeasExtension *exten,
- gpointer user_data)
+ide_editor_view_addin_added (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ PeasExtension *exten,
+ gpointer user_data)
{
- IdeSourceView *source_view = user_data;
+ IdeEditorView *self = user_data;
g_assert (PEAS_IS_EXTENSION_SET (set));
g_assert (plugin_info != NULL);
g_assert (IDE_IS_EDITOR_VIEW_ADDIN (exten));
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
+ g_assert (IDE_IS_EDITOR_VIEW (self));
- ide_editor_view_addin_load_source_view (IDE_EDITOR_VIEW_ADDIN (exten), source_view);
+ ide_editor_view_addin_load (IDE_EDITOR_VIEW_ADDIN (exten), self);
}
static void
-addin_unload_source_view (PeasExtensionSet *set,
- PeasPluginInfo *plugin_info,
- PeasExtension *exten,
- gpointer user_data)
+ide_editor_view_addin_removed (PeasExtensionSet *set,
+ PeasPluginInfo *plugin_info,
+ PeasExtension *exten,
+ gpointer user_data)
{
- IdeSourceView *source_view = user_data;
+ IdeEditorView *self = user_data;
g_assert (PEAS_IS_EXTENSION_SET (set));
g_assert (plugin_info != NULL);
g_assert (IDE_IS_EDITOR_VIEW_ADDIN (exten));
- g_assert (IDE_IS_SOURCE_VIEW (source_view));
-
- ide_editor_view_addin_unload_source_view (IDE_EDITOR_VIEW_ADDIN (exten), source_view);
-}
-
-static gboolean
-ide_editor_view_get_split_view (IdeLayoutView *view)
-{
- IdeEditorView *self = (IdeEditorView *)view;
-
g_assert (IDE_IS_EDITOR_VIEW (self));
- return (self->frame2 != NULL);
-}
-
-static void
-ide_editor_view_set_split_view (IdeLayoutView *view,
- gboolean split_view)
-{
- IdeEditorView *self = (IdeEditorView *)view;
- gboolean spellcheck_state;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- if (split_view && (self->frame2 != NULL))
- return;
-
- if (!split_view && (self->frame2 == NULL))
- return;
-
- if (split_view)
- {
- self->frame2 = g_object_new (IDE_TYPE_EDITOR_FRAME,
- "show-ruler", TRUE,
- "document", self->document,
- "visible", TRUE,
- NULL);
-
- spellcheck_state = ide_source_view_get_spell_checking (self->frame1->source_view);
- ide_source_view_set_spell_checking (self->frame2->source_view, spellcheck_state);
-
- g_signal_connect_object (self->frame2->source_view,
- "request-documentation",
- G_CALLBACK (ide_editor_view_request_documentation),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (self->frame2->source_view,
- "focus-in-event",
- G_CALLBACK (ide_editor_view__focus_in_event),
- self,
- G_CONNECT_SWAPPED);
-
- gtk_container_add_with_properties (GTK_CONTAINER (self->paned), GTK_WIDGET (self->frame2),
- "shrink", FALSE,
- "resize", TRUE,
- NULL);
-
- peas_extension_set_foreach (self->extensions,
- addin_load_source_view,
- self->frame2->source_view);
-
- gtk_widget_grab_focus (GTK_WIDGET (self->frame2));
- }
- else
- {
- GtkWidget *copy = GTK_WIDGET (self->frame2);
-
- peas_extension_set_foreach (self->extensions,
- addin_unload_source_view,
- self->frame2->source_view);
-
- self->frame2 = NULL;
- gtk_container_remove (GTK_CONTAINER (self->paned), copy);
- gtk_widget_grab_focus (GTK_WIDGET (self->frame1));
- }
+ ide_editor_view_addin_unload (IDE_EDITOR_VIEW_ADDIN (exten), self);
}
static void
-ide_editor_view_set_back_forward_list (IdeLayoutView *view,
- IdeBackForwardList *back_forward_list)
-{
- IdeEditorView *self = (IdeEditorView *)view;
-
- g_assert (IDE_IS_LAYOUT_VIEW (view));
- g_assert (IDE_IS_BACK_FORWARD_LIST (back_forward_list));
-
- g_object_set (self->frame1, "back-forward-list", back_forward_list, NULL);
- if (self->frame2)
- g_object_set (self->frame2, "back-forward-list", back_forward_list, NULL);
-}
-
-static void
-ide_editor_view_hide_reload_bar (IdeEditorView *self,
- GtkWidget *button)
-{
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- gtk_revealer_set_reveal_child (self->modified_revealer, FALSE);
-}
-
-static GtkSizeRequestMode
-ide_editor_view_get_request_mode (GtkWidget *widget)
-{
- return GTK_SIZE_REQUEST_CONSTANT_SIZE;
-}
-
-static void
-ide_editor_view_get_preferred_height (GtkWidget *widget,
- gint *min_height,
- gint *nat_height)
-{
- /*
- * FIXME: Workaround GtkStack changes.
- *
- * This can probably be removed once upstream changes land.
- *
- * This ignores our potential giant size requests since we don't actually
- * care about keeping our size requests between animated transitions in
- * the stack.
- */
- GTK_WIDGET_CLASS (ide_editor_view_parent_class)->get_preferred_height (widget, min_height, nat_height);
- *nat_height = *min_height;
-}
-
-static void
-ide_editor_view__extension_added (PeasExtensionSet *set,
- PeasPluginInfo *info,
- PeasExtension *exten,
- gpointer user_data)
+ide_editor_view_hierarchy_changed (GtkWidget *widget,
+ GtkWidget *old_toplevel)
{
- IdeEditorView *self = user_data;
- IdeEditorViewAddin *addin = (IdeEditorViewAddin *)exten;
+ IdeEditorView *self = (IdeEditorView *)widget;
- g_assert (PEAS_IS_EXTENSION_SET (set));
- g_assert (info != NULL);
- g_assert (IDE_IS_EDITOR_VIEW_ADDIN (addin));
g_assert (IDE_IS_EDITOR_VIEW (self));
+ g_assert (!old_toplevel || GTK_IS_WIDGET (old_toplevel));
- /* Initialize the addin */
- ide_editor_view_addin_load (addin, self);
-
- /* Allow the addin to track the source views */
- ide_editor_view_addin_load_source_view (addin, self->frame1->source_view);
- if (self->frame2)
- ide_editor_view_addin_load_source_view (addin, self->frame2->source_view);
+ GTK_WIDGET_CLASS (ide_editor_view_parent_class)->hierarchy_changed (widget, old_toplevel);
- /* Notify the addin of the current language */
- if (self->document != NULL)
+ if (self->addins == NULL)
{
- GtkSourceLanguage *language;
+ self->addins = peas_extension_set_new (NULL, IDE_TYPE_EDITOR_VIEW_ADDIN, NULL);
- language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (self->document));
+ g_signal_connect (self->addins,
+ "extension-added",
+ G_CALLBACK (ide_editor_view_addin_added),
+ self);
- if (language != NULL)
- {
- const gchar *language_id;
+ g_signal_connect (self->addins,
+ "extension-removed",
+ G_CALLBACK (ide_editor_view_addin_removed),
+ self);
- language_id = gtk_source_language_get_id (language);
- ide_editor_view_addin_language_changed (addin, language_id);
- }
+ peas_extension_set_foreach (self->addins,
+ ide_editor_view_addin_added,
+ self);
}
}
static void
-ide_editor_view__extension_removed (PeasExtensionSet *set,
- PeasPluginInfo *info,
- PeasExtension *exten,
- gpointer user_data)
-{
- IdeEditorViewAddin *addin = (IdeEditorViewAddin *)exten;
- IdeEditorView *self = user_data;
-
- g_assert (PEAS_IS_EXTENSION_SET (set));
- g_assert (info != NULL);
- g_assert (IDE_IS_EDITOR_VIEW_ADDIN (addin));
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- if (self->frame2 && self->frame2->source_view)
- ide_editor_view_addin_unload_source_view (addin, self->frame2->source_view);
-
- if (self->frame1 && self->frame1->source_view)
- ide_editor_view_addin_unload_source_view (addin, self->frame1->source_view);
-
- ide_editor_view_addin_unload (addin, self);
-}
-
-static void
-ide_editor_view_load_addins (IdeEditorView *self)
-{
- PeasEngine *engine;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (self->extensions == NULL);
-
- engine = peas_engine_get_default ();
-
- self->extensions = peas_extension_set_new (engine,
- IDE_TYPE_EDITOR_VIEW_ADDIN,
- NULL);
-
- g_signal_connect_object (self->extensions,
- "extension-added",
- G_CALLBACK (ide_editor_view__extension_added),
- self,
- 0);
-
- g_signal_connect_object (self->extensions,
- "extension-removed",
- G_CALLBACK (ide_editor_view__extension_removed),
- self,
- 0);
-
- peas_extension_set_foreach (self->extensions, ide_editor_view__extension_added, self);
-}
-
-static void
-ide_editor_view_unload_addins (IdeEditorView *self)
-{
- g_assert (IDE_IS_EDITOR_VIEW (self));
- g_assert (!self->extensions || PEAS_IS_EXTENSION_SET (self->extensions));
-
- g_clear_object (&self->extensions);
-}
-
-static void
-ide_editor_view_hierarchy_changed (GtkWidget *widget,
- GtkWidget *previous_toplevel)
-{
- IdeEditorView *self = (IdeEditorView *)widget;
- GtkWidget *toplevel;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- /*
- * NOTE: If we ever support tearing out the editor, we should probably use
- * ide_widget_get_workbench() to discover a "synthetic" toplevel.
- */
-
- toplevel = gtk_widget_get_toplevel (widget);
-
- if (IDE_IS_WORKBENCH (previous_toplevel) && self->extensions != NULL)
- ide_editor_view_unload_addins (self);
-
- if (IDE_IS_WORKBENCH (toplevel))
- ide_editor_view_load_addins (self);
-}
-
-static gchar *
-ide_editor_view_get_title (IdeLayoutView *view)
+ide_editor_view_constructed (GObject *object)
{
- IdeEditorView *self = (IdeEditorView *)view;
+ IdeEditorView *self = (IdeEditorView *)object;
g_assert (IDE_IS_EDITOR_VIEW (self));
- if (self->document)
- return g_strdup (ide_buffer_get_title (self->document));
+ G_OBJECT_CLASS (ide_editor_view_parent_class)->constructed (object);
- return NULL;
+ _ide_editor_view_init_actions (self);
+ _ide_editor_view_init_shortcuts (self);
+ _ide_editor_view_init_settings (self);
}
static void
@@ -743,62 +220,25 @@ ide_editor_view_destroy (GtkWidget *widget)
{
IdeEditorView *self = (IdeEditorView *)widget;
- IDE_ENTRY;
-
- ide_editor_view_unload_addins (self);
+ g_assert (IDE_IS_EDITOR_VIEW (self));
- /*
- * We want to make extra sure these widgets get destroyed, so manually
- * destroy them here before doing any other work.
- */
+ g_clear_object (&self->addins);
- if (self->frame1)
+ if (self->buffer_bindings != NULL)
{
- gtk_widget_destroy (GTK_WIDGET (self->frame1));
- self->frame1 = NULL;
+ dzl_binding_group_set_source (self->buffer_bindings, NULL);
+ g_clear_object (&self->buffer_bindings);
}
- if (self->frame2)
+ if (self->buffer_signals != NULL)
{
- gtk_widget_destroy (GTK_WIDGET (self->frame2));
- self->frame2 = NULL;
+ dzl_signal_group_set_target (self->buffer_signals, NULL);
+ g_clear_object (&self->buffer_signals);
}
- g_clear_object (&self->document);
+ g_clear_object (&self->buffer);
GTK_WIDGET_CLASS (ide_editor_view_parent_class)->destroy (widget);
-
- IDE_EXIT;
-}
-
-static gboolean
-ide_editor_view_agree_to_close (IdeLayoutView *view)
-{
- IdeEditorView *self = (IdeEditorView *)view;
-
- g_assert (IDE_IS_EDITOR_VIEW (self));
-
- /* We autosave documents, so we don't really need to ask the user
- * to close the document. But we do need to release our plugins
- * immediately before we start closing. Otherwise we rely on widget
- * destruction which is a rather nasty way to cleanup.
- */
- ide_editor_view_unload_addins (self);
-
- return TRUE;
-}
-
-static void
-ide_editor_view_finalize (GObject *object)
-{
- IdeEditorView *self = (IdeEditorView *)object;
-
- g_clear_pointer (&self->title, g_free);
- g_clear_object (&self->extensions);
- g_clear_object (&self->document);
- g_clear_object (&self->settings);
-
- G_OBJECT_CLASS (ide_editor_view_parent_class)->finalize (object);
}
static void
@@ -811,8 +251,8 @@ ide_editor_view_get_property (GObject *object,
switch (prop_id)
{
- case PROP_DOCUMENT:
- g_value_set_object (value, self->document);
+ case PROP_BUFFER:
+ g_value_set_object (value, ide_editor_view_get_buffer (self));
break;
default:
@@ -830,8 +270,8 @@ ide_editor_view_set_property (GObject *object,
switch (prop_id)
{
- case PROP_DOCUMENT:
- ide_editor_view_set_document (self, g_value_get_object (value));
+ case PROP_BUFFER:
+ ide_editor_view_set_buffer (self, g_value_get_object (value));
break;
default:
@@ -844,56 +284,30 @@ ide_editor_view_class_init (IdeEditorViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- IdeLayoutViewClass *view_class = IDE_LAYOUT_VIEW_CLASS (klass);
+ IdeLayoutViewClass *layout_view_class = IDE_LAYOUT_VIEW_CLASS (klass);
- object_class->finalize = ide_editor_view_finalize;
+ object_class->constructed = ide_editor_view_constructed;
object_class->get_property = ide_editor_view_get_property;
object_class->set_property = ide_editor_view_set_property;
widget_class->destroy = ide_editor_view_destroy;
- widget_class->grab_focus = ide_editor_view_grab_focus;
- widget_class->get_request_mode = ide_editor_view_get_request_mode;
- widget_class->get_preferred_height = ide_editor_view_get_preferred_height;
widget_class->hierarchy_changed = ide_editor_view_hierarchy_changed;
- view_class->create_split = ide_editor_view_create_split;
- view_class->get_special_title = ide_editor_view_get_special_title;
- view_class->get_modified = ide_editor_view_get_modified;
- view_class->get_split_view = ide_editor_view_get_split_view;
- view_class->set_split_view = ide_editor_view_set_split_view;
- view_class->set_back_forward_list = ide_editor_view_set_back_forward_list;
- view_class->navigate_to = ide_editor_view_navigate_to;
- view_class->get_title = ide_editor_view_get_title;
- view_class->agree_to_close = ide_editor_view_agree_to_close;
-
- properties [PROP_DOCUMENT] =
- g_param_spec_object ("document",
- "Document",
- "The editor document.",
+ layout_view_class->create_split_view = ide_editor_view_create_split_view;
+
+ properties [PROP_BUFFER] =
+ g_param_spec_object ("buffer",
+ "Buffer",
+ "The buffer for the view",
IDE_TYPE_BUFFER,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
- g_object_class_install_properties (object_class, LAST_PROP, properties);
-
- signals [REQUEST_DOCUMENTATION] =
- g_signal_new ("request-documentation",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- G_TYPE_STRING);
+ g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/ide-editor-view.ui");
-
- gtk_widget_class_bind_template_child (widget_class, IdeEditorView, frame1);
- gtk_widget_class_bind_template_child (widget_class, IdeEditorView, modified_cancel_button);
- gtk_widget_class_bind_template_child (widget_class, IdeEditorView, modified_revealer);
- gtk_widget_class_bind_template_child (widget_class, IdeEditorView, paned);
- gtk_widget_class_bind_template_child (widget_class, IdeEditorView, progress_bar);
-
- g_type_ensure (IDE_TYPE_EDITOR_FRAME);
- g_type_ensure (IDE_TYPE_EDITOR_TWEAK_WIDGET);
+ gtk_widget_class_bind_template_child (widget_class, IdeEditorView, overlay);
+ gtk_widget_class_bind_template_child (widget_class, IdeEditorView, scroller);
+ gtk_widget_class_bind_template_child (widget_class, IdeEditorView, source_view);
}
static void
@@ -901,66 +315,68 @@ ide_editor_view_init (IdeEditorView *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
- self->settings = g_settings_new ("org.gnome.builder.editor");
- self->last_focused_frame = self->frame1;
+ ide_layout_view_set_can_split (IDE_LAYOUT_VIEW (self), TRUE);
+ ide_layout_view_set_menu_id (IDE_LAYOUT_VIEW (self), "ide-editor-view-document-menu");
+
+ /*
+ * Setup signals to monitor on the buffer.
+ */
+ self->buffer_signals = dzl_signal_group_new (IDE_TYPE_BUFFER);
+
+ dzl_signal_group_connect_swapped (self->buffer_signals,
+ "modified-changed",
+ G_CALLBACK (ide_editor_view_buffer_modified_changed),
+ self);
+
+ dzl_signal_group_connect_swapped (self->buffer_signals,
+ "notify::language",
+ G_CALLBACK (ide_editor_view_buffer_notify_language),
+ self);
- ide_editor_view_actions_init (self);
+ g_signal_connect_swapped (self->buffer_signals,
+ "bind",
+ G_CALLBACK (ide_editor_view_bind_signals),
+ self);
/*
- * XXX: Refactor all of this.
- *
- * In frame1, we don't show the floating bar, so no need to alter the
- * editor map allocation.
+ * Setup bindings for the buffer.
*/
- g_object_set (self->frame1->source_map_container,
- "floating-bar", NULL,
- NULL);
-
- g_signal_connect_object (self->modified_cancel_button,
- "clicked",
- G_CALLBACK (ide_editor_view_hide_reload_bar),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (self->frame1->source_view,
- "request-documentation",
- G_CALLBACK (ide_editor_view_request_documentation),
- self,
- G_CONNECT_SWAPPED);
-
- g_signal_connect_object (self->frame1->source_view,
- "focus-in-event",
- G_CALLBACK (ide_editor_view__focus_in_event),
- self,
- G_CONNECT_SWAPPED);
+ self->buffer_bindings = dzl_binding_group_new ();
+ dzl_binding_group_bind (self->buffer_bindings, "title", self, "title", 0);
}
/**
- * ide_editor_view_get_active_source_view:
+ * ide_editor_view_get_buffer:
+ * @self: a #IdeEditorView
+ *
+ * Gets the underlying buffer for the view.
+ *
+ * Returns: (transfer none): An #IdeBuffer
*
- * Returns: (transfer none): An #IdeSourceView.
+ * Since: 3.26
*/
-IdeSourceView *
-ide_editor_view_get_active_source_view (IdeEditorView *self)
+IdeBuffer *
+ide_editor_view_get_buffer (IdeEditorView *self)
{
- IdeEditorFrame *frame;
-
g_return_val_if_fail (IDE_IS_EDITOR_VIEW (self), NULL);
- frame = ide_editor_view_get_last_focused (self);
-
- return ide_editor_frame_get_source_view (frame);
+ return self->buffer;
}
/**
- * ide_editor_view_get_document:
+ * ide_editor_view_get_source_view:
+ * @self: a #IdeEditorView
*
- * Returns: (transfer none): An #IdeBuffer.
+ * Gets the #IdeSourceView that is part of the #IdeEditorView.
+ *
+ * Returns: (transfer none): An #IdeSourceView
+ *
+ * Since: 3.26
*/
-IdeBuffer *
-ide_editor_view_get_document (IdeEditorView *self)
+IdeSourceView *
+ide_editor_view_get_source_view (IdeEditorView *self)
{
g_return_val_if_fail (IDE_IS_EDITOR_VIEW (self), NULL);
- return self->document;
+ return self->source_view;
}
diff --git a/libide/editor/ide-editor-view.h b/libide/editor/ide-editor-view.h
index 28a4402..2e0a979 100644
--- a/libide/editor/ide-editor-view.h
+++ b/libide/editor/ide-editor-view.h
@@ -1,6 +1,6 @@
/* ide-editor-view.h
*
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * 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
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IDE_EDITOR_VIEW_H
-#define IDE_EDITOR_VIEW_H
+#pragma once
+
+#include <gtksourceview/gtksource.h>
#include "buffers/ide-buffer.h"
#include "layout/ide-layout-view.h"
@@ -29,9 +30,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeEditorView, ide_editor_view, IDE, EDITOR_VIEW, IdeLayoutView)
-IdeBuffer *ide_editor_view_get_document (IdeEditorView *self);
-IdeSourceView *ide_editor_view_get_active_source_view (IdeEditorView *self);
+IdeBuffer *ide_editor_view_get_buffer (IdeEditorView *self);
+IdeSourceView *ide_editor_view_get_source_view (IdeEditorView *self);
G_END_DECLS
-
-#endif /* IDE_EDITOR_VIEW_H */
diff --git a/libide/editor/ide-editor-view.ui b/libide/editor/ide-editor-view.ui
index ea4f32b..58a717f 100644
--- a/libide/editor/ide-editor-view.ui
+++ b/libide/editor/ide-editor-view.ui
@@ -1,86 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.15 -->
<template class="IdeEditorView" parent="IdeLayoutView">
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
+ <object class="GtkOverlay" id="overlay">
<property name="visible">true</property>
<child>
- <object class="GtkRevealer" id="modified_revealer">
+ <object class="GtkScrolledWindow" id="scroller">
<property name="visible">true</property>
- <property name="reveal-child">false</property>
<child>
- <object class="GtkInfoBar">
+ <object class="IdeSourceView" id="source_view">
+ <property name="show-line-numbers">true</property>
<property name="visible">true</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="spacing">6</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton">
- <property name="action-name">view.reload-buffer</property>
- <property name="label" translatable="yes">_Reload</property>
- <property name="visible">true</property>
- <property name="receives_default">true</property>
- <property name="use_underline">true</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="modified_cancel_button">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">true</property>
- <property name="use_underline">true</property>
- </object>
- </child>
- </object>
- </child>
- <child internal-child="content_area">
- <object class="GtkBox">
- <property name="spacing">16</property>
- <child>
- <object class="GtkLabel" id="modified_label">
- <property name="hexpand">true</property>
- <property name="label" translatable="yes">Builder has discovered that this file has
been modified externally. Would you like to reload the file?</property>
- <property name="visible">true</property>
- <property name="wrap">true</property>
- <property name="xalign">0</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkOverlay">
- <property name="visible">true</property>
- <child type="overlay">
- <object class="GtkProgressBar" id="progress_bar">
- <property name="halign">fill</property>
- <property name="orientation">horizontal</property>
- <property name="valign">start</property>
- <property name="visible">false</property>
- <style>
- <class name="osd"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPaned" id="paned">
- <property name="expand">true</property>
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- <child>
- <object class="IdeEditorFrame" id="frame1">
- <property name="visible">true</property>
- </object>
- <packing>
- <property name="resize">true</property>
- <property name="shrink">false</property>
- </packing>
- </child>
</object>
</child>
</object>
@@ -88,16 +18,4 @@
</object>
</child>
</template>
- <object class="GtkPopover" id="tweak_popover">
- <child>
- <object class="IdeEditorTweakWidget" id="tweak_widget">
- <property name="border-width">12</property>
- <property name="visible">true</property>
- </object>
- </child>
- </object>
- <object class="DzlSimplePopover" id="goto_line_popover">
- <property name="title" translatable="yes">Go to Line</property>
- <property name="button-text" translatable="yes">Go</property>
- </object>
</interface>
diff --git a/libide/editor/ide-editor-workbench-addin.c b/libide/editor/ide-editor-workbench-addin.c
index 0f9e53a..54c38eb 100644
--- a/libide/editor/ide-editor-workbench-addin.c
+++ b/libide/editor/ide-editor-workbench-addin.c
@@ -26,6 +26,7 @@
#include "buffers/ide-buffer-manager.h"
#include "buffers/ide-buffer.h"
+#include "diagnostics/ide-source-location.h"
#include "editor/ide-editor-perspective.h"
#include "editor/ide-editor-workbench-addin.h"
#include "util/ide-gtk.h"
diff --git a/libide/layout/ide-layout-stack-actions.c b/libide/layout/ide-layout-stack-actions.c
index 00713f1..011ecf9 100644
--- a/libide/layout/ide-layout-stack-actions.c
+++ b/libide/layout/ide-layout-stack-actions.c
@@ -316,6 +316,9 @@ _ide_layout_stack_update_actions (IdeLayoutStack *self)
dzl_gtk_widget_action_set (GTK_WIDGET (self), "layoutstack", "open-in-new-frame",
"enabled", can_split_view,
NULL);
+ dzl_gtk_widget_action_set (GTK_WIDGET (self), "layoutstack", "split-view",
+ "enabled", can_split_view,
+ NULL);
dzl_gtk_widget_action_set (GTK_WIDGET (self), "layoutstack", "close-stack",
"enabled", can_close_stack,
NULL);
diff --git a/libide/libide.gresource.xml b/libide/libide.gresource.xml
index d4ee7a3..305a6db 100644
--- a/libide/libide.gresource.xml
+++ b/libide/libide.gresource.xml
@@ -53,11 +53,8 @@
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-layout-pane.ui">layout/ide-layout-pane.ui</file>
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-layout-stack-header.ui">layout/ide-layout-stack-header.ui</file>
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-layout-stack.ui">layout/ide-layout-stack.ui</file>
-
- <file compressed="true" preprocess="xml-stripblanks"
alias="ide-editor-frame.ui">editor/ide-editor-frame.ui</file>
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-editor-perspective.ui">editor/ide-editor-perspective.ui</file>
- <file compressed="true" preprocess="xml-stripblanks"
alias="ide-editor-spell-widget.ui">editor/ide-editor-spell-widget.ui</file>
- <file compressed="true" preprocess="xml-stripblanks"
alias="ide-editor-tweak-widget.ui">editor/ide-editor-tweak-widget.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks"
alias="ide-editor-spell-widget.ui">spellcheck/ide-editor-spell-widget.ui</file>
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-editor-view.ui">editor/ide-editor-view.ui</file>
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-greeter-perspective.ui">greeter/ide-greeter-perspective.ui</file>
<file compressed="true" preprocess="xml-stripblanks"
alias="ide-greeter-project-row.ui">greeter/ide-greeter-project-row.ui</file>
diff --git a/libide/meson.build b/libide/meson.build
index 8eae760..8370103 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -126,7 +126,6 @@ libide_public_headers = [
'layout/ide-layout-grid.h',
'layout/ide-layout-grid-column.h',
'layout/ide-layout-stack.h',
- 'layout/ide-layout-stack-addin.h',
'layout/ide-layout-stack-header.h',
'layout/ide-layout-view.h',
'layout/ide-layout-pane.h',
@@ -325,7 +324,6 @@ libide_public_sources = [
'layout/ide-layout-grid.c',
'layout/ide-layout-grid-column.c',
'layout/ide-layout-pane.c',
- 'layout/ide-layout-stack-addin.c',
'layout/ide-layout-stack-header.c',
'layout/ide-layout-stack.c',
'layout/ide-layout-view.c',
@@ -458,36 +456,13 @@ libide_sources = libide_generated_headers + libide_public_sources + [
'buildui/ide-environment-editor-row.h',
'buildui/ide-environment-editor.c',
'buildui/ide-environment-editor.h',
- 'editor/ide-editor-frame-actions.c',
- 'editor/ide-editor-frame-actions.h',
- 'editor/ide-editor-frame-private.h',
- 'editor/ide-editor-frame.c',
- 'editor/ide-editor-frame.h',
- 'editor/ide-editor-map-bin.c',
- 'editor/ide-editor-map-bin.h',
'editor/ide-editor-plugin.c',
- 'editor/ide-editor-layout-stack-addin.c',
- 'editor/ide-editor-layout-stack-addin.h',
- 'editor/ide-editor-layout-stack-controls.c',
- 'editor/ide-editor-layout-stack-controls.h',
'editor/ide-editor-print-operation.c',
'editor/ide-editor-print-operation.h',
- 'editor/ide-editor-spell-navigator.c',
- 'editor/ide-editor-spell-navigator.h',
- 'editor/ide-editor-spell-utils.c',
- 'editor/ide-editor-spell-utils.h',
- 'editor/ide-editor-spell-dict.c',
- 'editor/ide-editor-spell-dict.h',
- 'editor/ide-editor-spell-language-popover.c',
- 'editor/ide-editor-spell-language-popover.h',
- 'editor/ide-editor-spell-widget.c',
- 'editor/ide-editor-spell-widget.h',
- 'editor/ide-editor-tweak-widget.c',
- 'editor/ide-editor-tweak-widget.h',
'editor/ide-editor-view-actions.c',
- 'editor/ide-editor-view-actions.h',
- 'editor/ide-editor-view-addin-private.h',
- 'editor/ide-editor-view-private.h',
+ 'editor/ide-editor-view-settings.c',
+ 'editor/ide-editor-view-shortcuts.c',
+ 'editor/ide-editor-private.h',
'editor/ide-editor-workbench-addin.c',
'editor/ide-editor-workbench-addin.h',
'gconstructor.h',
@@ -547,6 +522,16 @@ libide_sources = libide_generated_headers + libide_public_sources + [
'sourceview/ide-text-iter.h',
'sourceview/ide-text-util.c',
'sourceview/ide-text-util.h',
+ 'spellcheck/ide-editor-spell-navigator.c',
+ 'spellcheck/ide-editor-spell-navigator.h',
+ 'spellcheck/ide-editor-spell-utils.c',
+ 'spellcheck/ide-editor-spell-utils.h',
+ 'spellcheck/ide-editor-spell-dict.c',
+ 'spellcheck/ide-editor-spell-dict.h',
+ 'spellcheck/ide-editor-spell-language-popover.c',
+ 'spellcheck/ide-editor-spell-language-popover.h',
+ 'spellcheck/ide-editor-spell-widget.c',
+ 'spellcheck/ide-editor-spell-widget.h',
'subprocess/ide-breakout-subprocess.c',
'subprocess/ide-breakout-subprocess.h',
'subprocess/ide-breakout-subprocess-private.h',
diff --git a/libide/editor/ide-editor-spell-dict.c b/libide/spellcheck/ide-editor-spell-dict.c
similarity index 100%
rename from libide/editor/ide-editor-spell-dict.c
rename to libide/spellcheck/ide-editor-spell-dict.c
diff --git a/libide/editor/ide-editor-spell-dict.h b/libide/spellcheck/ide-editor-spell-dict.h
similarity index 100%
rename from libide/editor/ide-editor-spell-dict.h
rename to libide/spellcheck/ide-editor-spell-dict.h
diff --git a/libide/editor/ide-editor-spell-language-popover.c
b/libide/spellcheck/ide-editor-spell-language-popover.c
similarity index 100%
rename from libide/editor/ide-editor-spell-language-popover.c
rename to libide/spellcheck/ide-editor-spell-language-popover.c
diff --git a/libide/editor/ide-editor-spell-language-popover.h
b/libide/spellcheck/ide-editor-spell-language-popover.h
similarity index 100%
rename from libide/editor/ide-editor-spell-language-popover.h
rename to libide/spellcheck/ide-editor-spell-language-popover.h
diff --git a/libide/editor/ide-editor-spell-navigator.c b/libide/spellcheck/ide-editor-spell-navigator.c
similarity index 100%
rename from libide/editor/ide-editor-spell-navigator.c
rename to libide/spellcheck/ide-editor-spell-navigator.c
diff --git a/libide/editor/ide-editor-spell-navigator.h b/libide/spellcheck/ide-editor-spell-navigator.h
similarity index 100%
rename from libide/editor/ide-editor-spell-navigator.h
rename to libide/spellcheck/ide-editor-spell-navigator.h
diff --git a/libide/editor/ide-editor-spell-utils.c b/libide/spellcheck/ide-editor-spell-utils.c
similarity index 100%
rename from libide/editor/ide-editor-spell-utils.c
rename to libide/spellcheck/ide-editor-spell-utils.c
diff --git a/libide/editor/ide-editor-spell-utils.h b/libide/spellcheck/ide-editor-spell-utils.h
similarity index 100%
rename from libide/editor/ide-editor-spell-utils.h
rename to libide/spellcheck/ide-editor-spell-utils.h
diff --git a/libide/editor/ide-editor-spell-widget.c b/libide/spellcheck/ide-editor-spell-widget.c
similarity index 99%
rename from libide/editor/ide-editor-spell-widget.c
rename to libide/spellcheck/ide-editor-spell-widget.c
index 13534db..4619ad4 100644
--- a/libide/editor/ide-editor-spell-widget.c
+++ b/libide/spellcheck/ide-editor-spell-widget.c
@@ -24,10 +24,10 @@
#include "ide-debug.h"
#include "buffers/ide-buffer.h"
-#include "editor/ide-editor-spell-dict.h"
-#include "editor/ide-editor-spell-language-popover.h"
-#include "editor/ide-editor-spell-navigator.h"
-#include "editor/ide-editor-spell-widget.h"
+#include "spellcheck/ide-editor-spell-dict.h"
+#include "spellcheck/ide-editor-spell-language-popover.h"
+#include "spellcheck/ide-editor-spell-navigator.h"
+#include "spellcheck/ide-editor-spell-widget.h"
#include "util/ide-gtk.h"
typedef enum
diff --git a/libide/editor/ide-editor-spell-widget.h b/libide/spellcheck/ide-editor-spell-widget.h
similarity index 100%
rename from libide/editor/ide-editor-spell-widget.h
rename to libide/spellcheck/ide-editor-spell-widget.h
diff --git a/libide/editor/ide-editor-spell-widget.ui b/libide/spellcheck/ide-editor-spell-widget.ui
similarity index 100%
rename from libide/editor/ide-editor-spell-widget.ui
rename to libide/spellcheck/ide-editor-spell-widget.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]