]> Pileus Git - ~andy/gtk/commitdiff
Use object data to mark widgets and groups as visited, so that we avoid
authorMatthias Clasen <mclasen@redhat.com>
Mon, 15 Aug 2005 13:46:32 +0000 (13:46 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 15 Aug 2005 13:46:32 +0000 (13:46 +0000)
2005-08-15  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtksizegroup.c: Use object data to mark widgets and
groups as visited, so that we avoid constant extra list
traversals. Also allocate quarks in class_init.  (#311618,
Michael Natterer)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtksizegroup.c

index 777ce089321b12d4be581cf1135b17f91ac42629..2cf76c7be7a609b605063f615cbe4585c236ddce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
 2005-08-15  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtksizegroup.c: Use object data to mark widgets and
+       groups as visited, so that we avoid constant extra list
+       traversals. Also allocate quarks in class_init.  (#311618,
+       Michael Natterer)
+
        * gtk/gtkicontheme.c (gtk_icon_theme_lookup_icon): Correct the 
        download location for the hicolor icon theme. (#313475, Olexiy 
        Avramchenko)
 
+       * gtk/gtkicontheme.c: Remove debug spew. 
+
 2005-08-15  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap): 
index 777ce089321b12d4be581cf1135b17f91ac42629..2cf76c7be7a609b605063f615cbe4585c236ddce 100644 (file)
@@ -1,9 +1,16 @@
 2005-08-15  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtksizegroup.c: Use object data to mark widgets and
+       groups as visited, so that we avoid constant extra list
+       traversals. Also allocate quarks in class_init.  (#311618,
+       Michael Natterer)
+
        * gtk/gtkicontheme.c (gtk_icon_theme_lookup_icon): Correct the 
        download location for the hicolor icon theme. (#313475, Olexiy 
        Avramchenko)
 
+       * gtk/gtkicontheme.c: Remove debug spew. 
+
 2005-08-15  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap): 
index 777ce089321b12d4be581cf1135b17f91ac42629..2cf76c7be7a609b605063f615cbe4585c236ddce 100644 (file)
@@ -1,9 +1,16 @@
 2005-08-15  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtksizegroup.c: Use object data to mark widgets and
+       groups as visited, so that we avoid constant extra list
+       traversals. Also allocate quarks in class_init.  (#311618,
+       Michael Natterer)
+
        * gtk/gtkicontheme.c (gtk_icon_theme_lookup_icon): Correct the 
        download location for the hicolor icon theme. (#313475, Olexiy 
        Avramchenko)
 
+       * gtk/gtkicontheme.c: Remove debug spew. 
+
 2005-08-15  Owen Taylor  <otaylor@redhat.com>
 
        * gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap): 
index 10d2c43b861c598460df5ea0c1e084e28f7f4a45..a1577ecb95b06c27c533bfd3ad42262cc8278212 100644 (file)
@@ -52,12 +52,12 @@ static void add_widget_to_closure (GtkWidget         *widget,
 static GQuark size_groups_quark;
 static const gchar size_groups_tag[] = "gtk-size-groups";
 
+static GQuark visited_quark;
+static const gchar visited_tag[] = "gtk-size-group-visited";
+
 static GSList *
 get_size_groups (GtkWidget *widget)
 {
-  if (!size_groups_quark)
-    size_groups_quark = g_quark_from_static_string (size_groups_tag);
-  
   return g_object_get_qdata (G_OBJECT (widget), size_groups_quark);
 }
 
@@ -65,12 +65,27 @@ static void
 set_size_groups (GtkWidget *widget,
                 GSList    *groups)
 {
-  if (!size_groups_quark)
-    size_groups_quark = g_quark_from_static_string (size_groups_tag);
-
   g_object_set_qdata (G_OBJECT (widget), size_groups_quark, groups);
 }
 
+static void
+mark_visited (gpointer object)
+{
+  g_object_set_qdata (object, visited_quark, "visited");
+}
+
+static void
+mark_unvisited (gpointer object)
+{
+  g_object_set_qdata (object, visited_quark, NULL);
+}
+
+static gboolean
+is_visited (gpointer object)
+{
+  return g_object_get_qdata (object, visited_quark) != NULL;
+}
+
 static void
 add_group_to_closure (GtkSizeGroup    *group,
                      GtkSizeGroupMode mode,
@@ -80,13 +95,14 @@ add_group_to_closure (GtkSizeGroup    *group,
   GSList *tmp_widgets;
   
   *groups = g_slist_prepend (*groups, group);
+  mark_visited (group);
 
   tmp_widgets = group->widgets;
   while (tmp_widgets)
     {
       GtkWidget *tmp_widget = tmp_widgets->data;
       
-      if (!g_slist_find (*widgets, tmp_widget))
+      if (!is_visited (tmp_widget))
        add_widget_to_closure (tmp_widget, mode, groups, widgets);
       
       tmp_widgets = tmp_widgets->next;
@@ -102,6 +118,7 @@ add_widget_to_closure (GtkWidget       *widget,
   GSList *tmp_groups;
 
   *widgets = g_slist_prepend (*widgets, widget);
+  mark_visited (widget);
 
   tmp_groups = get_size_groups (widget);
   while (tmp_groups)
@@ -109,7 +126,7 @@ add_widget_to_closure (GtkWidget       *widget,
       GtkSizeGroup *tmp_group = tmp_groups->data;
       
       if ((tmp_group->mode == GTK_SIZE_GROUP_BOTH || tmp_group->mode == mode) &&
-         !g_slist_find (*groups, tmp_group))
+         !is_visited (tmp_group))
        add_group_to_closure (tmp_group, mode, groups, widgets);
 
       tmp_groups = tmp_groups->next;
@@ -177,6 +194,9 @@ queue_resize_on_widget (GtkWidget *widget,
       widgets = NULL;
          
       add_widget_to_closure (parent, GTK_SIZE_GROUP_HORIZONTAL, &groups, &widgets);
+      g_slist_foreach (widgets, (GFunc)mark_unvisited, NULL);
+      g_slist_foreach (groups, (GFunc)mark_unvisited, NULL);
+
       reset_group_sizes (groups);
              
       tmp_list = widgets;
@@ -200,6 +220,9 @@ queue_resize_on_widget (GtkWidget *widget,
       widgets = NULL;
              
       add_widget_to_closure (parent, GTK_SIZE_GROUP_VERTICAL, &groups, &widgets);
+      g_slist_foreach (widgets, (GFunc)mark_unvisited, NULL);
+      g_slist_foreach (groups, (GFunc)mark_unvisited, NULL);
+
       reset_group_sizes (groups);
              
       tmp_list = widgets;
@@ -264,6 +287,9 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass)
                                                            "when determining the size of the group"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE));
+
+  size_groups_quark = g_quark_from_static_string (size_groups_tag);
+  visited_quark = g_quark_from_string (visited_tag);
 }
 
 static void
@@ -589,6 +615,9 @@ compute_dimension (GtkWidget        *widget,
 
   add_widget_to_closure (widget, mode, &groups, &widgets);
 
+  g_slist_foreach (widgets, (GFunc)mark_unvisited, NULL);
+  g_slist_foreach (groups, (GFunc)mark_unvisited, NULL);
+  
   g_slist_foreach (widgets, (GFunc)g_object_ref, NULL);
   
   if (!groups)
@@ -643,7 +672,7 @@ compute_dimension (GtkWidget        *widget,
     }
 
   g_slist_foreach (widgets, (GFunc)g_object_unref, NULL);
-  
+
   g_slist_free (widgets);
   g_slist_free (groups);
 
@@ -660,6 +689,9 @@ get_dimension (GtkWidget        *widget,
 
   add_widget_to_closure (widget, mode, &groups, &widgets);
 
+  g_slist_foreach (widgets, (GFunc)mark_unvisited, NULL);
+  g_slist_foreach (groups, (GFunc)mark_unvisited, NULL);  
+
   if (!groups)
     {
       result = get_base_dimension (widget, mode);