diff options
author | Chris Toshok <toshok@ximian.com> | 2004-02-03 10:32:29 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2004-02-03 10:32:29 +0800 |
commit | 4d0eb82b047273f3f6a05bc29be26160258639f4 (patch) | |
tree | 2aec80c5f7bb3277506ea4c8778c0cddc49d988f /widgets | |
parent | fe2cdc8e943d7331d6c21867748a338b97eefc28 (diff) | |
download | gsoc2013-evolution-4d0eb82b047273f3f6a05bc29be26160258639f4.tar.gz gsoc2013-evolution-4d0eb82b047273f3f6a05bc29be26160258639f4.tar.zst gsoc2013-evolution-4d0eb82b047273f3f6a05bc29be26160258639f4.zip |
set image_buf/image_buf_size here instead of in all callers. also emit the
2004-02-02 Chris Toshok <toshok@ximian.com>
* e-image-chooser.c (set_image_from_data): set
image_buf/image_buf_size here instead of in all callers. also
emit the "changed" signal here.
(image_drag_data_received_cb): remove the copying to image_buf and
emitting of "changed" from here.
(e_image_chooser_set_from_file): only g_free (data) here if
set_image_from_data failed.
(e_image_chooser_set_image_data): copy the image data we're passed
before calling set_image_data. free it if rv == FALSE.
svn path=/trunk/; revision=24577
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/ChangeLog | 12 | ||||
-rw-r--r-- | widgets/misc/e-image-chooser.c | 36 |
2 files changed, 32 insertions, 16 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index e806ec9bf6..1d1e6af08c 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,15 @@ +2004-02-02 Chris Toshok <toshok@ximian.com> + + * e-image-chooser.c (set_image_from_data): set + image_buf/image_buf_size here instead of in all callers. also + emit the "changed" signal here. + (image_drag_data_received_cb): remove the copying to image_buf and + emitting of "changed" from here. + (e_image_chooser_set_from_file): only g_free (data) here if + set_image_from_data failed. + (e_image_chooser_set_image_data): copy the image data we're passed + before calling set_image_data. free it if rv == FALSE. + 2004-01-30 Chris Toshok <toshok@ximian.com> * e-image-chooser.c (e_image_chooser_init): add an alignment diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c index 2b7efb064e..ac71a20d24 100644 --- a/widgets/misc/e-image-chooser.c +++ b/widgets/misc/e-image-chooser.c @@ -312,6 +312,13 @@ set_image_from_data (EImageChooser *chooser, gdk_pixbuf_unref (pixbuf); + g_free (chooser->priv->image_buf); + chooser->priv->image_buf = data; + chooser->priv->image_buf_size = length; + + g_signal_emit (chooser, + image_chooser_signals [CHANGED], 0); + rv = TRUE; } @@ -397,7 +404,6 @@ image_drag_data_received_cb (GtkWidget *widget, guint info, guint time, EImageChooser *chooser) { char *target_type; - gboolean changed = FALSE; gboolean handled = FALSE; target_type = gdk_atom_name (selection_data->target); @@ -440,15 +446,10 @@ image_drag_data_received_cb (GtkWidget *widget, printf ("read %d bytes\n", (int)total_read); if (set_image_from_data (chooser, buf, total_read)) { - changed = TRUE; handled = TRUE; - g_free (chooser->priv->image_buf); - chooser->priv->image_buf = buf; - chooser->priv->image_buf_size = total_read; } else { - /* XXX we should pop up a - warning dialog here */ + /* XXX we should pop up a warning dialog here */ g_free (buf); } } @@ -460,11 +461,6 @@ image_drag_data_received_cb (GtkWidget *widget, } g_free (uri); - - if (changed) { - g_signal_emit (chooser, - image_chooser_signals [CHANGED], 0); - } } gtk_drag_finish (context, handled, FALSE, time); @@ -485,9 +481,8 @@ e_image_chooser_set_from_file (EImageChooser *chooser, const char *filename) return FALSE; } - set_image_from_data (chooser, data, data_length); - - g_free (data); + if (!set_image_from_data (chooser, data, data_length)) + g_free (data); return TRUE; } @@ -519,10 +514,19 @@ e_image_chooser_get_image_data (EImageChooser *chooser, char **data, gsize *data gboolean e_image_chooser_set_image_data (EImageChooser *chooser, char *data, gsize data_length) { + char *buf; + g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE); g_return_val_if_fail (data != NULL, FALSE); - set_image_from_data (chooser, data, data_length); + /* yuck, a copy... */ + buf = g_malloc (data_length); + memcpy (buf, data, data_length); + + if (!set_image_from_data (chooser, buf, data_length)) { + g_free (buf); + return FALSE; + } return TRUE; } |