pidgin: 450dfc46: Select the first item in the mail-notifi...

qulogic at pidgin.im qulogic at pidgin.im
Thu Dec 22 18:55:22 EST 2011


----------------------------------------------------------------------
Revision: 450dfc46a4682fc424c205fb56699f20e9836386
Parent:   4fb8f4c68fbbb1248aab21b9149875c29b6c9944
Author:   tim at retout.co.uk
Date:     12/22/11 18:51:01
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/450dfc46a4682fc424c205fb56699f20e9836386

Changelog: 

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.

Changes against parent 4fb8f4c68fbbb1248aab21b9149875c29b6c9944

  patched  COPYRIGHT
  patched  pidgin/gtknotify.c

-------------- next part --------------
============================================================
--- pidgin/gtknotify.c	35fc7bf4442310ebef1029249873acc485eb852e
+++ pidgin/gtknotify.c	3166736e70002506c8b3d84a2014b0c059a1026d
@@ -689,6 +689,8 @@ pidgin_notify_emails(PurpleConnection *g
 	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 @@ pidgin_notify_emails(PurpleConnection *g
 		}
 	}
 
+	/* 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 @@ pidgin_create_notification_dialog(Pidgin
 		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();
============================================================
--- COPYRIGHT	b09077839d6387f0ee90a7d52fd931f7dc88a955
+++ COPYRIGHT	9365e9f27d791f96def355c73ff0ff8b050e3271
@@ -429,6 +429,7 @@ Noa Resare
 David Reiss
 Luoh Ren-Shan
 Noa Resare
+Tim Retout
 Daniele Ricci
 Kristian Rietveld
 Pekka Riikonen


More information about the Commits mailing list