changeset 11983:39f2aa4350d8

[gaim-migrate @ 14276] Finally turning this on, after sticking in a vpane so you can get it out of your way. I also changed the icons. Still todo is making it show and hide based on if they match the global status, and misc stuff like adding and removing the selectors based on account enable/disable and add/delete. Anyway, now that they're enabled, y'all can tell me what you think, and if I'm really going in the right direction. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 05 Nov 2005 19:22:26 +0000
parents 54a3eae03182
children 59494e5f7fdf
files src/gtkblist.c src/gtkstatusbox.c
diffstat 2 files changed, 63 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Sat Nov 05 13:34:37 2005 +0000
+++ b/src/gtkblist.c	Sat Nov 05 19:22:26 2005 +0000
@@ -1996,7 +1996,7 @@
 	pango_layout_set_markup(td->layout, tooltip_text, strlen(tooltip_text));
 	pango_layout_set_wrap(td->layout, PANGO_WRAP_WORD);
 	pango_layout_set_width(td->layout, 300000);
-	
+
 	pango_layout_get_size (td->layout, &td->width, &td->height);
 	td->width = PANGO_PIXELS(td->width) + 38 + 8;
 	td->height = MAX(PANGO_PIXELS(td->height) + 8, 38);
@@ -2045,7 +2045,7 @@
 		gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, current_height + 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
 		if(td->avatar)
 			gdk_pixbuf_render_to_drawable(td->avatar,
-					GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 
+					GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0,
 					max_width - (td->avatar_width + 4),
 					current_height + 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
 #endif
@@ -3193,6 +3193,7 @@
 	GtkTreeViewColumn *column;
 	GtkWidget *menu;
 	GtkWidget *sw;
+	GtkWidget *vpane;
 	GtkAccelGroup *accel_group;
 	GtkTreeSelection *selection;
 	GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW},
@@ -3243,6 +3244,11 @@
 	gtkblist->bpmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounce"));
 	protomenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Account Actions"));
 
+	/****************************** GtkVPaned ************************************/
+	vpane = gtk_vpaned_new();
+	gtk_widget_show(vpane);
+	gtk_box_pack_start(GTK_BOX(gtkblist->vbox), vpane, TRUE, TRUE, 0);
+
 	/****************************** GtkTreeView **********************************/
 	sw = gtk_scrolled_window_new(NULL,NULL);
 	gtk_widget_show(sw);
@@ -3327,19 +3333,19 @@
 	gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN);
 	gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), _search_func, NULL, NULL);
 
-	gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0);
+	gtk_paned_pack1(GTK_PANED(vpane), sw, TRUE, FALSE);
 	gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview);
 	gaim_gtk_blist_update_columns();
 
 	/* TODO: functionize this */
 	{
-#if 0
 		GList *accounts, *l;
-#endif
+		GtkWidget *sw2 = gtk_scrolled_window_new(NULL, NULL);
+
 		/* Set up some per account status boxes */
 		gtkblist->statusboxbox = gtk_vbox_new(FALSE, 0);
 		gtkblist->statusboxes = NULL;
-#if 0
+
 		for (l = accounts = gaim_accounts_get_all_active(); l; l = l->next) {
 			GtkWidget *statusbox = gtk_gaim_status_box_new_with_account(l->data);
 			gtkblist->statusboxes = g_list_append(gtkblist->statusboxes, statusbox);
@@ -3347,9 +3353,12 @@
 			gtk_widget_show(statusbox);
 		}
 		g_list_free(accounts);
-#endif
+
 		gtk_widget_show(gtkblist->statusboxbox);
-		gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusboxbox, FALSE, TRUE, 0);
+		gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), gtkblist->statusboxbox);
+		gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+		gtk_widget_show(sw2);
+		gtk_paned_pack2(GTK_PANED(vpane), sw2, FALSE, TRUE);
 
 		gtkblist->statusbox = gtk_gaim_status_box_new();
 
--- a/src/gtkstatusbox.c	Sat Nov 05 13:34:37 2005 +0000
+++ b/src/gtkstatusbox.c	Sat Nov 05 19:22:26 2005 +0000
@@ -279,40 +279,62 @@
 }
 
 static GdkPixbuf *
-load_icon(const char *basename)
+load_icon(GaimAccount *account, GaimStatusType *status_type)
 {
 	char basename2[BUFSIZ];
 	char *filename;
-	GdkPixbuf *pixbuf, *scale = NULL;
+	GaimPluginProtocolInfo *prpl_info = NULL;
+	GaimPlugin *plugin;
+	const char *proto_name, *type_name;
+	GdkPixbuf *pixbuf, *scale = NULL, *emblem;
 
-	if (!strcmp(basename, "available"))
-		basename = "online";
-	else if (!strcmp(basename, "hidden"))
-		basename = "invisible";
+
+	plugin = gaim_find_prpl(gaim_account_get_protocol_id(account));
 
-	/*
-	 * TODO: Find a way to fallback to the GaimStatusPrimitive
-	 * if an icon for this id does not exist.
-	 */
+	if (plugin != NULL) {
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
+		proto_name = prpl_info->list_icon(account, NULL);
+	}
+
 	g_snprintf(basename2, sizeof(basename2), "%s.png",
-	           basename);
-	filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons",
+	           proto_name);
+	filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default",
 	                            basename2, NULL);
 	pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
 	g_free(filename);
 
 	if (pixbuf != NULL) {
-		scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
+		scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32,
 		                                GDK_INTERP_BILINEAR);
-
 		g_object_unref(G_OBJECT(pixbuf));
-	} else {
-		filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
-		                            "default", basename, NULL);
-		scale = gdk_pixbuf_new_from_file(filename, NULL);
-		g_free(filename);
 	}
 
+
+	/* TODO: let the prpl pick the emblem on a per status bases, and only
+	 * use the primitive as a fallback */
+	type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type));
+	if (!strcmp(type_name, "hidden"))
+		type_name = "invisible";
+	if (!strcmp(type_name, "unavailable"))
+		type_name = "na";
+	g_snprintf(basename2, sizeof(basename2), "%s.png",
+	           type_name);
+	filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default",
+	                            basename2, NULL);
+	emblem = gdk_pixbuf_new_from_file(filename, NULL);
+	g_free(filename);
+
+	if (emblem) {
+		gdk_pixbuf_composite(emblem,
+		                     scale, 32-15, 32-15,
+		                     15, 15,
+		                     32-15, 32-15,
+		                     1, 1,
+		                     GDK_INTERP_BILINEAR,
+		                     255);
+
+		g_object_unref(emblem);
+	}
 	return scale;
 }
 
@@ -332,6 +354,10 @@
 	const char *current_savedstatus_name;
 	GaimSavedStatus *saved_status;
 
+	/* this function is inappropriate for ones with accounts */
+	if (status_box->account)
+		return;
+
 	current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
 	saved_status = gaim_savedstatus_find(current_savedstatus_name);
 
@@ -442,7 +468,7 @@
 
 			gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box),
 									gaim_status_type_get_primitive(status_type),
-									load_icon(gaim_status_type_get_id(status_type)),
+									load_icon(account, status_type),
 									gaim_status_type_get_name(status_type),
 									NULL);
 		}