# HG changeset patch # User Paul Aurich # Date 1251093856 0 # Node ID 9affcab625224f368fa514b78f77109ba874113a # Parent aca6f567cc1fcda23ff2fd50ee2c575920fcbbc4 pounce dialog: Try to always have a row selected. Fixes #10037. When dismissing a row, this is used to determine what to select: if (one selected) select next if possible, otherwise select previous else select first element diff -r aca6f567cc1f -r 9affcab62522 pidgin/gtknotify.c --- a/pidgin/gtknotify.c Mon Aug 24 04:43:31 2009 +0000 +++ b/pidgin/gtknotify.c Mon Aug 24 06:04:16 2009 +0000 @@ -211,25 +211,53 @@ static void pounce_response_dismiss() { + GtkTreeModel *model = GTK_TREE_MODEL(pounce_dialog->treemodel); GtkTreeSelection *selection; GtkTreeIter iter; + GtkTreeIter new_selection; GList *list = NULL; + gboolean found_selection = FALSE; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); gtk_tree_selection_selected_foreach(selection, delete_foreach, pounce_dialog); gtk_tree_selection_selected_foreach(selection, append_to_list, &list); + g_return_if_fail(list != NULL); + + if (list->next == NULL) { + gtk_tree_model_get_iter(model, &new_selection, list->data); + if (gtk_tree_model_iter_next(model, &new_selection)) + found_selection = TRUE; + else { + /* This is the last thing in the list */ + GtkTreePath *path; + + /* Because gtk_tree_model_iter_prev doesn't exist... */ + gtk_tree_model_get_iter(model, &new_selection, list->data); + path = gtk_tree_model_get_path(model, &new_selection); + if (gtk_tree_path_prev(path)) { + gtk_tree_model_get_iter(model, &new_selection, path); + found_selection = TRUE; + } + + gtk_tree_path_free(path); + } + } + while (list) { - GtkTreeIter iter; - if (gtk_tree_model_get_iter(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter, - list->data)) { + if (gtk_tree_model_get_iter(model, &iter, list->data)) { gtk_tree_store_remove(GTK_TREE_STORE(pounce_dialog->treemodel), &iter); } gtk_tree_path_free(list->data); list = g_list_delete_link(list, list); } - if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter)) + if (gtk_tree_model_get_iter_first(model, &iter)) { + if (found_selection) + gtk_tree_selection_select_iter(selection, &new_selection); + else + gtk_tree_selection_select_iter(selection, &iter); + } else pounce_response_close(pounce_dialog); } @@ -240,7 +268,7 @@ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); gtk_tree_selection_selected_foreach(selection, open_im_foreach, pounce_dialog); - + pounce_response_dismiss(); } @@ -1400,6 +1428,7 @@ GdkPixbuf *icon; GtkTreeIter iter; PidginNotifyPounceData *pounce_data; + gboolean first = (pounce_dialog == NULL); if (pounce_dialog == NULL) pounce_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_POUNCE); @@ -1423,6 +1452,12 @@ PIDGIN_POUNCE_DATA, pounce_data, -1); + if (first) { + GtkTreeSelection *selection = + gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); + gtk_tree_selection_select_iter(selection, &iter); + } + if (icon) g_object_unref(icon);