changeset 15178:9b2a65069744

[gaim-migrate @ 17965] Patch from eperez: Show buddy icons in Accounts window. I also took the liberty of rearranging the columns in the list to something a little more sensible. I'm also thinking we should show the global icon for accounts that are using it committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 11 Dec 2006 23:41:34 +0000
parents 5a7648191611
children 6c43dbf293ad
files gtk/gtkaccount.c gtk/gtkscrollbook.c
diffstat 2 files changed, 66 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkaccount.c	Mon Dec 11 22:03:18 2006 +0000
+++ b/gtk/gtkaccount.c	Mon Dec 11 23:41:34 2006 +0000
@@ -49,6 +49,7 @@
 enum
 {
 	COLUMN_ICON,
+	COLUMN_BUDDYICON,
 	COLUMN_SCREENNAME,
 	COLUMN_ENABLED,
 	COLUMN_PROTOCOL,
@@ -1920,43 +1921,50 @@
 	GtkCellRenderer *renderer;
 	GtkTreeViewColumn *column;
 
+	/* Enabled */
+	renderer = gtk_cell_renderer_toggle_new();
+
+	g_signal_connect(G_OBJECT(renderer), "toggled",
+			 G_CALLBACK(enabled_cb), dialog);
+
+	column = gtk_tree_view_column_new_with_attributes(_("Enabled"),
+			 renderer, "active", COLUMN_ENABLED, NULL);
+
+	gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
+	gtk_tree_view_column_set_resizable(column, TRUE);
+
 	/* Screen Name column */
 	column = gtk_tree_view_column_new();
 	gtk_tree_view_column_set_title(column, _("Screen Name"));
 	gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
 	gtk_tree_view_column_set_resizable(column, TRUE);
 
+	/* Status Icon */
+	renderer = gtk_cell_renderer_pixbuf_new();
+	gtk_tree_view_column_pack_start(column, renderer, FALSE);
+	gtk_tree_view_column_add_attribute(column, renderer,
+					   "pixbuf", COLUMN_BUDDYICON);
+
+	/* Screen Name */
+	renderer = gtk_cell_renderer_text_new();
+	gtk_tree_view_column_pack_start(column, renderer, TRUE);
+	gtk_tree_view_column_add_attribute(column, renderer,
+					   "text", COLUMN_SCREENNAME);
+	dialog->screenname_col = column;
+
+
+	/* Protocol name */
+	column = gtk_tree_view_column_new();
+	gtk_tree_view_column_set_title(column, _("Protocol"));
+	gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
+	gtk_tree_view_column_set_resizable(column, TRUE);
+
 	/* Icon */
 	renderer = gtk_cell_renderer_pixbuf_new();
 	gtk_tree_view_column_pack_start(column, renderer, FALSE);
 	gtk_tree_view_column_add_attribute(column, renderer,
 					   "pixbuf", COLUMN_ICON);
 
-	/* Screen Name */
-	renderer = gtk_cell_renderer_text_new();
-	gtk_tree_view_column_pack_start(column, renderer, TRUE);
-	gtk_tree_view_column_add_attribute(column, renderer,
-					   "text", COLUMN_SCREENNAME);
-	dialog->screenname_col = column;
-
-	/* Enabled */
-	renderer = gtk_cell_renderer_toggle_new();
-
-	g_signal_connect(G_OBJECT(renderer), "toggled",
-					 G_CALLBACK(enabled_cb), dialog);
-
-	column = gtk_tree_view_column_new_with_attributes(_("Enabled"),
-			renderer, "active", COLUMN_ENABLED, NULL);
-
-	gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
-	gtk_tree_view_column_set_resizable(column, TRUE);
-
-	/* Protocol name */
-	column = gtk_tree_view_column_new();
-	gtk_tree_view_column_set_title(column, _("Protocol"));
-	gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1);
-	gtk_tree_view_column_set_resizable(column, TRUE);
-
 	renderer = gtk_cell_renderer_text_new();
 	gtk_tree_view_column_pack_start(column, renderer, TRUE);
 	gtk_tree_view_column_add_attribute(column, renderer,
@@ -1967,13 +1975,23 @@
 set_account(GtkListStore *store, GtkTreeIter *iter, GaimAccount *account)
 {
 	GdkPixbuf *pixbuf;
+	GdkPixbuf *statusicon_pixbuf;
+	GdkPixbuf *statusicon_pixbuf_scaled;
 
 	pixbuf = gaim_gtk_create_prpl_icon(account, 0.5);
 	if ((pixbuf != NULL) && gaim_account_is_disconnected(account))
 		gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE);
 
+	statusicon_pixbuf = gdk_pixbuf_new_from_file(gaim_account_get_ui_string(account, GAIM_GTK_UI, "non-global-buddyicon-path", NULL), NULL); 
+	if (statusicon_pixbuf) {
+		statusicon_pixbuf_scaled = gdk_pixbuf_scale_simple(statusicon_pixbuf, 16, 16, GDK_INTERP_HYPER);
+	} else {
+		statusicon_pixbuf_scaled = NULL;
+	}
+
 	gtk_list_store_set(store, iter,
 			COLUMN_ICON, pixbuf,
+			COLUMN_BUDDYICON, statusicon_pixbuf_scaled,
 			COLUMN_SCREENNAME, gaim_account_get_username(account),
 			COLUMN_ENABLED, gaim_account_get_enabled(account, GAIM_GTK_UI),
 			COLUMN_PROTOCOL, gaim_account_get_protocol_name(account),
@@ -1982,6 +2000,10 @@
 
 	if (pixbuf != NULL)
 		g_object_unref(G_OBJECT(pixbuf));
+	if (statusicon_pixbuf != NULL)
+		g_object_unref(G_OBJECT(statusicon_pixbuf));
+	if (statusicon_pixbuf_scaled != NULL)
+		g_object_unref(G_OBJECT(statusicon_pixbuf_scaled));
 }
 
 static void
@@ -2128,6 +2150,7 @@
 	/* Create the list model. */
 	dialog->model = gtk_list_store_new(NUM_COLUMNS,
 					GDK_TYPE_PIXBUF,   /* COLUMN_ICON */
+					GDK_TYPE_PIXBUF,   /* COLUMN_BUDDYICON */
 					G_TYPE_STRING,     /* COLUMN_SCREENNAME */
 					G_TYPE_BOOLEAN,    /* COLUMN_ENABLED */
 					G_TYPE_STRING,     /* COLUMN_PROTOCOL */
--- a/gtk/gtkscrollbook.c	Mon Dec 11 22:03:18 2006 +0000
+++ b/gtk/gtkscrollbook.c	Mon Dec 11 23:41:34 2006 +0000
@@ -28,6 +28,10 @@
 
 static void gtk_gaim_scroll_book_init (GtkGaimScrollBook *scroll_book);
 static void gtk_gaim_scroll_book_class_init (GtkGaimScrollBookClass *klass);
+static void gtk_gaim_scroll_book_forall (GtkContainer *c, 
+					 gboolean include_internals,
+			 		 GtkCallback callback,
+					 gpointer user_data);
 
 GType
 gtk_gaim_scroll_book_get_type (void)
@@ -145,11 +149,25 @@
 }
 
 static void
+gtk_gaim_scroll_book_forall(GtkContainer *container,
+			   gboolean include_internals,
+			   GtkCallback callback,
+			   gpointer callback_data)
+{
+	GtkGaimScrollBook *scroll_book = GTK_GAIM_SCROLL_BOOK(container);
+	if (include_internals) {
+		(*callback)(scroll_book->hbox, callback_data);
+	}
+	(*callback)(scroll_book->notebook, callback_data);
+}
+
+static void
 gtk_gaim_scroll_book_class_init (GtkGaimScrollBookClass *klass)
 {
 	GtkContainerClass *container_class = (GtkContainerClass*)klass;
 
 	container_class->add = gtk_gaim_scroll_book_add;
+	container_class->forall = gtk_gaim_scroll_book_forall;	
 	
 }
 
@@ -186,7 +204,6 @@
 	g_signal_connect_swapped(G_OBJECT(scroll_book->notebook), "add", G_CALLBACK(page_count_change_cb), scroll_book);
 	g_signal_connect_swapped(G_OBJECT(scroll_book->notebook), "remove", G_CALLBACK(page_count_change_cb), scroll_book);
 	g_signal_connect(G_OBJECT(scroll_book->notebook), "switch-page", G_CALLBACK(switch_page_cb), scroll_book);
-	gtk_widget_hide(scroll_book->hbox);
 }