dia r3924 - in trunk: . lib objects/standard plug-ins/pixbuf
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r3924 - in trunk: . lib objects/standard plug-ins/pixbuf
- Date: Sat, 5 Apr 2008 21:11:55 +0100 (BST)
Author: hans
Date: Sat Apr 5 21:11:54 2008
New Revision: 3924
URL: http://svn.gnome.org/viewvc/dia?rev=3924&view=rev
Log:
2008-04-05 Hans Breuer <hans breuer org>
* lib/widgets.c : setup pixbuf file formats filter for "Load Image"
fixing bug #439847
* objects/standard/image.c : not only check for a different filename
but also for different modification time when setting changing
"Standard - Image". Fixes bug #439849
* plug-ins/pixbuf/pixbuf.c : plug a memory leak
Modified:
trunk/ChangeLog
trunk/lib/widgets.c
trunk/objects/standard/image.c
trunk/plug-ins/pixbuf/pixbuf.c
Modified: trunk/lib/widgets.c
==============================================================================
--- trunk/lib/widgets.c (original)
+++ trunk/lib/widgets.c Sat Apr 5 21:11:54 2008
@@ -1436,6 +1436,8 @@
toplevel = NULL;
if (fs->dialog == NULL) {
+ GtkFileFilter *filter;
+
dialog = fs->dialog =
gtk_file_chooser_dialog_new (_("Select image file"), toplevel ? GTK_WINDOW(toplevel) : NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -1449,6 +1451,16 @@
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&fs->dialog);
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Supported Formats"));
+ gtk_file_filter_add_pixbuf_formats (filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All Files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
gtk_object_set_user_data(GTK_OBJECT(dialog), fs);
}
Modified: trunk/objects/standard/image.c
==============================================================================
--- trunk/objects/standard/image.c (original)
+++ trunk/objects/standard/image.c Sat Apr 5 21:11:54 2008
@@ -20,9 +20,11 @@
#include <assert.h>
#include <string.h>
#include <math.h>
+#include <sys/stat.h>
#ifdef HAVE_UNIST_H
#include <unistd.h>
#endif
+#include <glib/gstdio.h>
#include "intl.h"
#include "message.h"
@@ -59,6 +61,8 @@
gchar *file;
gboolean draw_border;
gboolean keep_aspect;
+
+ time_t mtime;
};
static struct _ImageProperties {
@@ -171,12 +175,20 @@
static void
image_set_props(Image *image, GPtrArray *props)
{
- char *old_file = image->file ? g_strdup(image->file) : NULL;
+ struct stat st;
+ time_t mtime = 0;
+ char *old_file = image->file ? g_strdup(image->file) : "";
object_set_props_from_offsets(&image->element.object, image_offsets, props);
+ /* use old value on error */
+ if (g_stat (image->file, &st) != 0)
+ mtime = image->mtime;
+ else
+ mtime = st.st_mtime;
+
/* handle changing the image. */
- if (strcmp(image->file, old_file) != 0) {
+ if (strcmp(image->file, old_file) != 0 || image->mtime != mtime) {
Element *elem = &image->element;
DiaImage img = NULL;
@@ -189,6 +201,8 @@
(float)dia_image_width(image->image);
}
g_free(old_file);
+ /* remember it */
+ image->mtime = mtime;
image_update_data(image);
}
@@ -725,6 +739,14 @@
g_free(diafile_dir);
}
+ /* update mtime */
+ {
+ struct stat st;
+ if (g_stat (image->file, &st) != 0)
+ st.st_mtime = 0;
+
+ image->mtime = st.st_mtime;
+ }
image_update_data(image);
return &image->element.object;
Modified: trunk/plug-ins/pixbuf/pixbuf.c
==============================================================================
--- trunk/plug-ins/pixbuf/pixbuf.c (original)
+++ trunk/plug-ins/pixbuf/pixbuf.c Sat Apr 5 21:11:54 2008
@@ -233,7 +233,7 @@
}
/* there is no write only filter */
{
- DiaImportFilter* ifilter = g_new0 (DiaImportFilter, 1);
+ DiaImportFilter* ifilter;
gchar* name;
name = gdk_pixbuf_format_get_name (format);
@@ -252,6 +252,7 @@
g_free (name);
continue;
}
+ ifilter = g_new0 (DiaImportFilter, 1);
/* the pixbuf desriptions are too generic for Dia's usage, make our own */
ifilter->description = g_strdup_printf ("Pixbuf[%s]", name);
ifilter->extensions = (const gchar**)gdk_pixbuf_format_get_extensions (format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]