[gtk/stack-fixes: 9/9] stack: Drop the position property



commit fe83a259c47e934047a1255476ae7f98cad43404
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Feb 8 18:32:28 2019 -0500

    stack: Drop the position property
    
    GtkStackSwitcher and GtkStackSidebar no longer
    use the GtkStackPage::position property, so we
    don't need to maintain it anymore.

 gtk/gtkstack.c | 85 ----------------------------------------------------------
 1 file changed, 85 deletions(-)
---
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 619531e3b6..ec5b4deaef 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -171,7 +171,6 @@ enum
   CHILD_PROP_NAME,
   CHILD_PROP_TITLE,
   CHILD_PROP_ICON_NAME,
-  CHILD_PROP_POSITION,
   CHILD_PROP_NEEDS_ATTENTION,
   CHILD_PROP_VISIBLE,
   LAST_CHILD_PROP
@@ -246,18 +245,6 @@ gtk_stack_page_get_property (GObject      *object,
       g_value_set_string (value, info->icon_name);
       break;
 
-    case CHILD_PROP_POSITION:
-      if (info->widget)
-        {
-          GtkWidget *stack = gtk_widget_get_parent (GTK_WIDGET (info->widget));
-          GtkStackPrivate *priv = gtk_stack_get_instance_private (GTK_STACK (stack));
-
-          g_value_set_int (value, g_list_index (priv->children, info));
-        }
-      else
-        g_value_set_int (value, 0);
-      break;
-
     case CHILD_PROP_NEEDS_ATTENTION:
       g_value_set_boolean (value, info->needs_attention);
       break;
@@ -272,10 +259,6 @@ gtk_stack_page_get_property (GObject      *object,
     }
 }
 
-static void reorder_child (GtkStack  *stack,
-                           GtkWidget *child,
-                           gint       position);
-
 static void
 gtk_stack_page_set_property (GObject      *object,
                              guint         property_id,
@@ -338,11 +321,6 @@ gtk_stack_page_set_property (GObject      *object,
       g_object_notify_by_pspec (object, pspec);
       break;
 
-    case CHILD_PROP_POSITION:
-      if (stack)
-        reorder_child (GTK_STACK (stack), info->widget, g_value_get_int (value));
-      break;
-
     case CHILD_PROP_NEEDS_ATTENTION:
       if (info->needs_attention != g_value_get_boolean (value))
         {
@@ -402,14 +380,6 @@ gtk_stack_page_class_init (GtkStackPageClass *class)
                          NULL,
                          GTK_PARAM_READWRITE);
 
-  stack_child_props[CHILD_PROP_POSITION] =
-    g_param_spec_int ("position",
-                      P_("Position"),
-                      P_("The index of the child in the parent"),
-                      -1, G_MAXINT,
-                      0,
-                      GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
   /**
    * GtkStack:needs-attention:
    *
@@ -840,59 +810,6 @@ find_child_info_for_widget (GtkStack  *stack,
   return NULL;
 }
 
-static void
-reorder_child (GtkStack  *stack,
-               GtkWidget *child,
-               gint       position)
-{
-  GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
-  GList *l;
-  GList *old_link = NULL;
-  GList *new_link = NULL;
-  GtkStackPage *child_info = NULL;
-  gint num = 0;
-
-  l = priv->children;
-
-  /* Loop to find the old position and link of child, new link of child and
-   * total number of children. new_link will be NULL if the child should be
-   * moved to the end (in case of position being < 0 || >= num)
-   */
-  while (l && (new_link == NULL || old_link == NULL))
-    {
-      /* Record the new position if found */
-      if (position == num)
-        new_link = l;
-
-      if (old_link == NULL)
-        {
-          GtkStackPage *info;
-          info = l->data;
-
-          /* Keep trying to find the current position and link location of the child */
-          if (info->widget == child)
-            {
-              old_link = l;
-              child_info = info;
-            }
-        }
-
-      l = l->next;
-      num++;
-    }
-
-  g_return_if_fail (old_link != NULL);
-
-  if (old_link == new_link || (old_link->next == NULL && new_link == NULL))
-    return;
-
-  priv->children = g_list_delete_link (priv->children, old_link);
-  priv->children = g_list_insert_before (priv->children, new_link, child_info);
-
-  gtk_container_child_notify_by_pspec (GTK_CONTAINER (stack), child, stack_child_props[CHILD_PROP_POSITION]);
-}
-
-
 static inline gboolean
 is_left_transition (GtkStackTransitionType transition_type)
 {
@@ -1480,8 +1397,6 @@ gtk_stack_add_page (GtkStack     *stack,
   g_signal_connect (child_info->widget, "notify::visible",
                     G_CALLBACK (stack_child_visibility_notify_cb), stack);
 
-  g_object_notify_by_pspec (G_OBJECT (child_info), stack_child_props[CHILD_PROP_POSITION]);
-
   if (priv->visible_child == NULL &&
       gtk_widget_get_visible (child_info->widget))
     set_visible_child (stack, child_info, priv->transition_type, priv->transition_duration);


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