diff options
author | Havoc Pennington <hp@redhat.com> | 2000-10-18 18:42:54 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-10-18 18:42:54 +0000 |
commit | 7a4c68938789206bfec3c6d15cc4bb922daf6443 (patch) | |
tree | e5f031fc609e50a8b7b12e7d6abf63cc78cc88e7 /demos | |
parent | 7420908815651a1ff2ceb1c0fb5e92fe9b260619 (diff) | |
download | gtk+-7a4c68938789206bfec3c6d15cc4bb922daf6443.tar.gz |
Some updates
2000-10-18 Havoc Pennington <hp@redhat.com>
* gtk/gtk-sections.txt: Some updates
* gdk/gdk-sections.txt: remove GdkPixbufAlphaMode
* gdk-pixbuf/gdk-pixbuf-sections.txt: Add new API, remove
GdkPixbufClass/GdkAnimationClass since those are private
* gdk-pixbuf/Makefile.am (IGNORE_HFILES): ignore more headers
2000-10-18 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.c (gtk_text_iter_forward_to_newline): Fix a bug
where any number of empty lines would get skipped
* gtk/gtktextiter.h: Remove padding from GtkTextIter; live on the
edge.
* gtk/gtktextiter.c (gtk_text_iter_make_surreal): enhance the
warning about invalid iterators (explain more thoroughly)
(gtk_text_iter_in_region): rename gtk_text_iter_in_range
* gtk/gtktextview.c (FOCUS_EDGE_WIDTH): Make focus rectangle less
big
* demos/*.c: Add error handling
* gtk/gtktextbuffer.c: don't modify const iterators
* gtk/gdk-pixbuf-loader.c: Add full error handling here
* gtk/gtkimage.c (gtk_image_set_from_file): ignore errors
on file load
* gtk/gtkiconfactory.c: Update to reflect addition of error
handling to gdk-pixbuf loaders
2000-10-16 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-io.c (gdk_pixbuf_get_module)
(gdk_pixbuf_get_named_module) (gdk_pixbuf_load_module):
add error reporting here also
* make-inline-pixbuf.c (main): use GError
* io-xpm.c: include unistd.h
* gdk-pixbuf-util.c: include string.h
* io-*.c: add error reporting
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file): add
error reporting
* gdk-pixbuf-io.c (gdk_pixbuf_new_from_file): Add error reporting
* gdk-pixbuf-io.h: Add GError** to load_increment and load
methods
* gdk-pixbuf-io.c (gdk_pixbuf_save) (gdk_pixbuf_savev): return
a G_FILE_ERROR if we fail to write or close the file.
* gdk-pixbuf.h: remove GDK_PIXBUF_ERROR_IO, instead we'll use
G_FILE_ERROR_*. Rename enum to GdkPixbufError, properly following
the GError naming rules. Add GError** to load functions.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/pixbuf-demo.c | 8 | ||||
-rw-r--r-- | demos/testanimation.c | 14 | ||||
-rw-r--r-- | demos/testpixbuf-scale.c | 10 | ||||
-rw-r--r-- | demos/testpixbuf.c | 37 |
4 files changed, 48 insertions, 21 deletions
diff --git a/demos/pixbuf-demo.c b/demos/pixbuf-demo.c index 528101d3e4..ae9a0998e2 100644 --- a/demos/pixbuf-demo.c +++ b/demos/pixbuf-demo.c @@ -65,7 +65,11 @@ load_pixbufs (void) { int i; - background = gdk_pixbuf_new_from_file (BACKGROUND_NAME); + /* We pass NULL for the error return location, we don't care + * about the error message. + */ + + background = gdk_pixbuf_new_from_file (BACKGROUND_NAME, NULL); if (!background) return FALSE; @@ -73,7 +77,7 @@ load_pixbufs (void) back_height = gdk_pixbuf_get_height (background); for (i = 0; i < N_IMAGES; i++) { - images[i] = gdk_pixbuf_new_from_file (image_names[i]); + images[i] = gdk_pixbuf_new_from_file (image_names[i], NULL); if (!images[i]) return FALSE; } diff --git a/demos/testanimation.c b/demos/testanimation.c index 35f981b2eb..fcfbde739f 100644 --- a/demos/testanimation.c +++ b/demos/testanimation.c @@ -408,8 +408,18 @@ main (int argc, char **argv) return 0; } else { for (i = 1; i < argc; i++) { - animation = gdk_pixbuf_animation_new_from_file (argv[i]); - + GError *error; + + error = NULL; + animation = gdk_pixbuf_animation_new_from_file (argv[i], + &error); + + if (animation == NULL) { + g_warning ("Failed to load animation: %s", + error->message); + g_error_free (error); + } + if (animation) { gint i = 0; GList *listptr; diff --git a/demos/testpixbuf-scale.c b/demos/testpixbuf-scale.c index 932d13cf4b..68b57a5bca 100644 --- a/demos/testpixbuf-scale.c +++ b/demos/testpixbuf-scale.c @@ -62,7 +62,8 @@ main(int argc, char **argv) GtkWidget *hbox, *label, *hscale; GtkAdjustment *adjustment; GtkRequisition scratch_requisition; - + GError *error; + pixbuf_init (); gtk_init (&argc, &argv); @@ -73,9 +74,12 @@ main(int argc, char **argv) exit (1); } - pixbuf = gdk_pixbuf_new_from_file (argv[1]); + error = NULL; + pixbuf = gdk_pixbuf_new_from_file (argv[1], &error); if (!pixbuf) { - fprintf (stderr, "Cannot load %s\n", argv[1]); + fprintf (stderr, "Cannot load image: %s\n", + error->message); + g_error_free (error); exit(1); } diff --git a/demos/testpixbuf.c b/demos/testpixbuf.c index f118205e21..fac01f6b87 100644 --- a/demos/testpixbuf.c +++ b/demos/testpixbuf.c @@ -428,22 +428,27 @@ static gint update_timeout(gpointer data) { ProgressFileStatus *status = data; - gboolean done, error; + gboolean done; + GError *error; done = FALSE; error = FALSE; if (!feof(status->imagefile)) { gint nbytes; - + nbytes = fread(status->buf, 1, status->readlen, status->imagefile); - error = !gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (status->loader), status->buf, nbytes); - if (error) { - G_BREAKPOINT(); + error = NULL; + if (!gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (status->loader), status->buf, nbytes, &error)) { + g_warning ("Error writing to loader: %s", + error->message); + g_error_free (error); + done = TRUE; } - + + } else { /* Really done */ GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (status->loader); @@ -452,11 +457,6 @@ update_timeout(gpointer data) } - if (error) { - g_warning ("Serious error writing to loader"); - done = TRUE; - } - if (done) { gtk_widget_queue_draw(*status->rgbwin); gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (status->loader)); @@ -556,17 +556,26 @@ main (int argc, char **argv) } /* Test loading from inline data. */ - pixbuf = gdk_pixbuf_new_from_inline (apple_red, FALSE, -1); + pixbuf = gdk_pixbuf_new_from_inline (apple_red, FALSE, -1, NULL); new_testrgb_window (pixbuf, "Red apple from inline data"); - pixbuf = gdk_pixbuf_new_from_inline (gnome_foot, TRUE, sizeof (gnome_foot)); + pixbuf = gdk_pixbuf_new_from_inline (gnome_foot, TRUE, sizeof (gnome_foot), NULL); new_testrgb_window (pixbuf, "Foot from inline data"); found_valid = TRUE; } else { for (i = 1; i < argc; i++) { + GError *error; + + error = NULL; + pixbuf = gdk_pixbuf_new_from_file (argv[i], &error); - pixbuf = gdk_pixbuf_new_from_file (argv[i]); + if (pixbuf == NULL) { + g_warning ("Error loading image: %s", + error->message); + g_error_free (error); + } + #if 0 pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0); #endif |