changeset 32412:eb8f424876a5

Select the first item in the mail-notification dialog. Also, change the treeview to "Browse" mode. I changed the patch to use a GtkTreeIter instead of a GtkTreePath, which is simpler. Also, remove some redundant function calls due to the newly introduced variables. Fixes #5789. committer: Elliott Sales de Andrade <qulogic@pidgin.im>
author tim@retout.co.uk
date Thu, 22 Dec 2011 23:51:01 +0000
parents 85d75e81e12f
children 82e524e447f1
files COPYRIGHT pidgin/gtknotify.c
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Thu Dec 22 23:23:49 2011 +0000
+++ b/COPYRIGHT	Thu Dec 22 23:51:01 2011 +0000
@@ -429,6 +429,7 @@
 David Reiss
 Luoh Ren-Shan
 Noa Resare
+Tim Retout
 Daniele Ricci
 Kristian Rietveld
 Pekka Riikonen
--- a/pidgin/gtknotify.c	Thu Dec 22 23:23:49 2011 +0000
+++ b/pidgin/gtknotify.c	Thu Dec 22 23:51:01 2011 +0000
@@ -689,6 +689,8 @@
 	PurpleAccount *account;
 	PidginNotifyMailData *data = NULL, *data2;
 	gboolean new_data = FALSE;
+	GtkTreeSelection *sel;
+	GtkTreeIter iter;
 
 	/* Don't bother updating if there aren't new emails and we don't have any displayed currently */
 	if (count == 0 && mail_dialog == NULL)
@@ -775,6 +777,13 @@
 		}
 	}
 
+	/* Select first item if nothing selected */
+	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(mail_dialog->treeview));
+	if ((gtk_tree_selection_count_selected_rows(sel) < 1)
+		&& gtk_tree_model_get_iter_first(GTK_TREE_MODEL(mail_dialog->treemodel), &iter)) {
+		gtk_tree_selection_select_iter(sel, &iter);
+	}
+
 	if (!GTK_WIDGET_VISIBLE(mail_dialog->dialog)) {
 		GdkPixbuf *pixbuf = gtk_widget_render_icon(mail_dialog->dialog, PIDGIN_STOCK_DIALOG_MAIL,
 							   gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), NULL);
@@ -1530,11 +1539,13 @@
 		gtk_tree_view_set_search_column(GTK_TREE_VIEW(spec_dialog->treeview), PIDGIN_MAIL_TEXT);
 		gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(spec_dialog->treeview),
 			             pidgin_tree_view_search_equal_func, NULL, NULL);
+		sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(spec_dialog->treeview));
+		gtk_tree_selection_set_mode(sel, GTK_SELECTION_BROWSE);
 
 		g_signal_connect(G_OBJECT(dialog), "response",
 						 G_CALLBACK(email_response_cb), spec_dialog);
-		g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(spec_dialog->treeview))),
-						 "changed", G_CALLBACK(selection_changed_cb), spec_dialog);
+		g_signal_connect(G_OBJECT(sel), "changed",
+		                 G_CALLBACK(selection_changed_cb), spec_dialog);
 		g_signal_connect(G_OBJECT(spec_dialog->treeview), "row-activated", G_CALLBACK(email_row_activated_cb), NULL);
 
 		column = gtk_tree_view_column_new();