Re: [evolution-patches] Please review my patch for bug #45908



Unfortunately this has broken Evolution 1.4.x for me. I no longer see
icons in my composer attachment bar (nor any text signifying I *have*
attachments)

I think we should revert this.

Jeff

On Tue, 2003-07-29 at 09:16, Dan Winship wrote:
> OK, the attached patch pulls up the icon changes. (It also pulls up the
> removal of some unused files in composer/.)
> 
> 
> 
> ______________________________________________________________________
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/ChangeLog,v
> retrieving revision 1.1215.2.4
> diff -u -r1.1215.2.4 ChangeLog
> --- ChangeLog	28 Jul 2003 19:54:49 -0000	1.1215.2.4
> +++ ChangeLog	29 Jul 2003 13:07:43 -0000
> @@ -1,3 +1,8 @@
> +2003-07-29  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)
> +
>  == Version 1.4.4 ==
>  
>  2003-07-28  Ettore Perazzoli  <ettore ximian com>
> Index: configure.in
> ===================================================================
> RCS file: /cvs/gnome/evolution/configure.in,v
> retrieving revision 1.591.2.4
> diff -u -r1.591.2.4 configure.in
> --- configure.in	28 Jul 2003 19:54:50 -0000	1.591.2.4
> +++ configure.in	29 Jul 2003 13:07:44 -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.2.1
> diff -u -r1.398.2.1 ChangeLog
> --- e-util/ChangeLog	17 Jul 2003 12:41:04 -0000	1.398.2.1
> +++ e-util/ChangeLog	29 Jul 2003 13:07:44 -0000
> @@ -1,3 +1,9 @@
> +2003-07-29  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-07-03  JP Rosevear  <jpr ximian com>
>  
>  	* e-xml-hash-utils.c (foreach_save_func): encode the text
> 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	29 Jul 2003 13:07:44 -0000
> @@ -11,6 +11,8 @@
>   */
>  #include <config.h>
>  
> +#include <string.h>
> +
>  #include "e-gui-utils.h"
>  
>  #include <glib.h>
> @@ -20,6 +22,15 @@
>  #include <gtk/gtklabel.h>
>  #include <gtk/gtkhbox.h>
>  
> +#include <libgnome/gnome-program.h>
> +#include <libgnomevfs/gnome-vfs-mime-handlers.h>
> +
> +#ifdef HAVE_LIBGNOMEUI_GNOME_ICON_LOOKUP_H
> +#include <libgnomeui/gnome-icon-lookup.h>
> +#else
> +#include "art/empty.xpm"
> +#endif
> +
>  GtkWidget *e_create_image_widget(gchar *name,
>  				 gchar *string1, gchar *string2,
>  				 gint int1, gint int2)
> @@ -75,5 +86,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: mail/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
> retrieving revision 1.2761.2.7
> diff -u -r1.2761.2.7 ChangeLog
> --- mail/ChangeLog	28 Jul 2003 21:01:33 -0000	1.2761.2.7
> +++ mail/ChangeLog	29 Jul 2003 13:07:44 -0000
> @@ -1,3 +1,8 @@
> +2003-07-29  Dan Winship  <danw ximian com>
> +
> +	* mail-display.c (pixbuf_for_mime_type): Gone
> +	(pixbuf_gen_idle): Use e_icon_for_mime_type instead.
> +
>  2003-07-25  Jeffrey Stedfast  <fejj ximian com>
>  
>  	* message-browser.c (on_key_press): New callback function to
> Index: mail/mail-display.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/mail/mail-display.c,v
> retrieving revision 1.282.4.2
> diff -u -r1.282.4.2 mail-display.c
> --- mail/mail-display.c	10 Jul 2003 14:03:00 -0000	1.282.4.2
> +++ mail/mail-display.c	29 Jul 2003 13:07:44 -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>
> @@ -66,6 +65,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"
>  
> @@ -82,8 +82,6 @@
>  
>  #include "camel/camel-data-cache.h"
>  
> -#include "art/empty.xpm"
> -
>  #define d(x)
>  
>  struct _MailDisplayPrivate {
> @@ -580,60 +578,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)
>  {
> @@ -717,7 +661,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.544.2.7
> diff -u -r1.544.2.7 ChangeLog
> --- composer/ChangeLog	23 Jul 2003 18:17:20 -0000	1.544.2.7
> +++ composer/ChangeLog	29 Jul 2003 13:07:44 -0000
> @@ -1,4 +1,22 @@
> +2003-07-29  Antonio Xu <antonio xu sun com>
> + 
> +	* e-msg-composer-attachment-bar.c  (update): add
> +	gdk_pixbuf_loader_close to close pix buffer loading.  [#45908]
> +
> +2003-07-29  Dan Winship  <danw ximian com>
> +
> +	* e-msg-composer-attachment-bar.c (pixbuf_for_mime_type): Gone.
> +	(update): Use e_icon_for_mime_type instead.
> +
> +	* bad-icon.xpm: Remove this. It was only used by e-icon-list,
> +	which is no longer there.
> +
> +	* composer-marshal.list: Likewise
> +
> +	* Makefile.am: Remove bad-icon.xpm and composer-marshal refs.
> +	(INCLUDES): remove EVOLUTION_IMAGESDIR define
> +
>  2003-07-17  Michel Dänzer  <michel daenzer net>
>  
>  	* e-msg-composer.c (autosave_manager_query_load_orphans): Set
> 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	29 Jul 2003 13:07:44 -0000
> @@ -29,19 +29,6 @@
>  
>  ##
>  
> -composer-marshal.h: composer-marshal.list
> -	( @GLIB_GENMARSHAL@ --prefix=e_msg_composer_marshal composer-marshal.list --header > composer-marshal.tmp \
> -	&& mv composer-marshal.tmp composer-marshal.h ) \
> -	|| ( rm -f composer-marshal.tmp && exit 1 )
> -composer-marshal.c: composer-marshal.h
> -	( @GLIB_GENMARSHAL@ --prefix=e_msg_composer_marshal composer-marshal.list --body > composer-marshal.tmp \
> -	&& mv composer-marshal.tmp composer-marshal.c ) \
> -	|| ( rm -f composer-marshal.tmp && exit 1 )
> -
> -$(libcomposer_la_OBJECTS): composer-marshal.h
> -
> -##
> -
>  idl_DATA = $(IDLS)
>  
>  glade_DATA =					\
> @@ -62,7 +49,6 @@
>  	-I$(top_builddir)/shell						\
>  	-I$(top_srcdir)/shell						\
>  	-DEVOLUTION_DATADIR=\"$(datadir)\"				\
> -	-DEVOLUTION_IMAGESDIR=\"$(imagesdir)\"				\
>  	-DEVOLUTION_UIDIR=\"$(evolutionuidir)\"				\
>  	-DEVOLUTION_GLADEDIR=\"$(gladedir)\"				\
>  	-DPREFIX=\"$(prefix)\"						\
> @@ -74,7 +60,6 @@
>  libcomposer_la_SOURCES = 			\
>  	$(IDL_GENERATED)			\
>  	$(HTML_EDITOR_GENERATED)		\
> -	composer-marshal.c			\
>  	e-msg-composer-attachment-bar.c		\
>  	e-msg-composer-attachment-bar.h		\
>  	e-msg-composer-attachment.c		\
> @@ -93,9 +78,7 @@
>  EXTRA_DIST =					\
>  	$(glade_DATA)				\
>  	$(IDLS)					\
> -	ChangeLog.pre-1-4			\
> -	composer-marshal.list			\
> -	bad-icon.xpm
> +	ChangeLog.pre-1-4
>  
>  BUILT_SOURCES = $(IDL_GENERATED) $(HTML_EDITOR_GENERATED)
>  CLEANFILES = $(BUILT_SOURCES)
> Index: composer/bad-icon.xpm
> ===================================================================
> RCS file: composer/bad-icon.xpm
> diff -N composer/bad-icon.xpm
> --- composer/bad-icon.xpm	2 Oct 2000 00:42:10 -0000	1.1
> +++ /dev/null	1 Jan 1970 00:00:00 -0000
> @@ -1,53 +0,0 @@
> -/* XPM */
> -static char * bad_icon_xpm[] = {
> -"48 48 2 1",
> -" 	g None",
> -".	g #000000",
> -"................................................",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".        .                              .      .",
> -".         .                            .       .",
> -".          .                          .        .",
> -".           .                        .         .",
> -".            .                      .          .",
> -".             .                    .           .",
> -".              .                  .            .",
> -".               .                .             .",
> -".                .              .              .",
> -".                 .            .               .",
> -".                  .          .                .",
> -".                   .        .                 .",
> -".                    .      .                  .",
> -".                     .    .                   .",
> -".                      .  .                    .",
> -".                       ..                     .",
> -".                       ..                     .",
> -".                      .  .                    .",
> -".                     .    .                   .",
> -".                    .      .                  .",
> -".                   .        .                 .",
> -".                  .          .                .",
> -".                 .            .               .",
> -".                .              .              .",
> -".               .                .             .",
> -".              .                  .            .",
> -".             .                    .           .",
> -".            .                      .          .",
> -".           .                        .         .",
> -".          .                          .        .",
> -".         .                            .       .",
> -".        .                              .      .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -".                                              .",
> -"................................................"};
> Index: composer/composer-marshal.list
> ===================================================================
> RCS file: composer/composer-marshal.list
> diff -N composer/composer-marshal.list
> --- composer/composer-marshal.list	8 Nov 2002 06:49:14 -0000	1.1
> +++ /dev/null	1 Jan 1970 00:00:00 -0000
> @@ -1,4 +0,0 @@
> -
> -# for e-icon-list
> -VOID:INT,BOXED
> -BOOLEAN:INT,POINTER
> 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.4.2
> diff -u -r1.67.4.2 e-msg-composer-attachment-bar.c
> --- composer/e-msg-composer-attachment-bar.c	17 Jul 2003 05:32:56 -0000	1.67.4.2
> +++ composer/e-msg-composer-attachment-bar.c	29 Jul 2003 13:07:44 -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)
>  {
> @@ -327,7 +268,9 @@
>  			
>  			if (!error) {
>  				int ratio, width, height;
> -				
> +
> +				gdk_pixbuf_loader_close (loader, NULL);
> +
>  				/* Shrink pixbuf */
>  				pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
>  				width = gdk_pixbuf_get_width (pixbuf);
> @@ -382,7 +325,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]