Mercurial > pidgin.yaz
changeset 13066:0afb445a3433
[gaim-migrate @ 15428]
Don't assume the popular statuses start at the 5th menu item in the
dropdown. I hope this is a step toward fixing the bug where
inifinite status windows appear. If not, it is at least more robust
code.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 29 Jan 2006 22:11:35 +0000 |
parents | 788409b5a7f0 |
children | 9aa0536fe83c |
files | src/gtkstatusbox.c |
diffstat | 1 files changed, 25 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkstatusbox.c Sun Jan 29 21:42:24 2006 +0000 +++ b/src/gtkstatusbox.c Sun Jan 29 22:11:35 2006 +0000 @@ -401,7 +401,6 @@ GaimStatusPrimitive primitive; gint index; const char *message; - GList *list; /* this function is inappropriate for ones with accounts */ if (status_box->account) @@ -428,23 +427,36 @@ (!gaim_savedstatus_has_substatuses(saved_status))) { index = get_statusbox_index(status_box, saved_status); + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); + } else { - /* - * TODO: This code is really bad. We need to look at the DATA - * column of the saved statuses, instead. - */ - list = gaim_savedstatuses_get_popular(6); - if ((index = g_list_index(list, saved_status)) > -1) - index += 5; /* Skip over the primitives and a spacer that may or may not exist! (Fix this) */ - else - index = 0; /* TODO: Need to do something better here */ - g_list_free(list); + GtkTreeIter iter; + gpointer data; + + /* Unset the active item */ + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), -1); + + /* If this saved status is in the list store, then set it as the active item */ + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(status_box->dropdown_store), &iter)) + { + do + { + gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, + DATA_COLUMN, &data, + -1); + if (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status)) + { + /* Found! */ + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); + break; + } + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); + } } - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); - message = gaim_savedstatus_get_message(saved_status); if (!gaim_savedstatus_is_transient(saved_status) || !message || !*message) {