[gnome-builder] markdown: add markdown preview widget.



commit 96d0f3b4644ecd48b9e4c0dfec8832576b109347
Author: Christian Hergert <christian hergert me>
Date:   Thu Sep 11 15:46:30 2014 -0700

    markdown: add markdown preview widget.

 src/editor/gb-editor-tab.c            |   50 +++++++
 src/editor/gb-editor-tab.h            |    1 +
 src/editor/gb-editor-workspace.c      |   17 +++
 src/gnome-builder.mk                  |    2 +
 src/markdown/gb-markdown-preview.c    |  245 +++++++++++++++++++++++++++++++++
 src/markdown/gb-markdown-preview.h    |   60 ++++++++
 src/markdown/gs-markdown.c            |   36 +++--
 src/resources/keybindings/default.ini |    1 +
 src/resources/ui/gb-editor-tab.ui     |   12 ++-
 9 files changed, 408 insertions(+), 16 deletions(-)
---
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 66c1dd1..d92377b 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -25,6 +25,7 @@
 #include "gb-box-theatric.h"
 #include "gb-editor-tab.h"
 #include "gb-log.h"
+#include "gb-markdown-preview.h"
 #include "gb-notebook.h"
 #include "gb-rgba.h"
 #include "gb-source-formatter.h"
@@ -89,6 +90,7 @@ struct _GbEditorTabPrivate
   GtkButton           *go_down_button;
   GtkButton           *go_up_button;
   GtkOverlay          *overlay;
+  GtkBox              *preview_container;
   GtkProgressBar      *progress_bar;
   GtkRevealer         *revealer;
   GtkScrolledWindow   *scroller;
@@ -374,6 +376,53 @@ gb_editor_tab_focus_search (GbEditorTab *tab)
   EXIT;
 }
 
+void
+gb_editor_tab_toggle_preview (GbEditorTab *tab)
+{
+  GbEditorTabPrivate *priv;
+  GtkSourceLanguage *lang;
+  GtkWidget *child;
+  GList *children;
+
+  g_return_if_fail (GB_IS_EDITOR_TAB (tab));
+
+  priv = tab->priv;
+
+  children = gtk_container_get_children (GTK_CONTAINER (priv->preview_container));
+
+  if (children)
+    {
+      child = children->data;
+      g_list_free (children);
+
+      gtk_container_remove (GTK_CONTAINER (priv->preview_container), child);
+      gtk_widget_hide (GTK_WIDGET (priv->preview_container));
+
+      return;
+    }
+
+  lang = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (priv->document));
+
+  if (lang)
+    {
+      const gchar *lang_id;
+
+      lang_id = gtk_source_language_get_id (lang);
+
+      if (g_strcmp0 (lang_id, "markdown") == 0)
+        {
+          child = g_object_new (GB_TYPE_MARKDOWN_PREVIEW,
+                                "buffer", priv->document,
+                                "width-request", 100,
+                                "hexpand", TRUE,
+                                "visible", TRUE,
+                                NULL);
+          gtk_container_add (GTK_CONTAINER (priv->preview_container), child);
+          gtk_widget_show (GTK_WIDGET (priv->preview_container));
+        }
+    }
+}
+
 static void
 gb_editor_tab_reload_snippets (GbEditorTab       *tab,
                                GtkSourceLanguage *language)
@@ -1706,6 +1755,7 @@ gb_editor_tab_class_init (GbEditorTabClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, go_down_button);
   gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, go_up_button);
   gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, overlay);
+  gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, preview_container);
   gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, progress_bar);
   gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, revealer);
   gtk_widget_class_bind_template_child_private (widget_class, GbEditorTab, scroller);
diff --git a/src/editor/gb-editor-tab.h b/src/editor/gb-editor-tab.h
index 2993bb0..1af6b23 100644
--- a/src/editor/gb-editor-tab.h
+++ b/src/editor/gb-editor-tab.h
@@ -68,6 +68,7 @@ void              gb_editor_tab_save_as        (GbEditorTab                *tab)
 void              gb_editor_tab_save           (GbEditorTab                *tab);
 void              gb_editor_tab_open_file      (GbEditorTab                *tab,
                                                 GFile                      *file);
+void              gb_editor_tab_toggle_preview (GbEditorTab                *tab);
 
 G_END_DECLS
 
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 2a51b84..9a6dc2e 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -268,6 +268,22 @@ on_go_to_end_activate (GSimpleAction *action,
 }
 
 static void
+on_preview_activate (GSimpleAction *action,
+                     GVariant      *variant,
+                     gpointer       user_data)
+{
+  GbEditorWorkspace *workspace = user_data;
+  GbTab *tab;
+
+  g_return_if_fail (GB_IS_EDITOR_WORKSPACE (workspace));
+
+  tab = gb_multi_notebook_get_active_tab (workspace->priv->multi_notebook);
+
+  if (tab)
+    gb_editor_tab_toggle_preview (GB_EDITOR_TAB (tab));
+}
+
+static void
 gb_editor_workspace_grab_focus (GtkWidget *widget)
 {
   GbEditorWorkspace *workspace = GB_EDITOR_WORKSPACE (widget);
@@ -318,6 +334,7 @@ gb_editor_workspace_init (GbEditorWorkspace *workspace)
     { "reformat", on_reformat_activate },
     { "save", on_save_activate },
     { "save-as", on_save_as_activate },
+    { "preview", on_preview_activate },
   };
   GbEditorWorkspacePrivate *priv;
   GbNotebook *notebook;
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index adf9374..5df19fc 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -30,6 +30,8 @@ gnome_builder_SOURCES = \
        src/editor/gb-source-search-highlighter.c \
        src/markdown/gs-markdown.c \
        src/markdown/gs-markdown.h \
+       src/markdown/gb-markdown-preview.c \
+       src/markdown/gb-markdown-preview.h \
        src/snippets/gb-source-snippet-chunk.c \
        src/snippets/gb-source-snippet-chunk.h \
        src/snippets/gb-source-snippet-completion-item.c \
diff --git a/src/markdown/gb-markdown-preview.c b/src/markdown/gb-markdown-preview.c
new file mode 100644
index 0000000..3822fc1
--- /dev/null
+++ b/src/markdown/gb-markdown-preview.c
@@ -0,0 +1,245 @@
+/* gb-markdown-preview.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 "markdown"
+
+#include <glib/gi18n.h>
+
+#include "gb-log.h"
+#include "gb-markdown-preview.h"
+#include "gs-markdown.h"
+
+struct _GbMarkdownPreviewPrivate
+{
+  GtkTextBuffer *buffer;
+  guint          buffer_changed_handler;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbMarkdownPreview, gb_markdown_preview, WEBKIT_TYPE_WEB_VIEW)
+
+enum {
+  PROP_0,
+  PROP_BUFFER,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GtkWidget *
+gb_markdown_preview_new (void)
+{
+  return g_object_new (GB_TYPE_MARKDOWN_PREVIEW, NULL);
+}
+
+/**
+ * gb_markdown_preview_get_buffer:
+ *
+ *
+ *
+ * Returns: (transfer none): A #GtkTextBuffer.
+ */
+GtkTextBuffer *
+gb_markdown_preview_get_buffer (GbMarkdownPreview *preview)
+{
+  g_return_val_if_fail (GB_IS_MARKDOWN_PREVIEW (preview), NULL);
+
+  return preview->priv->buffer;
+}
+
+static void
+gb_markdown_preview_load_html (GbMarkdownPreview *preview,
+                               const gchar       *html)
+{
+  gchar *built_html;
+  const gchar *css = "";
+
+  built_html = g_strdup_printf ("<html>\n"
+                                " <style>%s</style>\n"
+                                " <body>\n"
+                                "   %s\n"
+                                " </body>\n"
+                                "</html>",
+                                css, html);
+
+  /*
+   * TODO: Load CSS
+   * TODO: Set base_uri based on a GFile or something.
+   */
+  webkit_web_view_load_html (WEBKIT_WEB_VIEW (preview),
+                             built_html, NULL);
+
+  g_free (built_html);
+}
+
+static void
+gb_markdown_preview_reload (GbMarkdownPreview *preview)
+{
+  GbMarkdownPreviewPrivate *priv;
+  GsMarkdown *markdown;
+  GtkTextIter begin;
+  GtkTextIter end;
+  gchar *text;
+  gchar *html = NULL;
+
+  ENTRY;
+
+  g_return_if_fail (GB_IS_MARKDOWN_PREVIEW (preview));
+
+  priv = preview->priv;
+
+  gtk_text_buffer_get_bounds (priv->buffer, &begin, &end);
+  text = gtk_text_buffer_get_text (priv->buffer, &begin, &end, TRUE);
+
+  markdown = gs_markdown_new (GS_MARKDOWN_OUTPUT_HTML);
+
+  if (!(html = gs_markdown_parse (markdown, text)))
+    {
+      g_warning ("Failed to parse markdown.");
+      GOTO (cleanup);
+    }
+
+  gb_markdown_preview_load_html (preview, html);
+
+cleanup:
+  g_free (html);
+  g_free (text);
+  g_object_unref (markdown);
+
+  EXIT;
+}
+
+static void
+on_buffer_changed_cb (GbMarkdownPreview *preview,
+                      GtkTextBuffer     *buffer)
+{
+  g_return_if_fail (GB_IS_MARKDOWN_PREVIEW (preview));
+  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+  gb_markdown_preview_reload (preview);
+}
+
+void
+gb_markdown_preview_set_buffer (GbMarkdownPreview *preview,
+                                GtkTextBuffer     *buffer)
+{
+  GbMarkdownPreviewPrivate *priv;
+
+  g_return_if_fail (GB_IS_MARKDOWN_PREVIEW (preview));
+  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+  priv = preview->priv;
+
+  if (priv->buffer == buffer)
+    return;
+
+  if (priv->buffer)
+    {
+      g_signal_handler_disconnect (priv->buffer, priv->buffer_changed_handler);
+      priv->buffer_changed_handler = 0;
+      g_clear_object (&priv->buffer);
+    }
+
+  if (buffer)
+    {
+      priv->buffer = g_object_ref (buffer);
+      priv->buffer_changed_handler =
+        g_signal_connect_object (priv->buffer,
+                                 "changed",
+                                 G_CALLBACK (on_buffer_changed_cb),
+                                 preview,
+                                 G_CONNECT_SWAPPED);
+      gb_markdown_preview_reload (preview);
+    }
+}
+
+static void
+gb_markdown_preview_dispose (GObject *object)
+{
+  GbMarkdownPreviewPrivate *priv = GB_MARKDOWN_PREVIEW (object)->priv;
+
+  if (priv->buffer)
+    {
+      g_signal_handler_disconnect (priv->buffer, priv->buffer_changed_handler);
+      priv->buffer_changed_handler = 0;
+      g_clear_object (&priv->buffer);
+    }
+
+  G_OBJECT_CLASS (gb_markdown_preview_parent_class)->dispose (object);
+}
+
+static void
+gb_markdown_preview_get_property (GObject    *object,
+                                  guint       prop_id,
+                                  GValue     *value,
+                                  GParamSpec *pspec)
+{
+  GbMarkdownPreview *self = GB_MARKDOWN_PREVIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_BUFFER:
+      g_value_set_object (value, gb_markdown_preview_get_buffer (self));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_markdown_preview_set_property (GObject      *object,
+                                  guint         prop_id,
+                                  const GValue *value,
+                                  GParamSpec   *pspec)
+{
+  GbMarkdownPreview *self = GB_MARKDOWN_PREVIEW (object);
+
+  switch (prop_id)
+    {
+    case PROP_BUFFER:
+      gb_markdown_preview_set_buffer (self, g_value_get_object (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_markdown_preview_class_init (GbMarkdownPreviewClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = gb_markdown_preview_dispose;
+  object_class->get_property = gb_markdown_preview_get_property;
+  object_class->set_property = gb_markdown_preview_set_property;
+
+  gParamSpecs [PROP_BUFFER] =
+    g_param_spec_object ("buffer",
+                         _("Buffer"),
+                         _("The text buffer containing the markdown text."),
+                         GTK_TYPE_TEXT_BUFFER,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_BUFFER,
+                                   gParamSpecs [PROP_BUFFER]);
+}
+
+static void
+gb_markdown_preview_init (GbMarkdownPreview *self)
+{
+  self->priv = gb_markdown_preview_get_instance_private (self);
+}
diff --git a/src/markdown/gb-markdown-preview.h b/src/markdown/gb-markdown-preview.h
new file mode 100644
index 0000000..5b2a6bc
--- /dev/null
+++ b/src/markdown/gb-markdown-preview.h
@@ -0,0 +1,60 @@
+/* gb-markdown-preview.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_MARKDOWN_PREVIEW_H
+#define GB_MARKDOWN_PREVIEW_H
+
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_MARKDOWN_PREVIEW            (gb_markdown_preview_get_type())
+#define GB_MARKDOWN_PREVIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_MARKDOWN_PREVIEW, 
GbMarkdownPreview))
+#define GB_MARKDOWN_PREVIEW_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_MARKDOWN_PREVIEW, 
GbMarkdownPreview const))
+#define GB_MARKDOWN_PREVIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GB_TYPE_MARKDOWN_PREVIEW, 
GbMarkdownPreviewClass))
+#define GB_IS_MARKDOWN_PREVIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_MARKDOWN_PREVIEW))
+#define GB_IS_MARKDOWN_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GB_TYPE_MARKDOWN_PREVIEW))
+#define GB_MARKDOWN_PREVIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GB_TYPE_MARKDOWN_PREVIEW, 
GbMarkdownPreviewClass))
+
+typedef struct _GbMarkdownPreview        GbMarkdownPreview;
+typedef struct _GbMarkdownPreviewClass   GbMarkdownPreviewClass;
+typedef struct _GbMarkdownPreviewPrivate GbMarkdownPreviewPrivate;
+
+struct _GbMarkdownPreview
+{
+  WebKitWebView parent;
+
+  /*< private >*/
+  GbMarkdownPreviewPrivate *priv;
+};
+
+struct _GbMarkdownPreviewClass
+{
+  WebKitWebViewClass parent;
+};
+
+GType          gb_markdown_preview_get_type   (void) G_GNUC_CONST;
+GtkWidget     *gb_markdown_preview_new        (void);
+GtkTextBuffer *gb_markdown_preview_get_buffer (GbMarkdownPreview *preview);
+void           gb_markdown_preview_set_buffer (GbMarkdownPreview *preview,
+                                               GtkTextBuffer     *buffer);
+
+G_END_DECLS
+
+#endif /* GB_MARKDOWN_PREVIEW_H */
diff --git a/src/markdown/gs-markdown.c b/src/markdown/gs-markdown.c
index 27db532..1b7202e 100644
--- a/src/markdown/gs-markdown.c
+++ b/src/markdown/gs-markdown.c
@@ -19,11 +19,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#define G_LOG_DOMAIN "markdown"
+
 #include <string.h>
 #include <glib.h>
 
 #include "gs-markdown.h"
 
+#if 0
+# define DEBUG g_debug
+#else
+# define DEBUG(...)
+#endif
+
 /*******************************************************************************
  *
  * This is a simple Markdown parser.
@@ -735,7 +743,7 @@ gs_markdown_flush_pending (GsMarkdown *self)
                                        priv->tags.codeblock_end);
        }
 
-       g_debug ("adding '%s'", temp);
+       DEBUG ("adding '%s'", temp);
 
        /* clear */
        g_string_truncate (priv->pending, 0);
@@ -754,7 +762,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
 
        /* inside code */
        if (priv->mode == GS_MARKDOWN_MODE_CODE) {
-               g_debug ("code: '%s'", line);
+               DEBUG ("code: '%s'", line);
                ret = gs_markdown_to_text_line_is_code (line);
                if (ret) {
                        gs_markdown_flush_pending (self);
@@ -772,7 +780,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* code */
        ret = gs_markdown_to_text_line_is_code (line);
        if (ret) {
-               g_debug ("code: '%s'", line);
+               DEBUG ("code: '%s'", line);
                gs_markdown_flush_pending (self);
                priv->mode = GS_MARKDOWN_MODE_CODE;
                goto out;
@@ -781,7 +789,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* blank */
        ret = gs_markdown_to_text_line_is_blank (line);
        if (ret) {
-               g_debug ("blank: '%s'", line);
+               DEBUG ("blank: '%s'", line);
                gs_markdown_flush_pending (self);
                /* a new line after a list is the end of list, not a gap */
                if (priv->mode != GS_MARKDOWN_MODE_BULLETT)
@@ -793,7 +801,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* header1_type2 */
        ret = gs_markdown_to_text_line_is_header1_type2 (line);
        if (ret) {
-               g_debug ("header1_type2: '%s'", line);
+               DEBUG ("header1_type2: '%s'", line);
                if (priv->mode == GS_MARKDOWN_MODE_PARA)
                        priv->mode = GS_MARKDOWN_MODE_H1;
                goto out;
@@ -802,7 +810,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* header2_type2 */
        ret = gs_markdown_to_text_line_is_header2_type2 (line);
        if (ret) {
-               g_debug ("header2_type2: '%s'", line);
+               DEBUG ("header2_type2: '%s'", line);
                if (priv->mode == GS_MARKDOWN_MODE_PARA)
                        priv->mode = GS_MARKDOWN_MODE_H2;
                goto out;
@@ -811,7 +819,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* rule */
        ret = gs_markdown_to_text_line_is_rule (line);
        if (ret) {
-               g_debug ("rule: '%s'", line);
+               DEBUG ("rule: '%s'", line);
                gs_markdown_flush_pending (self);
                priv->mode = GS_MARKDOWN_MODE_RULE;
                ret = gs_markdown_add_pending (self, priv->tags.rule);
@@ -821,7 +829,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* bullet */
        ret = gs_markdown_to_text_line_is_bullet (line);
        if (ret) {
-               g_debug ("bullet: '%s'", line);
+               DEBUG ("bullet: '%s'", line);
                gs_markdown_flush_pending (self);
                priv->mode = GS_MARKDOWN_MODE_BULLETT;
                ret = gs_markdown_add_pending (self, &line[2]);
@@ -831,7 +839,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* header1 */
        ret = gs_markdown_to_text_line_is_header1 (line);
        if (ret) {
-               g_debug ("header1: '%s'", line);
+               DEBUG ("header1: '%s'", line);
                gs_markdown_flush_pending (self);
                priv->mode = GS_MARKDOWN_MODE_H1;
                ret = gs_markdown_add_pending_header (self, &line[2]);
@@ -841,7 +849,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* header2 */
        ret = gs_markdown_to_text_line_is_header2 (line);
        if (ret) {
-               g_debug ("header2: '%s'", line);
+               DEBUG ("header2: '%s'", line);
                gs_markdown_flush_pending (self);
                priv->mode = GS_MARKDOWN_MODE_H2;
                ret = gs_markdown_add_pending_header (self, &line[3]);
@@ -851,7 +859,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        /* header3 */
        ret = gs_markdown_to_text_line_is_header3 (line);
        if (ret) {
-               g_debug ("header3: '%s'", line);
+               DEBUG ("header3: '%s'", line);
                gs_markdown_flush_pending (self);
                priv->mode = GS_MARKDOWN_MODE_H3;
                ret = gs_markdown_add_pending_header (self, &line[4]);
@@ -866,7 +874,7 @@ gs_markdown_to_text_line_process (GsMarkdown *self, const gchar *line)
        }
 
        /* add to pending */
-       g_debug ("continue: '%s'", line);
+       DEBUG ("continue: '%s'", line);
        ret = gs_markdown_add_pending (self, line);
 out:
        /* if we failed to add, we don't know the mode */
@@ -1034,7 +1042,7 @@ gs_markdown_parse (GsMarkdown *self, const gchar *markdown)
 
        g_return_val_if_fail (GS_IS_MARKDOWN (self), NULL);
 
-       g_debug ("input='%s'", markdown);
+       DEBUG ("input='%s'", markdown);
 
        /* process */
        priv->mode = GS_MARKDOWN_MODE_UNKNOWN;
@@ -1062,7 +1070,7 @@ gs_markdown_parse (GsMarkdown *self, const gchar *markdown)
        g_string_truncate (priv->pending, 0);
        g_string_truncate (priv->processed, 0);
 
-       g_debug ("output='%s'", temp);
+       DEBUG ("output='%s'", temp);
 
        return temp;
 }
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index d5bb8ed..df04815 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -10,3 +10,4 @@ open = <Control>O
 reformat = <Control><Shift>R
 save = <Control>S
 save-as = <Control><Shift>S
+preview = <Control><Alt>P
diff --git a/src/resources/ui/gb-editor-tab.ui b/src/resources/ui/gb-editor-tab.ui
index 97de5cc..aaa3ca3 100644
--- a/src/resources/ui/gb-editor-tab.ui
+++ b/src/resources/ui/gb-editor-tab.ui
@@ -4,14 +4,15 @@
   <template class="GbEditorTab" parent="GbTab">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="orientation">vertical</property>
+    <property name="orientation">horizontal</property>
+    <property name="expand">True</property>
     <child>
       <object class="GtkOverlay" id="overlay">
         <property name="visible">True</property>
         <child>
           <object class="GtkScrolledWindow" id="scroller">
             <property name="visible">True</property>
-            <property name="vexpand">True</property>
+            <property name="expand">True</property>
             <child>
               <object class="GbSourceView" id="source_view">
                 <property name="buffer">document</property>
@@ -111,6 +112,13 @@
         </child>
       </object>
     </child>
+    <child>
+      <object class="GtkBox" id="preview_container">
+        <property name="orientation">horizontal</property>
+        <property name="visible">False</property>
+        <property name="hexpand">True</property>
+      </object>
+    </child>
   </template>
   <object class="GtkSourceFile" id="file">
   </object>


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