[gnome-builder] navigation: start plumbing global navigation.



commit cb80bb3022a7088da44caa76a8534d1bc1134fde
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 23 18:52:16 2014 -0700

    navigation: start plumbing global navigation.

 src/gnome-builder.mk                |    5 +
 src/navigation/gb-navigation-item.c |  173 ++++++++++++++++++++++++++++++++
 src/navigation/gb-navigation-item.h |   63 ++++++++++++
 src/navigation/gb-navigation-list.c |  187 +++++++++++++++++++++++++++++++++++
 src/navigation/gb-navigation-list.h |   65 ++++++++++++
 src/resources/ui/gb-workbench.ui    |    2 +
 src/workbench/gb-workbench.c        |   59 +++++++++++-
 7 files changed, 553 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 4610b59..105ad01 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -42,6 +42,10 @@ gnome_builder_SOURCES = \
        src/markdown/gs-markdown.h \
        src/markdown/gb-markdown-preview.c \
        src/markdown/gb-markdown-preview.h \
+       src/navigation/gb-navigation-list.h \
+       src/navigation/gb-navigation-list.c \
+       src/navigation/gb-navigation-item.h \
+       src/navigation/gb-navigation-item.c \
        src/snippets/gb-source-snippet-chunk.c \
        src/snippets/gb-source-snippet-chunk.h \
        src/snippets/gb-source-snippet-completion-item.c \
@@ -126,6 +130,7 @@ gnome_builder_CFLAGS = \
        -I$(top_srcdir)/src/log \
        -I$(top_srcdir)/src/markdown \
        -I$(top_srcdir)/src/nautilus \
+       -I$(top_srcdir)/src/navigation \
        -I$(top_builddir)/src/resources \
        -I$(top_srcdir)/src/snippets \
        -I$(top_srcdir)/src/tabs \
diff --git a/src/navigation/gb-navigation-item.c b/src/navigation/gb-navigation-item.c
new file mode 100644
index 0000000..b50d581
--- /dev/null
+++ b/src/navigation/gb-navigation-item.c
@@ -0,0 +1,173 @@
+/* gb-navigation-item.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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-navigation-item.h"
+
+struct _GbNavigationItemPrivate
+{
+  gchar *label;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbNavigationItem, gb_navigation_item, G_TYPE_INITIALLY_UNOWNED)
+
+enum {
+  PROP_0,
+  PROP_LABEL,
+  LAST_PROP
+};
+
+enum {
+  ACTIVATE,
+  LAST_SIGNAL
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+static guint       gSignals [LAST_SIGNAL];
+
+GbNavigationItem *
+gb_navigation_item_new (const gchar *label)
+{
+  return g_object_new (GB_TYPE_NAVIGATION_ITEM,
+                       "label", label,
+                       NULL);
+}
+
+const gchar *
+gb_navigation_item_get_label (GbNavigationItem *item)
+{
+  g_return_val_if_fail (GB_IS_NAVIGATION_ITEM (item), NULL);
+  
+  return item->priv->label;
+}
+
+void
+gb_navigation_item_set_label (GbNavigationItem *item,
+                              const gchar      *label)
+{
+  g_return_if_fail (GB_IS_NAVIGATION_ITEM (item));
+  
+  g_free (item->priv->label);
+  item->priv->label = g_strdup (label);
+  g_object_notify_by_pspec (G_OBJECT (item), gParamSpecs [PROP_LABEL]);
+}
+
+void
+gb_navigation_item_emit_activate (GbNavigationItem *item)
+{
+  g_return_if_fail (GB_IS_NAVIGATION_ITEM (item));
+  
+  g_signal_emit (item, gSignals [ACTIVATE], 0);
+}
+
+static void
+gb_navigation_item_finalize (GObject *object)
+{
+  GbNavigationItemPrivate *priv = GB_NAVIGATION_ITEM (object)->priv;
+  
+  g_clear_pointer (&priv->label, g_free);
+
+  G_OBJECT_CLASS (gb_navigation_item_parent_class)->finalize (object);
+}
+
+static void
+gb_navigation_item_get_property (GObject    *object,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  GbNavigationItem *self = GB_NAVIGATION_ITEM (object);
+
+  switch (prop_id)
+    {
+    case PROP_LABEL:
+      g_value_set_string (value, gb_navigation_item_get_label (self));
+      break;
+      
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_navigation_item_set_property (GObject      *object,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  GbNavigationItem *self = GB_NAVIGATION_ITEM (object);
+
+  switch (prop_id)
+    {
+    case PROP_LABEL:
+      gb_navigation_item_set_label (self, g_value_get_string (value));
+      break;
+      
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_navigation_item_class_init (GbNavigationItemClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_navigation_item_finalize;
+  object_class->get_property = gb_navigation_item_get_property;
+  object_class->set_property = gb_navigation_item_set_property;
+  
+  /**
+   * GbNavigationItem:label:
+   * 
+   * The "label" for the item within the navigation list.
+   */
+  gParamSpecs [PROP_LABEL] =
+    g_param_spec_string ("label",
+                         _("Label"),
+                         _("The label for the navigation item."),
+                         NULL,
+                         (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_LABEL,
+                                   gParamSpecs [PROP_LABEL]);
+  
+  /**
+   * GbNavigationItem::activate:
+   * 
+   * This signal is emitted when the navigation item should be navigated
+   * to. The subscriber should change to their respective workspace and focus
+   * anything necessary to view the represented state.
+   */
+  gSignals [ACTIVATE] =
+    g_signal_new ("activate",
+                  GB_TYPE_NAVIGATION_ITEM,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GbNavigationItemClass, activate),
+                  NULL,
+                  NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  0);
+}
+
+static void
+gb_navigation_item_init (GbNavigationItem *self)
+{
+  self->priv = gb_navigation_item_get_instance_private (self);
+}
diff --git a/src/navigation/gb-navigation-item.h b/src/navigation/gb-navigation-item.h
new file mode 100644
index 0000000..b467f06
--- /dev/null
+++ b/src/navigation/gb-navigation-item.h
@@ -0,0 +1,63 @@
+/* gb-navigation-item.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_NAVIGATION_ITEM_H
+#define GB_NAVIGATION_ITEM_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_NAVIGATION_ITEM            (gb_navigation_item_get_type())
+#define GB_NAVIGATION_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_NAVIGATION_ITEM, 
GbNavigationItem))
+#define GB_NAVIGATION_ITEM_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_NAVIGATION_ITEM, 
GbNavigationItem const))
+#define GB_NAVIGATION_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GB_TYPE_NAVIGATION_ITEM, 
GbNavigationItemClass))
+#define GB_IS_NAVIGATION_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_NAVIGATION_ITEM))
+#define GB_IS_NAVIGATION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GB_TYPE_NAVIGATION_ITEM))
+#define GB_NAVIGATION_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GB_TYPE_NAVIGATION_ITEM, 
GbNavigationItemClass))
+
+typedef struct _GbNavigationItem        GbNavigationItem;
+typedef struct _GbNavigationItemClass   GbNavigationItemClass;
+typedef struct _GbNavigationItemPrivate GbNavigationItemPrivate;
+
+struct _GbNavigationItem
+{
+  GInitiallyUnowned parent;
+
+  /*< private >*/
+  GbNavigationItemPrivate *priv;
+};
+
+struct _GbNavigationItemClass
+{
+  GInitiallyUnownedClass parent;
+  
+  void (*activate) (GbNavigationItem *item);
+};
+
+GType             gb_navigation_item_get_type      (void) G_GNUC_CONST;
+GbNavigationItem *gb_navigation_item_new           (const gchar      *label);
+void              gb_navigation_item_emit_activate (GbNavigationItem *item);
+const gchar      *gb_navigation_item_get_label     (GbNavigationItem *item);
+void              gb_navigation_item_set_label     (GbNavigationItem *item,
+                                                    const gchar      *label);
+
+
+G_END_DECLS
+
+#endif /* GB_NAVIGATION_ITEM_H */
diff --git a/src/navigation/gb-navigation-list.c b/src/navigation/gb-navigation-list.c
new file mode 100644
index 0000000..f055ee7
--- /dev/null
+++ b/src/navigation/gb-navigation-list.c
@@ -0,0 +1,187 @@
+/* gb-navigation-list.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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-navigation-list.h"
+
+struct _GbNavigationListPrivate
+{
+  GPtrArray *items;
+  gint       current;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbNavigationList, gb_navigation_list, G_TYPE_OBJECT)
+
+enum {
+  PROP_0,
+  PROP_CAN_GO_BACKWARD,
+  PROP_CAN_GO_FORWARD,
+  PROP_CURRENT_ITEM,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GbNavigationList *
+gb_navigation_list_new (void)
+{
+  return g_object_new (GB_TYPE_NAVIGATION_LIST, NULL);
+}
+
+gboolean
+gb_navigation_list_get_can_go_backward (GbNavigationList *list)
+{
+  g_return_val_if_fail (GB_IS_NAVIGATION_LIST (list), FALSE);
+
+  return (list->priv->current > 0);
+}
+
+gboolean
+gb_navigation_list_get_can_go_forward (GbNavigationList *list)
+{
+  g_return_val_if_fail (GB_IS_NAVIGATION_LIST (list), FALSE);
+
+  return ((list->priv->current + 1) < list->priv->items->len);
+}
+
+void
+gb_navigation_list_go_backward (GbNavigationList *list)
+{
+  g_return_if_fail (GB_IS_NAVIGATION_LIST (list));
+
+  if (gb_navigation_list_get_can_go_backward (list))
+    {
+      g_object_notify_by_pspec (G_OBJECT (list),
+                                gParamSpecs [PROP_CURRENT_ITEM]);
+      g_object_notify_by_pspec (G_OBJECT (list),
+                                gParamSpecs [PROP_CAN_GO_BACKWARD]);
+      g_object_notify_by_pspec (G_OBJECT (list),
+                                gParamSpecs [PROP_CAN_GO_FORWARD]);
+    }
+}
+
+void
+gb_navigation_list_go_forward (GbNavigationList *list)
+{
+  g_return_if_fail (GB_IS_NAVIGATION_LIST (list));
+
+  if (gb_navigation_list_get_can_go_forward (list))
+    {
+      g_object_notify_by_pspec (G_OBJECT (list),
+                                gParamSpecs [PROP_CURRENT_ITEM]);
+      g_object_notify_by_pspec (G_OBJECT (list),
+                                gParamSpecs [PROP_CAN_GO_BACKWARD]);
+      g_object_notify_by_pspec (G_OBJECT (list),
+                                gParamSpecs [PROP_CAN_GO_FORWARD]);
+    }
+}
+
+GbNavigationItem *
+gb_navigation_list_get_current_item (GbNavigationList *list)
+{
+  g_return_val_if_fail (GB_IS_NAVIGATION_LIST (list), NULL);
+
+  if (list->priv->current < list->priv->items->len)
+    return g_ptr_array_index (list->priv->items, list->priv->current);
+
+  return NULL;
+}
+
+static void
+gb_navigation_list_finalize (GObject *object)
+{
+  GbNavigationListPrivate *priv = GB_NAVIGATION_LIST (object)->priv;
+
+  g_clear_pointer (&priv->items, g_ptr_array_unref);
+
+  G_OBJECT_CLASS (gb_navigation_list_parent_class)->finalize (object);
+}
+
+static void
+gb_navigation_list_get_property (GObject    *object,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  GbNavigationList *self = GB_NAVIGATION_LIST (object);
+
+  switch (prop_id)
+    {
+    case PROP_CAN_GO_BACKWARD:
+      g_value_set_boolean (value, gb_navigation_list_get_can_go_backward (self));
+      break;
+
+    case PROP_CAN_GO_FORWARD:
+      g_value_set_boolean (value, gb_navigation_list_get_can_go_forward (self));
+      break;
+
+    case PROP_CURRENT_ITEM:
+      g_value_set_object (value, gb_navigation_list_get_current_item (self));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gb_navigation_list_class_init (GbNavigationListClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_navigation_list_finalize;
+  object_class->get_property = gb_navigation_list_get_property;
+
+  gParamSpecs [PROP_CAN_GO_BACKWARD] =
+    g_param_spec_boolean ("can-go-backward",
+                          _("Can Go Backward"),
+                          _("If we can go backwards in the navigation list."),
+                          FALSE,
+                          (G_PARAM_READABLE |
+                           G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_CAN_GO_BACKWARD,
+                                   gParamSpecs [PROP_CAN_GO_BACKWARD]);
+
+  gParamSpecs [PROP_CAN_GO_FORWARD] =
+    g_param_spec_boolean ("can-go-forward",
+                          _("Can Go Forward"),
+                          _("If we can go forward in the navigation list."),
+                          FALSE,
+                          (G_PARAM_READABLE |
+                           G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_CAN_GO_FORWARD,
+                                   gParamSpecs [PROP_CAN_GO_FORWARD]);
+
+  gParamSpecs [PROP_CURRENT_ITEM] =
+    g_param_spec_object ("current-item",
+                         _("Current Item"),
+                         _("The current item in the navigation list."),
+                         GB_TYPE_NAVIGATION_ITEM,
+                         (G_PARAM_READABLE |
+                          G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_CURRENT_ITEM,
+                                   gParamSpecs [PROP_CURRENT_ITEM]);
+}
+
+static void
+gb_navigation_list_init (GbNavigationList *self)
+{
+  self->priv = gb_navigation_list_get_instance_private (self);
+  self->priv->items = g_ptr_array_new_with_free_func (g_object_unref);
+}
diff --git a/src/navigation/gb-navigation-list.h b/src/navigation/gb-navigation-list.h
new file mode 100644
index 0000000..c2c62e9
--- /dev/null
+++ b/src/navigation/gb-navigation-list.h
@@ -0,0 +1,65 @@
+/* gb-navigation-list.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_NAVIGATION_LIST_H
+#define GB_NAVIGATION_LIST_H
+
+#include <glib-object.h>
+
+#include "gb-navigation-item.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_NAVIGATION_LIST            (gb_navigation_list_get_type())
+#define GB_NAVIGATION_LIST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_NAVIGATION_LIST, 
GbNavigationList))
+#define GB_NAVIGATION_LIST_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_NAVIGATION_LIST, 
GbNavigationList const))
+#define GB_NAVIGATION_LIST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GB_TYPE_NAVIGATION_LIST, 
GbNavigationListClass))
+#define GB_IS_NAVIGATION_LIST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_NAVIGATION_LIST))
+#define GB_IS_NAVIGATION_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GB_TYPE_NAVIGATION_LIST))
+#define GB_NAVIGATION_LIST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GB_TYPE_NAVIGATION_LIST, 
GbNavigationListClass))
+
+typedef struct _GbNavigationList        GbNavigationList;
+typedef struct _GbNavigationListClass   GbNavigationListClass;
+typedef struct _GbNavigationListPrivate GbNavigationListPrivate;
+
+struct _GbNavigationList
+{
+  GObject parent;
+
+  /*< private >*/
+  GbNavigationListPrivate *priv;
+};
+
+struct _GbNavigationListClass
+{
+  GObjectClass parent;
+};
+
+GType                 gb_navigation_list_get_type            (void) G_GNUC_CONST;
+GbNavigationList     *gb_navigation_list_new                 (void);
+gboolean              gb_navigation_list_get_can_go_backward (GbNavigationList *list);
+gboolean              gb_navigation_list_get_can_go_forward  (GbNavigationList *list);
+GbNavigationItem     *gb_navigation_list_get_current_item    (GbNavigationList *list);
+void                  gb_navigation_list_append              (GbNavigationList *list,
+                                                              GbNavigationItem *item);
+void                  gb_navigation_list_go_backward         (GbNavigationList *list);
+void                  gb_navigation_list_go_forward          (GbNavigationList *list);
+
+G_END_DECLS
+
+#endif /* GB_NAVIGATION_LIST_H */
diff --git a/src/resources/ui/gb-workbench.ui b/src/resources/ui/gb-workbench.ui
index 49b1e8a..db34f5c 100644
--- a/src/resources/ui/gb-workbench.ui
+++ b/src/resources/ui/gb-workbench.ui
@@ -17,6 +17,7 @@
             </style>
             <child>
               <object class="GtkButton" id="back_button">
+                <property name="action-name">workbench.go-backward</property>
                 <property name="visible">True</property>
                 <property name="sensitive">False</property>
                 <style>
@@ -36,6 +37,7 @@
                 <style>
                   <class name="image-button"/>
                 </style>
+                <property name="action-name">workbench.go-forward</property>
                 <property name="visible">True</property>
                 <property name="sensitive">False</property>
                 <child>
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 40fc522..292334b 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -23,6 +23,7 @@
 #include "gb-devhelp-workspace.h"
 #include "gb-editor-workspace.h"
 #include "gb-log.h"
+#include "gb-navigation-list.h"
 #include "gb-widget.h"
 #include "gb-workbench.h"
 #include "gb-workbench-actions.h"
@@ -33,6 +34,7 @@
 struct _GbWorkbenchPrivate
 {
   GbWorkbenchActions     *actions;
+  GbNavigationList       *navigation_list;
 
   GbWorkspace            *active_workspace;
   GbWorkspace            *devhelp;
@@ -50,6 +52,7 @@ struct _GbWorkbenchPrivate
 
 enum {
   PROP_0,
+  PROP_NAVIGATION_LIST,
   LAST_PROP
 };
 
@@ -62,7 +65,24 @@ G_DEFINE_TYPE_WITH_PRIVATE (GbWorkbench,
                             gb_workbench,
                             GTK_TYPE_APPLICATION_WINDOW)
 
-static guint gSignals[LAST_SIGNAL];
+static GParamSpec *gParamSpecs [LAST_PROP];
+static guint       gSignals [LAST_SIGNAL];
+
+/**
+ * gb_workbench_get_navigation_list:
+ *
+ * Fetches the navigation list for the workbench. This can be used to move
+ * between edit points between workspaces.
+ *
+ * Returns: (transfer none): A #GbNavigationlist.
+ */
+GbNavigationList *
+gb_workbench_get_navigation_list (GbWorkbench *workbench)
+{
+  g_return_val_if_fail (GB_IS_WORKBENCH (workbench), NULL);
+
+  return workbench->priv->navigation_list;
+}
 
 GbWorkspace *
 gb_workbench_get_active_workspace (GbWorkbench *workbench)
@@ -192,15 +212,32 @@ on_workspace2_activate (GSimpleAction *action,
 }
 
 static void
+on_go_forward_activate (GSimpleAction *action,
+                        GVariant      *variant,
+                        gpointer       user_data)
+{
+}
+
+static void
+on_go_backward_activate (GSimpleAction *action,
+                         GVariant      *variant,
+                         gpointer       user_data)
+{
+}
+
+static void
 gb_workbench_constructed (GObject *object)
 {
   static const GActionEntry actions[] = {
     { "workspace1", on_workspace1_activate },
     { "workspace2", on_workspace2_activate },
+    { "go-backward", on_go_backward_activate },
+    { "go-forward", on_go_forward_activate },
   };
   GbWorkbenchPrivate *priv;
   GbWorkbench *workbench = (GbWorkbench *)object;
   GtkApplication *app;
+  GAction *action;
   GMenu *menu;
 
   g_assert (GB_IS_WORKBENCH (workbench));
@@ -228,6 +265,14 @@ gb_workbench_constructed (GObject *object)
   g_action_map_add_action_entries (G_ACTION_MAP (workbench), actions,
                                    G_N_ELEMENTS (actions), workbench);
 
+  action = g_action_map_lookup_action (G_ACTION_MAP (workbench), "go-backward");
+  g_object_bind_property (priv->navigation_list, "can-go-backward",
+                          action, "enabled", G_BINDING_SYNC_CREATE);
+
+  action = g_action_map_lookup_action (G_ACTION_MAP (workbench), "go-forward");
+  g_object_bind_property (priv->navigation_list, "can-go-forward",
+                          action, "enabled", G_BINDING_SYNC_CREATE);
+
   G_OBJECT_CLASS (gb_workbench_parent_class)->constructed (object);
 
   EXIT;
@@ -243,6 +288,7 @@ gb_workbench_dispose (GObject *object)
   priv = GB_WORKBENCH (object)->priv;
 
   g_clear_object (&priv->actions);
+  g_clear_object (&priv->navigation_list);
 
   G_OBJECT_CLASS (gb_workbench_parent_class)->dispose (object);
 
@@ -290,6 +336,16 @@ gb_workbench_class_init (GbWorkbenchClass *klass)
 
   klass->workspace_changed = gb_workbench_workspace_changed;
 
+  gParamSpecs [PROP_NAVIGATION_LIST] =
+    g_param_spec_object ("navigation-list",
+                         _("Navigation List"),
+                         _("The navigation list for the workbench."),
+                         GB_TYPE_NAVIGATION_LIST,
+                         (G_PARAM_READABLE |
+                          G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_NAVIGATION_LIST,
+                                   gParamSpecs [PROP_NAVIGATION_LIST]);
+
   gSignals [WORKSPACE_CHANGED] =
     g_signal_new ("workspace-changed",
                   G_OBJECT_CLASS_TYPE (object_class),
@@ -338,6 +394,7 @@ gb_workbench_init (GbWorkbench *workbench)
 
   gtk_widget_init_template (GTK_WIDGET (workbench));
 
+  workbench->priv->navigation_list = gb_navigation_list_new ();
   workbench->priv->actions = gb_workbench_actions_new (workbench);
   gtk_widget_insert_action_group (GTK_WIDGET (workbench),
                                   "workbench",


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