[gnome-builder: 118/139] retab: port to libide-editor
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 118/139] retab: port to libide-editor
- Date: Thu, 10 Jan 2019 04:27:14 +0000 (UTC)
commit 7936f836eb84b09382a223c2a1a2851c675e6a82
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 9 17:36:36 2019 -0800
retab: port to libide-editor
...-view-addin.c => gbp-retab-editor-page-addin.c} | 69 +++++++++++-----------
...-view-addin.h => gbp-retab-editor-page-addin.h} | 6 +-
src/plugins/retab/meson.build | 20 +++----
.../retab/{gbp-retab-plugin.c => retab-plugin.c} | 18 +++---
src/plugins/retab/retab.gresource.xml | 6 +-
src/plugins/retab/retab.plugin | 11 ++--
6 files changed, 66 insertions(+), 64 deletions(-)
---
diff --git a/src/plugins/retab/gbp-retab-view-addin.c b/src/plugins/retab/gbp-retab-editor-page-addin.c
similarity index 76%
rename from src/plugins/retab/gbp-retab-view-addin.c
rename to src/plugins/retab/gbp-retab-editor-page-addin.c
index 507c3175b..49c496d7b 100644
--- a/src/plugins/retab/gbp-retab-view-addin.c
+++ b/src/plugins/retab/gbp-retab-editor-page-addin.c
@@ -1,5 +1,5 @@
-/* gbp-retab-view-addin.c
+/* gbp-retab-editor-page-addin.c
*
* Copyright 2017 Lucie Charvat <luci charvat gmail com>
*
@@ -19,19 +19,20 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#include <glib.h>
+#define G_LOG_DOMAIN "gbp-retab-editor-page-addin"
+
+#include "config.h"
+
#include <glib/gi18n.h>
#include <gtksourceview/gtksource.h>
-#include <ide.h>
-
-#include "sourceview/ide-text-iter.h"
+#include <libide-editor.h>
-#include "gbp-retab-view-addin.h"
+#include "gbp-retab-editor-page-addin.h"
-struct _GbpRetabViewAddin
+struct _GbpRetabEditorPageAddin
{
GObject parent_instance;
- IdeEditorView *editor_view;
+ IdeEditorPage *editor_view;
};
static gint
@@ -56,7 +57,7 @@ get_buffer_range_indent (GtkTextBuffer *buffer,
/* Removes indent that is mean to be changes and inserts
* tabs and/or spaces insted */
static void
-gbp_retab_view_addin_retab (GtkTextBuffer *buffer,
+gbp_retab_editor_page_addin_retab (GtkTextBuffer *buffer,
gint line,
gint tab_width,
gint indent,
@@ -113,11 +114,11 @@ gbp_retab_view_addin_retab (GtkTextBuffer *buffer,
}
static void
-gbp_retab_view_addin_action (GSimpleAction *action,
+gbp_retab_editor_page_addin_action (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
- GbpRetabViewAddin *self = user_data;
+ GbpRetabEditorPageAddin *self = user_data;
IdeSourceView *source_view;
GtkTextBuffer *buffer;
IdeCompletion *completion;
@@ -130,11 +131,11 @@ gbp_retab_view_addin_action (GSimpleAction *action,
gboolean editable;
gboolean to_spaces;
- g_assert (GBP_IS_RETAB_VIEW_ADDIN (self));
+ g_assert (GBP_IS_RETAB_EDITOR_PAGE_ADDIN (self));
g_assert (G_IS_SIMPLE_ACTION (action));
- buffer = GTK_TEXT_BUFFER (ide_editor_view_get_buffer (self->editor_view));
- source_view = ide_editor_view_get_view (self->editor_view);
+ buffer = GTK_TEXT_BUFFER (ide_editor_page_get_buffer (self->editor_view));
+ source_view = ide_editor_page_get_view (self->editor_view);
g_assert (IDE_IS_SOURCE_VIEW (source_view));
@@ -162,7 +163,7 @@ gbp_retab_view_addin_action (GSimpleAction *action,
{
indent = get_buffer_range_indent (buffer, line, to_spaces);
if (indent > 0)
- gbp_retab_view_addin_retab (buffer, line, tab_width, indent, to_spaces);
+ gbp_retab_editor_page_addin_retab (buffer, line, tab_width, indent, to_spaces);
}
gtk_text_buffer_end_user_action (buffer);
@@ -170,56 +171,56 @@ gbp_retab_view_addin_action (GSimpleAction *action,
}
static const GActionEntry actions[] = {
- { "retab", gbp_retab_view_addin_action },
+ { "retab", gbp_retab_editor_page_addin_action },
};
static void
-gbp_retab_view_addin_load (IdeEditorViewAddin *addin,
- IdeEditorView *view)
+gbp_retab_editor_page_addin_load (IdeEditorPageAddin *addin,
+ IdeEditorPage *view)
{
- GbpRetabViewAddin *self = (GbpRetabViewAddin *)addin;
+ GbpRetabEditorPageAddin *self = (GbpRetabEditorPageAddin *)addin;
GActionGroup *group;
- g_assert (GBP_IS_RETAB_VIEW_ADDIN (addin));
- g_assert (IDE_IS_EDITOR_VIEW (view));
+ g_assert (GBP_IS_RETAB_EDITOR_PAGE_ADDIN (addin));
+ g_assert (IDE_IS_EDITOR_PAGE (view));
self->editor_view = view;
- group = gtk_widget_get_action_group (GTK_WIDGET (view), "editor-view");
+ group = gtk_widget_get_action_group (GTK_WIDGET (view), "editor-page");
g_action_map_add_action_entries (G_ACTION_MAP (group), actions, G_N_ELEMENTS (actions), self);
}
static void
-gbp_retab_view_addin_unload (IdeEditorViewAddin *addin,
- IdeEditorView *view)
+gbp_retab_editor_page_addin_unload (IdeEditorPageAddin *addin,
+ IdeEditorPage *view)
{
GActionGroup *group;
- g_assert (GBP_IS_RETAB_VIEW_ADDIN (addin));
- g_assert (IDE_IS_EDITOR_VIEW (view));
+ g_assert (GBP_IS_RETAB_EDITOR_PAGE_ADDIN (addin));
+ g_assert (IDE_IS_EDITOR_PAGE (view));
- group = gtk_widget_get_action_group (GTK_WIDGET (view), "editor-view");
+ group = gtk_widget_get_action_group (GTK_WIDGET (view), "editor-page");
g_action_map_remove_action (G_ACTION_MAP (group), "retab");
}
static void
-editor_view_addin_iface_init (IdeEditorViewAddinInterface *iface)
+editor_view_addin_iface_init (IdeEditorPageAddinInterface *iface)
{
- iface->load = gbp_retab_view_addin_load;
- iface->unload = gbp_retab_view_addin_unload;
+ iface->load = gbp_retab_editor_page_addin_load;
+ iface->unload = gbp_retab_editor_page_addin_unload;
}
-G_DEFINE_TYPE_WITH_CODE (GbpRetabViewAddin, gbp_retab_view_addin, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_VIEW_ADDIN,
+G_DEFINE_TYPE_WITH_CODE (GbpRetabEditorPageAddin, gbp_retab_editor_page_addin, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_PAGE_ADDIN,
editor_view_addin_iface_init))
static void
-gbp_retab_view_addin_class_init (GbpRetabViewAddinClass *klass)
+gbp_retab_editor_page_addin_class_init (GbpRetabEditorPageAddinClass *klass)
{
}
static void
-gbp_retab_view_addin_init (GbpRetabViewAddin *self)
+gbp_retab_editor_page_addin_init (GbpRetabEditorPageAddin *self)
{
}
diff --git a/src/plugins/retab/gbp-retab-view-addin.h b/src/plugins/retab/gbp-retab-editor-page-addin.h
similarity index 77%
rename from src/plugins/retab/gbp-retab-view-addin.h
rename to src/plugins/retab/gbp-retab-editor-page-addin.h
index a798bc56e..9cb6073bc 100644
--- a/src/plugins/retab/gbp-retab-view-addin.h
+++ b/src/plugins/retab/gbp-retab-editor-page-addin.h
@@ -1,4 +1,4 @@
-/* gbp-retab-view-addin.h
+/* gbp-retab-editor-page-addin.h
*
* Copyright 2017 Lucie Charvat <luci charvat gmail com>
*
@@ -22,8 +22,8 @@
G_BEGIN_DECLS
-#define GBP_TYPE_RETAB_VIEW_ADDIN (gbp_retab_view_addin_get_type())
+#define GBP_TYPE_RETAB_EDITOR_PAGE_ADDIN (gbp_retab_editor_page_addin_get_type())
-G_DECLARE_FINAL_TYPE (GbpRetabViewAddin, gbp_retab_view_addin, GBP, RETAB_VIEW_ADDIN, GObject)
+G_DECLARE_FINAL_TYPE (GbpRetabEditorPageAddin, gbp_retab_editor_page_addin, GBP, RETAB_EDITOR_PAGE_ADDIN,
GObject)
G_END_DECLS
diff --git a/src/plugins/retab/meson.build b/src/plugins/retab/meson.build
index c0b61aa49..ecb8e9476 100644
--- a/src/plugins/retab/meson.build
+++ b/src/plugins/retab/meson.build
@@ -1,18 +1,16 @@
-if get_option('with_retab')
+if get_option('plugin_retab')
-retab_resources = gnome.compile_resources(
- 'gbp-retab-resources',
+plugins_sources += files([
+ 'retab-plugin.c',
+ 'gbp-retab-editor-page-addin.c',
+])
+
+plugin_retab_resources = gnome.compile_resources(
+ 'retab-resources',
'retab.gresource.xml',
c_name: 'gbp_retab',
)
-retab_sources = [
- 'gbp-retab-plugin.c',
- 'gbp-retab-view-addin.c',
- 'gbp-retab-view-addin.h',
-]
-
-gnome_builder_plugins_sources += files(retab_sources)
-gnome_builder_plugins_sources += retab_resources[0]
+plugins_sources += plugin_retab_resources[0]
endif
diff --git a/src/plugins/retab/gbp-retab-plugin.c b/src/plugins/retab/retab-plugin.c
similarity index 69%
rename from src/plugins/retab/gbp-retab-plugin.c
rename to src/plugins/retab/retab-plugin.c
index df54849fd..eb79d16af 100644
--- a/src/plugins/retab/gbp-retab-plugin.c
+++ b/src/plugins/retab/retab-plugin.c
@@ -1,4 +1,4 @@
-/* gbp-retab-plugin.c
+/* retab-plugin.c
*
* Copyright 2017 Lucie Charvat <luci charvat gmail com>
*
@@ -18,15 +18,19 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-#include <ide.h>
+#define G_LOG_DOMAIN "retab-plugin"
+
+#include "config.h"
+
+#include <libide-editor.h>
#include <libpeas/peas.h>
-#include "gbp-retab-view-addin.h"
+#include "gbp-retab-editor-page-addin.h"
-void
-gbp_retab_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_gbp_retab_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
- IDE_TYPE_EDITOR_VIEW_ADDIN,
- GBP_TYPE_RETAB_VIEW_ADDIN);
+ IDE_TYPE_EDITOR_PAGE_ADDIN,
+ GBP_TYPE_RETAB_EDITOR_PAGE_ADDIN);
}
diff --git a/src/plugins/retab/retab.gresource.xml b/src/plugins/retab/retab.gresource.xml
index c0b78703d..ddfd8d045 100644
--- a/src/plugins/retab/retab.gresource.xml
+++ b/src/plugins/retab/retab.gresource.xml
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/builder/plugins">
+ <gresource prefix="/plugins/retab">
<file>retab.plugin</file>
- </gresource>
- <gresource prefix="/org/gnome/builder/plugins/retab-plugin">
- <file>gtk/menus.ui</file>
+ <file preprocess="xml-stripblanks">gtk/menus.ui</file>
</gresource>
</gresources>
diff --git a/src/plugins/retab/retab.plugin b/src/plugins/retab/retab.plugin
index 5e9f1cfd5..c7bc1aa42 100644
--- a/src/plugins/retab/retab.plugin
+++ b/src/plugins/retab/retab.plugin
@@ -1,9 +1,10 @@
[Plugin]
-Module=retab-plugin
-Name=Retab
-Description=Retab lines with Builder editor.
Authors=Lucie Charvat <luci charvat gmail com>
-Copyright=Copyright © 2017 Lucie Charvat
Builtin=true
+Copyright=Copyright © 2017 Lucie Charvat
Depends=editor
-Embedded=gbp_retab_register_types
+Description=Retab lines with Builder editor.
+Embedded=_gbp_retab_register_types
+Hidden=true
+Module=retab
+Name=Retab
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]