[gtk+] combobox: Stop using old styling code



commit bf95c8462bbc2420bea95885bf7fb8a21b4ed878
Author: Benjamin Otte <otte redhat com>
Date:   Sun Sep 13 01:52:49 2015 +0200

    combobox: Stop using old styling code
    
    Instead of get_path_for_child() use CSS nodes.

 gtk/gtkcombobox.c |   89 ++++------------------------------------------------
 1 files changed, 7 insertions(+), 82 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 4d2d825..c9962ba 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -26,6 +26,7 @@
 #include "gtkcelllayout.h"
 #include "gtkcellrenderertext.h"
 #include "gtkcellview.h"
+#include "gtkcssnodeprivate.h"
 #include "gtkeventbox.h"
 #include "gtkframe.h"
 #include "gtkbox.h"
@@ -453,8 +454,6 @@ static void     gtk_combo_box_get_preferred_height_for_width (GtkWidget    *widg
                                                               gint          avail_size,
                                                               gint         *minimum_size,
                                                               gint         *natural_size);
-static GtkWidgetPath *gtk_combo_box_get_path_for_child       (GtkContainer *container,
-                                                              GtkWidget    *child);
 static void     gtk_combo_box_direction_changed              (GtkWidget    *widget,
                                                               GtkTextDirection  previous_direction);
 
@@ -481,7 +480,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   container_class->forall = gtk_combo_box_forall;
   container_class->add = gtk_combo_box_add;
   container_class->remove = gtk_combo_box_remove;
-  container_class->get_path_for_child = gtk_combo_box_get_path_for_child;
 
   gtk_container_class_handle_border_width (container_class);
 
@@ -1363,88 +1361,10 @@ gtk_combo_box_button_state_flags_changed (GtkWidget     *widget,
 }
 
 static void
-gtk_combo_box_invalidate_order_foreach (GtkWidget *widget)
-{
-  _gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
-}
-
-static void
-gtk_combo_box_invalidate_order (GtkComboBox *combo_box)
-{
-  gtk_container_forall (GTK_CONTAINER (combo_box),
-                        (GtkCallback) gtk_combo_box_invalidate_order_foreach,
-                        NULL);
-}
-
-static void
 gtk_combo_box_direction_changed (GtkWidget        *widget,
                                  GtkTextDirection  previous_direction)
 {
-  gtk_combo_box_invalidate_order (GTK_COMBO_BOX (widget));
-}
-
-static GtkWidgetPath *
-gtk_combo_box_get_path_for_child (GtkContainer *container,
-                                  GtkWidget    *child)
-{
-  GtkComboBoxPrivate *priv = GTK_COMBO_BOX (container)->priv;
-  GtkWidgetPath *path;
-  GtkWidget *widget;
-  gboolean found = FALSE;
-  GList *visible_children, *l;
-  GtkWidgetPath *sibling_path;
-  int pos;
-
-  path = _gtk_widget_create_path (GTK_WIDGET (container));
-
-  if (gtk_widget_get_visible (child))
-    {
-      visible_children = NULL;
-
-      if (priv->button && gtk_widget_get_visible (priv->button))
-        visible_children = g_list_prepend (visible_children, priv->button);
-
-      widget = gtk_bin_get_child (GTK_BIN (container));
-      if (widget && gtk_widget_get_visible (widget))
-        visible_children = g_list_prepend (visible_children, widget);
-
-      if (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL)
-        visible_children = g_list_reverse (visible_children);
-
-      pos = 0;
-
-      for (l = visible_children; l; l = l->next)
-        {
-          widget = l->data;
-
-          if (widget == child)
-            {
-              found = TRUE;
-              break;
-            }
-
-          pos++;
-        }
-    }
-
-  if (found)
-    {
-      sibling_path = gtk_widget_path_new ();
-
-      for (l = visible_children; l; l = l->next)
-        gtk_widget_path_append_for_widget (sibling_path, l->data);
-
-      gtk_widget_path_append_with_siblings (path, sibling_path, pos);
-
-      g_list_free (visible_children);
-      gtk_widget_path_unref (sibling_path);
-    }
-  else
-    {
-      gtk_widget_path_append_for_widget (path, child);
-    }
-
-  return path;
+  gtk_css_node_reverse_children (gtk_widget_get_css_node (widget));
 }
 
 static void
@@ -1561,6 +1481,11 @@ gtk_combo_box_add (GtkContainer *container,
     }
   
   gtk_widget_set_parent (widget, GTK_WIDGET (container));
+  if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
+    gtk_css_node_insert_after (gtk_widget_get_css_node (GTK_WIDGET (combo_box)),
+                               gtk_widget_get_css_node (widget),
+                               NULL);
+
   _gtk_bin_set_child (GTK_BIN (container), widget);
 
   if (priv->has_entry)


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