[gdm/gnome-2-30] Use a cheaper way to find the active item in the list
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/gnome-2-30] Use a cheaper way to find the active item in the list
- Date: Fri, 11 Jun 2010 01:53:11 +0000 (UTC)
commit e850a8bc5e0149b7f669fa29a41d0022cd312ec6
Author: William Jon McCann <jmccann redhat com>
Date: Wed Jun 9 18:04:42 2010 -0400
Use a cheaper way to find the active item in the list
https://bugzilla.gnome.org/show_bug.cgi?id=621131
gui/simple-greeter/gdm-chooser-widget.c | 43 ++++++++++++++++--------------
1 files changed, 23 insertions(+), 20 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-chooser-widget.c b/gui/simple-greeter/gdm-chooser-widget.c
index f69f058..53b5074 100644
--- a/gui/simple-greeter/gdm-chooser-widget.c
+++ b/gui/simple-greeter/gdm-chooser-widget.c
@@ -678,6 +678,21 @@ update_chooser_visibility (GdmChooserWidget *widget)
return FALSE;
}
+static inline gboolean
+iters_equal (GtkTreeIter *a,
+ GtkTreeIter *b)
+{
+ if (a->stamp != b->stamp)
+ return FALSE;
+
+ if (a->user_data != b->user_data)
+ return FALSE;
+
+ /* user_data2 and user_data3 are not used in GtkListStore */
+
+ return TRUE;
+}
+
static void
set_inactive_items_visible (GdmChooserWidget *widget,
gboolean should_show)
@@ -687,38 +702,26 @@ set_inactive_items_visible (GdmChooserWidget *widget,
GtkTreeIter active_item_iter;
GtkTreeIter iter;
+ active_item_id = get_active_item_id (widget, &active_item_iter);
+ if (active_item_id == NULL) {
+ g_debug ("No active item set");
+ }
+
model = GTK_TREE_MODEL (widget->priv->list_store);
if (!gtk_tree_model_get_iter_first (model, &iter)) {
return;
}
- active_item_id = get_active_item_id (widget, &active_item_iter);
-
do {
- gboolean is_active;
-
- is_active = FALSE;
- if (active_item_id != NULL) {
- char *id;
-
- gtk_tree_model_get (model, &iter,
- CHOOSER_ID_COLUMN, &id, -1);
-
- if (strcmp (active_item_id, id) == 0) {
- is_active = TRUE;
- g_free (active_item_id);
- active_item_id = NULL;
- }
- g_free (id);
- }
-
- if (!is_active) {
+ if (active_item_id == NULL || !iters_equal (&active_item_iter, &iter)) {
+ /* inactive item */
gtk_list_store_set (widget->priv->list_store,
&iter,
CHOOSER_ITEM_IS_VISIBLE_COLUMN, should_show,
-1);
} else {
+ /* always show the active item */
gtk_list_store_set (widget->priv->list_store,
&iter,
CHOOSER_ITEM_IS_VISIBLE_COLUMN, TRUE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]