[gnome-builder] html: add manual refresh facility to html preview



commit 8f1ed4dd541b66ee49d39d6de37ebd460e30b0fa
Author: Christian Hergert <christian hergert me>
Date:   Sat Jan 3 15:23:20 2015 -0800

    html: add manual refresh facility to html preview
    
    This allows you to return to the document after following a link, etc.

 src/html/gb-html-view.c          |   37 +++++++++++++++++++++++++++++++++++++
 src/resources/ui/gb-html-view.ui |   17 +++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/html/gb-html-view.c b/src/html/gb-html-view.c
index 88d1dda..967f18a 100644
--- a/src/html/gb-html-view.c
+++ b/src/html/gb-html-view.c
@@ -178,6 +178,26 @@ gb_html_view_set_document (GbHtmlView *view,
 }
 
 static void
+gb_html_view_refresh (GSimpleAction *action,
+                      GVariant      *parameters,
+                      gpointer       user_data)
+{
+  GtkTextBuffer *buffer;
+  GbHtmlView *view = user_data;
+
+  g_return_if_fail (GB_IS_HTML_VIEW (view));
+
+  if (!view->priv->document)
+    return;
+
+  buffer = gb_html_document_get_buffer (view->priv->document);
+  if (!buffer)
+    return;
+
+  gb_html_view_changed (view, buffer);
+}
+
+static void
 gb_html_view_finalize (GObject *object)
 {
   GbHtmlViewPrivate *priv = GB_HTML_VIEW (object)->priv;
@@ -258,7 +278,24 @@ gb_html_view_class_init (GbHtmlViewClass *klass)
 static void
 gb_html_view_init (GbHtmlView *self)
 {
+  static const GActionEntry entries[] = {
+    { "refresh", gb_html_view_refresh },
+  };
+  GSimpleActionGroup *actions;
+  GtkWidget *controls;
+
   self->priv = gb_html_view_get_instance_private (self);
 
   gtk_widget_init_template (GTK_WIDGET (self));
+
+  controls = gb_document_view_get_controls (GB_DOCUMENT_VIEW (self));
+
+  actions = g_simple_action_group_new ();
+  g_action_map_add_action_entries (G_ACTION_MAP (actions), entries,
+                                   G_N_ELEMENTS (entries), self);
+  gtk_widget_insert_action_group (GTK_WIDGET (self), "html-view",
+                                  G_ACTION_GROUP (actions));
+  gtk_widget_insert_action_group (controls, "html-view",
+                                  G_ACTION_GROUP (actions));
+  g_object_unref (actions);
 }
diff --git a/src/resources/ui/gb-html-view.ui b/src/resources/ui/gb-html-view.ui
index 4bcdf96..6655725 100644
--- a/src/resources/ui/gb-html-view.ui
+++ b/src/resources/ui/gb-html-view.ui
@@ -8,6 +8,23 @@
         <style>
           <class name="linked"/>
         </style>
+        <child>
+          <object class="GtkButton">
+            <property name="visible">True</property>
+            <property name="action_name">html-view.refresh</property>
+            <style>
+              <class name="image-button"/>
+              <class name="tab-control-first"/>
+              <class name="tab-control-last"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon_name">view-refresh-symbolic</property>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
     <child>


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