Use object data to mark widgets and groups as visited, so that we avoid

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)
This commit is contained in:
Matthias Clasen 2005-08-15 13:46:32 +00:00 committed by Matthias Clasen
parent 0bdd39e497
commit 4b5f259ba0
4 changed files with 62 additions and 9 deletions

View File

@ -1,9 +1,16 @@
2005-08-15 Matthias Clasen <mclasen@redhat.com> 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 * gtk/gtkicontheme.c (gtk_icon_theme_lookup_icon): Correct the
download location for the hicolor icon theme. (#313475, Olexiy download location for the hicolor icon theme. (#313475, Olexiy
Avramchenko) Avramchenko)
* gtk/gtkicontheme.c: Remove debug spew.
2005-08-15 Owen Taylor <otaylor@redhat.com> 2005-08-15 Owen Taylor <otaylor@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap): * gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap):

View File

@ -1,9 +1,16 @@
2005-08-15 Matthias Clasen <mclasen@redhat.com> 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 * gtk/gtkicontheme.c (gtk_icon_theme_lookup_icon): Correct the
download location for the hicolor icon theme. (#313475, Olexiy download location for the hicolor icon theme. (#313475, Olexiy
Avramchenko) Avramchenko)
* gtk/gtkicontheme.c: Remove debug spew.
2005-08-15 Owen Taylor <otaylor@redhat.com> 2005-08-15 Owen Taylor <otaylor@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap): * gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap):

View File

@ -1,9 +1,16 @@
2005-08-15 Matthias Clasen <mclasen@redhat.com> 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 * gtk/gtkicontheme.c (gtk_icon_theme_lookup_icon): Correct the
download location for the hicolor icon theme. (#313475, Olexiy download location for the hicolor icon theme. (#313475, Olexiy
Avramchenko) Avramchenko)
* gtk/gtkicontheme.c: Remove debug spew.
2005-08-15 Owen Taylor <otaylor@redhat.com> 2005-08-15 Owen Taylor <otaylor@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap): * gdk/linux-fb/gdkwindow-fb.c (gdk_window_set_back_pixmap):

View File

@ -52,12 +52,12 @@ static void add_widget_to_closure (GtkWidget *widget,
static GQuark size_groups_quark; static GQuark size_groups_quark;
static const gchar size_groups_tag[] = "gtk-size-groups"; static const gchar size_groups_tag[] = "gtk-size-groups";
static GQuark visited_quark;
static const gchar visited_tag[] = "gtk-size-group-visited";
static GSList * static GSList *
get_size_groups (GtkWidget *widget) 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); return g_object_get_qdata (G_OBJECT (widget), size_groups_quark);
} }
@ -65,12 +65,27 @@ static void
set_size_groups (GtkWidget *widget, set_size_groups (GtkWidget *widget,
GSList *groups) 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); 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 static void
add_group_to_closure (GtkSizeGroup *group, add_group_to_closure (GtkSizeGroup *group,
GtkSizeGroupMode mode, GtkSizeGroupMode mode,
@ -80,13 +95,14 @@ add_group_to_closure (GtkSizeGroup *group,
GSList *tmp_widgets; GSList *tmp_widgets;
*groups = g_slist_prepend (*groups, group); *groups = g_slist_prepend (*groups, group);
mark_visited (group);
tmp_widgets = group->widgets; tmp_widgets = group->widgets;
while (tmp_widgets) while (tmp_widgets)
{ {
GtkWidget *tmp_widget = tmp_widgets->data; 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); add_widget_to_closure (tmp_widget, mode, groups, widgets);
tmp_widgets = tmp_widgets->next; tmp_widgets = tmp_widgets->next;
@ -102,6 +118,7 @@ add_widget_to_closure (GtkWidget *widget,
GSList *tmp_groups; GSList *tmp_groups;
*widgets = g_slist_prepend (*widgets, widget); *widgets = g_slist_prepend (*widgets, widget);
mark_visited (widget);
tmp_groups = get_size_groups (widget); tmp_groups = get_size_groups (widget);
while (tmp_groups) while (tmp_groups)
@ -109,7 +126,7 @@ add_widget_to_closure (GtkWidget *widget,
GtkSizeGroup *tmp_group = tmp_groups->data; GtkSizeGroup *tmp_group = tmp_groups->data;
if ((tmp_group->mode == GTK_SIZE_GROUP_BOTH || tmp_group->mode == mode) && 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); add_group_to_closure (tmp_group, mode, groups, widgets);
tmp_groups = tmp_groups->next; tmp_groups = tmp_groups->next;
@ -177,6 +194,9 @@ queue_resize_on_widget (GtkWidget *widget,
widgets = NULL; widgets = NULL;
add_widget_to_closure (parent, GTK_SIZE_GROUP_HORIZONTAL, &groups, &widgets); 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); reset_group_sizes (groups);
tmp_list = widgets; tmp_list = widgets;
@ -200,6 +220,9 @@ queue_resize_on_widget (GtkWidget *widget,
widgets = NULL; widgets = NULL;
add_widget_to_closure (parent, GTK_SIZE_GROUP_VERTICAL, &groups, &widgets); 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); reset_group_sizes (groups);
tmp_list = widgets; tmp_list = widgets;
@ -264,6 +287,9 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass)
"when determining the size of the group"), "when determining the size of the group"),
FALSE, FALSE,
GTK_PARAM_READWRITE)); GTK_PARAM_READWRITE));
size_groups_quark = g_quark_from_static_string (size_groups_tag);
visited_quark = g_quark_from_string (visited_tag);
} }
static void static void
@ -589,6 +615,9 @@ compute_dimension (GtkWidget *widget,
add_widget_to_closure (widget, mode, &groups, &widgets); 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); g_slist_foreach (widgets, (GFunc)g_object_ref, NULL);
if (!groups) if (!groups)
@ -660,6 +689,9 @@ get_dimension (GtkWidget *widget,
add_widget_to_closure (widget, mode, &groups, &widgets); 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) if (!groups)
{ {
result = get_base_dimension (widget, mode); result = get_base_dimension (widget, mode);