[gnome-builder/document-manager] html: add html preview view/document



commit efcc6ec84b119314ccfc0d108f8b891ff98e229c
Author: Christian Hergert <christian hergert me>
Date:   Mon Dec 8 20:07:55 2014 -0800

    html: add html preview view/document

 src/gnome-builder.mk                      |    5 +
 src/html/gb-html-document.c               |  283 +++++++++++++++++++++++++++++
 src/html/gb-html-document.h               |   56 ++++++
 src/html/gb-html-view.c                   |  268 +++++++++++++++++++++++++++
 src/html/gb-html-view.h                   |   57 ++++++
 src/resources/gnome-builder.gresource.xml |    1 +
 src/resources/ui/gb-html-view.ui          |   20 ++
 7 files changed, 690 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 5cff6b2..1499a15 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -100,6 +100,10 @@ libgnome_builder_la_SOURCES = \
        src/gca/gca-service.h \
        src/gca/gca-structs.c \
        src/gca/gca-structs.h \
+       src/html/gb-html-document.c \
+       src/html/gb-html-document.h \
+       src/html/gb-html-view.c \
+       src/html/gb-html-view.h \
        src/markdown/gs-markdown.c \
        src/markdown/gs-markdown.h \
        src/markdown/gb-markdown-preview.c \
@@ -225,6 +229,7 @@ libgnome_builder_la_CFLAGS = \
        -I$(top_srcdir)/src/gca \
        -I$(top_srcdir)/src/gd \
        -I$(top_srcdir)/src/gedit \
+       -I$(top_srcdir)/src/html \
        -I$(top_srcdir)/src/keybindings \
        -I$(top_srcdir)/src/log \
        -I$(top_srcdir)/src/markdown \
diff --git a/src/html/gb-html-document.c b/src/html/gb-html-document.c
new file mode 100644
index 0000000..c823c59
--- /dev/null
+++ b/src/html/gb-html-document.c
@@ -0,0 +1,283 @@
+/* gb-html-document.c
+ *
+ * Copyright (C) 2014 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
+ * 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 "html-document"
+
+#include <glib/gi18n.h>
+#include <gtksourceview/gtksourcefile.h>
+
+#include "gb-editor-document.h"
+#include "gb-html-document.h"
+#include "gb-html-view.h"
+
+struct _GbHtmlDocumentPrivate
+{
+  GtkTextBuffer *buffer;
+  gchar         *title;
+};
+
+static void gb_html_document_init_document (GbDocumentInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (GbHtmlDocument, gb_html_document, G_TYPE_OBJECT, 0,
+                        G_ADD_PRIVATE (GbHtmlDocument)
+                        G_IMPLEMENT_INTERFACE (GB_TYPE_DOCUMENT,
+                                               gb_html_document_init_document))
+
+enum {
+  PROP_0,
+  PROP_BUFFER,
+  PROP_MODIFIED,
+  PROP_TITLE,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GbHtmlDocument *
+gb_html_document_new (void)
+{
+  return g_object_new (GB_TYPE_HTML_DOCUMENT, NULL);
+}
+
+static const gchar *
+gb_html_document_get_title (GbDocument *document)
+{
+  GbHtmlDocument *self = (GbHtmlDocument *)document;
+
+  g_return_val_if_fail (GB_IS_HTML_DOCUMENT (self), NULL);
+
+  if (self->priv->title)
+    return self->priv->title;
+
+  return _("HTML Preview");
+}
+
+static void
+gb_html_document_notify_location (GbHtmlDocument *document,
+                                  GParamSpec     *pspec,
+                                  GtkSourceFile  *file)
+{
+  GFile *location;
+
+  g_return_if_fail (GB_IS_HTML_DOCUMENT (document));
+  g_return_if_fail (GTK_SOURCE_IS_FILE (file));
+
+  location = gtk_source_file_get_location (file);
+
+  g_clear_pointer (&document->priv->title, g_free);
+
+  if (location)
+    {
+      gchar *filename;
+
+      filename = g_file_get_basename (location);
+      document->priv->title = g_strdup_printf (_("%s (Preview)"), filename);
+    }
+
+  g_object_notify (G_OBJECT (document), "title");
+}
+
+static void
+gb_html_document_connect (GbHtmlDocument *document,
+                          GtkTextBuffer  *buffer)
+{
+  g_return_if_fail (GB_IS_HTML_DOCUMENT (document));
+  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+  if (GB_IS_EDITOR_DOCUMENT (buffer))
+    {
+      GtkSourceFile *file;
+
+      file = gb_editor_document_get_file (GB_EDITOR_DOCUMENT (buffer));
+      g_signal_connect_object (file,
+                               "notify::location",
+                               G_CALLBACK (gb_html_document_notify_location),
+                               document,
+                               G_CONNECT_SWAPPED);
+      gb_html_document_notify_location (document, NULL, file);
+    }
+}
+
+static void
+gb_html_document_disconnect (GbHtmlDocument *document,
+                             GtkTextBuffer  *buffer)
+{
+  g_return_if_fail (GB_IS_HTML_DOCUMENT (document));
+  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+  if (GB_IS_EDITOR_DOCUMENT (buffer))
+    {
+      GtkSourceFile *file;
+
+      file = gb_editor_document_get_file (GB_EDITOR_DOCUMENT (buffer));
+      g_signal_handlers_disconnect_by_func (file,
+                                            G_CALLBACK (gb_html_document_notify_location),
+                                            document);
+    }
+}
+
+GtkTextBuffer *
+gb_html_document_get_buffer (GbHtmlDocument *document)
+{
+  g_return_val_if_fail (GB_IS_HTML_DOCUMENT (document), NULL);
+
+  return document->priv->buffer;
+}
+
+static void
+gb_html_document_set_buffer (GbHtmlDocument *document,
+                             GtkTextBuffer  *buffer)
+{
+  GbHtmlDocument *self = (GbHtmlDocument *)document;
+
+  g_return_if_fail (GB_IS_HTML_DOCUMENT (self));
+  g_return_if_fail (!buffer || GTK_IS_TEXT_BUFFER (buffer));
+
+  if (buffer != self->priv->buffer)
+    {
+      if (self->priv->buffer)
+        {
+          gb_html_document_disconnect (self, buffer);
+          g_clear_object (&self->priv->buffer);
+        }
+
+      if (buffer)
+        {
+          self->priv->buffer = g_object_ref (buffer);
+          gb_html_document_connect (self, buffer);
+        }
+
+      g_object_notify_by_pspec (G_OBJECT (document), gParamSpecs [PROP_BUFFER]);
+    }
+}
+
+static gboolean
+gb_html_document_get_modified (GbDocument *document)
+{
+  return FALSE;
+}
+
+static GtkWidget *
+gb_html_document_create_view (GbDocument *document)
+{
+  GbHtmlDocument *self = (GbHtmlDocument *)document;
+
+  g_return_val_if_fail (GB_IS_HTML_DOCUMENT (self), NULL);
+
+  return g_object_new (GB_TYPE_HTML_VIEW,
+                       "document", self,
+                       "visible", TRUE,
+                       NULL);
+}
+
+static void
+gb_html_document_finalize (GObject *object)
+{
+  GbHtmlDocumentPrivate *priv = GB_HTML_DOCUMENT (object)->priv;
+
+  g_clear_pointer (&priv->title, g_free);
+  g_clear_object (&priv->buffer);
+
+  G_OBJECT_CLASS (gb_html_document_parent_class)->finalize (object);
+}
+
+static void
+gb_html_document_get_property (GObject    *object,
+                               guint       prop_id,
+                               GValue     *value,
+                               GParamSpec *pspec)
+{
+  GbHtmlDocument *self = GB_HTML_DOCUMENT (object);
+
+  switch (prop_id)
+    {
+    case PROP_BUFFER:
+      g_value_set_object (value, gb_html_document_get_buffer (self));
+      break;
+
+    case PROP_MODIFIED:
+      g_value_set_boolean (value,
+                           gb_html_document_get_modified (GB_DOCUMENT (self)));
+      break;
+
+    case PROP_TITLE:
+      g_value_set_string (value,
+                          gb_html_document_get_title (GB_DOCUMENT (self)));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_html_document_set_property (GObject      *object,
+                               guint         prop_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  GbHtmlDocument *self = GB_HTML_DOCUMENT (object);
+
+  switch (prop_id)
+    {
+    case PROP_BUFFER:
+      gb_html_document_set_buffer (self, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_html_document_class_init (GbHtmlDocumentClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_html_document_finalize;
+  object_class->get_property = gb_html_document_get_property;
+  object_class->set_property = gb_html_document_set_property;
+
+  g_object_class_override_property (object_class, PROP_TITLE, "modified");
+  g_object_class_override_property (object_class, PROP_TITLE, "title");
+
+  gParamSpecs [PROP_BUFFER] =
+    g_param_spec_object ("buffer",
+                         _("Buffer"),
+                         _("The buffer to monitor for changes."),
+                         GTK_TYPE_TEXT_BUFFER,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT_ONLY |
+                          G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_BUFFER,
+                                   gParamSpecs [PROP_BUFFER]);
+}
+
+static void
+gb_html_document_init (GbHtmlDocument *self)
+{
+  self->priv = gb_html_document_get_instance_private (self);
+}
+
+static void
+gb_html_document_init_document (GbDocumentInterface *iface)
+{
+  iface->get_title = gb_html_document_get_title;
+  iface->get_modified = gb_html_document_get_modified;
+  iface->create_view = gb_html_document_create_view;
+}
diff --git a/src/html/gb-html-document.h b/src/html/gb-html-document.h
new file mode 100644
index 0000000..17fe731
--- /dev/null
+++ b/src/html/gb-html-document.h
@@ -0,0 +1,56 @@
+/* gb-html-document.h
+ *
+ * Copyright (C) 2014 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
+ * 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/>.
+ */
+
+#ifndef GB_HTML_DOCUMENT_H
+#define GB_HTML_DOCUMENT_H
+
+#include "gb-document.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_HTML_DOCUMENT            (gb_html_document_get_type())
+#define GB_HTML_DOCUMENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_HTML_DOCUMENT, 
GbHtmlDocument))
+#define GB_HTML_DOCUMENT_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_HTML_DOCUMENT, 
GbHtmlDocument const))
+#define GB_HTML_DOCUMENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GB_TYPE_HTML_DOCUMENT, 
GbHtmlDocumentClass))
+#define GB_IS_HTML_DOCUMENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_HTML_DOCUMENT))
+#define GB_IS_HTML_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GB_TYPE_HTML_DOCUMENT))
+#define GB_HTML_DOCUMENT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GB_TYPE_HTML_DOCUMENT, 
GbHtmlDocumentClass))
+
+typedef struct _GbHtmlDocument        GbHtmlDocument;
+typedef struct _GbHtmlDocumentClass   GbHtmlDocumentClass;
+typedef struct _GbHtmlDocumentPrivate GbHtmlDocumentPrivate;
+
+struct _GbHtmlDocument
+{
+  GObject parent;
+
+  /*< private >*/
+  GbHtmlDocumentPrivate *priv;
+};
+
+struct _GbHtmlDocumentClass
+{
+  GObjectClass parent;
+};
+
+GType          gb_html_document_get_type   (void);
+GtkTextBuffer *gb_html_document_get_buffer (GbHtmlDocument *document);
+
+G_END_DECLS
+
+#endif /* GB_HTML_DOCUMENT_H */
diff --git a/src/html/gb-html-view.c b/src/html/gb-html-view.c
new file mode 100644
index 0000000..6968fd6
--- /dev/null
+++ b/src/html/gb-html-view.c
@@ -0,0 +1,268 @@
+/* gb-html-view.c
+ *
+ * Copyright (C) 2014 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
+ * 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 "html-view"
+
+#include <glib/gi18n.h>
+#include <gtksourceview/gtksourcefile.h>
+#include <webkit2/webkit2.h>
+
+#include "gb-editor-document.h"
+#include "gb-html-view.h"
+#include "gb-log.h"
+
+struct _GbHtmlViewPrivate
+{
+  /* Objects owned by view */
+  GbHtmlDocument *document;
+
+  /* References owned by Gtk template */
+  WebKitWebView  *web_view;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbHtmlView, gb_html_view, GB_TYPE_DOCUMENT_VIEW)
+
+enum {
+  PROP_0,
+  PROP_DOCUMENT,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GtkWidget *
+gb_html_view_new (GbHtmlDocument *document)
+{
+  return g_object_new (GB_TYPE_HTML_VIEW,
+                       "document", document,
+                       NULL);
+}
+
+static void
+gb_html_view_changed (GbHtmlView    *view,
+                      GtkTextBuffer *buffer)
+{
+  GbHtmlViewPrivate *priv;
+  GtkTextIter begin;
+  GtkTextIter end;
+  gchar *content = NULL;
+  gchar *base_uri = NULL;
+
+  ENTRY;
+
+  g_return_if_fail (GB_IS_HTML_VIEW (view));
+  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+  priv = view->priv;
+
+  if (GB_IS_EDITOR_DOCUMENT (view->priv->document))
+    {
+      GtkSourceFile *file;
+
+      file = gb_editor_document_get_file (GB_EDITOR_DOCUMENT (priv->document));
+
+      if (file)
+        {
+          GFile *location;
+
+          location = gtk_source_file_get_location (file);
+
+          if (location)
+            base_uri = g_file_get_uri (location);
+        }
+    }
+
+  gtk_text_buffer_get_bounds (buffer, &begin, &end);
+  content = gtk_text_buffer_get_text (buffer, &begin, &end, TRUE);
+
+  webkit_web_view_load_html (view->priv->web_view, content, base_uri);
+
+  g_free (content);
+  g_free (base_uri);
+
+  EXIT;
+}
+
+static void
+gb_html_view_connect (GbHtmlView     *view,
+                      GbHtmlDocument *document)
+{
+  GtkTextBuffer *buffer;
+
+  g_return_if_fail (GB_IS_HTML_VIEW (view));
+  g_return_if_fail (GB_IS_HTML_DOCUMENT (document));
+
+  buffer = gb_html_document_get_buffer (document);
+  if (!buffer)
+    return;
+
+  g_signal_connect_object (buffer,
+                           "changed",
+                           G_CALLBACK (gb_html_view_changed),
+                           view,
+                           G_CONNECT_SWAPPED);
+
+  gb_html_view_changed (view, buffer);
+}
+
+static void
+gb_html_view_disconnect (GbHtmlView     *view,
+                         GbHtmlDocument *document)
+{
+  GtkTextBuffer *buffer;
+
+  g_return_if_fail (GB_IS_HTML_VIEW (view));
+  g_return_if_fail (GB_IS_HTML_DOCUMENT (document));
+
+  buffer = gb_html_document_get_buffer (document);
+  if (!buffer)
+    return;
+
+  g_signal_handlers_disconnect_by_func (buffer,
+                                        G_CALLBACK (gb_html_view_changed),
+                                        view);
+}
+
+static GbDocument *
+gb_html_view_get_document (GbDocumentView *view)
+{
+  GbHtmlView *self = (GbHtmlView *)view;
+
+  g_return_val_if_fail (GB_IS_HTML_VIEW (self), NULL);
+
+  return GB_DOCUMENT (self->priv->document);
+}
+
+static void
+gb_html_view_set_document (GbHtmlView *view,
+                           GbDocument *document)
+{
+  g_return_if_fail (GB_IS_HTML_VIEW (view));
+  g_return_if_fail (GB_IS_DOCUMENT (document));
+
+  if (!GB_IS_HTML_DOCUMENT (document))
+    {
+      g_warning ("GbHtmlView does not know how to handle a document "
+                 "of type %s",
+                 g_type_name (G_TYPE_FROM_INSTANCE (document)));
+      return;
+    }
+
+  if (document != (GbDocument *)view->priv->document)
+    {
+      if (view->priv->document)
+        {
+          gb_html_view_disconnect (view, view->priv->document);
+          g_clear_object (&view->priv->document);
+        }
+
+      if (document)
+        {
+          view->priv->document = g_object_ref (document);
+          gb_html_view_connect (view, view->priv->document);
+        }
+
+      g_object_notify_by_pspec (G_OBJECT (view), gParamSpecs [PROP_DOCUMENT]);
+    }
+}
+
+static void
+gb_html_view_finalize (GObject *object)
+{
+  GbHtmlViewPrivate *priv = GB_HTML_VIEW (object)->priv;
+
+  g_clear_object (&priv->document);
+
+  G_OBJECT_CLASS (gb_html_view_parent_class)->finalize (object);
+}
+
+static void
+gb_html_view_get_property (GObject    *object,
+                           guint       prop_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
+{
+  GbHtmlView *self = GB_HTML_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_DOCUMENT:
+      g_value_set_object (value,
+                          gb_html_view_get_document (GB_DOCUMENT_VIEW (self)));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_html_view_set_property (GObject      *object,
+                           guint         prop_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
+{
+  GbHtmlView *self = GB_HTML_VIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_DOCUMENT:
+      gb_html_view_set_document (self, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_html_view_class_init (GbHtmlViewClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  GbDocumentViewClass *view_class = GB_DOCUMENT_VIEW_CLASS (klass);
+
+  object_class->finalize = gb_html_view_finalize;
+  object_class->get_property = gb_html_view_get_property;
+  object_class->set_property = gb_html_view_set_property;
+
+  view_class->get_document = gb_html_view_get_document;
+
+  gParamSpecs [PROP_DOCUMENT] =
+    g_param_spec_object ("document",
+                         _("Document"),
+                         _("The document to view as HTML."),
+                         GB_TYPE_DOCUMENT,
+                         (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_DOCUMENT,
+                                   gParamSpecs [PROP_DOCUMENT]);
+
+  gtk_widget_class_set_template_from_resource (widget_class,
+                                               "/org/gnome/builder/ui/gb-html-view.ui");
+  gtk_widget_class_bind_template_child_private (widget_class, GbHtmlView, web_view);
+
+  g_type_ensure (WEBKIT_TYPE_WEB_VIEW);
+}
+
+static void
+gb_html_view_init (GbHtmlView *self)
+{
+  self->priv = gb_html_view_get_instance_private (self);
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/html/gb-html-view.h b/src/html/gb-html-view.h
new file mode 100644
index 0000000..18a0ce8
--- /dev/null
+++ b/src/html/gb-html-view.h
@@ -0,0 +1,57 @@
+/* gb-html-view.h
+ *
+ * Copyright (C) 2014 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
+ * 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/>.
+ */
+
+#ifndef GB_HTML_VIEW_H
+#define GB_HTML_VIEW_H
+
+#include "gb-document-view.h"
+#include "gb-html-document.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_HTML_VIEW            (gb_html_view_get_type())
+#define GB_HTML_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_HTML_VIEW, GbHtmlView))
+#define GB_HTML_VIEW_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_HTML_VIEW, GbHtmlView 
const))
+#define GB_HTML_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GB_TYPE_HTML_VIEW, GbHtmlViewClass))
+#define GB_IS_HTML_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_HTML_VIEW))
+#define GB_IS_HTML_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GB_TYPE_HTML_VIEW))
+#define GB_HTML_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GB_TYPE_HTML_VIEW, GbHtmlViewClass))
+
+typedef struct _GbHtmlView        GbHtmlView;
+typedef struct _GbHtmlViewClass   GbHtmlViewClass;
+typedef struct _GbHtmlViewPrivate GbHtmlViewPrivate;
+
+struct _GbHtmlView
+{
+  GbDocumentView parent;
+
+  /*< private >*/
+  GbHtmlViewPrivate *priv;
+};
+
+struct _GbHtmlViewClass
+{
+  GbDocumentViewClass parent;
+};
+
+GType      gb_html_view_get_type (void);
+GtkWidget *gb_html_view_new      (GbHtmlDocument *document);
+
+G_END_DECLS
+
+#endif /* GB_HTML_VIEW_H */
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 942046f..8a8539f 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -29,6 +29,7 @@
     <file>ui/gb-editor-tab.ui</file>
     <file>ui/gb-editor-view.ui</file>
     <file>ui/gb-editor-workspace.ui</file>
+    <file>ui/gb-html-view.ui</file>
     <file>ui/gb-markdown-tab.ui</file>
     <file>ui/gb-preferences-window.ui</file>
     <file>ui/gb-preferences-page-editor.ui</file>
diff --git a/src/resources/ui/gb-html-view.ui b/src/resources/ui/gb-html-view.ui
new file mode 100644
index 0000000..4bcdf96
--- /dev/null
+++ b/src/resources/ui/gb-html-view.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.14 -->
+  <template class="GbHtmlView" parent="GbDocumentView">
+    <child internal-child="controls">
+      <object class="GtkBox">
+        <property name="visible">true</property>
+        <style>
+          <class name="linked"/>
+        </style>
+      </object>
+    </child>
+    <child>
+      <object class="WebKitWebView" id="web_view">
+        <property name="expand">true</property>
+        <property name="visible">true</property>
+      </object>
+    </child>
+  </template>
+</interface>


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