diff options
author | Diego Escalante Urrelo <diegoe@src.gnome.org> | 2007-09-28 12:59:47 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <diegoe@src.gnome.org> | 2007-09-28 12:59:47 +0800 |
commit | 0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b (patch) | |
tree | b631fa5fe20bda7193a8ad0b060674cb784c493b /lib | |
parent | c4c9521c8138c8d14ceb8f1959f8b9ce314b6f5b (diff) | |
download | gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.tar gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.tar.gz gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.tar.bz2 gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.tar.lz gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.tar.xz gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.tar.zst gsoc2013-epiphany-0ab8d7a8cc5ba8bf9ccf805a0a16111049d79c5b.zip |
Add a preview for the FileChooser. The default size is 150x150. Fixes bug
* lib/ephy-file-chooser.c:
Add a preview for the FileChooser. The default size is 150x150.
Fixes bug #440859.
svn path=/trunk/; revision=7502
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-file-chooser.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c index 2edfb11bc..0bdc52f48 100644 --- a/lib/ephy-file-chooser.c +++ b/lib/ephy-file-chooser.c @@ -30,6 +30,7 @@ #include "ephy-stock-icons.h" #include <gtk/gtkstock.h> +#include <gtk/gtkimage.h> #include <libgnomevfs/gnome-vfs-utils.h> #include <glib/gi18n.h> @@ -42,6 +43,8 @@ struct _EphyFileChooserPrivate static void ephy_file_chooser_class_init (EphyFileChooserClass *klass); static void ephy_file_chooser_init (EphyFileChooser *dialog); +static void ephy_file_chooser_image_preview (GtkFileChooser *file_chooser, + gpointer user_data); enum { @@ -49,6 +52,9 @@ enum PROP_PERSIST_KEY }; +#define PREVIEW_WIDTH 150 +#define PREVIEW_HEIGHT 150 + static GObjectClass *parent_class = NULL; GType @@ -314,6 +320,34 @@ ephy_file_chooser_class_init (EphyFileChooserClass *klass) g_type_class_add_private (object_class, sizeof (EphyFileChooserPrivate)); } +static void +ephy_file_chooser_image_preview (GtkFileChooser *file_chooser, + gpointer user_data) +{ + char *filename; + GtkWidget *preview; + GdkPixbuf *pixbuf; + gboolean have_preview; + + pixbuf = NULL; + preview = GTK_WIDGET (user_data); + filename = gtk_file_chooser_get_preview_filename (file_chooser); + + if (filename) + pixbuf = gdk_pixbuf_new_from_file_at_size (filename, + PREVIEW_WIDTH, PREVIEW_HEIGHT, NULL); + g_free (filename); + + have_preview = (pixbuf != NULL); + gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf); + + if (pixbuf) + g_object_unref (pixbuf); + + gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview); + +} + EphyFileChooser * ephy_file_chooser_new (const char *title, GtkWidget *parent, @@ -323,6 +357,7 @@ ephy_file_chooser_new (const char *title, { EphyFileChooser *dialog; GtkFileFilter *filter[EPHY_FILE_FILTER_LAST]; + GtkWidget *preview; g_return_val_if_fail (default_filter >= 0 && default_filter <= EPHY_FILE_FILTER_LAST, NULL); @@ -363,6 +398,10 @@ ephy_file_chooser_new (const char *title, GTK_RESPONSE_ACCEPT); } + preview = gtk_image_new (); + gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (dialog), preview); + g_signal_connect (dialog, "update-preview", G_CALLBACK (ephy_file_chooser_image_preview), preview); + if (default_filter != EPHY_FILE_FILTER_NONE) { filter[EPHY_FILE_FILTER_ALL_SUPPORTED] = |