[gnome-builder: 93/139] history: port to libide-editor



commit 9dac7be0dcf27e6a25d7d408e33685847aa80072
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:26:53 2019 -0800

    history: port to libide-editor

 ...iew-addin.c => gbp-history-editor-page-addin.c} | 160 ++++++++++-----------
 ...iew-addin.h => gbp-history-editor-page-addin.h} |   8 +-
 ...out-stack-addin.c => gbp-history-frame-addin.c} | 132 ++++++++---------
 ...out-stack-addin.h => gbp-history-frame-addin.h} |  12 +-
 src/plugins/history/gbp-history-item.c             |  31 ++--
 src/plugins/history/gbp-history-item.h             |  16 +--
 .../{gbp-history-plugin.c => history-plugin.c}     |  21 +--
 src/plugins/history/history.gresource.xml          |   2 +-
 src/plugins/history/history.plugin                 |  12 +-
 src/plugins/history/meson.build                    |  24 ++--
 10 files changed, 202 insertions(+), 216 deletions(-)
---
diff --git a/src/plugins/history/gbp-history-editor-view-addin.c 
b/src/plugins/history/gbp-history-editor-page-addin.c
similarity index 60%
rename from src/plugins/history/gbp-history-editor-view-addin.c
rename to src/plugins/history/gbp-history-editor-page-addin.c
index d81062fdf..43133ac58 100644
--- a/src/plugins/history/gbp-history-editor-view-addin.c
+++ b/src/plugins/history/gbp-history-editor-page-addin.c
@@ -1,4 +1,4 @@
-/* gbp-history-editor-view-addin.c
+/* gbp-history-editor-page-addin.c
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -18,52 +18,52 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#define G_LOG_DOMAIN "gbp-history-editor-view-addin"
+#define G_LOG_DOMAIN "gbp-history-editor-page-addin"
 
-#include "gbp-history-editor-view-addin.h"
+#include "gbp-history-editor-page-addin.h"
 #include "gbp-history-item.h"
-#include "gbp-history-layout-stack-addin.h"
+#include "gbp-history-frame-addin.h"
 
-struct _GbpHistoryEditorViewAddin
+struct _GbpHistoryEditorPageAddin
 {
-  GObject                     parent_instance;
+  GObject               parent_instance;
 
   /* Unowned pointer */
-  IdeEditorView              *editor;
+  IdeEditorPage        *editor;
 
   /* Weak pointer */
-  GbpHistoryLayoutStackAddin *stack_addin;
+  GbpHistoryFrameAddin *frame_addin;
 
-  gsize                       last_change_count;
+  gsize                 last_change_count;
 
-  guint                       queued_edit_line;
-  guint                       queued_edit_source;
+  guint                 queued_edit_line;
+  guint                 queued_edit_source;
 };
 
 static void
-gbp_history_editor_view_addin_stack_set (IdeEditorViewAddin *addin,
-                                         IdeLayoutStack     *stack)
+gbp_history_editor_page_addin_frame_set (IdeEditorPageAddin *addin,
+                                         IdeFrame           *stack)
 {
-  GbpHistoryEditorViewAddin *self = (GbpHistoryEditorViewAddin *)addin;
-  IdeLayoutStackAddin *stack_addin;
+  GbpHistoryEditorPageAddin *self = (GbpHistoryEditorPageAddin *)addin;
+  IdeFrameAddin *frame_addin;
 
   IDE_ENTRY;
 
-  g_assert (IDE_IS_EDITOR_VIEW_ADDIN (self));
-  g_assert (IDE_IS_LAYOUT_STACK (stack));
+  g_assert (IDE_IS_EDITOR_PAGE_ADDIN (self));
+  g_assert (IDE_IS_FRAME (stack));
 
-  stack_addin = ide_layout_stack_addin_find_by_module_name (stack, "history-plugin");
+  frame_addin = ide_frame_addin_find_by_module_name (stack, "history");
 
-  g_assert (stack_addin != NULL);
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (stack_addin));
+  g_assert (frame_addin != NULL);
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (frame_addin));
 
-  g_set_weak_pointer (&self->stack_addin, GBP_HISTORY_LAYOUT_STACK_ADDIN (stack_addin));
+  g_set_weak_pointer (&self->frame_addin, GBP_HISTORY_FRAME_ADDIN (frame_addin));
 
   IDE_EXIT;
 }
 
 static void
-gbp_history_editor_view_addin_push (GbpHistoryEditorViewAddin *self,
+gbp_history_editor_page_addin_push (GbpHistoryEditorPageAddin *self,
                                     const GtkTextIter         *iter)
 {
   g_autoptr(GbpHistoryItem) item = NULL;
@@ -72,11 +72,11 @@ gbp_history_editor_view_addin_push (GbpHistoryEditorViewAddin *self,
 
   IDE_ENTRY;
 
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
   g_assert (iter != NULL);
   g_assert (self->editor != NULL);
 
-  if (self->stack_addin == NULL)
+  if (self->frame_addin == NULL)
     IDE_GOTO (no_stack_loaded);
 
   /*
@@ -87,14 +87,14 @@ gbp_history_editor_view_addin_push (GbpHistoryEditorViewAddin *self,
   mark = gtk_text_buffer_create_mark (buffer, NULL, iter, TRUE);
   item = gbp_history_item_new (mark);
 
-  gbp_history_layout_stack_addin_push (self->stack_addin, item);
+  gbp_history_frame_addin_push (self->frame_addin, item);
 
 no_stack_loaded:
   IDE_EXIT;
 }
 
 static void
-gbp_history_editor_view_addin_jump (GbpHistoryEditorViewAddin *self,
+gbp_history_editor_page_addin_jump (GbpHistoryEditorPageAddin *self,
                                     const GtkTextIter         *from,
                                     const GtkTextIter         *to,
                                     IdeSourceView             *source_view)
@@ -102,7 +102,7 @@ gbp_history_editor_view_addin_jump (GbpHistoryEditorViewAddin *self,
   IdeBuffer *buffer;
   gsize change_count;
 
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
   g_assert (from != NULL);
   g_assert (to != NULL);
   g_assert (IDE_IS_SOURCE_VIEW (source_view));
@@ -126,35 +126,35 @@ gbp_history_editor_view_addin_jump (GbpHistoryEditorViewAddin *self,
   //if (change_count != self->last_change_count)
     {
       self->last_change_count = change_count;
-      gbp_history_editor_view_addin_push (self, from);
-      gbp_history_editor_view_addin_push (self, to);
+      gbp_history_editor_page_addin_push (self, from);
+      gbp_history_editor_page_addin_push (self, to);
     }
 }
 
 static gboolean
-gbp_history_editor_view_addin_flush_edit (gpointer user_data)
+gbp_history_editor_page_addin_flush_edit (gpointer user_data)
 {
-  GbpHistoryEditorViewAddin *self = user_data;
+  GbpHistoryEditorPageAddin *self = user_data;
   IdeBuffer *buffer;
   GtkTextIter iter;
 
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
   g_assert (self->editor != NULL);
 
   self->queued_edit_source = 0;
 
-  buffer = ide_editor_view_get_buffer (self->editor);
+  buffer = ide_editor_page_get_buffer (self->editor);
   gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (buffer), &iter, self->queued_edit_line);
-  gbp_history_editor_view_addin_push (self, &iter);
+  gbp_history_editor_page_addin_push (self, &iter);
 
   return G_SOURCE_REMOVE;
 }
 
 static void
-gbp_history_editor_view_addin_queue (GbpHistoryEditorViewAddin *self,
+gbp_history_editor_page_addin_queue (GbpHistoryEditorPageAddin *self,
                                      guint                      line)
 {
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
 
   /*
    * If the buffer is modified, we want to keep track of this position in the
@@ -170,51 +170,51 @@ gbp_history_editor_view_addin_queue (GbpHistoryEditorViewAddin *self,
     {
       self->queued_edit_line = line;
       self->queued_edit_source = gdk_threads_add_idle_full (G_PRIORITY_LOW,
-                                                            gbp_history_editor_view_addin_flush_edit,
+                                                            gbp_history_editor_page_addin_flush_edit,
                                                             g_object_ref (self),
                                                             g_object_unref);
     }
 }
 
 static void
-gbp_history_editor_view_addin_insert_text (GbpHistoryEditorViewAddin *self,
+gbp_history_editor_page_addin_insert_text (GbpHistoryEditorPageAddin *self,
                                            const GtkTextIter         *location,
                                            const gchar               *text,
                                            gint                       length,
                                            IdeBuffer                 *buffer)
 {
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
   g_assert (IDE_IS_BUFFER (buffer));
   g_assert (location != NULL);
   g_assert (text != NULL);
 
   if (!ide_buffer_get_loading (buffer))
-    gbp_history_editor_view_addin_queue (self, gtk_text_iter_get_line (location));
+    gbp_history_editor_page_addin_queue (self, gtk_text_iter_get_line (location));
 }
 
 static void
-gbp_history_editor_view_addin_delete_range (GbpHistoryEditorViewAddin *self,
+gbp_history_editor_page_addin_delete_range (GbpHistoryEditorPageAddin *self,
                                             const GtkTextIter         *begin,
                                             const GtkTextIter         *end,
                                             IdeBuffer                 *buffer)
 {
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
   g_assert (begin != NULL);
   g_assert (end != NULL);
   g_assert (IDE_IS_BUFFER (buffer));
 
   if (!ide_buffer_get_loading (buffer))
-    gbp_history_editor_view_addin_queue (self, gtk_text_iter_get_line (begin));
+    gbp_history_editor_page_addin_queue (self, gtk_text_iter_get_line (begin));
 }
 
 static void
-gbp_history_editor_view_addin_buffer_loaded (GbpHistoryEditorViewAddin *self,
+gbp_history_editor_page_addin_buffer_loaded (GbpHistoryEditorPageAddin *self,
                                              IdeBuffer                 *buffer)
 {
   IdeSourceView *source_view;
 
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
-  g_assert (IDE_IS_EDITOR_VIEW (self->editor));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
+  g_assert (IDE_IS_EDITOR_PAGE (self->editor));
   g_assert (IDE_IS_BUFFER (buffer));
 
   /*
@@ -222,111 +222,111 @@ gbp_history_editor_view_addin_buffer_loaded (GbpHistoryEditorViewAddin *self,
    * history stack so that ctrl+i works after jumping backwards.
    */
 
-  source_view = ide_editor_view_get_view (self->editor);
+  source_view = ide_editor_page_get_view (self->editor);
 
   if (gtk_widget_has_focus (GTK_WIDGET (source_view)))
     {
       GtkTextIter iter;
 
       ide_buffer_get_selection_bounds (buffer, &iter, NULL);
-      gbp_history_editor_view_addin_queue (self, gtk_text_iter_get_line (&iter));
+      gbp_history_editor_page_addin_queue (self, gtk_text_iter_get_line (&iter));
     }
 }
 
 static void
-gbp_history_editor_view_addin_load (IdeEditorViewAddin *addin,
-                                    IdeEditorView      *view)
+gbp_history_editor_page_addin_load (IdeEditorPageAddin *addin,
+                                    IdeEditorPage      *view)
 {
-  GbpHistoryEditorViewAddin *self = (GbpHistoryEditorViewAddin *)addin;
+  GbpHistoryEditorPageAddin *self = (GbpHistoryEditorPageAddin *)addin;
   IdeSourceView *source_view;
   IdeBuffer *buffer;
 
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
-  g_assert (IDE_IS_EDITOR_VIEW (view));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
+  g_assert (IDE_IS_EDITOR_PAGE (view));
 
   self->editor = view;
 
-  buffer = ide_editor_view_get_buffer (view);
-  source_view = ide_editor_view_get_view (view);
+  buffer = ide_editor_page_get_buffer (view);
+  source_view = ide_editor_page_get_view (view);
 
   self->last_change_count = ide_buffer_get_change_count (buffer);
 
   g_signal_connect_swapped (source_view,
                             "jump",
-                            G_CALLBACK (gbp_history_editor_view_addin_jump),
+                            G_CALLBACK (gbp_history_editor_page_addin_jump),
                             addin);
 
   g_signal_connect_swapped (buffer,
                             "insert-text",
-                            G_CALLBACK (gbp_history_editor_view_addin_insert_text),
+                            G_CALLBACK (gbp_history_editor_page_addin_insert_text),
                             self);
 
   g_signal_connect_swapped (buffer,
                             "delete-range",
-                            G_CALLBACK (gbp_history_editor_view_addin_delete_range),
+                            G_CALLBACK (gbp_history_editor_page_addin_delete_range),
                             self);
 
   g_signal_connect_swapped (buffer,
                             "loaded",
-                            G_CALLBACK (gbp_history_editor_view_addin_buffer_loaded),
+                            G_CALLBACK (gbp_history_editor_page_addin_buffer_loaded),
                             self);
 }
 
 static void
-gbp_history_editor_view_addin_unload (IdeEditorViewAddin *addin,
-                                      IdeEditorView      *view)
+gbp_history_editor_page_addin_unload (IdeEditorPageAddin *addin,
+                                      IdeEditorPage      *view)
 {
-  GbpHistoryEditorViewAddin *self = (GbpHistoryEditorViewAddin *)addin;
+  GbpHistoryEditorPageAddin *self = (GbpHistoryEditorPageAddin *)addin;
   IdeSourceView *source_view;
   IdeBuffer *buffer;
 
-  g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
-  g_assert (IDE_IS_EDITOR_VIEW (view));
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
+  g_assert (IDE_IS_EDITOR_PAGE (view));
 
-  dzl_clear_source (&self->queued_edit_source);
+  g_clear_handle_id (&self->queued_edit_source, g_source_remove);
 
-  source_view = ide_editor_view_get_view (view);
-  buffer = ide_editor_view_get_buffer (view);
+  source_view = ide_editor_page_get_view (view);
+  buffer = ide_editor_page_get_buffer (view);
 
   g_signal_handlers_disconnect_by_func (source_view,
-                                        G_CALLBACK (gbp_history_editor_view_addin_jump),
+                                        G_CALLBACK (gbp_history_editor_page_addin_jump),
                                         self);
 
   g_signal_handlers_disconnect_by_func (buffer,
-                                        G_CALLBACK (gbp_history_editor_view_addin_insert_text),
+                                        G_CALLBACK (gbp_history_editor_page_addin_insert_text),
                                         self);
 
   g_signal_handlers_disconnect_by_func (buffer,
-                                        G_CALLBACK (gbp_history_editor_view_addin_delete_range),
+                                        G_CALLBACK (gbp_history_editor_page_addin_delete_range),
                                         self);
 
   g_signal_handlers_disconnect_by_func (buffer,
-                                        G_CALLBACK (gbp_history_editor_view_addin_buffer_loaded),
+                                        G_CALLBACK (gbp_history_editor_page_addin_buffer_loaded),
                                         self);
 
-  g_clear_weak_pointer (&self->stack_addin);
+  g_clear_weak_pointer (&self->frame_addin);
 
   self->editor = NULL;
 }
 
 static void
-editor_view_addin_iface_init (IdeEditorViewAddinInterface *iface)
+editor_view_addin_iface_init (IdeEditorPageAddinInterface *iface)
 {
-  iface->load = gbp_history_editor_view_addin_load;
-  iface->unload = gbp_history_editor_view_addin_unload;
-  iface->stack_set = gbp_history_editor_view_addin_stack_set;
+  iface->load = gbp_history_editor_page_addin_load;
+  iface->unload = gbp_history_editor_page_addin_unload;
+  iface->frame_set = gbp_history_editor_page_addin_frame_set;
 }
 
-G_DEFINE_TYPE_WITH_CODE (GbpHistoryEditorViewAddin, gbp_history_editor_view_addin, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_VIEW_ADDIN,
+G_DEFINE_TYPE_WITH_CODE (GbpHistoryEditorPageAddin, gbp_history_editor_page_addin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_PAGE_ADDIN,
                                                 editor_view_addin_iface_init))
 
 static void
-gbp_history_editor_view_addin_class_init (GbpHistoryEditorViewAddinClass *klass)
+gbp_history_editor_page_addin_class_init (GbpHistoryEditorPageAddinClass *klass)
 {
 }
 
 static void
-gbp_history_editor_view_addin_init (GbpHistoryEditorViewAddin *self)
+gbp_history_editor_page_addin_init (GbpHistoryEditorPageAddin *self)
 {
 }
diff --git a/src/plugins/history/gbp-history-editor-view-addin.h 
b/src/plugins/history/gbp-history-editor-page-addin.h
similarity index 75%
rename from src/plugins/history/gbp-history-editor-view-addin.h
rename to src/plugins/history/gbp-history-editor-page-addin.h
index 23b9e0856..494febdbb 100644
--- a/src/plugins/history/gbp-history-editor-view-addin.h
+++ b/src/plugins/history/gbp-history-editor-page-addin.h
@@ -1,4 +1,4 @@
-/* gbp-history-editor-view-addin.h
+/* gbp-history-editor-page-addin.h
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -20,12 +20,12 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-editor.h>
 
 G_BEGIN_DECLS
 
-#define GBP_TYPE_HISTORY_EDITOR_VIEW_ADDIN (gbp_history_editor_view_addin_get_type())
+#define GBP_TYPE_HISTORY_EDITOR_PAGE_ADDIN (gbp_history_editor_page_addin_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpHistoryEditorViewAddin, gbp_history_editor_view_addin, GBP, 
HISTORY_EDITOR_VIEW_ADDIN, GObject)
+G_DECLARE_FINAL_TYPE (GbpHistoryEditorPageAddin, gbp_history_editor_page_addin, GBP, 
HISTORY_EDITOR_PAGE_ADDIN, GObject)
 
 G_END_DECLS
diff --git a/src/plugins/history/gbp-history-layout-stack-addin.c 
b/src/plugins/history/gbp-history-frame-addin.c
similarity index 74%
rename from src/plugins/history/gbp-history-layout-stack-addin.c
rename to src/plugins/history/gbp-history-frame-addin.c
index 8da647ea4..a0f5fb3cc 100644
--- a/src/plugins/history/gbp-history-layout-stack-addin.c
+++ b/src/plugins/history/gbp-history-frame-addin.c
@@ -1,4 +1,4 @@
-/* gbp-history-layout-stack-addin.c
+/* gbp-history-frame-addin.c
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -18,14 +18,14 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#define G_LOG_DOMAIN "gbp-history-layout-stack-addin"
+#define G_LOG_DOMAIN "gbp-history-frame-addin"
 
-#include "gbp-history-layout-stack-addin.h"
+#include "gbp-history-frame-addin.h"
 
 #define MAX_HISTORY_ITEMS   20
 #define NEARBY_LINES_THRESH 10
 
-struct _GbpHistoryLayoutStackAddin
+struct _GbpHistoryFrameAddin
 {
   GObject         parent_instance;
 
@@ -36,17 +36,17 @@ struct _GbpHistoryLayoutStackAddin
   GtkButton      *previous_button;
   GtkButton      *next_button;
 
-  IdeLayoutStack *stack;
+  IdeFrame *stack;
 
   guint           navigating;
 };
 
 static void
-gbp_history_layout_stack_addin_update (GbpHistoryLayoutStackAddin *self)
+gbp_history_frame_addin_update (GbpHistoryFrameAddin *self)
 {
   gboolean has_items;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
 
   has_items = g_list_model_get_n_items (G_LIST_MODEL (self->back_store)) > 0;
   dzl_gtk_widget_action_set (GTK_WIDGET (self->controls),
@@ -82,24 +82,24 @@ gbp_history_layout_stack_addin_update (GbpHistoryLayoutStackAddin *self)
 }
 
 static void
-gbp_history_layout_stack_addin_navigate (GbpHistoryLayoutStackAddin *self,
+gbp_history_frame_addin_navigate (GbpHistoryFrameAddin *self,
                                          GbpHistoryItem             *item)
 {
-  g_autoptr(IdeSourceLocation) location = NULL;
+  g_autoptr(IdeLocation) location = NULL;
   GtkWidget *editor;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
   g_assert (GBP_IS_HISTORY_ITEM (item));
 
   location = gbp_history_item_get_location (item);
-  editor = gtk_widget_get_ancestor (GTK_WIDGET (self->controls), IDE_TYPE_EDITOR_PERSPECTIVE);
-  ide_editor_perspective_focus_location (IDE_EDITOR_PERSPECTIVE (editor), location);
+  editor = gtk_widget_get_ancestor (GTK_WIDGET (self->controls), IDE_TYPE_EDITOR_SURFACE);
+  ide_editor_surface_focus_location (IDE_EDITOR_SURFACE (editor), location);
 
-  gbp_history_layout_stack_addin_update (self);
+  gbp_history_frame_addin_update (self);
 }
 
 static gboolean
-item_is_nearby (IdeEditorView  *editor,
+item_is_nearby (IdeEditorPage  *editor,
                 GbpHistoryItem *item)
 {
   GtkTextIter insert;
@@ -109,13 +109,13 @@ item_is_nearby (IdeEditorView  *editor,
   gint buffer_line;
   gint item_line;
 
-  g_assert (IDE_IS_EDITOR_VIEW (editor));
+  g_assert (IDE_IS_EDITOR_PAGE (editor));
   g_assert (GBP_IS_HISTORY_ITEM (item));
 
-  buffer = ide_editor_view_get_buffer (editor);
+  buffer = ide_editor_page_get_buffer (editor);
 
   /* Make sure this is the same file */
-  buffer_file = ide_file_get_file (ide_buffer_get_file (buffer));
+  buffer_file = ide_buffer_get_file (buffer);
   item_file = gbp_history_item_get_file (item);
   if (!g_file_equal (buffer_file, item_file))
     return FALSE;
@@ -133,18 +133,18 @@ move_previous_edit_action (GSimpleAction *action,
                            GVariant      *param,
                            gpointer       user_data)
 {
-  GbpHistoryLayoutStackAddin *self = user_data;
-  IdeLayoutView *current;
+  GbpHistoryFrameAddin *self = user_data;
+  IdePage *current;
   GListModel *model;
   guint n_items;
 
   g_assert (G_IS_SIMPLE_ACTION (action));
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
   g_assert (self->stack != NULL);
 
   model = G_LIST_MODEL (self->back_store);
   n_items = g_list_model_get_n_items (model);
-  current = ide_layout_stack_get_visible_child (self->stack);
+  current = ide_frame_get_visible_child (self->stack);
 
   /*
    * The tip of the backward jumplist could be very close to
@@ -161,10 +161,10 @@ move_previous_edit_action (GSimpleAction *action,
       g_list_store_remove (self->back_store, i - 1);
       g_list_store_insert (self->forward_store, 0, item);
 
-      if (!IDE_IS_EDITOR_VIEW (current) ||
-          !item_is_nearby (IDE_EDITOR_VIEW (current), item))
+      if (!IDE_IS_EDITOR_PAGE (current) ||
+          !item_is_nearby (IDE_EDITOR_PAGE (current), item))
         {
-          gbp_history_layout_stack_addin_navigate (self, item);
+          gbp_history_frame_addin_navigate (self, item);
           break;
         }
     }
@@ -177,15 +177,15 @@ move_next_edit_action (GSimpleAction *action,
                        GVariant      *param,
                        gpointer       user_data)
 {
-  GbpHistoryLayoutStackAddin *self = user_data;
-  IdeLayoutView *current;
+  GbpHistoryFrameAddin *self = user_data;
+  IdePage *current;
   GListModel *model;
 
   g_assert (G_IS_SIMPLE_ACTION (action));
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
 
   model = G_LIST_MODEL (self->forward_store);
-  current = ide_layout_stack_get_visible_child (self->stack);
+  current = ide_frame_get_visible_child (self->stack);
 
   self->navigating++;
 
@@ -196,10 +196,10 @@ move_next_edit_action (GSimpleAction *action,
       g_list_store_remove (self->forward_store, 0);
       g_list_store_append (self->back_store, item);
 
-      if (!IDE_IS_EDITOR_VIEW (current) ||
-          !item_is_nearby (IDE_EDITOR_VIEW (current), item))
+      if (!IDE_IS_EDITOR_PAGE (current) ||
+          !item_is_nearby (IDE_EDITOR_PAGE (current), item))
         {
-          gbp_history_layout_stack_addin_navigate (self, item);
+          gbp_history_frame_addin_navigate (self, item);
           break;
         }
     }
@@ -213,15 +213,15 @@ static const GActionEntry entries[] = {
 };
 
 static void
-gbp_history_layout_stack_addin_load (IdeLayoutStackAddin *addin,
-                                     IdeLayoutStack      *stack)
+gbp_history_frame_addin_load (IdeFrameAddin *addin,
+                                     IdeFrame      *stack)
 {
-  GbpHistoryLayoutStackAddin *self = (GbpHistoryLayoutStackAddin *)addin;
+  GbpHistoryFrameAddin *self = (GbpHistoryFrameAddin *)addin;
   g_autoptr(GSimpleActionGroup) actions = NULL;
   GtkWidget *header;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (addin));
-  g_assert (IDE_IS_LAYOUT_STACK (stack));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (addin));
+  g_assert (IDE_IS_FRAME (stack));
 
   self->stack = stack;
 
@@ -234,7 +234,7 @@ gbp_history_layout_stack_addin_load (IdeLayoutStackAddin *addin,
                                   "history",
                                   G_ACTION_GROUP (actions));
 
-  header = ide_layout_stack_get_titlebar (stack);
+  header = ide_frame_get_titlebar (stack);
 
   self->controls = g_object_new (GTK_TYPE_BOX,
                                  "orientation", GTK_ORIENTATION_HORIZONTAL,
@@ -278,17 +278,17 @@ gbp_history_layout_stack_addin_load (IdeLayoutStackAddin *addin,
                     &self->next_button);
   gtk_container_add (GTK_CONTAINER (self->controls), GTK_WIDGET (self->next_button));
 
-  gbp_history_layout_stack_addin_update (self);
+  gbp_history_frame_addin_update (self);
 }
 
 static void
-gbp_history_layout_stack_addin_unload (IdeLayoutStackAddin *addin,
-                                       IdeLayoutStack      *stack)
+gbp_history_frame_addin_unload (IdeFrameAddin *addin,
+                                       IdeFrame      *stack)
 {
-  GbpHistoryLayoutStackAddin *self = (GbpHistoryLayoutStackAddin *)addin;
+  GbpHistoryFrameAddin *self = (GbpHistoryFrameAddin *)addin;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (addin));
-  g_assert (IDE_IS_LAYOUT_STACK (stack));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (addin));
+  g_assert (IDE_IS_FRAME (stack));
 
   gtk_widget_insert_action_group (GTK_WIDGET (stack), "history", NULL);
 
@@ -306,47 +306,47 @@ gbp_history_layout_stack_addin_unload (IdeLayoutStackAddin *addin,
 }
 
 static void
-gbp_history_layout_stack_addin_set_view (IdeLayoutStackAddin *addin,
-                                         IdeLayoutView       *view)
+gbp_history_frame_addin_set_view (IdeFrameAddin *addin,
+                                         IdePage       *view)
 {
-  GbpHistoryLayoutStackAddin *self = (GbpHistoryLayoutStackAddin *)addin;
+  GbpHistoryFrameAddin *self = (GbpHistoryFrameAddin *)addin;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
-  g_assert (!view || IDE_IS_LAYOUT_VIEW (view));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
+  g_assert (!view || IDE_IS_PAGE (view));
 
-  gtk_widget_set_sensitive (GTK_WIDGET (self->controls), IDE_IS_EDITOR_VIEW (view));
+  gtk_widget_set_sensitive (GTK_WIDGET (self->controls), IDE_IS_EDITOR_PAGE (view));
 }
 
 static void
-layout_stack_addin_iface_init (IdeLayoutStackAddinInterface *iface)
+frame_addin_iface_init (IdeFrameAddinInterface *iface)
 {
-  iface->load = gbp_history_layout_stack_addin_load;
-  iface->unload = gbp_history_layout_stack_addin_unload;
-  iface->set_view = gbp_history_layout_stack_addin_set_view;
+  iface->load = gbp_history_frame_addin_load;
+  iface->unload = gbp_history_frame_addin_unload;
+  iface->set_page = gbp_history_frame_addin_set_view;
 }
 
-G_DEFINE_TYPE_WITH_CODE (GbpHistoryLayoutStackAddin, gbp_history_layout_stack_addin, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (IDE_TYPE_LAYOUT_STACK_ADDIN,
-                                                layout_stack_addin_iface_init))
+G_DEFINE_TYPE_WITH_CODE (GbpHistoryFrameAddin, gbp_history_frame_addin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_FRAME_ADDIN,
+                                                frame_addin_iface_init))
 
 static void
-gbp_history_layout_stack_addin_class_init (GbpHistoryLayoutStackAddinClass *klass)
+gbp_history_frame_addin_class_init (GbpHistoryFrameAddinClass *klass)
 {
 }
 
 static void
-gbp_history_layout_stack_addin_init (GbpHistoryLayoutStackAddin *self)
+gbp_history_frame_addin_init (GbpHistoryFrameAddin *self)
 {
   self->back_store = g_list_store_new (GBP_TYPE_HISTORY_ITEM);
   self->forward_store = g_list_store_new (GBP_TYPE_HISTORY_ITEM);
 }
 
 static void
-move_forward_to_back_store (GbpHistoryLayoutStackAddin *self)
+move_forward_to_back_store (GbpHistoryFrameAddin *self)
 {
   IDE_ENTRY;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
 
   /* Be certain we're not disposed */
   if (self->forward_store == NULL || self->back_store == NULL)
@@ -365,11 +365,11 @@ move_forward_to_back_store (GbpHistoryLayoutStackAddin *self)
 }
 
 static void
-gbp_history_layout_stack_addin_remove_dups (GbpHistoryLayoutStackAddin *self)
+gbp_history_frame_addin_remove_dups (GbpHistoryFrameAddin *self)
 {
   guint n_items;
 
-  g_assert (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_assert (GBP_IS_HISTORY_FRAME_ADDIN (self));
   g_assert (self->forward_store != NULL);
   g_assert (g_list_model_get_n_items (G_LIST_MODEL (self->forward_store)) == 0);
 
@@ -410,14 +410,14 @@ gbp_history_layout_stack_addin_remove_dups (GbpHistoryLayoutStackAddin *self)
 }
 
 void
-gbp_history_layout_stack_addin_push (GbpHistoryLayoutStackAddin *self,
+gbp_history_frame_addin_push (GbpHistoryFrameAddin *self,
                                      GbpHistoryItem             *item)
 {
   guint n_items;
 
   IDE_ENTRY;
 
-  g_return_if_fail (GBP_IS_HISTORY_LAYOUT_STACK_ADDIN (self));
+  g_return_if_fail (GBP_IS_HISTORY_FRAME_ADDIN (self));
   g_return_if_fail (GBP_IS_HISTORY_ITEM (item));
   g_return_if_fail (self->back_store != NULL);
   g_return_if_fail (self->forward_store != NULL);
@@ -434,14 +434,14 @@ gbp_history_layout_stack_addin_push (GbpHistoryLayoutStackAddin *self,
   g_list_store_append (self->back_store, item);
 
   /* Now remove dups in the list */
-  gbp_history_layout_stack_addin_remove_dups (self);
+  gbp_history_frame_addin_remove_dups (self);
 
   /* Truncate from head if necessary */
   n_items = g_list_model_get_n_items (G_LIST_MODEL (self->back_store));
   if (n_items >= MAX_HISTORY_ITEMS)
     g_list_store_remove (self->back_store, 0);
 
-  gbp_history_layout_stack_addin_update (self);
+  gbp_history_frame_addin_update (self);
 
   IDE_EXIT;
 }
diff --git a/src/plugins/history/gbp-history-layout-stack-addin.h 
b/src/plugins/history/gbp-history-frame-addin.h
similarity index 66%
rename from src/plugins/history/gbp-history-layout-stack-addin.h
rename to src/plugins/history/gbp-history-frame-addin.h
index bad137bf1..f81aeedf4 100644
--- a/src/plugins/history/gbp-history-layout-stack-addin.h
+++ b/src/plugins/history/gbp-history-frame-addin.h
@@ -1,4 +1,4 @@
-/* gbp-history-layout-stack-addin.h
+/* gbp-history-frame-addin.h
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -20,17 +20,15 @@
 
 #pragma once
 
-#include <ide.h>
-
 #include "gbp-history-item.h"
 
 G_BEGIN_DECLS
 
-#define GBP_TYPE_HISTORY_LAYOUT_STACK_ADDIN (gbp_history_layout_stack_addin_get_type())
+#define GBP_TYPE_HISTORY_FRAME_ADDIN (gbp_history_frame_addin_get_type())
 
-G_DECLARE_FINAL_TYPE (GbpHistoryLayoutStackAddin, gbp_history_layout_stack_addin, GBP, 
HISTORY_LAYOUT_STACK_ADDIN, GObject)
+G_DECLARE_FINAL_TYPE (GbpHistoryFrameAddin, gbp_history_frame_addin, GBP, HISTORY_FRAME_ADDIN, GObject)
 
-void gbp_history_layout_stack_addin_push (GbpHistoryLayoutStackAddin *self,
-                                          GbpHistoryItem             *item);
+void gbp_history_frame_addin_push (GbpHistoryFrameAddin *self,
+                                   GbpHistoryItem       *item);
 
 G_END_DECLS
diff --git a/src/plugins/history/gbp-history-item.c b/src/plugins/history/gbp-history-item.c
index 5a65021ea..290bf1bc5 100644
--- a/src/plugins/history/gbp-history-item.c
+++ b/src/plugins/history/gbp-history-item.c
@@ -74,11 +74,11 @@ gbp_history_item_init (GbpHistoryItem *self)
 GbpHistoryItem *
 gbp_history_item_new (GtkTextMark *mark)
 {
-  GtkTextIter iter;
+  g_autoptr(IdeContext) context = NULL;
   GbpHistoryItem *item;
   GtkTextBuffer *buffer;
-  IdeContext *context;
-  IdeFile *file;
+  GtkTextIter iter;
+  GFile *file;
 
   g_return_val_if_fail (GTK_IS_TEXT_MARK (mark), NULL);
 
@@ -88,16 +88,16 @@ gbp_history_item_new (GtkTextMark *mark)
   item = g_object_new (GBP_TYPE_HISTORY_ITEM, NULL);
   item->mark = g_object_ref (mark);
 
-  context = ide_buffer_get_context (IDE_BUFFER (buffer));
+  context = ide_buffer_ref_context (IDE_BUFFER (buffer));
   g_set_weak_pointer (&item->context, context);
 
   gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
   item->line = gtk_text_iter_get_line (&iter);
 
   file = ide_buffer_get_file (IDE_BUFFER (buffer));
-  item->file = g_object_ref (ide_file_get_file (file));
+  item->file = g_object_ref (file);
 
-  return item;
+  return g_steal_pointer (&item);
 }
 
 gboolean
@@ -138,8 +138,8 @@ gbp_history_item_chain (GbpHistoryItem *self,
 gchar *
 gbp_history_item_get_label (GbpHistoryItem *self)
 {
+  g_autofree gchar *title = NULL;
   GtkTextBuffer *buffer;
-  const gchar *title;
   GtkTextIter iter;
   guint line;
 
@@ -153,7 +153,7 @@ gbp_history_item_get_label (GbpHistoryItem *self)
 
   gtk_text_buffer_get_iter_at_mark (buffer, &iter, self->mark);
   line = gtk_text_iter_get_line (&iter) + 1;
-  title = ide_buffer_get_title (IDE_BUFFER (buffer));
+  title = ide_buffer_dup_title (IDE_BUFFER (buffer));
 
   return g_strdup_printf ("%s <span fgcolor='32767'>%u</span>", title, line);
 }
@@ -162,13 +162,13 @@ gbp_history_item_get_label (GbpHistoryItem *self)
  * gbp_history_item_get_location:
  * @self: a #GbpHistoryItem
  *
- * Gets an #IdeSourceLocation represented by this item.
+ * Gets an #IdeLocation represented by this item.
  *
- * Returns: (transfer full): A new #IdeSourceLocation
+ * Returns: (transfer full): A new #IdeLocation
  *
  * Since: 3.32
  */
-IdeSourceLocation *
+IdeLocation *
 gbp_history_item_get_location (GbpHistoryItem *self)
 {
   GtkTextBuffer *buffer;
@@ -180,13 +180,8 @@ gbp_history_item_get_location (GbpHistoryItem *self)
   if (self->context == NULL)
     return NULL;
 
-  buffer = gtk_text_mark_get_buffer (self->mark);
-
-  if (buffer == NULL)
-    {
-      g_autoptr(IdeFile) file = ide_file_new (self->context, self->file);
-      return ide_source_location_new (file, self->line, 0, 0);
-    }
+  if (!(buffer = gtk_text_mark_get_buffer (self->mark)))
+    return ide_location_new (self->file, self->line, 0);
 
   g_return_val_if_fail (IDE_IS_BUFFER (buffer), NULL);
   gtk_text_buffer_get_iter_at_mark (buffer, &iter, self->mark);
diff --git a/src/plugins/history/gbp-history-item.h b/src/plugins/history/gbp-history-item.h
index 9c1e1d1b3..57292edf6 100644
--- a/src/plugins/history/gbp-history-item.h
+++ b/src/plugins/history/gbp-history-item.h
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-editor.h>
 
 G_BEGIN_DECLS
 
@@ -28,12 +28,12 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbpHistoryItem, gbp_history_item, GBP, HISTORY_ITEM, GObject)
 
-GbpHistoryItem    *gbp_history_item_new          (GtkTextMark    *mark);
-gchar             *gbp_history_item_get_label    (GbpHistoryItem *self);
-IdeSourceLocation *gbp_history_item_get_location (GbpHistoryItem *self);
-GFile             *gbp_history_item_get_file     (GbpHistoryItem *self);
-guint              gbp_history_item_get_line     (GbpHistoryItem *self);
-gboolean           gbp_history_item_chain        (GbpHistoryItem *self,
-                                                  GbpHistoryItem *other);
+GbpHistoryItem *gbp_history_item_new          (GtkTextMark    *mark);
+gchar          *gbp_history_item_get_label    (GbpHistoryItem *self);
+IdeLocation    *gbp_history_item_get_location (GbpHistoryItem *self);
+GFile          *gbp_history_item_get_file     (GbpHistoryItem *self);
+guint           gbp_history_item_get_line     (GbpHistoryItem *self);
+gboolean        gbp_history_item_chain        (GbpHistoryItem *self,
+                                               GbpHistoryItem *other);
 
 G_END_DECLS
diff --git a/src/plugins/history/gbp-history-plugin.c b/src/plugins/history/history-plugin.c
similarity index 67%
rename from src/plugins/history/gbp-history-plugin.c
rename to src/plugins/history/history-plugin.c
index a420c6edd..fd76bbff6 100644
--- a/src/plugins/history/gbp-history-plugin.c
+++ b/src/plugins/history/history-plugin.c
@@ -1,4 +1,4 @@
-/* gbp-history-plugin.c
+/* history-plugin.c
  *
  * Copyright 2017-2019 Christian Hergert <chergert redhat com>
  *
@@ -18,19 +18,20 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
-#include <ide.h>
+#include <libide-gui.h>
+#include <libide-editor.h>
 #include <libpeas/peas.h>
 
-#include "gbp-history-editor-view-addin.h"
-#include "gbp-history-layout-stack-addin.h"
+#include "gbp-history-editor-page-addin.h"
+#include "gbp-history-frame-addin.h"
 
-void
-gbp_history_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_history_register_types (PeasObjectModule *module)
 {
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_EDITOR_VIEW_ADDIN,
-                                              GBP_TYPE_HISTORY_EDITOR_VIEW_ADDIN);
+                                              IDE_TYPE_EDITOR_PAGE_ADDIN,
+                                              GBP_TYPE_HISTORY_EDITOR_PAGE_ADDIN);
   peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_LAYOUT_STACK_ADDIN,
-                                              GBP_TYPE_HISTORY_LAYOUT_STACK_ADDIN);
+                                              IDE_TYPE_FRAME_ADDIN,
+                                              GBP_TYPE_HISTORY_FRAME_ADDIN);
 }
diff --git a/src/plugins/history/history.gresource.xml b/src/plugins/history/history.gresource.xml
index fdb0a5e24..bb8a986b7 100644
--- a/src/plugins/history/history.gresource.xml
+++ b/src/plugins/history/history.gresource.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gnome/builder/plugins">
+  <gresource prefix="/plugins/history">
     <file>history.plugin</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/history/history.plugin b/src/plugins/history/history.plugin
index a547cbf5c..9637ae72d 100644
--- a/src/plugins/history/history.plugin
+++ b/src/plugins/history/history.plugin
@@ -1,9 +1,9 @@
 [Plugin]
-Module=history-plugin
-Name=Edit History
-Description=Tracks edits in buffer to provide navigation history
 Authors=Christian Hergert <christian hergert me>
-Copyright=Copyright © 2017 Christian Hergert
-Depends=editor
 Builtin=true
-Embedded=gbp_history_register_types
+Copyright=Copyright © 2017 Christian Hergert
+Depends=editor;
+Description=Tracks edits in buffer to provide navigation history
+Embedded=_gbp_history_register_types
+Module=history
+Name=Editor History
diff --git a/src/plugins/history/meson.build b/src/plugins/history/meson.build
index 6c58e54cb..78d5e5cc1 100644
--- a/src/plugins/history/meson.build
+++ b/src/plugins/history/meson.build
@@ -1,22 +1,14 @@
-if get_option('with_history')
+plugins_sources += files([
+  'gbp-history-editor-page-addin.c',
+  'gbp-history-frame-addin.c',
+  'gbp-history-item.c',
+  'history-plugin.c',
+])
 
-history_resources = gnome.compile_resources(
+plugin_history_resources = gnome.compile_resources(
   'history-resources',
   'history.gresource.xml',
   c_name: 'gbp_history',
 )
 
-history_sources = [
-  'gbp-history-layout-stack-addin.c',
-  'gbp-history-layout-stack-addin.h',
-  'gbp-history-editor-view-addin.c',
-  'gbp-history-editor-view-addin.h',
-  'gbp-history-item.c',
-  'gbp-history-item.h',
-  'gbp-history-plugin.c',
-]
-
-gnome_builder_plugins_sources += files(history_sources)
-gnome_builder_plugins_sources += history_resources[0]
-
-endif
+plugins_sources += plugin_history_resources[0]



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