[gnome-builder] libide: make structure definition private



commit a03a7194140346f234d559a9c2c17f8c572a52ea
Author: Christian Hergert <christian hergert me>
Date:   Thu Mar 12 18:00:21 2015 -0700

    libide: make structure definition private

 libide/ide-back-forward-list.c |  151 +++++++++++++++-------------------------
 libide/ide-back-forward-list.h |    5 --
 2 files changed, 56 insertions(+), 100 deletions(-)
---
diff --git a/libide/ide-back-forward-list.c b/libide/ide-back-forward-list.c
index 52fa499..1103100 100644
--- a/libide/ide-back-forward-list.c
+++ b/libide/ide-back-forward-list.c
@@ -23,14 +23,17 @@
 #include "ide-back-forward-item.h"
 #include "ide-back-forward-list.h"
 
-typedef struct
+struct _IdeBackForwardList
 {
+  IdeObject           parent_instance;
+
   GQueue             *backward;
   IdeBackForwardItem *current_item;
   GQueue             *forward;
-} IdeBackForwardListPrivate;
+};
+
 
-G_DEFINE_TYPE_WITH_PRIVATE (IdeBackForwardList, ide_back_forward_list, IDE_TYPE_OBJECT)
+G_DEFINE_TYPE (IdeBackForwardList, ide_back_forward_list, IDE_TYPE_OBJECT)
 
 enum {
   PROP_0,
@@ -59,13 +62,9 @@ static guint       gSignals [LAST_SIGNAL];
 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;
+  return self->current_item;
 }
 
 static void
@@ -81,27 +80,22 @@ ide_back_forward_list_navigate_to (IdeBackForwardList *self,
 void
 ide_back_forward_list_go_backward (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
   IdeBackForwardItem *current_item;
 
   g_return_if_fail (IDE_IS_BACK_FORWARD_LIST (self));
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
-  current_item = g_queue_pop_head (priv->backward);
+  current_item = g_queue_pop_head (self->backward);
 
   if (current_item)
     {
-      if (priv->current_item)
-        g_queue_push_head (priv->forward, priv->current_item);
+      if (self->current_item)
+        g_queue_push_head (self->forward, self->current_item);
 
-      priv->current_item = current_item;
-      ide_back_forward_list_navigate_to (self, priv->current_item);
+      self->current_item = current_item;
+      ide_back_forward_list_navigate_to (self, self->current_item);
 
-      g_object_notify_by_pspec (G_OBJECT (self),
-                                gParamSpecs [PROP_CAN_GO_BACKWARD]);
-      g_object_notify_by_pspec (G_OBJECT (self),
-                                gParamSpecs [PROP_CAN_GO_FORWARD]);
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_BACKWARD]);
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_FORWARD]);
     }
   else
     g_warning ("Cannot go backward, no more items in queue.");
@@ -110,27 +104,22 @@ ide_back_forward_list_go_backward (IdeBackForwardList *self)
 void
 ide_back_forward_list_go_forward (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
   IdeBackForwardItem *current_item;
 
   g_return_if_fail (IDE_IS_BACK_FORWARD_LIST (self));
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
-  current_item = g_queue_pop_head (priv->forward);
+  current_item = g_queue_pop_head (self->forward);
 
   if (current_item)
     {
-      if (priv->current_item)
-        g_queue_push_head (priv->backward, priv->current_item);
+      if (self->current_item)
+        g_queue_push_head (self->backward, self->current_item);
 
-      priv->current_item = current_item;
-      ide_back_forward_list_navigate_to (self, priv->current_item);
+      self->current_item = current_item;
+      ide_back_forward_list_navigate_to (self, self->current_item);
 
-      g_object_notify_by_pspec (G_OBJECT (self),
-                                gParamSpecs [PROP_CAN_GO_BACKWARD]);
-      g_object_notify_by_pspec (G_OBJECT (self),
-                                gParamSpecs [PROP_CAN_GO_FORWARD]);
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_BACKWARD]);
+      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_FORWARD]);
     }
   else
     g_warning ("Cannot go forward, no more items in queue.");
@@ -139,38 +128,26 @@ ide_back_forward_list_go_forward (IdeBackForwardList *self)
 gboolean
 ide_back_forward_list_get_can_go_backward (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
-
   g_return_val_if_fail (IDE_IS_BACK_FORWARD_LIST (self), FALSE);
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
-  return (priv->backward->length > 0);
+  return (self->backward->length > 0);
 }
 
 gboolean
 ide_back_forward_list_get_can_go_forward (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
-
   g_return_val_if_fail (IDE_IS_BACK_FORWARD_LIST (self), FALSE);
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
-  return (priv->forward->length > 0);
+  return (self->forward->length > 0);
 }
 
 void
 ide_back_forward_list_push (IdeBackForwardList *self,
                             IdeBackForwardItem *item)
 {
-  IdeBackForwardListPrivate *priv;
-
   g_return_if_fail (IDE_IS_BACK_FORWARD_LIST (self));
   g_return_if_fail (IDE_IS_BACK_FORWARD_ITEM (item));
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
   /*
    * The following algorithm tries to loosely copy the design of jump lists
    * in Vim. If we are not all the way forward, we push all items back onto
@@ -180,34 +157,32 @@ ide_back_forward_list_push (IdeBackForwardList *self,
    * the history from previously forward progress.
    */
 
-  if (!priv->current_item)
+  if (!self->current_item)
     {
-      priv->current_item = g_object_ref (item);
+      self->current_item = g_object_ref (item);
 
-      g_return_if_fail (priv->backward->length == 0);
-      g_return_if_fail (priv->forward->length == 0);
+      g_return_if_fail (self->backward->length == 0);
+      g_return_if_fail (self->forward->length == 0);
 
       return;
     }
 
-  g_queue_push_head (priv->backward, priv->current_item);
+  g_queue_push_head (self->backward, self->current_item);
 
-  if (priv->forward->length)
+  if (self->forward->length)
     {
-      while (priv->forward->length)
-        g_queue_push_head (priv->backward, g_queue_pop_head (priv->forward));
-      g_queue_push_head (priv->backward, g_object_ref (priv->current_item));
+      while (self->forward->length)
+        g_queue_push_head (self->backward, g_queue_pop_head (self->forward));
+      g_queue_push_head (self->backward, g_object_ref (self->current_item));
     }
 
-  priv->current_item = g_object_ref (item);
+  self->current_item = g_object_ref (item);
 
-  g_object_notify_by_pspec (G_OBJECT (self),
-                            gParamSpecs [PROP_CAN_GO_BACKWARD]);
-  g_object_notify_by_pspec (G_OBJECT (self),
-                            gParamSpecs [PROP_CAN_GO_FORWARD]);
+  g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_BACKWARD]);
+  g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_FORWARD]);
 
-  g_return_if_fail (priv->forward->length == 0);
-  g_return_if_fail (priv->backward->length > 0);
+  g_return_if_fail (self->forward->length == 0);
+  g_return_if_fail (self->backward->length > 0);
 }
 
 /**
@@ -224,31 +199,28 @@ ide_back_forward_list_push (IdeBackForwardList *self,
 IdeBackForwardList *
 ide_back_forward_list_branch (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
   IdeBackForwardList *ret;
   IdeContext *context;
   GList *iter;
 
   g_return_val_if_fail (IDE_IS_BACK_FORWARD_LIST (self), NULL);
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
   context = ide_object_get_context (IDE_OBJECT (self));
 
   ret = g_object_new (IDE_TYPE_BACK_FORWARD_LIST,
                       "context", context,
                       NULL);
 
-  for (iter = priv->backward->head; iter; iter = iter->next)
+  for (iter = self->backward->head; iter; iter = iter->next)
     {
       IdeBackForwardItem *item = iter->data;
       ide_back_forward_list_push (ret, item);
     }
 
-  if (priv->current_item)
-    ide_back_forward_list_push (ret, priv->current_item);
+  if (self->current_item)
+    ide_back_forward_list_push (ret, self->current_item);
 
-  for (iter = priv->forward->head; iter; iter = iter->next)
+  for (iter = self->forward->head; iter; iter = iter->next)
     {
       IdeBackForwardItem *item = iter->data;
       ide_back_forward_list_push (ret, item);
@@ -260,23 +232,20 @@ ide_back_forward_list_branch (IdeBackForwardList *self)
 static GPtrArray *
 ide_back_forward_list_to_array (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
   GPtrArray *ret;
   GList *iter;
 
   g_return_val_if_fail (IDE_IS_BACK_FORWARD_LIST (self), NULL);
 
-  priv = ide_back_forward_list_get_instance_private (self);
-
   ret = g_ptr_array_new ();
 
-  for (iter = priv->backward->tail; iter; iter = iter->prev)
+  for (iter = self->backward->tail; iter; iter = iter->prev)
     g_ptr_array_add (ret, iter->data);
 
-  if (priv->current_item)
-    g_ptr_array_add (ret, priv->current_item);
+  if (self->current_item)
+    g_ptr_array_add (ret, self->current_item);
 
-  for (iter = priv->forward->head; iter; iter = iter->next)
+  for (iter = self->forward->head; iter; iter = iter->next)
     g_ptr_array_add (ret, iter->data);
 
   return ret;
@@ -361,21 +330,20 @@ static void
 ide_back_forward_list_dispose (GObject *object)
 {
   IdeBackForwardList *self = (IdeBackForwardList *)object;
-  IdeBackForwardListPrivate *priv = ide_back_forward_list_get_instance_private (self);
   IdeBackForwardItem *item;
 
-  if (priv->backward)
+  if (self->backward)
     {
-      while ((item = g_queue_pop_head (priv->backward)))
+      while ((item = g_queue_pop_head (self->backward)))
         g_object_unref (item);
-      g_clear_pointer (&priv->backward, g_queue_free);
+      g_clear_pointer (&self->backward, g_queue_free);
     }
 
-  if (priv->forward)
+  if (self->forward)
     {
-      while ((item = g_queue_pop_head (priv->forward)))
+      while ((item = g_queue_pop_head (self->forward)))
         g_object_unref (item);
-      g_clear_pointer (&priv->forward, g_queue_free);
+      g_clear_pointer (&self->forward, g_queue_free);
     }
 
   G_OBJECT_CLASS (ide_back_forward_list_parent_class)->dispose (object);
@@ -392,13 +360,11 @@ ide_back_forward_list_get_property (GObject    *object,
   switch (prop_id)
     {
     case PROP_CAN_GO_BACKWARD:
-      g_value_set_boolean (value,
-                           ide_back_forward_list_get_can_go_backward (self));
+      g_value_set_boolean (value, ide_back_forward_list_get_can_go_backward (self));
       break;
 
     case PROP_CAN_GO_FORWARD:
-      g_value_set_boolean (value,
-                           ide_back_forward_list_get_can_go_forward (self));
+      g_value_set_boolean (value, ide_back_forward_list_get_can_go_forward (self));
       break;
 
     case PROP_CURRENT_ITEM:
@@ -450,8 +416,7 @@ ide_back_forward_list_class_init (IdeBackForwardListClass *klass)
                   G_TYPE_FROM_CLASS (klass),
                   G_SIGNAL_RUN_LAST,
                   0,
-                  NULL,
-                  NULL,
+                  NULL, NULL,
                   g_cclosure_marshal_VOID__OBJECT,
                   G_TYPE_NONE,
                   1,
@@ -461,10 +426,6 @@ ide_back_forward_list_class_init (IdeBackForwardListClass *klass)
 static void
 ide_back_forward_list_init (IdeBackForwardList *self)
 {
-  IdeBackForwardListPrivate *priv;
-
-  priv = ide_back_forward_list_get_instance_private (self);
-
-  priv->backward = g_queue_new ();
-  priv->forward = g_queue_new ();
+  self->backward = g_queue_new ();
+  self->forward = g_queue_new ();
 }
diff --git a/libide/ide-back-forward-list.h b/libide/ide-back-forward-list.h
index 0e66a2d..8f49288 100644
--- a/libide/ide-back-forward-list.h
+++ b/libide/ide-back-forward-list.h
@@ -27,11 +27,6 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (IdeBackForwardList, ide_back_forward_list, IDE, BACK_FORWARD_LIST, IdeObject)
 
-struct _IdeBackForwardList
-{
-  IdeObject parent_instance;
-};
-
 void                ide_back_forward_list_go_backward         (IdeBackForwardList *self);
 void                ide_back_forward_list_go_forward          (IdeBackForwardList *self);
 gboolean            ide_back_forward_list_get_can_go_backward (IdeBackForwardList *self);


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