[gnome-builder] devhelp: start porting to IdeWorkbench



commit 71b72644de22c555766cba0445bf14fc998c650e
Author: Christian Hergert <chergert redhat com>
Date:   Thu Nov 19 03:40:25 2015 -0800

    devhelp: start porting to IdeWorkbench

 plugins/devhelp/Makefile.am                        |   39 ++--
 plugins/devhelp/devhelp.plugin                     |    4 +-
 plugins/devhelp/gb-devhelp-document.c              |  277 ------------------
 plugins/devhelp/gb-devhelp-document.h              |   39 ---
 plugins/devhelp/gb-devhelp-panel.c                 |  302 --------------------
 plugins/devhelp/gb-devhelp-plugin.c                |   39 ---
 plugins/devhelp/gb-devhelp-search-provider.c       |  242 ----------------
 plugins/devhelp/gb-devhelp-search-provider.h       |   34 ---
 plugins/devhelp/gb-devhelp-search-result.c         |  110 -------
 plugins/devhelp/gb-devhelp-view.c                  |  287 -------------------
 plugins/devhelp/gbp-devhelp-panel.c                |  170 +++++++++++
 .../{gb-devhelp-private.h => gbp-devhelp-panel.h}  |   17 +-
 ...evhelp-search-result.h => gbp-devhelp-plugin.c} |   27 +-
 ...rce.xml => gbp-devhelp-resources.gresource.xml} |    2 +-
 plugins/devhelp/gbp-devhelp-view.c                 |  106 +++++++
 .../{gb-devhelp-panel.h => gbp-devhelp-view.h}     |   18 +-
 .../{gb-devhelp-view.ui => gbp-devhelp-view.ui}    |    4 +-
 plugins/devhelp/gbp-devhelp-workbench-addin.c      |   96 ++++++
 ...evhelp-view.h => gbp-devhelp-workbench-addin.h} |   19 +-
 19 files changed, 433 insertions(+), 1399 deletions(-)
---
diff --git a/plugins/devhelp/Makefile.am b/plugins/devhelp/Makefile.am
index 5a8ac12..cf116f8 100644
--- a/plugins/devhelp/Makefile.am
+++ b/plugins/devhelp/Makefile.am
@@ -10,42 +10,39 @@ plugin_LTLIBRARIES = libdevhelp-plugin.la
 dist_plugin_DATA = devhelp.plugin
 
 libdevhelp_plugin_la_SOURCES = \
-       gb-devhelp-document.c \
-       gb-devhelp-document.h \
-       gb-devhelp-panel.c \
-       gb-devhelp-panel.h \
-       gb-devhelp-plugin.c \
-       gb-devhelp-private.h \
-       gb-devhelp-resources.c \
-       gb-devhelp-resources.h \
-       gb-devhelp-search-provider.c \
-       gb-devhelp-search-provider.h \
-       gb-devhelp-search-result.c \
-       gb-devhelp-search-result.h \
-       gb-devhelp-view.c \
-       gb-devhelp-view.h \
+       gbp-devhelp-panel.c \
+       gbp-devhelp-panel.h \
+       gbp-devhelp-plugin.c \
+       gbp-devhelp-view.c \
+       gbp-devhelp-view.h \
+       gbp-devhelp-workbench-addin.c \
+       gbp-devhelp-workbench-addin.h \
        $(NULL)
 
+nodist_libdevhelp_plugin_la_SOURCES = \
+       gbp-devhelp-resources.c \
+       gbp-devhelp-resources.h
+
 libdevhelp_plugin_la_CFLAGS = \
        $(LIBIDE_CFLAGS) \
        $(DEVHELP_CFLAGS) \
+       $(OPTIMIZE_CFLAGS) \
        -I$(top_srcdir)/libide \
        $(NULL)
 
-libdevhelp_plugin_la_LIBADD = \
-       $(DEVHELP_LIBS) \
-       $(NULL)
+libdevhelp_plugin_la_LIBADD = $(DEVHELP_LIBS)
 
 libdevhelp_plugin_la_LDFLAGS = \
        $(OPTIMIZE_LDFLAGS) \
        -avoid-version \
        -module \
+       -export-regex peas_register_types \
        $(NULL)
 
-glib_resources_c = gb-devhelp-resources.c
-glib_resources_h = gb-devhelp-resources.h
-glib_resources_xml = gb-devhelp.gresource.xml
-glib_resources_namespace = gb_devhelp
+glib_resources_c = gbp-devhelp-resources.c
+glib_resources_h = gbp-devhelp-resources.h
+glib_resources_xml = gbp-devhelp-resources.gresource.xml
+glib_resources_namespace = gbp_devhelp
 include $(top_srcdir)/build/autotools/Makefile.am.gresources
 
 include $(top_srcdir)/plugins/Makefile.plugin
diff --git a/plugins/devhelp/devhelp.plugin b/plugins/devhelp/devhelp.plugin
index 6b53376..bed5eb8 100644
--- a/plugins/devhelp/devhelp.plugin
+++ b/plugins/devhelp/devhelp.plugin
@@ -1,8 +1,8 @@
 [Plugin]
 Module=devhelp-plugin
 Name=Devhelp
-Description=Provides devhelp documentation
+Description=Integration with devhelp documentation
 Authors=Christian Hergert <christian hergert me>
 Copyright=Copyright © 2015 Christian Hergert
+Depends=editor
 Builtin=true
-Hidden=true
diff --git a/plugins/devhelp/gbp-devhelp-panel.c b/plugins/devhelp/gbp-devhelp-panel.c
new file mode 100644
index 0000000..39fa0c5
--- /dev/null
+++ b/plugins/devhelp/gbp-devhelp-panel.c
@@ -0,0 +1,170 @@
+/* gbp-devhelp-panel.c
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#include <devhelp/devhelp.h>
+#include <ide.h>
+
+#include "gbp-devhelp-panel.h"
+#include "gbp-devhelp-view.h"
+
+struct _GbpDevhelpPanel
+{
+  GtkBin         parent_instance;
+  DhBookManager *books;
+  DhSidebar     *sidebar;
+};
+
+G_DEFINE_TYPE (GbpDevhelpPanel, gbp_devhelp_panel, GTK_TYPE_BIN)
+
+enum {
+  PROP_0,
+  PROP_BOOK_MANAGER,
+  LAST_PROP
+};
+
+static GParamSpec *properties [LAST_PROP];
+
+static void
+fixup_box_border_width (GtkWidget *widget,
+                        gpointer   user_data)
+{
+  if (GTK_IS_BOX (widget))
+    gtk_container_set_border_width (GTK_CONTAINER (widget), 0);
+}
+
+static void
+gbp_devhelp_panel_find_view (GtkWidget *widget,
+                             gpointer   user_data)
+{
+  GbpDevhelpView **view = user_data;
+
+  if (*view != NULL)
+    return;
+
+  if (GBP_IS_DEVHELP_VIEW (widget))
+    *view = GBP_DEVHELP_VIEW (widget);
+}
+
+static void
+gbp_devhelp_panel_link_selected (GbpDevhelpPanel *self,
+                                 DhLink          *link,
+                                 DhSidebar       *sidebar)
+{
+  GbpDevhelpView *view = NULL;
+  IdePerspective *perspective;
+  IdeWorkbench *workbench;
+  gchar *uri;
+
+  g_assert (GBP_IS_DEVHELP_PANEL (self));
+  g_assert (link != NULL);
+  g_assert (DH_IS_SIDEBAR (sidebar));
+
+  workbench = ide_widget_get_workbench (GTK_WIDGET (self));
+  g_assert (IDE_IS_WORKBENCH (workbench));
+
+  perspective = ide_workbench_get_perspective_by_name (workbench, "editor");
+  g_assert (IDE_IS_LAYOUT (perspective));
+
+  ide_perspective_views_foreach (perspective, gbp_devhelp_panel_find_view, &view);
+
+  if (view == NULL)
+    {
+      view = g_object_new (GBP_TYPE_DEVHELP_VIEW,
+                           "visible", TRUE,
+                           NULL);
+      gtk_container_add (GTK_CONTAINER (perspective), GTK_WIDGET (view));
+    }
+
+  uri = dh_link_get_uri (link);
+  gbp_devhelp_view_set_uri (view, uri);
+  g_free (uri);
+}
+
+static void
+gbp_devhelp_panel_constructed (GObject *object)
+{
+  GbpDevhelpPanel *self = (GbpDevhelpPanel *)object;
+
+  G_OBJECT_CLASS (gbp_devhelp_panel_parent_class)->constructed (object);
+
+  g_assert (self->books != NULL);
+
+  self->sidebar = DH_SIDEBAR (dh_sidebar_new (self->books));
+  gtk_container_foreach (GTK_CONTAINER (self->sidebar), fixup_box_border_width, NULL);
+  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->sidebar));
+  gtk_widget_show (GTK_WIDGET (self->sidebar));
+
+  g_signal_connect_object (self->sidebar,
+                           "link-selected",
+                           G_CALLBACK (gbp_devhelp_panel_link_selected),
+                           self,
+                           G_CONNECT_SWAPPED);
+}
+
+static void
+gbp_devhelp_panel_finalize (GObject *object)
+{
+  GbpDevhelpPanel *self = (GbpDevhelpPanel *)object;
+
+  g_clear_object (&self->books);
+
+  G_OBJECT_CLASS (gbp_devhelp_panel_parent_class)->finalize (object);
+}
+
+static void
+gbp_devhelp_panel_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  GbpDevhelpPanel *self = GBP_DEVHELP_PANEL(object);
+
+  switch (prop_id)
+    {
+    case PROP_BOOK_MANAGER:
+      self->books = g_value_dup_object (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_devhelp_panel_class_init (GbpDevhelpPanelClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->constructed = gbp_devhelp_panel_constructed;
+  object_class->finalize = gbp_devhelp_panel_finalize;
+  object_class->set_property = gbp_devhelp_panel_set_property;
+
+  properties [PROP_BOOK_MANAGER] =
+    g_param_spec_object ("book-manager",
+                         "Book Manager",
+                         "Book Manager",
+                         DH_TYPE_BOOK_MANAGER,
+                         (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, LAST_PROP, properties);
+}
+
+static void
+gbp_devhelp_panel_init (GbpDevhelpPanel *self)
+{
+}
diff --git a/plugins/devhelp/gb-devhelp-private.h b/plugins/devhelp/gbp-devhelp-panel.h
similarity index 66%
rename from plugins/devhelp/gb-devhelp-private.h
rename to plugins/devhelp/gbp-devhelp-panel.h
index 6339db1..858a3ef 100644
--- a/plugins/devhelp/gb-devhelp-private.h
+++ b/plugins/devhelp/gbp-devhelp-panel.h
@@ -1,6 +1,6 @@
-/* gb-devhelp-private.h
+/* gbp-devhelp-panel.h
  *
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * Copyright (C) 2015 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,17 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GB_DEVHELP_PRIVATE_H
-#define GB_DEVHELP_PRIVATE_H
+#ifndef GBP_DEVHELP_PANEL_H
+#define GBP_DEVHELP_PANEL_H
 
-#include <glib-object.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
-void _gb_devhelp_panel_register_type           (GTypeModule *module);
-void _gb_devhelp_search_provider_register_type (GTypeModule *module);
+#define GBP_TYPE_DEVHELP_PANEL (gbp_devhelp_panel_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpDevhelpPanel, gbp_devhelp_panel, GBP, DEVHELP_PANEL, GtkBin)
 
 G_END_DECLS
 
-#endif /* GB_DEVHELP_PRIVATE_H */
+#endif /* GBP_DEVHELP_PANEL_H */
diff --git a/plugins/devhelp/gb-devhelp-search-result.h b/plugins/devhelp/gbp-devhelp-plugin.c
similarity index 58%
rename from plugins/devhelp/gb-devhelp-search-result.h
rename to plugins/devhelp/gbp-devhelp-plugin.c
index fea8f23..60f9add 100644
--- a/plugins/devhelp/gb-devhelp-search-result.h
+++ b/plugins/devhelp/gbp-devhelp-plugin.c
@@ -1,6 +1,6 @@
-/* gb-devhelp-search-result.h
+/* gbp-devhelp-plugin.c
  *
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * Copyright (C) 2015 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,18 +16,15 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GB_DEVHELP_SEARCH_RESULT_H
-#define GB_DEVHELP_SEARCH_RESULT_H
+#include <ide.h>
+#include <libpeas/peas.h>
 
-#include "ide-search-result.h"
+#include "gbp-devhelp-workbench-addin.h"
 
-G_BEGIN_DECLS
-
-#define GB_TYPE_DEVHELP_SEARCH_RESULT (gb_devhelp_search_result_get_type())
-
-G_DECLARE_FINAL_TYPE (GbDevhelpSearchResult, gb_devhelp_search_result,
-                      GB, DEVHELP_SEARCH_RESULT, IdeSearchResult)
-
-G_END_DECLS
-
-#endif /* GB_DEVHELP_SEARCH_RESULT_H */
+void
+peas_register_types (PeasObjectModule *module)
+{
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_WORKBENCH_ADDIN,
+                                              GBP_TYPE_DEVHELP_WORKBENCH_ADDIN);
+}
diff --git a/plugins/devhelp/gb-devhelp.gresource.xml b/plugins/devhelp/gbp-devhelp-resources.gresource.xml
similarity index 78%
rename from plugins/devhelp/gb-devhelp.gresource.xml
rename to plugins/devhelp/gbp-devhelp-resources.gresource.xml
index 8a90838..b430988 100644
--- a/plugins/devhelp/gb-devhelp.gresource.xml
+++ b/plugins/devhelp/gbp-devhelp-resources.gresource.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/builder/plugins/devhelp">
-    <file>gb-devhelp-view.ui</file>
+    <file>gbp-devhelp-view.ui</file>
   </gresource>
 </gresources>
diff --git a/plugins/devhelp/gbp-devhelp-view.c b/plugins/devhelp/gbp-devhelp-view.c
new file mode 100644
index 0000000..27b54ae
--- /dev/null
+++ b/plugins/devhelp/gbp-devhelp-view.c
@@ -0,0 +1,106 @@
+/* gbp-devhelp-view.c
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#include <devhelp/devhelp.h>
+#include <glib/gi18n.h>
+#include <webkit2/webkit2.h>
+
+#include "gbp-devhelp-view.h"
+
+struct _GbpDevhelpView
+{
+  IdeLayoutView  parent_instance;
+  WebKitWebView *web_view1;
+};
+
+enum {
+  PROP_0,
+  PROP_URI,
+  LAST_PROP
+};
+
+G_DEFINE_TYPE (GbpDevhelpView, gbp_devhelp_view, IDE_TYPE_LAYOUT_VIEW)
+
+static GParamSpec *properties [LAST_PROP];
+
+void
+gbp_devhelp_view_set_uri (GbpDevhelpView *self,
+                          const gchar    *uri)
+{
+  g_return_if_fail (GBP_IS_DEVHELP_VIEW (self));
+
+  if (uri == NULL)
+    return;
+
+  webkit_web_view_load_uri (self->web_view1, uri);
+}
+
+static void
+gbp_devhelp_view_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gbp_devhelp_view_parent_class)->finalize (object);
+}
+
+static void
+gbp_devhelp_view_set_property (GObject      *object,
+                               guint         prop_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  GbpDevhelpView *self = GBP_DEVHELP_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_URI:
+      gbp_devhelp_view_set_uri (self, g_value_get_string (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gbp_devhelp_view_class_init (GbpDevhelpViewClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->finalize = gbp_devhelp_view_finalize;
+  object_class->set_property = gbp_devhelp_view_set_property;
+
+  properties [PROP_URI] =
+    g_param_spec_string ("uri",
+                         "Uri",
+                         "The uri of the documentation.",
+                         NULL,
+                         (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, LAST_PROP, properties);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/devhelp/gbp-devhelp-view.ui");
+  gtk_widget_class_bind_template_child (widget_class, GbpDevhelpView, web_view1);
+
+  g_type_ensure (WEBKIT_TYPE_WEB_VIEW);
+}
+
+static void
+gbp_devhelp_view_init (GbpDevhelpView *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/plugins/devhelp/gb-devhelp-panel.h b/plugins/devhelp/gbp-devhelp-view.h
similarity index 65%
rename from plugins/devhelp/gb-devhelp-panel.h
rename to plugins/devhelp/gbp-devhelp-view.h
index 7ad228c..b57f775 100644
--- a/plugins/devhelp/gb-devhelp-panel.h
+++ b/plugins/devhelp/gbp-devhelp-view.h
@@ -1,6 +1,6 @@
-/* gb-devhelp-panel.h
+/* gbp-devhelp-view.h
  *
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * Copyright (C) 2015 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,20 +16,20 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GB_DEVHELP_PANEL_H
-#define GB_DEVHELP_PANEL_H
+#ifndef GBP_DEVHELP_VIEW_H
+#define GBP_DEVHELP_VIEW_H
 
-#include <gtk/gtk.h>
+#include <ide.h>
 
 G_BEGIN_DECLS
 
-#define GB_TYPE_DEVHELP_PANEL (gb_devhelp_panel_get_type())
+#define GBP_TYPE_DEVHELP_VIEW (gbp_devhelp_view_get_type())
 
-G_DECLARE_FINAL_TYPE (GbDevhelpPanel, gb_devhelp_panel, GB, DEVHELP_PANEL, GtkBin)
+G_DECLARE_FINAL_TYPE (GbpDevhelpView, gbp_devhelp_view, GBP, DEVHELP_VIEW, IdeLayoutView)
 
-void gb_devhelp_panel_set_uri (GbDevhelpPanel *self,
+void gbp_devhelp_view_set_uri (GbpDevhelpView *self,
                                const gchar    *uri);
 
 G_END_DECLS
 
-#endif /* GB_DEVHELP_PANEL_H */
+#endif /* GBP_DEVHELP_VIEW_H */
diff --git a/plugins/devhelp/gb-devhelp-view.ui b/plugins/devhelp/gbp-devhelp-view.ui
similarity index 89%
rename from plugins/devhelp/gb-devhelp-view.ui
rename to plugins/devhelp/gbp-devhelp-view.ui
index 837a950..5e98379 100644
--- a/plugins/devhelp/gb-devhelp-view.ui
+++ b/plugins/devhelp/gbp-devhelp-view.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 3.14 -->
-  <template class="GbDevhelpView" parent="GbView">
+  <!-- interface-requires gtk+ 3.18 -->
+  <template class="GbpDevhelpView" parent="IdeLayoutView">
     <child internal-child="controls">
       <object class="GtkBox">
         <property name="visible">true</property>
diff --git a/plugins/devhelp/gbp-devhelp-workbench-addin.c b/plugins/devhelp/gbp-devhelp-workbench-addin.c
new file mode 100644
index 0000000..08d1f21
--- /dev/null
+++ b/plugins/devhelp/gbp-devhelp-workbench-addin.c
@@ -0,0 +1,96 @@
+/* gbp-devhelp-workbench-addin.c
+ *
+ * Copyright (C) 2015 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 "devhelp-plugin"
+
+#include <devhelp/devhelp.h>
+#include <glib/gi18n.h>
+#include <ide.h>
+
+#include "gbp-devhelp-panel.h"
+#include "gbp-devhelp-workbench-addin.h"
+
+struct _GbpDevhelpWorkbenchAddin
+{
+  GObject          parent_instance;
+  GbpDevhelpPanel *panel;
+  DhBookManager   *books;
+};
+
+static void gbp_devhelp_workbench_addin_init_iface (IdeWorkbenchAddinInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (GbpDevhelpWorkbenchAddin, gbp_devhelp_workbench_addin, G_TYPE_OBJECT, 0,
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKBENCH_ADDIN,
+                                               gbp_devhelp_workbench_addin_init_iface))
+
+static void
+gbp_devhelp_workbench_addin_class_init (GbpDevhelpWorkbenchAddinClass *klass)
+{
+}
+
+static void
+gbp_devhelp_workbench_addin_init (GbpDevhelpWorkbenchAddin *self)
+{
+}
+
+static void
+gbp_devhelp_workbench_addin_load (IdeWorkbenchAddin *addin,
+                                  IdeWorkbench      *workbench)
+{
+  GbpDevhelpWorkbenchAddin *self = (GbpDevhelpWorkbenchAddin *)addin;
+  IdePerspective *perspective;
+  GtkWidget *pane;
+
+  g_assert (IDE_IS_WORKBENCH_ADDIN (self));
+  g_assert (IDE_IS_WORKBENCH (workbench));
+
+  self->books = dh_book_manager_new ();
+  dh_book_manager_populate (self->books);
+
+  perspective = ide_workbench_get_perspective_by_name (workbench, "editor");
+  g_assert (IDE_IS_LAYOUT (perspective));
+
+  pane = ide_layout_get_right_pane (IDE_LAYOUT (perspective));
+  g_assert (IDE_IS_LAYOUT_PANE (pane));
+
+  self->panel = g_object_new (GBP_TYPE_DEVHELP_PANEL,
+                              "book-manager", self->books,
+                              "visible", TRUE,
+                              NULL);
+  ide_layout_pane_add_page (IDE_LAYOUT_PANE (pane), GTK_WIDGET (self->panel),
+                            _("Devhelp"), "devhelp-symbolic");
+}
+
+static void
+gbp_devhelp_workbench_addin_unload (IdeWorkbenchAddin *addin,
+                                    IdeWorkbench      *workbench)
+{
+  GbpDevhelpWorkbenchAddin *self = (GbpDevhelpWorkbenchAddin *)addin;
+
+  g_assert (IDE_IS_WORKBENCH_ADDIN (self));
+  g_assert (IDE_IS_WORKBENCH (workbench));
+
+  g_clear_object (&self->books);
+}
+
+static void
+gbp_devhelp_workbench_addin_init_iface (IdeWorkbenchAddinInterface *iface)
+{
+  iface->load = gbp_devhelp_workbench_addin_load;
+  iface->unload = gbp_devhelp_workbench_addin_unload;
+}
diff --git a/plugins/devhelp/gb-devhelp-view.h b/plugins/devhelp/gbp-devhelp-workbench-addin.h
similarity index 61%
rename from plugins/devhelp/gb-devhelp-view.h
rename to plugins/devhelp/gbp-devhelp-workbench-addin.h
index d2ee3be..39eb159 100644
--- a/plugins/devhelp/gb-devhelp-view.h
+++ b/plugins/devhelp/gbp-devhelp-workbench-addin.h
@@ -1,6 +1,6 @@
-/* gb-devhelp-view.h
+/* gbp-devhelp-workbench-addin.h
  *
- * Copyright (C) 2014 Christian Hergert <christian hergert me>
+ * Copyright (C) 2015 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,20 +16,17 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GB_DEVHELP_VIEW_H
-#define GB_DEVHELP_VIEW_H
+#ifndef GBP_DEVHELP_WORKBENCH_ADDIN_H
+#define GBP_DEVHELP_WORKBENCH_ADDIN_H
 
-#include "gb-devhelp-document.h"
-#include "gb-view.h"
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
-#define GB_TYPE_DEVHELP_VIEW (gb_devhelp_view_get_type())
+#define GBP_TYPE_DEVHELP_WORKBENCH_ADDIN (gbp_devhelp_workbench_addin_get_type())
 
-G_DECLARE_FINAL_TYPE (GbDevhelpView, gb_devhelp_view, GB, DEVHELP_VIEW, GbView)
-
-GbView *gb_devhelp_view_new      (GbDevhelpDocument *document);
+G_DECLARE_FINAL_TYPE (GbpDevhelpWorkbenchAddin, gbp_devhelp_workbench_addin, GBP, DEVHELP_WORKBENCH_ADDIN, 
GObject)
 
 G_END_DECLS
 
-#endif /* GB_DEVHELP_VIEW_H */
+#endif /* GBP_DEVHELP_WORKBENCH_ADDIN_H */


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