[gnome-builder/wip/libide-merge] add back/forward plumbing to navigation list



commit b99ac383a342811e24c1d7692fae7454a672c686
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 20 20:08:38 2015 -0700

    add back/forward plumbing to navigation list

 data/ui/gb-view-stack.ui          |    7 ++-----
 src/editor/gb-editor-frame.c      |   14 ++++++++++++++
 src/editor/gb-editor-view.c       |   15 +++++++++++++++
 src/views/gb-view-stack-actions.c |   28 ++++++++++++++++++++++++++++
 4 files changed, 59 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/gb-view-stack.ui b/data/ui/gb-view-stack.ui
index 5fefc89..e1bb205 100644
--- a/data/ui/gb-view-stack.ui
+++ b/data/ui/gb-view-stack.ui
@@ -26,13 +26,10 @@
                   <object class="GtkBox">
                     <property name="orientation">horizontal</property>
                     <property name="visible">true</property>
-                    <style>
-                      <class name="linked"/>
-                    </style>
                     <child>
                       <object class="GtkButton" id="go_backward">
                         <property name="visible">true</property>
-                        <property name="action-name">navigation.go-backward</property>
+                        <property name="action-name">view-stack.go-backward</property>
                         <style>
                           <class name="dim-label"/>
                           <class name="flat"/>
@@ -49,7 +46,7 @@
                     <child>
                       <object class="GtkButton" id="go_forward">
                         <property name="visible">true</property>
-                        <property name="action-name">navigation.go-forward</property>
+                        <property name="action-name">view-stack.go-forward</property>
                         <style>
                           <class name="dim-label"/>
                           <class name="flat"/>
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 53a735c..d688d35 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -31,6 +31,7 @@ G_DEFINE_TYPE (GbEditorFrame, gb_editor_frame, GTK_TYPE_BIN)
 
 enum {
   PROP_0,
+  PROP_BACK_FORWARD_LIST,
   PROP_DOCUMENT,
   LAST_PROP
 };
@@ -413,6 +414,10 @@ gb_editor_frame_set_property (GObject      *object,
       gb_editor_frame_set_document (self, g_value_get_object (value));
       break;
 
+    case PROP_BACK_FORWARD_LIST:
+      ide_source_view_set_back_forward_list (self->source_view, g_value_get_object (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -431,6 +436,15 @@ gb_editor_frame_class_init (GbEditorFrameClass *klass)
 
   widget_class->grab_focus = gb_editor_frame_grab_focus;
 
+  gParamSpecs [PROP_BACK_FORWARD_LIST] =
+    g_param_spec_object ("back-forward-list",
+                         _("Back Forward List"),
+                         _("The back forward list."),
+                         IDE_TYPE_BACK_FORWARD_LIST,
+                         (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_BACK_FORWARD_LIST,
+                                   gParamSpecs [PROP_BACK_FORWARD_LIST]);
+
   gParamSpecs [PROP_DOCUMENT] =
     g_param_spec_object ("document",
                          _("Document"),
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index c912674..ed4fd55 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -155,6 +155,20 @@ gb_editor_view_set_split_view (GbView   *view,
 }
 
 static void
+gb_editor_view_set_back_forward_list (GbView             *view,
+                                      IdeBackForwardList *back_forward_list)
+{
+  GbEditorView *self = (GbEditorView *)view;
+
+  g_assert (GB_IS_VIEW (view));
+  g_assert (IDE_IS_BACK_FORWARD_LIST (back_forward_list));
+
+  g_object_set (self->frame1, "back-forward-list", back_forward_list, NULL);
+  if (self->frame2)
+    g_object_set (self->frame2, "back-forward-list", back_forward_list, NULL);
+}
+
+static void
 gb_editor_view_finalize (GObject *object)
 {
   GbEditorView *self = (GbEditorView *)object;
@@ -219,6 +233,7 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
   view_class->create_split = gb_editor_view_create_split;
   view_class->get_document = gb_editor_view_get_document;
   view_class->set_split_view = gb_editor_view_set_split_view;
+  view_class->set_back_forward_list = gb_editor_view_set_back_forward_list;
 
   gParamSpecs [PROP_DOCUMENT] =
     g_param_spec_object ("document",
diff --git a/src/views/gb-view-stack-actions.c b/src/views/gb-view-stack-actions.c
index 1cf5a1c..e0abaea 100644
--- a/src/views/gb-view-stack-actions.c
+++ b/src/views/gb-view-stack-actions.c
@@ -252,8 +252,36 @@ gb_view_stack_actions_previous_view (GSimpleAction *action,
   IDE_EXIT;
 }
 
+static void
+gb_view_stack_actions_go_forward (GSimpleAction *action,
+                                  GVariant      *param,
+                                  gpointer       user_data)
+{
+  GbViewStack *self = user_data;
+
+  g_assert (GB_IS_VIEW_STACK (self));
+
+  if (ide_back_forward_list_get_can_go_forward (self->back_forward_list))
+    ide_back_forward_list_go_forward (self->back_forward_list);
+}
+
+static void
+gb_view_stack_actions_go_backward (GSimpleAction *action,
+                                   GVariant      *param,
+                                   gpointer       user_data)
+{
+  GbViewStack *self = user_data;
+
+  g_assert (GB_IS_VIEW_STACK (self));
+
+  if (ide_back_forward_list_get_can_go_backward (self->back_forward_list))
+    ide_back_forward_list_go_backward (self->back_forward_list);
+}
+
 static const GActionEntry gGbViewStackActions[] = {
   { "close",         gb_view_stack_actions_close },
+  { "go-forward",    gb_view_stack_actions_go_forward },
+  { "go-backward",   gb_view_stack_actions_go_backward },
   { "move-left",     gb_view_stack_actions_move_left },
   { "move-right",    gb_view_stack_actions_move_right },
   { "next-view",     gb_view_stack_actions_next_view },


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