[gnome-builder] spellcheck: add editor perspective addin



commit fba93c2845c6d3c80c43dacec324e9990517e386
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 15 18:22:57 2017 -0700

    spellcheck: add editor perspective addin
    
    This starts the process of view tracking and adding a dock
    container to the transient panel so we can later add our
    spellcheck widget and make it visible.

 plugins/spellcheck/gbp-spell-editor-addin.c |  103 +++++++++++++++++++++++++++
 plugins/spellcheck/gbp-spell-editor-addin.h |   29 ++++++++
 plugins/spellcheck/meson.build              |    2 +
 plugins/spellcheck/spellcheck-plugin.c      |    2 +
 4 files changed, 136 insertions(+), 0 deletions(-)
---
diff --git a/plugins/spellcheck/gbp-spell-editor-addin.c b/plugins/spellcheck/gbp-spell-editor-addin.c
new file mode 100644
index 0000000..b84e322
--- /dev/null
+++ b/plugins/spellcheck/gbp-spell-editor-addin.c
@@ -0,0 +1,103 @@
+/* gbp-spell-editor-addin.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 "gbp-spell-editor-addin"
+
+#include <glib/gi18n.h>
+
+#include "gbp-spell-editor-addin.h"
+
+struct _GbpSpellEditorAddin
+{
+  GObject        parent_instance;
+
+  DzlDockWidget *dock;
+};
+
+static void
+gbp_spell_editor_addin_load (IdeEditorAddin       *addin,
+                             IdeEditorPerspective *editor)
+{
+  GbpSpellEditorAddin *self = (GbpSpellEditorAddin *)addin;
+  IdeLayoutTransientSidebar *sidebar;
+
+  g_assert (GBP_IS_SPELL_EDITOR_ADDIN (self));
+  g_assert (IDE_IS_EDITOR_PERSPECTIVE (editor));
+
+  sidebar = ide_editor_perspective_get_transient_sidebar (editor);
+
+  self->dock = g_object_new (DZL_TYPE_DOCK_WIDGET,
+                             "title", _("Spelling"),
+                             "icon-name", "tools-check-spelling-symbolic",
+                             "visible", TRUE,
+                             NULL);
+  g_signal_connect (self->dock,
+                    "destroy",
+                    G_CALLBACK (gtk_widget_destroyed),
+                    &self->dock);
+  gtk_container_add (GTK_CONTAINER (sidebar), GTK_WIDGET (self->dock));
+}
+
+static void
+gbp_spell_editor_addin_unload (IdeEditorAddin       *addin,
+                               IdeEditorPerspective *editor)
+{
+  GbpSpellEditorAddin *self = (GbpSpellEditorAddin *)addin;
+
+  g_assert (GBP_IS_SPELL_EDITOR_ADDIN (self));
+  g_assert (IDE_IS_EDITOR_PERSPECTIVE (editor));
+
+  if (self->dock != NULL)
+    gtk_widget_destroy (GTK_WIDGET (self->dock));
+}
+
+static void
+gbp_spell_editor_addin_view_set (IdeEditorAddin *addin,
+                                 IdeLayoutView  *view)
+{
+  GbpSpellEditorAddin *self = (GbpSpellEditorAddin *)addin;
+
+  g_assert (GBP_IS_SPELL_EDITOR_ADDIN (self));
+  g_assert (!view || IDE_IS_LAYOUT_VIEW (view));
+
+  if (!IDE_IS_EDITOR_VIEW (view))
+    view = NULL;
+
+
+}
+
+static void
+editor_addin_iface_init (IdeEditorAddinInterface *iface)
+{
+  iface->load = gbp_spell_editor_addin_load;
+  iface->unload = gbp_spell_editor_addin_unload;
+  iface->view_set = gbp_spell_editor_addin_view_set;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GbpSpellEditorAddin, gbp_spell_editor_addin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_EDITOR_ADDIN, editor_addin_iface_init))
+
+static void
+gbp_spell_editor_addin_class_init (GbpSpellEditorAddinClass *klass)
+{
+}
+
+static void
+gbp_spell_editor_addin_init (GbpSpellEditorAddin *self)
+{
+}
diff --git a/plugins/spellcheck/gbp-spell-editor-addin.h b/plugins/spellcheck/gbp-spell-editor-addin.h
new file mode 100644
index 0000000..58ca5a0
--- /dev/null
+++ b/plugins/spellcheck/gbp-spell-editor-addin.h
@@ -0,0 +1,29 @@
+/* gbp-spell-editor-addin.h
+ *
+ * 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/>.
+ */
+
+#pragma once
+
+#include <ide.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_SPELL_EDITOR_ADDIN (gbp_spell_editor_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpSpellEditorAddin, gbp_spell_editor_addin, GBP, SPELL_EDITOR_ADDIN, GObject)
+
+G_END_DECLS
diff --git a/plugins/spellcheck/meson.build b/plugins/spellcheck/meson.build
index 28b241d..91ce6e0 100644
--- a/plugins/spellcheck/meson.build
+++ b/plugins/spellcheck/meson.build
@@ -10,6 +10,8 @@ spellcheck_sources = [
   'spellcheck-plugin.c',
   'gbp-spell-buffer-addin.c',
   'gbp-spell-buffer-addin.h',
+  'gbp-spell-editor-addin.c',
+  'gbp-spell-editor-addin.h',
   'gbp-spell-editor-view-addin.c',
   'gbp-spell-editor-view-addin.h',
   spellcheck_resources[0],
diff --git a/plugins/spellcheck/spellcheck-plugin.c b/plugins/spellcheck/spellcheck-plugin.c
index ef17e74..5b42da4 100644
--- a/plugins/spellcheck/spellcheck-plugin.c
+++ b/plugins/spellcheck/spellcheck-plugin.c
@@ -20,11 +20,13 @@
 #include <ide.h>
 
 #include "gbp-spell-buffer-addin.h"
+#include "gbp-spell-editor-addin.h"
 #include "gbp-spell-editor-view-addin.h"
 
 void
 peas_register_types (PeasObjectModule *module)
 {
   peas_object_module_register_extension_type (module, IDE_TYPE_BUFFER_ADDIN, GBP_TYPE_SPELL_BUFFER_ADDIN);
+  peas_object_module_register_extension_type (module, IDE_TYPE_EDITOR_ADDIN, GBP_TYPE_SPELL_EDITOR_ADDIN);
   peas_object_module_register_extension_type (module, IDE_TYPE_EDITOR_VIEW_ADDIN, 
GBP_TYPE_SPELL_EDITOR_VIEW_ADDIN);
 }


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