[gnome-builder/wip/libide: 60/153] libide: add IdeBackForwardList:current-item property



commit 53926645837c6b416456fcf54927e2f5a41dc357
Author: Christian Hergert <christian hergert me>
Date:   Tue Feb 10 14:41:49 2015 -0800

    libide: add IdeBackForwardList:current-item property

 libide/ide-back-forward-list.c |   34 ++++++++++++++++++++++++++++++++++
 libide/ide-back-forward-list.h |    1 +
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-back-forward-list.c b/libide/ide-back-forward-list.c
index 762d74e..a4ffc05 100644
--- a/libide/ide-back-forward-list.c
+++ b/libide/ide-back-forward-list.c
@@ -36,6 +36,7 @@ enum {
   PROP_0,
   PROP_CAN_GO_BACKWARD,
   PROP_CAN_GO_FORWARD,
+  PROP_CURRENT_ITEM,
   LAST_PROP
 };
 
@@ -47,6 +48,26 @@ enum {
 static GParamSpec *gParamSpecs [LAST_PROP];
 static guint       gSignals [LAST_SIGNAL];
 
+/**
+ * ide_back_forward_list_get_current_item:
+ *
+ * Retrieves the current #IdeBackForwardItem or %NULL if no items have been
+ * added to the #IdeBackForwardList.
+ *
+ * Returns: (transfer none) (nullable): An #IdeBackForwardItem or %NULL.
+ */
+IdeBackForwardItem *
+ide_back_forward_list_get_current_item (IdeBackForwardList *self)
+{
+  IdeBackForwardListPrivate *priv;
+
+  g_return_val_if_fail (IDE_IS_BACK_FORWARD_LIST (self), NULL);
+
+  priv = ide_back_forward_list_get_instance_private (self);
+
+  return priv->current_item;
+}
+
 static void
 ide_back_forward_list_navigate_to (IdeBackForwardList *self,
                                    IdeBackForwardItem *item)
@@ -363,6 +384,10 @@ ide_back_forward_list_get_property (GObject    *object,
                            ide_back_forward_list_get_can_go_forward (self));
       break;
 
+    case PROP_CURRENT_ITEM:
+      g_value_set_object (value, ide_back_forward_list_get_current_item (self));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -394,6 +419,15 @@ ide_back_forward_list_class_init (IdeBackForwardListClass *klass)
   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 navigation item."),
+                         IDE_TYPE_BACK_FORWARD_ITEM,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_CURRENT_ITEM,
+                                   gParamSpecs [PROP_CURRENT_ITEM]);
+
   gSignals [NAVIGATE_TO] =
     g_signal_new ("navigate-to",
                   G_TYPE_FROM_CLASS (klass),
diff --git a/libide/ide-back-forward-list.h b/libide/ide-back-forward-list.h
index 3e506f5..0e66a2d 100644
--- a/libide/ide-back-forward-list.h
+++ b/libide/ide-back-forward-list.h
@@ -36,6 +36,7 @@ void                ide_back_forward_list_go_backward         (IdeBackForwardLis
 void                ide_back_forward_list_go_forward          (IdeBackForwardList *self);
 gboolean            ide_back_forward_list_get_can_go_backward (IdeBackForwardList *self);
 gboolean            ide_back_forward_list_get_can_go_forward  (IdeBackForwardList *self);
+IdeBackForwardItem *ide_back_forward_list_get_current_item    (IdeBackForwardList *self);
 void                ide_back_forward_list_push                (IdeBackForwardList *self,
                                                                IdeBackForwardItem *item);
 IdeBackForwardList *ide_back_forward_list_branch              (IdeBackForwardList *self);


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