[gnome-builder/wip/libide-merge] branch navigation list when stack is created and attached to workbench



commit beab8bcbd45bbef7c5c80af7e036e5137509a383
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 20 19:41:00 2015 -0700

    branch navigation list when stack is created and attached to workbench

 data/ui/gb-view-stack.ui          |    4 +++-
 src/views/gb-view-stack-private.h |   29 +++++++++++++++--------------
 src/views/gb-view-stack.c         |   29 +++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/data/ui/gb-view-stack.ui b/data/ui/gb-view-stack.ui
index 806608d..5fefc89 100644
--- a/data/ui/gb-view-stack.ui
+++ b/data/ui/gb-view-stack.ui
@@ -34,6 +34,7 @@
                         <property name="visible">true</property>
                         <property name="action-name">navigation.go-backward</property>
                         <style>
+                          <class name="dim-label"/>
                           <class name="flat"/>
                           <class name="image-button"/>
                         </style>
@@ -48,8 +49,9 @@
                     <child>
                       <object class="GtkButton" id="go_forward">
                         <property name="visible">true</property>
-                        <property name="action-name">navigation.go-forkward</property>
+                        <property name="action-name">navigation.go-forward</property>
                         <style>
+                          <class name="dim-label"/>
                           <class name="flat"/>
                           <class name="image-button"/>
                         </style>
diff --git a/src/views/gb-view-stack-private.h b/src/views/gb-view-stack-private.h
index 43c187b..9905a68 100644
--- a/src/views/gb-view-stack-private.h
+++ b/src/views/gb-view-stack-private.h
@@ -25,25 +25,26 @@ G_BEGIN_DECLS
 
 struct _GbViewStack
 {
-  GtkBin         parent_instance;
+  GtkBin              parent_instance;
 
-  GList         *focus_history;
+  GList              *focus_history;
+  IdeBackForwardList *back_forward_list;
 
   /* Weak references */
-  GtkWidget     *active_view;
-  GBinding      *title_binding;
+  GtkWidget          *active_view;
+  GBinding           *title_binding;
 
   /* Template references */
-  GtkStack      *controls_stack;
-  GtkButton     *close_button;
-  GtkMenuButton *document_button;
-  GtkButton     *go_backward;
-  GtkButton     *go_forward;
-  GtkPopover    *popover;
-  GtkStack      *stack;
-  GtkLabel      *title_label;
-
-  guint          focused : 1;
+  GtkStack           *controls_stack;
+  GtkButton          *close_button;
+  GtkMenuButton      *document_button;
+  GtkButton          *go_backward;
+  GtkButton          *go_forward;
+  GtkPopover         *popover;
+  GtkStack           *stack;
+  GtkLabel           *title_label;
+
+  guint               focused : 1;
 };
 
 G_END_DECLS
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 9f5f580..d1ed12b 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -162,6 +162,32 @@ gb_view_stack_real_empty (GbViewStack *self)
 }
 
 static void
+gb_view_stack_context_handler (GtkWidget  *widget,
+                               IdeContext *context)
+{
+  IdeBackForwardList *back_forward;
+  GbViewStack *self = (GbViewStack *)widget;
+
+  g_assert (GTK_IS_WIDGET (widget));
+  g_assert (!context || IDE_IS_CONTEXT (context));
+
+  if (context)
+    {
+      back_forward = ide_context_get_back_forward_list (context);
+
+      g_clear_object (&self->back_forward_list);
+      self->back_forward_list = ide_back_forward_list_branch (back_forward);
+
+      g_object_bind_property (self->back_forward_list, "can-go-backward",
+                              self->go_backward, "sensitive",
+                              G_BINDING_SYNC_CREATE);
+      g_object_bind_property (self->back_forward_list, "can-go-forward",
+                              self->go_forward, "sensitive",
+                              G_BINDING_SYNC_CREATE);
+    }
+}
+
+static void
 gb_view_stack_constructed (GObject *object)
 {
   GbViewStack *self = (GbViewStack *)object;
@@ -179,6 +205,7 @@ gb_view_stack_finalize (GObject *object)
   g_clear_pointer (&self->focus_history, g_list_free);
   ide_clear_weak_pointer (&self->title_binding);
   ide_clear_weak_pointer (&self->active_view);
+  g_clear_object (&self->back_forward_list);
 
   G_OBJECT_CLASS (gb_view_stack_parent_class)->finalize (object);
 }
@@ -288,6 +315,8 @@ gb_view_stack_init (GbViewStack *self)
                            G_CALLBACK (gb_view_stack__notify_visible_child),
                            self,
                            G_CONNECT_SWAPPED);
+
+  gb_widget_set_context_handler (self, gb_view_stack_context_handler);
 }
 
 GtkWidget *


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