Re: [evolution-patches] attachment icon fixes



sure, looks ok

On Tue, 2003-07-01 at 09:39, Dan Winship wrote:
> This makes evolution-mail use the GNOME 2.2 GnomeIconTheme API (if
> available) to find attachment icons. If it's not available, it tries
> gnome-vfs like it always did, but then if that doesn't return anything,
> it falls back to using the icons from gnome-mime-data, which of course
> are not actually pointed to by gnome-vfs for the most part, because that
> would be too easy. In either case, the generic document icon is now used
> as the fallback rather than gnome-unknown.
> 
> It also gets rid of the special case for digest and message/rfc822
> messages in the composer, but since the generic icon is now nicer,
> that's not a big deal. (And the so-called "email.png" that it was using
> before was actually the text/plain icon.)
> 
> 
> 
> ______________________________________________________________________
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/ChangeLog,v
> retrieving revision 1.1216
> diff -u -r1.1216 ChangeLog
> --- ChangeLog	30 Jun 2003 14:33:23 -0000	1.1216
> +++ ChangeLog	1 Jul 2003 13:30:17 -0000
> @@ -1,3 +1,8 @@
> +2003-07-01  Dan Winship  <danw ximian com>
> +
> +	* configure.in: Check for gnome-icon-lookup.h (which could mean
> +	either plain GNOME 2.2 or Sun GNOME 2.0)
> +
>  2003-06-30  Rodrigo Moya <rodrigo ximian com>
>  
>  	* configure.in:
> Index: configure.in
> ===================================================================
> RCS file: /cvs/gnome/evolution/configure.in,v
> retrieving revision 1.592
> diff -u -r1.592 configure.in
> --- configure.in	30 Jun 2003 14:33:24 -0000	1.592
> +++ configure.in	1 Jul 2003 13:30:18 -0000
> @@ -1057,6 +1057,11 @@
>  EVO_SET_COMPILE_FLAGS(GNOME_FULL, $FULL_GNOME_DEPS)
>  AC_SUBST(GNOME_FULL_CFLAGS)
>  AC_SUBST(GNOME_FULL_LIBS)
> +
> +CPPFLAGS_save="$CPPFLAGS"
> +CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags-only-I libgnomeui-2.0`"
> +AC_CHECK_HEADERS(libgnomeui/gnome-icon-lookup.h)
> +CPPFLAGS="$CPPFLAGS_save"
>  
>  dnl --- Flags for the various libraries we build
>  
> Index: e-util/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
> retrieving revision 1.398
> diff -u -r1.398 ChangeLog
> --- e-util/ChangeLog	20 Jun 2003 14:36:58 -0000	1.398
> +++ e-util/ChangeLog	1 Jul 2003 13:30:18 -0000
> @@ -1,3 +1,9 @@
> +2003-07-01  Dan Winship  <danw ximian com>
> +
> +	* e-gui-utils.c (e_icon_for_mime_type): New function to return an
> +	icon for a MIME type, using GnomeIconTheme if available or
> +	gnome-vfs and gnome-mime-data if not.
> +
>  2003-06-19  Dan Winship  <danw ximian com>
>  
>  	* e-xml-hash-utils.c (e_xml_to_hash): don't leak an extra copy of
> Index: e-util/e-gui-utils.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/e-util/e-gui-utils.c,v
> retrieving revision 1.15
> diff -u -r1.15 e-gui-utils.c
> --- e-util/e-gui-utils.c	29 Apr 2003 21:33:46 -0000	1.15
> +++ e-util/e-gui-utils.c	1 Jul 2003 13:30:18 -0000
> @@ -11,6 +11,8 @@
>   */
>  #include <config.h>
>  
> +#include <string.h>
> +
>  #include "e-gui-utils.h"
>  
>  #include <glib.h>
> @@ -20,6 +22,14 @@
>  #include <gtk/gtklabel.h>
>  #include <gtk/gtkhbox.h>
>  
> +#include <libgnome/gnome-program.h>
> +#ifdef HAVE_LIBGNOMEUI_GNOME_ICON_LOOKUP_H
> +#include <libgnomeui/gnome-icon-lookup.h>
> +#endif
> +#include <libgnomevfs/gnome-vfs-mime-handlers.h>
> +
> +#include "art/empty.xpm"
> +
>  GtkWidget *e_create_image_widget(gchar *name,
>  				 gchar *string1, gchar *string2,
>  				 gint int1, gint int2)
> @@ -75,5 +85,86 @@
>  	gtk_widget_show_all (align);
>  
>  	return button;
> +}
> +
> +/**
> + * e_icon_for_mime_type:
> + * @mime_type: a MIME type
> + * @size_hint: the size the caller plans to display the icon at
> + *
> + * Tries to find an icon representing @mime_type that will display
> + * nicely at @size_hint by @size_hint pixels. The returned icon
> + * may or may not actually be that size.
> + *
> + * Return value: a pixbuf, which the caller must unref when it is done
> + **/
> +GdkPixbuf *
> +e_icon_for_mime_type (const char *mime_type, int size_hint)
> +{
> +	char *icon_name, *icon_path = NULL;
> +	GdkPixbuf *pixbuf = NULL;
> +
> +#ifdef HAVE_LIBGNOMEUI_GNOME_ICON_LOOKUP_H
> +	static GnomeIconTheme *icon_theme = NULL;
> +
> +	/* Try the icon theme. (GNOME 2.2 or Sun GNOME 2.0).
> +	 * This will also look in GNOME VFS.
> +	 */
> +
> +	if (!icon_theme)
> +		icon_theme = gnome_icon_theme_new ();
> +
> +	icon_name = gnome_icon_lookup (icon_theme, NULL, NULL, NULL, NULL,
> +				       mime_type, 0, NULL);
> +	if (icon_name) {
> +		icon_path = gnome_icon_theme_lookup_icon (
> +			icon_theme, icon_name, size_hint, NULL, NULL);
> +		g_free (icon_name);
> +	}
> +
> +#else
> +	const char *vfs_icon_name;
> +
> +	/* Try gnome-vfs. (gnome-vfs.mime itself doesn't offer much,
> +	 * but other software packages may define icons for
> +	 * themselves.
> +	 */
> +	vfs_icon_name = gnome_vfs_mime_get_icon (mime_type);
> +	if (vfs_icon_name) {
> +		icon_path = gnome_program_locate_file (
> +			NULL, GNOME_FILE_DOMAIN_PIXMAP,
> +			vfs_icon_name, TRUE, NULL);
> +	}
> +
> +	if (!icon_path) {
> +		char *p;
> +
> +		/* Try gnome-mime-data. */
> +		icon_name = g_strdup_printf ("document-icons/gnome-%s.png",
> +					     mime_type);
> +		p = strrchr (icon_name, '/');
> +		if (p)
> +			*p = '-';
> +
> +		icon_path = gnome_program_locate_file (
> +			NULL, GNOME_FILE_DOMAIN_PIXMAP,
> +			icon_name, TRUE, NULL);
> +		g_free (icon_name);
> +	}
> +
> +	if (!icon_path) {
> +		/* Use the generic document icon. */
> +		icon_path = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
> +						      "document-icons/i-regular.png", TRUE, NULL);
> +		if (!icon_path) {
> +			g_warning ("Could not get any icon for %s!",mime_type);
> +			return gdk_pixbuf_new_from_xpm_data((const char **)empty_xpm);
> +		}
> +	}
> +#endif
> +
> +	pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL);
> +	g_free (icon_path);
> +	return pixbuf;
>  }
>  
> Index: e-util/e-gui-utils.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/e-util/e-gui-utils.h,v
> retrieving revision 1.10
> diff -u -r1.10 e-gui-utils.h
> --- e-util/e-gui-utils.h	29 Apr 2003 21:33:46 -0000	1.10
> +++ e-util/e-gui-utils.h	1 Jul 2003 13:30:18 -0000
> @@ -9,4 +9,6 @@
>  
>  GtkWidget *e_button_new_with_stock_icon  (const char *label_str, const char *stockid);
>  
> +GdkPixbuf *e_icon_for_mime_type          (const char *mime_type, int size);
> +
>  #endif /* E_GUI_UTILS_H */
> Index: mail/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
> retrieving revision 1.2761
> diff -u -r1.2761 ChangeLog
> --- mail/ChangeLog	25 Jun 2003 16:54:16 -0000	1.2761
> +++ mail/ChangeLog	1 Jul 2003 13:30:18 -0000
> @@ -1,3 +1,8 @@
> +2003-07-01  Dan Winship  <danw ximian com>
> +
> +	* mail-display.c (pixbuf_for_mime_type): Gone
> +	(pixbuf_gen_idle): Use e_icon_for_mime_type instead.
> +
>  2003-06-25  Radek Doulik  <rodo ximian com>
>  
>  	* mail-config.c (config_write_style): provide hardcoded default
> Index: mail/mail-display.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/mail/mail-display.c,v
> retrieving revision 1.282
> diff -u -r1.282 mail-display.c
> --- mail/mail-display.c	11 Jun 2003 16:19:34 -0000	1.282
> +++ mail/mail-display.c	1 Jul 2003 13:30:19 -0000
> @@ -41,7 +41,6 @@
>  #include <gconf/gconf.h>
>  #include <gconf/gconf-client.h>
>  
> -#include <libgnomevfs/gnome-vfs-mime-handlers.h>
>  #include <libgnomevfs/gnome-vfs.h>
>  #include <libgnome/gnome-url.h>
>  #include <bonobo/bonobo-exception.h>
> @@ -65,6 +64,7 @@
>  
>  #include <libsoup/soup-message.h>
>  
> +#include "e-util/e-gui-utils.h"
>  #include "e-util/e-mktemp.h"
>  #include "addressbook/backend/ebook/e-book-util.h"
>  
> @@ -81,8 +81,6 @@
>  
>  #include "camel/camel-data-cache.h"
>  
> -#include "art/empty.xpm"
> -
>  #define d(x)
>  
>  struct _MailDisplayPrivate {
> @@ -549,60 +547,6 @@
>  	return TRUE;
>  }	
>  
> -static GdkPixbuf *
> -pixbuf_for_mime_type (const char *mime_type)
> -{
> -	const char *icon_name;
> -	char *filename = NULL;
> -	GdkPixbuf *pixbuf = NULL;
> -	
> -	icon_name = gnome_vfs_mime_get_icon (mime_type);
> -	
> -	if (icon_name) {
> -		if (*icon_name == '/') {
> -			pixbuf = gdk_pixbuf_new_from_file (icon_name, NULL);
> -			if (pixbuf)
> -				return pixbuf;
> -		}
> -		
> -		filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
> -						      icon_name, TRUE, NULL);
> -		if (!filename) {
> -			char *fm_icon;
> -			
> -			fm_icon = g_strdup_printf ("nautilus/%s", icon_name);
> -			filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
> -							      fm_icon, TRUE, NULL);
> -			if (!filename) {
> -				g_free (fm_icon);
> -				fm_icon = g_strdup_printf ("mc/%s", icon_name);
> -				filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
> -								      fm_icon, TRUE, NULL);
> -			}
> -			g_free (fm_icon);
> -		}
> -		
> -		if (filename) {
> -			pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
> -			g_free (filename);
> -		}
> -	}
> -	
> -	if (!pixbuf) {
> -		filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
> -						      "gnome-unknown.png", TRUE, NULL);
> -		if (filename) {
> -			pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
> -			g_free (filename);
> -		} else {
> -			g_warning ("Could not get any icon for %s!",mime_type);
> -			pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)empty_xpm);
> -		}
> -	}
> -	
> -	return pixbuf;
> -}
> -
>  static gboolean
>  pixbuf_uncache (gpointer key)
>  {
> @@ -686,7 +630,7 @@
>  	
>  	if (error || !pbl->mstream) {
>  		if (pbl->type)
> -			pixbuf = pixbuf_for_mime_type (pbl->type);
> +			pixbuf = e_icon_for_mime_type (pbl->type, 24);
>  		else
>  			pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/pgp-signature-nokey.png", NULL);
>  	} else
> Index: composer/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
> retrieving revision 1.545
> diff -u -r1.545 ChangeLog
> --- composer/ChangeLog	30 Jun 2003 15:36:30 -0000	1.545
> +++ composer/ChangeLog	1 Jul 2003 13:30:19 -0000
> @@ -1,3 +1,10 @@
> +2003-07-01  Dan Winship  <danw ximian com>
> +
> +	* e-msg-composer-attachment-bar.c (pixbuf_for_mime_type): Gone.
> +	(update): Use e_icon_for_mime_type instead.
> +
> +	* Makefile.am (INCLUDES): remove EVOLUTION_IMAGESDIR define
> +
>  2003-06-27  Jeffrey Stedfast  <fejj ximian com>
>  
>  	* e-msg-composer.c (build_message): Set the rawtext bits for the
> Index: composer/Makefile.am
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/Makefile.am,v
> retrieving revision 1.62
> diff -u -r1.62 Makefile.am
> --- composer/Makefile.am	12 Jun 2003 21:13:55 -0000	1.62
> +++ composer/Makefile.am	1 Jul 2003 13:30:19 -0000
> @@ -62,7 +62,6 @@
>  	-I$(top_builddir)/shell						\
>  	-I$(top_srcdir)/shell						\
>  	-DEVOLUTION_DATADIR=\"$(datadir)\"				\
> -	-DEVOLUTION_IMAGESDIR=\"$(imagesdir)\"				\
>  	-DEVOLUTION_UIDIR=\"$(evolutionuidir)\"				\
>  	-DEVOLUTION_GLADEDIR=\"$(gladedir)\"				\
>  	-DPREFIX=\"$(prefix)\"						\
> Index: composer/e-msg-composer-attachment-bar.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/e-msg-composer-attachment-bar.c,v
> retrieving revision 1.67
> diff -u -r1.67 e-msg-composer-attachment-bar.c
> --- composer/e-msg-composer-attachment-bar.c	9 Jun 2003 18:18:32 -0000	1.67
> +++ composer/e-msg-composer-attachment-bar.c	1 Jul 2003 13:30:19 -0000
> @@ -51,6 +51,7 @@
>  #include "camel/camel-mime-filter-bestenc.h"
>  #include "camel/camel-mime-part.h"
>  
> +#include "e-util/e-gui-utils.h"
>  
>  #define ICON_WIDTH 64
>  #define ICON_SEPARATORS " /-_"
> @@ -203,66 +204,6 @@
>  
>  /* Icon list contents handling.  */
>  
> -static GdkPixbuf *
> -pixbuf_for_mime_type (const char *mime_type)
> -{
> -	const char *icon_name;
> -	char *filename = NULL;
> -	GdkPixbuf *pixbuf;
> -
> -	/* Special-case these two since GNOME VFS doesn't know about them and
> -	   they are used every time the user forwards one or more messages
> -	   inline.  (See #9786.)  */
> -	if (strcmp (mime_type, "message/digest") == 0
> -	    || strcmp (mime_type, "multipart/digest") == 0
> -	    || strcmp (mime_type, "message/rfc822") == 0) {
> -		char *name;
> -		
> -		name = g_build_filename (EVOLUTION_IMAGESDIR, "mail.png", NULL);
> -		pixbuf = gdk_pixbuf_new_from_file (name, NULL);
> -		g_free (name);
> -		
> -		if (pixbuf != NULL)
> -			return pixbuf;
> -	}
> -	
> -	icon_name = gnome_vfs_mime_get_icon (mime_type);
> -	if (icon_name) {
> -		if (*icon_name == '/') {
> -			pixbuf = gdk_pixbuf_new_from_file (icon_name, NULL);
> -			if (pixbuf)
> -				return pixbuf;
> -		}
> -		
> -		filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, icon_name, TRUE, NULL);
> -		if (!filename) {
> -			char *fm_icon;
> -			
> -			fm_icon = g_strdup_printf ("nautilus/%s", icon_name);
> -			filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, fm_icon, TRUE, NULL);
> -			if (!filename) {
> -				g_free (fm_icon);
> -				fm_icon = g_strdup_printf ("mc/%s", icon_name);
> -				filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, fm_icon, TRUE, NULL);
> -			}
> -			g_free (fm_icon);
> -		}
> -	}
> -	
> -	if (filename && (pixbuf = gdk_pixbuf_new_from_file (filename, NULL))) {
> -		g_free (filename);
> -		return pixbuf;
> -	}
> -	
> -	g_free (filename);
> -	filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, "gnome-unknown.png", TRUE, NULL);
> -	
> -	pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
> -	g_free (filename);
> -	
> -	return pixbuf;
> -}
> -
>  static void
>  update (EMsgComposerAttachmentBar *bar)
>  {
> @@ -382,7 +323,7 @@
>  			char *mime_type;
>  			
>  			mime_type = header_content_type_simple (content_type);
> -			pixbuf = pixbuf_for_mime_type (mime_type);
> +			pixbuf = e_icon_for_mime_type (mime_type, 48);
>  			g_free (mime_type);
>  			gnome_icon_list_append_pixbuf (icon_list, pixbuf, NULL, label);
>  			if (pixbuf)
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com




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