Index: gtk/gtkfilechooserentry.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserentry.c,v
retrieving revision 1.20
diff -u -r1.20 gtkfilechooserentry.c
--- gtk/gtkfilechooserentry.c	22 Apr 2004 05:08:19 -0000	1.20
+++ gtk/gtkfilechooserentry.c	31 May 2004 22:52:12 -0000
@@ -22,7 +22,9 @@
 #include <string.h>
 
 #include "gtkcelllayout.h"
+#include "gtkcellrendererpixbuf.h"
 #include "gtkcellrenderertext.h"
+#include "gtkiconfactory.h"
 #include "gtkentry.h"
 #include "gtkfilechooserentry.h"
 #include "gtkmain.h"
@@ -33,6 +35,9 @@
 #define GTK_IS_FILE_CHOOSER_ENTRY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_ENTRY))
 #define GTK_FILE_CHOOSER_ENTRY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_CHOOSER_ENTRY, GtkFileChooserEntryClass))
 
+#define FALLBACK_ICON_SIZE 20
+
+
 struct _GtkFileChooserEntryClass
 {
   GtkEntryClass parent_class;
@@ -54,6 +59,9 @@
 
   GtkListStore *completion_store;
 
+  gint icon_size;
+  gulong settings_signal_id;
+
   guint has_completion : 1;
   guint in_change      : 1;
 };
@@ -72,6 +80,8 @@
 static void     gtk_file_chooser_entry_finalize       (GObject          *object);
 static gboolean gtk_file_chooser_entry_focus          (GtkWidget        *widget,
 						       GtkDirectionType  direction);
+static void     gtk_file_chooser_entry_style_set      (GtkWidget        *object,
+						       GtkStyle		*previous_style);
 static void     gtk_file_chooser_entry_activate       (GtkEntry         *entry);
 static void     gtk_file_chooser_entry_changed        (GtkEditable      *editable);
 static void     gtk_file_chooser_entry_do_insert_text (GtkEditable *editable,
@@ -79,6 +89,11 @@
 						       gint         new_text_length,
 						       gint        *position);
 
+static void	render_mime_icon	  (GtkCellLayout      *layout,
+					   GtkCellRenderer     *cell,
+					   GtkTreeModel	       *model,
+					   GtkTreeIter	       *iter,
+					   gpointer	       user_data);
 static void     clear_completion_callback (GtkFileChooserEntry *chooser_entry,
 					   GParamSpec          *pspec);
 static gboolean match_selected_callback   (GtkEntryCompletion  *completion,
@@ -153,6 +168,7 @@
   gobject_class->finalize = gtk_file_chooser_entry_finalize;
 
   widget_class->focus = gtk_file_chooser_entry_focus;
+  widget_class->style_set = gtk_file_chooser_entry_style_set;
 
   entry_class->activate = gtk_file_chooser_entry_activate;
 }
@@ -178,6 +194,14 @@
 				       chooser_entry,
 				       NULL);
 
+  cell = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (comp),
+                              cell, FALSE);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (comp), 
+				      cell,
+				      render_mime_icon,
+				      chooser_entry, NULL);
+
   cell = gtk_cell_renderer_text_new ();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (comp),
                               cell, TRUE);
@@ -216,6 +240,10 @@
 
   if (chooser_entry->file_system)
     g_object_unref (chooser_entry->file_system);
+  
+  if (chooser_entry->settings_signal_id)
+    g_signal_handler_disconnect (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (object))),
+				 chooser_entry->settings_signal_id);
 
   gtk_file_path_free (chooser_entry->base_folder);
   gtk_file_path_free (chooser_entry->current_folder_path);
@@ -224,6 +252,38 @@
   parent_class->finalize (object);
 }
 
+
+static void
+render_mime_icon (GtkCellLayout	      *layout,
+		  GtkCellRenderer     *cell,
+		  GtkTreeModel	      *model,
+		  GtkTreeIter	      *iter,
+		  gpointer	      user_data)
+{
+  GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (user_data);
+  GdkPixbuf *pixbuf;
+  GtkFilePath *path;
+
+  path = NULL;
+  gtk_tree_model_get (model, iter, PATH_COLUMN, &path, -1);
+
+  if (path != NULL)
+    {
+      pixbuf = gtk_file_system_render_icon (chooser_entry->file_system, path,
+					    GTK_WIDGET (chooser_entry),
+					    chooser_entry->icon_size, NULL);
+
+      gtk_file_path_free (path);
+    }
+  else
+    pixbuf = NULL;
+
+  g_object_set (cell, "pixbuf", pixbuf, NULL);
+
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+}
+
 /* Match functions for the GtkEntryCompletion */
 static gboolean
 match_selected_callback (GtkEntryCompletion  *completion,
@@ -653,6 +713,73 @@
     }
   else
     return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction);
+}
+
+/* Changes the icons wherever it is needed */
+static void
+change_icon_theme (GtkFileChooserEntry *entry)
+{
+  GtkSettings *settings;
+  gint width, height;
+
+  settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (entry)));
+
+  if (gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_SMALL_TOOLBAR, &width, &height))
+    entry->icon_size = MAX (width, height);
+  else
+    entry->icon_size = FALLBACK_ICON_SIZE;
+}
+
+/* Callback used when a GtkSettings value changes */
+static void
+settings_notify_cb (GObject             *object,
+                    GParamSpec          *pspec,
+                    GtkFileChooserEntry *entry)
+{
+  const char *name;
+
+  name = g_param_spec_get_name (pspec);
+
+  if (strcmp (name, "gtk-icon-theme-name") == 0
+      || strcmp (name, "gtk-icon-sizes") == 0)
+    change_icon_theme (entry);
+}
+
+/* Installs a signal handler for GtkSettings so that we can monitor changes in
+ * the icon theme.
+ */
+static void
+check_icon_theme (GtkFileChooserEntry *entry)
+{
+  GtkSettings *settings;
+
+  if (entry->settings_signal_id)
+    return;
+
+  if (gtk_widget_has_screen (GTK_WIDGET (entry)))
+    {
+      settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (entry)));
+      entry->settings_signal_id = g_signal_connect (settings, "notify",
+                                                    G_CALLBACK (settings_notify_cb), entry);
+
+      change_icon_theme (entry);
+    }
+}
+
+static void
+gtk_file_chooser_entry_style_set (GtkWidget *widget,
+                                  GtkStyle  *previous_style)
+{
+  GtkFileChooserEntry *entry;
+
+  entry = GTK_FILE_CHOOSER_ENTRY (widget);
+
+  if (GTK_WIDGET_CLASS (parent_class)->style_set)
+    GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
+
+  check_icon_theme (entry);
+
+  g_signal_emit_by_name (widget, "default-size-changed");
 }
 
 static void
