xchat-gnome r2654 - in trunk: . src/fe-gnome



Author: cosimoc
Date: Fri Sep  5 13:31:02 2008
New Revision: 2654
URL: http://svn.gnome.org/viewvc/xchat-gnome?rev=2654&view=rev

Log:
2008-09-05  Cosimo Cecchi  <cosimoc gnome org>

	* src/fe-gnome/dcc-window.c: (dcc_window_init),
	(dcc_window_update):
	* src/fe-gnome/dcc-window.h:
	Use the GEmblem machinery instead of using custom code to composite
	emblems on icons (#550970).


Modified:
   trunk/ChangeLog
   trunk/src/fe-gnome/dcc-window.c
   trunk/src/fe-gnome/dcc-window.h

Modified: trunk/src/fe-gnome/dcc-window.c
==============================================================================
--- trunk/src/fe-gnome/dcc-window.c	(original)
+++ trunk/src/fe-gnome/dcc-window.c	Fri Sep  5 13:31:02 2008
@@ -101,7 +101,7 @@
 	window->transfer_store = gtk_list_store_new (N_COLUMNS,
 	                                             G_TYPE_POINTER,	/* DCC struct */
 	                                             G_TYPE_STRING,	/* Info text */
-	                                             GDK_TYPE_PIXBUF,	/* File icon */
+	                                             G_TYPE_ICON,	/* File icon */
 	                                             G_TYPE_INT,	/* % done */
 	                                             G_TYPE_STRING,	/* % done label */
 	                                             G_TYPE_STRING	/* time remaining */
@@ -127,7 +127,7 @@
 
 	window->icon_cell = gtk_cell_renderer_pixbuf_new ();
 	gtk_tree_view_column_pack_start (window->info_column, window->icon_cell, FALSE);
-	gtk_tree_view_column_add_attribute (window->info_column, window->icon_cell, "pixbuf", ICON_COLUMN);
+	gtk_tree_view_column_add_attribute (window->info_column, window->icon_cell, "gicon", ICON_COLUMN);
 
 	window->info_cell = gtk_cell_renderer_text_new ();
 	gtk_tree_view_column_pack_start (window->info_column, window->info_cell, TRUE);
@@ -152,10 +152,6 @@
 	gtk_tree_view_append_column (GTK_TREE_VIEW (window->transfer_list), window->info_column);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (window->transfer_list), window->remaining_column);
 
-	GtkIconTheme *theme = gtk_icon_theme_get_default ();
-	window->up_icon   = gtk_icon_theme_load_icon (theme, "go-up",   24, 0, NULL);
-	window->down_icon = gtk_icon_theme_load_icon (theme, "go-down", 24, 0, NULL);
-
 	g_signal_connect (
 		G_OBJECT (gtk_tree_view_get_selection (
 			GTK_TREE_VIEW (window->transfer_list))),
@@ -335,11 +331,8 @@
 				if (dcc->destfile != NULL && icon == NULL) {
 					GFile *file;
 					GFileInfo *info;
-					GIcon *icon;
-					GtkIconInfo *icon_info;
-					GdkPixbuf *mime_pixbuf, *file_icon, *direction_emblem;
-					int mime_w, mime_h;
-					gpointer image_data;
+					GIcon *mime_icon, *emblemed_icon, *direction_icon;
+					GEmblem *direction_emblem;
 
 					/* If the file doesn't exist yet, don't do the icon */
 					if (g_file_test (dcc->destfile, G_FILE_TEST_EXISTS) == FALSE) {
@@ -355,57 +348,25 @@
 						return;
 					}
 
-					icon = g_file_info_get_icon (info);
-					icon_info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
-										    icon, 48, 0);
-					mime_pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
-
-					gtk_icon_info_free (icon_info);
+					mime_icon = g_file_info_get_icon (info);
 					g_object_unref (info);
-					g_object_unref (icon);
-
-					if (!mime_pixbuf) {
-						return;
-					}	
-
-					mime_w   = gdk_pixbuf_get_width  (mime_pixbuf);
-					mime_h   = gdk_pixbuf_get_height (mime_pixbuf);
-
-					/* Create a new, empty image, 8px bigger than the MIME icon */
-					image_data = g_new0 (char, (mime_w + 8) * (mime_h + 8) * 4 * 8);
-					file_icon = gdk_pixbuf_new_from_data (image_data,
-					                                      GDK_COLORSPACE_RGB, TRUE, 8,
-					                                      mime_w + 8, mime_h + 8, (mime_w + 8) * 4,
-					                                      (GdkPixbufDestroyNotify) g_free, NULL);
-
-					/* Composite on our MIME icon */
-					gdk_pixbuf_composite (mime_pixbuf,
-					                      file_icon,
-					                      0, 0,
-					                      mime_w, mime_h,
-					                      0.0, 0.0,
-					                      1.0, 1.0,
-					                      GDK_INTERP_BILINEAR, 255);
 
 					/* Composite on an emblem which shows the direction of transfer */
 					if (dcc->type == 1) {
-						direction_emblem = window->down_icon;
+						direction_icon = g_themed_icon_new ("go-down");
 					} else {
-						direction_emblem = window->up_icon;
+						direction_icon = g_themed_icon_new ("go-up");
 					}
 
-					gdk_pixbuf_composite (direction_emblem,
-					                      file_icon,
-					                      mime_w - 16, mime_w - 16,
-					                      24, 24,
-					                      mime_w - 16, mime_w - 16,
-					                      1.0, 1.0,
-					                      GDK_INTERP_BILINEAR, 255);
+					direction_emblem = g_emblem_new (direction_icon);
+					emblemed_icon = g_emblemed_icon_new (mime_icon, direction_emblem);
 
-					gtk_list_store_set (window->transfer_store, &iter, ICON_COLUMN, file_icon, -1);
+					gtk_list_store_set (window->transfer_store, &iter, ICON_COLUMN, emblemed_icon, -1);
 
-					g_object_unref (mime_pixbuf);
-					g_object_unref (file_icon);
+					g_object_unref (mime_icon);
+					g_object_unref (emblemed_icon);
+					g_object_unref (direction_emblem);
+					g_object_unref (direction_icon);
 				}
 
 				return;

Modified: trunk/src/fe-gnome/dcc-window.h
==============================================================================
--- trunk/src/fe-gnome/dcc-window.h	(original)
+++ trunk/src/fe-gnome/dcc-window.h	Fri Sep  5 13:31:02 2008
@@ -56,9 +56,6 @@
 	GtkTreeViewColumn *progress_column;
 	GtkTreeViewColumn *info_column;
 	GtkTreeViewColumn *remaining_column;
-
-	GdkPixbuf *up_icon;
-	GdkPixbuf *down_icon;
 };
 
 struct _DccWindowClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]