[gnome-builder/wip/libide] documents: add back-forward list to document views.



commit fe6ed8866d5aa8cd6321ff819c582fb4a7682809
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 09:17:01 2015 -0800

    documents: add back-forward list to document views.

 src/documents/gb-document-stack.c |   16 ++++++++++++++++
 src/documents/gb-document-view.c  |   31 +++++++++++++++++++++++++++++++
 src/documents/gb-document-view.h  |   18 +++++++++++-------
 3 files changed, 58 insertions(+), 7 deletions(-)
---
diff --git a/src/documents/gb-document-stack.c b/src/documents/gb-document-stack.c
index ea6dfa6..e7f5f01 100644
--- a/src/documents/gb-document-stack.c
+++ b/src/documents/gb-document-stack.c
@@ -85,6 +85,8 @@ gb_document_stack_connect_context (GbDocumentStack *self,
 {
   GbDocumentStackPrivate *priv;
   IdeBackForwardList *list;
+  GList *children;
+  GList *iter;
 
   g_return_if_fail (GB_IS_DOCUMENT_STACK (self));
   g_return_if_fail (IDE_IS_CONTEXT (context));
@@ -105,6 +107,15 @@ gb_document_stack_connect_context (GbDocumentStack *self,
                             G_BINDING_SYNC_CREATE);
 
   gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE);
+
+  children = gtk_container_get_children (GTK_CONTAINER (self));
+  for (iter = children; iter; iter = iter->next)
+    {
+      if (GB_IS_DOCUMENT_VIEW (iter->data))
+        gb_document_view_set_back_forward_list (iter->data,
+                                                priv->back_forward_list);
+    }
+  g_list_free (children);
 }
 
 static void
@@ -888,9 +899,14 @@ gb_document_stack_finalize (GObject *object)
 {
   GbDocumentStackPrivate *priv = GB_DOCUMENT_STACK (object)->priv;
 
+  /*
+   * TODO: Merge back-forward list?
+   */
+
   gb_clear_weak_pointer (&priv->active_view);
   g_clear_object (&priv->document_manager);
   g_clear_object (&priv->actions);
+  g_clear_object (&priv->back_forward_list);
 
   G_OBJECT_CLASS (gb_document_stack_parent_class)->finalize (object);
 }
diff --git a/src/documents/gb-document-view.c b/src/documents/gb-document-view.c
index 4953389..f08f79c 100644
--- a/src/documents/gb-document-view.c
+++ b/src/documents/gb-document-view.c
@@ -25,6 +25,8 @@
 struct _GbDocumentViewPrivate
 {
   GtkBox *controls;
+
+  IdeBackForwardList *back_forward_list;
 };
 
 static void buildable_init (GtkBuildableIface *iface);
@@ -38,6 +40,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GbDocumentView,
 
 enum {
   PROP_0,
+  PROP_BACK_FORWARD_LIST,
   PROP_CAN_PREVIEW,
   PROP_CONTROLS,
   PROP_DOCUMENT,
@@ -53,6 +56,34 @@ static GParamSpec *gParamSpecs [LAST_PROP];
 static guint       gSignals [LAST_SIGNAL];
 
 /**
+ * gb_document_view_get_back_forward_list:
+ *
+ * Retrieves the #IdeBackForwardList to be used by this view.
+ *
+ * Returns: (transfer none) (nullable): An #IdeBackForwardList or %NULL.
+ */
+IdeBackForwardList *
+gb_document_view_get_back_forward_list (GbDocumentView *view)
+{
+  g_return_val_if_fail (GB_IS_DOCUMENT_VIEW (view), NULL);
+
+  return view->priv->back_forward_list;
+}
+
+void
+gb_document_view_set_back_forward_list (GbDocumentView     *view,
+                                        IdeBackForwardList *back_forward_list)
+{
+  g_return_if_fail (GB_IS_DOCUMENT_VIEW (view));
+  g_return_if_fail (!back_forward_list ||
+                    IDE_IS_BACK_FORWARD_LIST (back_forward_list));
+
+  if (g_set_object (&view->priv->back_forward_list, back_forward_list))
+    g_object_notify_by_pspec (G_OBJECT (view),
+                              gParamSpecs [PROP_BACK_FORWARD_LIST]);
+}
+
+/**
  * gb_document_view_get_controls:
  *
  * This returns a #GtkBox that can be used to place controls that should be
diff --git a/src/documents/gb-document-view.h b/src/documents/gb-document-view.h
index 5c2e3f9..b1dccec 100644
--- a/src/documents/gb-document-view.h
+++ b/src/documents/gb-document-view.h
@@ -20,6 +20,7 @@
 #define GB_DOCUMENT_VIEW_H
 
 #include <gtk/gtk.h>
+#include <ide.h>
 
 #include "gb-document.h"
 
@@ -55,13 +56,16 @@ struct _GbDocumentViewClass
   GbDocument  *(*create_preview)  (GbDocumentView *view);
 };
 
-GType           gb_document_view_get_type        (void);
-GbDocumentView *gb_document_view_new             (void);
-GbDocument     *gb_document_view_create_preview  (GbDocumentView *view);
-void            gb_document_view_close           (GbDocumentView *view);
-GbDocument     *gb_document_view_get_document    (GbDocumentView *view);
-GtkWidget      *gb_document_view_get_controls    (GbDocumentView *view);
-gboolean        gb_document_view_get_can_preview (GbDocumentView *view);
+GType               gb_document_view_get_type              (void);
+void                gb_document_view_set_back_forward_list (GbDocumentView     *view,
+                                                            IdeBackForwardList *list);
+IdeBackForwardList *gb_document_view_get_back_forward_list (GbDocumentView     *view);
+GbDocumentView     *gb_document_view_new                   (void);
+GbDocument         *gb_document_view_create_preview        (GbDocumentView     *view);
+void                gb_document_view_close                 (GbDocumentView     *view);
+GbDocument         *gb_document_view_get_document          (GbDocumentView     *view);
+GtkWidget          *gb_document_view_get_controls          (GbDocumentView     *view);
+gboolean            gb_document_view_get_can_preview       (GbDocumentView     *view);
 
 G_END_DECLS
 


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