2002-11-05 22:58:28 +00:00
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
/* GdkPixbuf library - Progressive loader object
1999-10-26 03:42:14 +00:00
*
* Copyright ( C ) 1999 The Free Software Foundation
*
* Authors : Mark Crichton < crichton @ gimp . org >
* Miguel de Icaza < miguel @ gnu . org >
* Federico Mena - Quintero < federico @ gimp . org >
* Jonathan Blandford < jrb @ redhat . com >
*
* This library is free software ; you can redistribute it and / or
2000-07-26 11:33:08 +00:00
* modify it under the terms of the GNU Lesser General Public
1999-10-26 03:42:14 +00:00
* License as published by the Free Software Foundation ; either
* version 2 of the License , or ( at your option ) any later version .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
2000-07-26 11:33:08 +00:00
* Lesser General Public License for more details .
1999-10-26 03:42:14 +00:00
*
2000-07-26 11:33:08 +00:00
* You should have received a copy of the GNU Lesser General Public
1999-10-26 03:42:14 +00:00
* License along with this library ; if not , write to the
* Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
* Boston , MA 02111 - 1307 , USA .
*/
2008-06-22 14:28:52 +00:00
# include "config.h"
2000-07-14 20:25:22 +00:00
# include <string.h>
2000-04-11 07:03:25 +00:00
# include "gdk-pixbuf-private.h"
2002-10-03 22:39:51 +00:00
# include "gdk-pixbuf-animation.h"
2007-03-08 16:21:09 +00:00
# include "gdk-pixbuf-scaled-anim.h"
1999-11-23 20:03:14 +00:00
# include "gdk-pixbuf-io.h"
2002-10-03 22:39:51 +00:00
# include "gdk-pixbuf-loader.h"
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
# include "gdk-pixbuf-marshal.h"
2005-03-14 19:37:00 +00:00
# include "gdk-pixbuf-alias.h"
1999-10-26 03:42:14 +00:00
1999-10-26 23:19:49 +00:00
enum {
2002-11-05 22:58:28 +00:00
SIZE_PREPARED ,
AREA_PREPARED ,
AREA_UPDATED ,
CLOSED ,
LAST_SIGNAL
1999-10-26 23:19:49 +00:00
} ;
1999-10-26 03:42:14 +00:00
2006-04-04 13:35:59 +00:00
static void gdk_pixbuf_loader_finalize ( GObject * loader ) ;
1999-10-26 03:42:14 +00:00
2000-06-24 22:32:05 +00:00
static guint pixbuf_loader_signals [ LAST_SIGNAL ] = { 0 } ;
1999-10-27 17:31:07 +00:00
1999-10-26 03:42:14 +00:00
/* Internal data */
1999-11-02 16:10:25 +00:00
2005-10-03 15:07:35 +00:00
# define LOADER_HEADER_SIZE 1024
1999-11-02 16:10:25 +00:00
2000-06-24 22:32:05 +00:00
typedef struct
{
2002-11-05 22:58:28 +00:00
GdkPixbufAnimation * animation ;
gboolean closed ;
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
gboolean holds_threadlock ;
2002-11-05 22:58:28 +00:00
guchar header_buf [ LOADER_HEADER_SIZE ] ;
gint header_buf_offset ;
GdkPixbufModule * image_module ;
gpointer context ;
gint width ;
gint height ;
gboolean size_fixed ;
gboolean needs_scale ;
1999-10-27 17:31:07 +00:00
} GdkPixbufLoaderPrivate ;
1999-10-26 23:19:49 +00:00
2006-05-14 04:25:34 +00:00
G_DEFINE_TYPE ( GdkPixbufLoader , gdk_pixbuf_loader , G_TYPE_OBJECT )
1999-10-26 03:42:14 +00:00
static void
1999-10-27 17:31:07 +00:00
gdk_pixbuf_loader_class_init ( GdkPixbufLoaderClass * class )
1999-10-26 03:42:14 +00:00
{
2002-11-05 22:58:28 +00:00
GObjectClass * object_class ;
object_class = ( GObjectClass * ) class ;
object_class - > finalize = gdk_pixbuf_loader_finalize ;
2003-12-11 00:57:20 +00:00
/**
* GdkPixbufLoader : : size - prepared :
* @ loader : the object which received the signal .
* @ width : the original width of the image
* @ height : the original height of the image
*
* This signal is emitted when the pixbuf loader has been fed the
* initial amount of data that is required to figure out the size
* of the image that it will create . Applications can call
* gdk_pixbuf_loader_set_size ( ) in response to this signal to set
* the desired size to which the image should be scaled .
*/
2002-11-05 22:58:28 +00:00
pixbuf_loader_signals [ SIZE_PREPARED ] =
2008-08-11 18:40:41 +00:00
g_signal_new ( " size-prepared " ,
2002-11-05 22:58:28 +00:00
G_TYPE_FROM_CLASS ( object_class ) ,
G_SIGNAL_RUN_LAST ,
G_STRUCT_OFFSET ( GdkPixbufLoaderClass , size_prepared ) ,
NULL , NULL ,
2004-08-25 16:21:15 +00:00
_gdk_pixbuf_marshal_VOID__INT_INT ,
2002-11-05 22:58:28 +00:00
G_TYPE_NONE , 2 ,
G_TYPE_INT ,
G_TYPE_INT ) ;
2003-12-11 00:57:20 +00:00
/**
* GdkPixbufLoader : : area - prepared :
* @ loader : the object which received the signal .
*
* This signal is emitted when the pixbuf loader has allocated the
* pixbuf in the desired size . After this signal is emitted ,
* applications can call gdk_pixbuf_loader_get_pixbuf ( ) to fetch
* the partially - loaded pixbuf .
*/
2002-11-05 22:58:28 +00:00
pixbuf_loader_signals [ AREA_PREPARED ] =
2008-08-11 18:40:41 +00:00
g_signal_new ( " area-prepared " ,
2002-11-05 22:58:28 +00:00
G_TYPE_FROM_CLASS ( object_class ) ,
G_SIGNAL_RUN_LAST ,
G_STRUCT_OFFSET ( GdkPixbufLoaderClass , area_prepared ) ,
NULL , NULL ,
2004-08-25 16:21:15 +00:00
_gdk_pixbuf_marshal_VOID__VOID ,
2002-11-05 22:58:28 +00:00
G_TYPE_NONE , 0 ) ;
2003-12-11 00:57:20 +00:00
/**
* GdkPixbufLoader : : area - updated :
* @ loader : the object which received the signal .
* @ x : X offset of upper - left corner of the updated area .
* @ y : Y offset of upper - left corner of the updated area .
* @ width : Width of updated area .
* @ height : Height of updated area .
*
* This signal is emitted when a significant area of the image being
* loaded has been updated . Normally it means that a complete
* scanline has been read in , but it could be a different area as
* well . Applications can use this signal to know when to repaint
* areas of an image that is being loaded .
*/
2002-11-05 22:58:28 +00:00
pixbuf_loader_signals [ AREA_UPDATED ] =
2008-08-11 18:40:41 +00:00
g_signal_new ( " area-updated " ,
2002-11-05 22:58:28 +00:00
G_TYPE_FROM_CLASS ( object_class ) ,
G_SIGNAL_RUN_LAST ,
G_STRUCT_OFFSET ( GdkPixbufLoaderClass , area_updated ) ,
NULL , NULL ,
2004-08-25 16:21:15 +00:00
_gdk_pixbuf_marshal_VOID__INT_INT_INT_INT ,
2002-11-05 22:58:28 +00:00
G_TYPE_NONE , 4 ,
G_TYPE_INT ,
G_TYPE_INT ,
G_TYPE_INT ,
G_TYPE_INT ) ;
2003-12-11 00:57:20 +00:00
/**
* GdkPixbufLoader : : closed :
* @ loader : the object which received the signal .
*
* This signal is emitted when gdk_pixbuf_loader_close ( ) is called .
* It can be used by different parts of an application to receive
* notification when an image loader is closed by the code that
* drives it .
*/
2002-11-05 22:58:28 +00:00
pixbuf_loader_signals [ CLOSED ] =
g_signal_new ( " closed " ,
G_TYPE_FROM_CLASS ( object_class ) ,
G_SIGNAL_RUN_LAST ,
G_STRUCT_OFFSET ( GdkPixbufLoaderClass , closed ) ,
NULL , NULL ,
2004-08-25 16:21:15 +00:00
_gdk_pixbuf_marshal_VOID__VOID ,
2002-11-05 22:58:28 +00:00
G_TYPE_NONE , 0 ) ;
1999-10-26 03:42:14 +00:00
}
static void
gdk_pixbuf_loader_init ( GdkPixbufLoader * loader )
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
priv = g_new0 ( GdkPixbufLoaderPrivate , 1 ) ;
2004-01-07 00:26:58 +00:00
priv - > width = - 1 ;
priv - > height = - 1 ;
2002-11-05 22:58:28 +00:00
loader - > priv = priv ;
1999-10-26 03:42:14 +00:00
}
static void
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
gdk_pixbuf_loader_finalize ( GObject * object )
1999-10-26 03:42:14 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoader * loader ;
GdkPixbufLoaderPrivate * priv = NULL ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
loader = GDK_PIXBUF_LOADER ( object ) ;
priv = loader - > priv ;
Port to GObject, can go back in gdk-pixbuf after setting up a
2000-12-16 Havoc Pennington <hp@pobox.com>
* gtk/gdk-pixbuf-loader.h, gtk/gdk-pixbuf-loader.c:
Port to GObject, can go back in gdk-pixbuf after setting up
a gdk-pixbuf-marshal.h header over there.
* gtk/gtktreeview.c: s/SEPERATOR/SEPARATOR/g;
(gtk_tree_view_class_init): specify GTK_TYPE_ADJUSTMENT for signal
args
(gtk_tree_view_init): don't unset GTK_NO_WINDOW, it shouldn't be
set
(gtk_tree_view_realize_buttons): don't gtk_widget_show() buttons
here, do it when we create the buttons later
(gtk_tree_view_realize_buttons): add some g_return_if_fail
(gtk_tree_view_map): paranoia checks that column->button is shown
and unmapped
(gtk_tree_view_size_request): only request visible children.
Move header size calculation in here, for cleanliness, and
to maintain invariants for child widgets if we eventually
let users set different children inside the buttons
(gtk_tree_view_map_buttons): factor out code to map buttons,
since it was being called several times
(gtk_tree_view_size_allocate_buttons): move_resize the drag
windows instead of just moving them; their height may change
if we allow random widgets in there, or the theme changes.
(gtk_tree_view_size_allocate): move button size allocation
above emitting the scroll signals, to ensure a sane state when we
hit user code
(gtk_tree_view_button_release): remove queue_resize after
tree_view_set_size(), set_size() will handle any resize queuing
that's needed
(gtk_tree_view_focus_in): just queue a draw, don't fool with
draw_focus goo
(gtk_tree_view_focus): use gtk_get_current_event() and
gdk_event_get_state()
(gtk_tree_view_deleted): don't queue_resize() after calling set_size()
(gtk_tree_view_build_tree): fix a "if (foo); {}" bug - i.e. remove
semicolon
(gtk_tree_view_create_button): show the button here
(gtk_tree_view_button_clicked): actually emit the clicked signal
on the column
(_gtk_tree_view_set_size): return right away if the size is
unchanged, as a cheesy optimization
(gtk_tree_view_setup_model): rename set_model_realized to
setup_model to match the flag that indicates whether we've
called it
(gtk_tree_view_get_hadjustment): create adjustment if it doesn't
exist, because set_scroll_adjustment does that and it shouldn't
matter what order you call these in
(gtk_tree_view_get_vadjustment): ditto
(gtk_tree_view_set_headers_visible): canonicalize the bool,
for paranoia
(gtk_tree_view_set_headers_visible): call
gtk_tree_view_map_buttons() instead of using cut-and-paste code
(gtk_tree_view_append_column): clarify whether the return value
is the count of columns before or after, and do the increment
separately from the return statement so you can tell from the code.
(gtk_tree_view_remove_column): ditto
(gtk_tree_view_insert_column): ditto
(gtk_tree_view_get_column): remove g_return_if_fail for columns
outside the existing range, the docs say that outside-range
columns are allowed, so we handle them as documented. (Presumably
this allows a nice loop with column != NULL as test.)
(gtk_tree_view_move_to): document what 0.0, 0.5, 1.0 alignments
mean (left/right/center etc.).
(gtk_tree_view_collapse_all): only queue a draw if we're mapped
(gtk_tree_view_expand_row): add docs
(gtk_tree_view_collapse_row): add docs
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_clicked): new
function to emit the clicked signal on a column
* gdk/gdkevents.c (gdk_event_get_state): new function, to get the
state of an event
(gdk_event_get_time): don't treat GDK_SCROLL
as a button event, remove default case from switch so gcc
will whine if we don't explicitly handle all event types
* gtk/gtktreeselection.h: added some FIXME
* gtk/gtktreeprivate.h (struct _GtkTreeViewPrivate): rename
"columns" to "n_columns" and "column" to "columns" for clarity
2000-12-17 23:50:00 +00:00
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
if ( ! priv - > closed ) {
2002-11-05 22:58:28 +00:00
g_warning ( " GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference. " ) ;
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
if ( priv - > holds_threadlock ) {
_gdk_pixbuf_unlock ( priv - > image_module ) ;
}
}
2002-11-05 22:58:28 +00:00
if ( priv - > animation )
g_object_unref ( priv - > animation ) ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
g_free ( priv ) ;
2000-06-24 22:32:05 +00:00
2006-04-04 13:35:59 +00:00
G_OBJECT_CLASS ( gdk_pixbuf_loader_parent_class ) - > finalize ( object ) ;
1999-10-26 03:42:14 +00:00
}
2002-07-06 23:10:46 +00:00
/**
* gdk_pixbuf_loader_set_size :
* @ loader : A pixbuf loader .
* @ width : The desired width of the image being loaded .
* @ height : The desired height of the image being loaded .
*
* Causes the image to be scaled while it is loaded . The desired
* image size can be determined relative to the original size of
* the image by calling gdk_pixbuf_loader_set_size ( ) from a
2008-08-11 18:40:41 +00:00
* signal handler for the : : size - prepared signal .
2002-07-06 23:10:46 +00:00
*
* Attempts to set the desired image size are ignored after the
2008-08-11 18:40:41 +00:00
* emission of the : : size - prepared signal .
2002-11-28 00:33:17 +00:00
*
* Since : 2.2
2002-07-06 23:10:46 +00:00
*/
void
gdk_pixbuf_loader_set_size ( GdkPixbufLoader * loader ,
gint width ,
gint height )
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv = GDK_PIXBUF_LOADER ( loader ) - > priv ;
2004-01-07 00:26:58 +00:00
g_return_if_fail ( width > = 0 & & height > = 0 ) ;
2002-11-05 22:58:28 +00:00
if ( ! priv - > size_fixed )
{
priv - > width = width ;
priv - > height = height ;
}
2002-07-06 23:10:46 +00:00
}
static void
gdk_pixbuf_loader_size_func ( gint * width , gint * height , gpointer loader )
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv = GDK_PIXBUF_LOADER ( loader ) - > priv ;
2002-07-06 23:10:46 +00:00
2002-11-05 22:58:28 +00:00
/* allow calling gdk_pixbuf_loader_set_size() before the signal */
2004-01-07 00:26:58 +00:00
if ( priv - > width = = - 1 & & priv - > height = = - 1 )
2002-11-05 22:58:28 +00:00
{
priv - > width = * width ;
priv - > height = * height ;
}
2002-07-06 23:10:46 +00:00
2002-11-05 22:58:28 +00:00
g_signal_emit ( loader , pixbuf_loader_signals [ SIZE_PREPARED ] , 0 , * width , * height ) ;
priv - > size_fixed = TRUE ;
2002-07-06 23:10:46 +00:00
2002-11-05 22:58:28 +00:00
* width = priv - > width ;
* height = priv - > height ;
2002-07-06 23:10:46 +00:00
}
1999-10-26 23:19:49 +00:00
static void
2001-05-07 15:58:47 +00:00
gdk_pixbuf_loader_prepare ( GdkPixbuf * pixbuf ,
GdkPixbufAnimation * anim ,
gpointer loader )
1999-10-26 23:19:49 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv = GDK_PIXBUF_LOADER ( loader ) - > priv ;
g_return_if_fail ( pixbuf ! = NULL ) ;
if ( ! priv - > size_fixed )
{
/* Defend against lazy loaders which don't call size_func */
gint width = gdk_pixbuf_get_width ( pixbuf ) ;
gint height = gdk_pixbuf_get_height ( pixbuf ) ;
gdk_pixbuf_loader_size_func ( & width , & height , loader ) ;
}
priv - > needs_scale = FALSE ;
if ( priv - > width > 0 & & priv - > height > 0 & &
( priv - > width ! = gdk_pixbuf_get_width ( pixbuf ) | |
priv - > height ! = gdk_pixbuf_get_height ( pixbuf ) ) )
priv - > needs_scale = TRUE ;
if ( anim )
g_object_ref ( anim ) ;
else
anim = gdk_pixbuf_non_anim_new ( pixbuf ) ;
2007-03-08 16:21:09 +00:00
if ( priv - > needs_scale ) {
2008-01-14 11:30:34 +00:00
priv - > animation = GDK_PIXBUF_ANIMATION ( _gdk_pixbuf_scaled_anim_new ( anim ,
2007-03-08 16:21:09 +00:00
( double ) priv - > width / gdk_pixbuf_get_width ( pixbuf ) ,
( double ) priv - > height / gdk_pixbuf_get_height ( pixbuf ) ,
2008-01-14 11:30:34 +00:00
1.0 ) ) ;
2007-03-08 16:21:09 +00:00
g_object_unref ( anim ) ;
}
else
priv - > animation = anim ;
2002-11-05 22:58:28 +00:00
if ( ! priv - > needs_scale )
g_signal_emit ( loader , pixbuf_loader_signals [ AREA_PREPARED ] , 0 ) ;
1999-10-26 23:19:49 +00:00
}
1999-11-04 18:18:07 +00:00
static void
2000-06-24 22:32:05 +00:00
gdk_pixbuf_loader_update ( GdkPixbuf * pixbuf ,
2001-05-07 15:58:47 +00:00
gint x ,
gint y ,
gint width ,
gint height ,
2000-06-24 22:32:05 +00:00
gpointer loader )
1999-11-04 18:18:07 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv = GDK_PIXBUF_LOADER ( loader ) - > priv ;
if ( ! priv - > needs_scale )
g_signal_emit ( loader ,
pixbuf_loader_signals [ AREA_UPDATED ] ,
0 ,
x , y ,
/* sanity check in here. Defend against an errant loader */
MIN ( width , gdk_pixbuf_animation_get_width ( priv - > animation ) ) ,
MIN ( height , gdk_pixbuf_animation_get_height ( priv - > animation ) ) ) ;
2000-01-07 18:29:13 +00:00
}
2006-07-17 02:37:29 +00:00
/* Defense against broken loaders; DO NOT take this as a GError example! */
static void
gdk_pixbuf_loader_ensure_error ( GdkPixbufLoader * loader ,
GError * * error )
{
GdkPixbufLoaderPrivate * priv = loader - > priv ;
if ( error = = NULL | | * error ! = NULL )
return ;
g_warning ( " Bug! loader '%s' didn't set an error on failure " ,
priv - > image_module - > module_name ) ;
g_set_error ( error ,
GDK_PIXBUF_ERROR ,
GDK_PIXBUF_ERROR_FAILED ,
_ ( " Internal error: Image loader module '%s' failed to "
" complete an operation, but didn't give a reason for "
" the failure " ) ,
priv - > image_module - > module_name ) ;
}
2000-06-24 22:32:05 +00:00
static gint
2000-10-18 18:42:54 +00:00
gdk_pixbuf_loader_load_module ( GdkPixbufLoader * loader ,
const char * image_type ,
GError * * error )
1999-11-02 16:10:25 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv = loader - > priv ;
if ( image_type )
{
priv - > image_module = _gdk_pixbuf_get_named_module ( image_type ,
error ) ;
}
else
{
priv - > image_module = _gdk_pixbuf_get_module ( priv - > header_buf ,
priv - > header_buf_offset ,
NULL ,
error ) ;
}
if ( priv - > image_module = = NULL )
return 0 ;
if ( priv - > image_module - > module = = NULL )
if ( ! _gdk_pixbuf_load_module ( priv - > image_module , error ) )
return 0 ;
if ( priv - > image_module - > module = = NULL )
return 0 ;
if ( ( priv - > image_module - > begin_load = = NULL ) | |
( priv - > image_module - > stop_load = = NULL ) | |
( priv - > image_module - > load_increment = = NULL ) )
{
g_set_error ( error ,
GDK_PIXBUF_ERROR ,
GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION ,
_ ( " Incremental loading of image type '%s' is not supported " ) ,
priv - > image_module - > module_name ) ;
return 0 ;
}
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
if ( ! priv - > holds_threadlock ) {
2004-11-16 02:51:19 +00:00
priv - > holds_threadlock = _gdk_pixbuf_lock ( priv - > image_module ) ;
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
}
2002-11-05 22:58:28 +00:00
priv - > context = priv - > image_module - > begin_load ( gdk_pixbuf_loader_size_func ,
gdk_pixbuf_loader_prepare ,
gdk_pixbuf_loader_update ,
loader ,
error ) ;
if ( priv - > context = = NULL )
{
2006-07-17 02:37:29 +00:00
gdk_pixbuf_loader_ensure_error ( loader , error ) ;
2002-11-05 22:58:28 +00:00
return 0 ;
}
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
if ( priv - > header_buf_offset
& & priv - > image_module - > load_increment ( priv - > context , priv - > header_buf , priv - > header_buf_offset , error ) )
return priv - > header_buf_offset ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
return 0 ;
1999-11-02 16:10:25 +00:00
}
static int
2000-06-24 22:32:05 +00:00
gdk_pixbuf_loader_eat_header_write ( GdkPixbufLoader * loader ,
const guchar * buf ,
2000-10-18 18:42:54 +00:00
gsize count ,
GError * * error )
1999-11-02 16:10:25 +00:00
{
2002-11-05 22:58:28 +00:00
gint n_bytes ;
GdkPixbufLoaderPrivate * priv = loader - > priv ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
n_bytes = MIN ( LOADER_HEADER_SIZE - priv - > header_buf_offset , count ) ;
memcpy ( priv - > header_buf + priv - > header_buf_offset , buf , n_bytes ) ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
priv - > header_buf_offset + = n_bytes ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
if ( priv - > header_buf_offset > = LOADER_HEADER_SIZE )
{
if ( gdk_pixbuf_loader_load_module ( loader , NULL , error ) = = 0 )
return 0 ;
}
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
return n_bytes ;
1999-11-02 16:10:25 +00:00
}
1999-10-26 03:42:14 +00:00
/**
* gdk_pixbuf_loader_write :
1999-10-27 17:31:07 +00:00
* @ loader : A pixbuf loader .
1999-11-10 22:48:46 +00:00
* @ buf : Pointer to image data .
* @ count : Length of the @ buf buffer in bytes .
2000-10-18 18:42:54 +00:00
* @ error : return location for errors
1999-10-26 20:43:39 +00:00
*
2000-10-18 18:42:54 +00:00
* This will cause a pixbuf loader to parse the next @ count bytes of
2001-12-12 22:11:37 +00:00
* an image . It will return % TRUE if the data was loaded successfully ,
* and % FALSE if an error occurred . In the latter case , the loader
* will be closed , and will not accept further writes . If % FALSE is
2000-10-18 18:42:54 +00:00
* returned , @ error will be set to an error from the # GDK_PIXBUF_ERROR
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
* or # G_FILE_ERROR domains .
1999-10-26 20:43:39 +00:00
*
2001-12-12 22:11:37 +00:00
* Return value : % TRUE if the write was successful , or % FALSE if the loader
1999-11-10 22:48:46 +00:00
* cannot parse the buffer .
1999-10-26 03:42:14 +00:00
* */
gboolean
2000-06-24 22:32:05 +00:00
gdk_pixbuf_loader_write ( GdkPixbufLoader * loader ,
const guchar * buf ,
2000-10-18 18:42:54 +00:00
gsize count ,
GError * * error )
1999-10-26 03:42:14 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
g_return_val_if_fail ( loader ! = NULL , FALSE ) ;
g_return_val_if_fail ( GDK_IS_PIXBUF_LOADER ( loader ) , FALSE ) ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
g_return_val_if_fail ( buf ! = NULL , FALSE ) ;
2003-04-24 18:51:07 +00:00
g_return_val_if_fail ( error = = NULL | | * error = = NULL , FALSE ) ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
priv = loader - > priv ;
2001-06-01 23:05:46 +00:00
2002-11-05 22:58:28 +00:00
/* we expect it's not to be closed */
g_return_val_if_fail ( priv - > closed = = FALSE , FALSE ) ;
2000-06-24 22:32:05 +00:00
2005-10-12 13:49:26 +00:00
if ( count > 0 & & priv - > image_module = = NULL )
2002-11-05 22:58:28 +00:00
{
gint eaten ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
eaten = gdk_pixbuf_loader_eat_header_write ( loader , buf , count , error ) ;
if ( eaten < = 0 )
2006-12-10 04:25:46 +00:00
goto fail ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
count - = eaten ;
buf + = eaten ;
}
if ( count > 0 & & priv - > image_module - > load_increment )
{
2006-12-10 04:25:46 +00:00
if ( ! priv - > image_module - > load_increment ( priv - > context , buf , count ,
error ) )
goto fail ;
2002-11-05 22:58:28 +00:00
}
2000-10-18 18:42:54 +00:00
2002-11-05 22:58:28 +00:00
return TRUE ;
2006-12-10 04:25:46 +00:00
fail :
gdk_pixbuf_loader_ensure_error ( loader , error ) ;
2007-01-17 04:24:00 +00:00
gdk_pixbuf_loader_close ( loader , NULL ) ;
2006-12-22 03:14:31 +00:00
2006-12-10 04:25:46 +00:00
return FALSE ;
1999-10-26 03:42:14 +00:00
}
2000-07-28 00:09:36 +00:00
/**
* gdk_pixbuf_loader_new :
*
* Creates a new pixbuf loader object .
*
* Return value : A newly - created pixbuf loader .
* */
GdkPixbufLoader *
gdk_pixbuf_loader_new ( void )
{
2002-11-05 22:58:28 +00:00
return g_object_new ( GDK_TYPE_PIXBUF_LOADER , NULL ) ;
2000-07-28 00:09:36 +00:00
}
/**
* gdk_pixbuf_loader_new_with_type :
2001-02-18 04:08:30 +00:00
* @ image_type : name of the image format to be loaded with the image
* @ error : return location for an allocated # GError , or % NULL to ignore errors
2000-07-28 00:09:36 +00:00
*
2001-02-18 04:08:30 +00:00
* Creates a new pixbuf loader object that always attempts to parse
* image data as if it were an image of type @ image_type , instead of
* identifying the type automatically . Useful if you want an error if
* the image isn ' t the expected type , for loading image formats
* that can ' t be reliably identified by looking at the data , or if
* the user manually forces a specific type .
2000-07-28 00:09:36 +00:00
*
2006-03-22 20:33:50 +00:00
* The list of supported image formats depends on what image loaders
* are installed , but typically " png " , " jpeg " , " gif " , " tiff " and
* " xpm " are among the supported formats . To obtain the full list of
* supported image formats , call gdk_pixbuf_format_get_name ( ) on each
* of the # GdkPixbufFormat structs returned by gdk_pixbuf_get_formats ( ) .
*
2000-07-28 00:09:36 +00:00
* Return value : A newly - created pixbuf loader .
* */
GdkPixbufLoader *
2000-10-18 18:42:54 +00:00
gdk_pixbuf_loader_new_with_type ( const char * image_type ,
GError * * error )
2000-07-28 00:09:36 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoader * retval ;
GError * tmp ;
2003-04-24 18:51:07 +00:00
g_return_val_if_fail ( error = = NULL | | * error = = NULL , NULL ) ;
2000-10-18 18:42:54 +00:00
2002-11-05 22:58:28 +00:00
retval = g_object_new ( GDK_TYPE_PIXBUF_LOADER , NULL ) ;
2000-07-28 00:09:36 +00:00
2002-11-05 22:58:28 +00:00
tmp = NULL ;
2003-04-24 18:51:07 +00:00
gdk_pixbuf_loader_load_module ( retval , image_type , & tmp ) ;
2002-11-05 22:58:28 +00:00
if ( tmp ! = NULL )
{
g_propagate_error ( error , tmp ) ;
2005-01-23 04:35:09 +00:00
gdk_pixbuf_loader_close ( retval , NULL ) ;
2002-11-05 22:58:28 +00:00
g_object_unref ( retval ) ;
return NULL ;
}
2000-07-28 00:09:36 +00:00
2002-11-05 22:58:28 +00:00
return retval ;
2000-07-28 00:09:36 +00:00
}
2003-06-22 19:08:12 +00:00
/**
* gdk_pixbuf_loader_new_with_mime_type :
* @ mime_type : the mime type to be loaded
* @ error : return location for an allocated # GError , or % NULL to ignore errors
*
* Creates a new pixbuf loader object that always attempts to parse
* image data as if it were an image of mime type @ mime_type , instead of
* identifying the type automatically . Useful if you want an error if
* the image isn ' t the expected mime type , for loading image formats
* that can ' t be reliably identified by looking at the data , or if
* the user manually forces a specific mime type .
*
2006-03-22 20:33:50 +00:00
* The list of supported mime types depends on what image loaders
* are installed , but typically " image/png " , " image/jpeg " , " image/gif " ,
* " image/tiff " and " image/x-xpixmap " are among the supported mime types .
* To obtain the full list of supported mime types , call
* gdk_pixbuf_format_get_mime_types ( ) on each of the # GdkPixbufFormat
* structs returned by gdk_pixbuf_get_formats ( ) .
*
2003-06-22 19:08:12 +00:00
* Return value : A newly - created pixbuf loader .
* Since : 2.4
* */
GdkPixbufLoader *
gdk_pixbuf_loader_new_with_mime_type ( const char * mime_type ,
GError * * error )
{
const char * image_type = NULL ;
char * * mimes ;
GdkPixbufLoader * retval ;
GError * tmp ;
GSList * formats ;
GdkPixbufFormat * info ;
int i , j , length ;
formats = gdk_pixbuf_get_formats ( ) ;
length = g_slist_length ( formats ) ;
for ( i = 0 ; i < length & & image_type = = NULL ; i + + ) {
info = ( GdkPixbufFormat * ) g_slist_nth_data ( formats , i ) ;
mimes = info - > mime_types ;
for ( j = 0 ; mimes [ j ] ! = NULL ; j + + )
2004-08-24 20:25:15 +00:00
if ( g_ascii_strcasecmp ( mimes [ j ] , mime_type ) = = 0 ) {
2003-06-22 19:08:12 +00:00
image_type = info - > name ;
break ;
}
}
g_slist_free ( formats ) ;
retval = g_object_new ( GDK_TYPE_PIXBUF_LOADER , NULL ) ;
tmp = NULL ;
2005-01-23 04:35:09 +00:00
gdk_pixbuf_loader_load_module ( retval , image_type , & tmp ) ;
2003-06-22 19:08:12 +00:00
if ( tmp ! = NULL )
{
g_propagate_error ( error , tmp ) ;
2005-01-23 04:35:09 +00:00
gdk_pixbuf_loader_close ( retval , NULL ) ;
2003-06-22 19:08:12 +00:00
g_object_unref ( retval ) ;
return NULL ;
}
return retval ;
}
1999-10-26 03:42:14 +00:00
/**
* gdk_pixbuf_loader_get_pixbuf :
1999-10-27 17:31:07 +00:00
* @ loader : A pixbuf loader .
1999-10-26 20:43:39 +00:00
*
2001-12-12 22:11:37 +00:00
* Queries the # GdkPixbuf that a pixbuf loader is currently creating .
2001-11-03 18:49:43 +00:00
* In general it only makes sense to call this function after the
2008-08-11 18:40:41 +00:00
* " area-prepared " signal has been emitted by the loader ; this means
2000-10-09 17:22:20 +00:00
* that enough data has been read to know the size of the image that
* will be allocated . If the loader has not received enough data via
2001-05-07 15:58:47 +00:00
* gdk_pixbuf_loader_write ( ) , then this function returns % NULL . The
2000-10-09 17:22:20 +00:00
* returned pixbuf will be the same in all future calls to the loader ,
2001-11-03 18:49:43 +00:00
* so simply calling g_object_ref ( ) should be sufficient to continue
2000-10-09 17:22:20 +00:00
* using it . Additionally , if the loader is an animation , it will
2001-05-07 15:58:47 +00:00
* return the " static image " of the animation
* ( see gdk_pixbuf_animation_get_static_image ( ) ) .
2000-10-09 17:22:20 +00:00
*
2001-05-07 15:58:47 +00:00
* Return value : The # GdkPixbuf that the loader is creating , or % NULL if not
1999-11-10 22:48:46 +00:00
* enough data has been read to determine how to create the image buffer .
1999-10-26 03:42:14 +00:00
* */
GdkPixbuf *
gdk_pixbuf_loader_get_pixbuf ( GdkPixbufLoader * loader )
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
g_return_val_if_fail ( loader ! = NULL , NULL ) ;
g_return_val_if_fail ( GDK_IS_PIXBUF_LOADER ( loader ) , NULL ) ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
priv = loader - > priv ;
2000-10-09 17:22:20 +00:00
2002-11-05 22:58:28 +00:00
if ( priv - > animation )
return gdk_pixbuf_animation_get_static_image ( priv - > animation ) ;
else
return NULL ;
1999-10-26 03:42:14 +00:00
}
1999-12-17 21:42:47 +00:00
/**
* gdk_pixbuf_loader_get_animation :
* @ loader : A pixbuf loader
2000-01-07 18:29:13 +00:00
*
2001-12-12 22:11:37 +00:00
* Queries the # GdkPixbufAnimation that a pixbuf loader is currently creating .
2008-08-11 18:40:41 +00:00
* In general it only makes sense to call this function after the " area-prepared "
2001-05-07 15:58:47 +00:00
* signal has been emitted by the loader . If the loader doesn ' t have enough
2008-08-11 18:40:41 +00:00
* bytes yet ( hasn ' t emitted the " area-prepared " signal ) this function will
2001-12-12 22:11:37 +00:00
* return % NULL .
2000-01-07 18:29:13 +00:00
*
2001-12-12 22:11:37 +00:00
* Return value : The # GdkPixbufAnimation that the loader is loading , or % NULL if
1999-12-17 21:42:47 +00:00
not enough data has been read to determine the information .
2000-06-24 22:32:05 +00:00
* */
1999-12-17 21:42:47 +00:00
GdkPixbufAnimation *
gdk_pixbuf_loader_get_animation ( GdkPixbufLoader * loader )
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
g_return_val_if_fail ( loader ! = NULL , NULL ) ;
g_return_val_if_fail ( GDK_IS_PIXBUF_LOADER ( loader ) , NULL ) ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
priv = loader - > priv ;
2000-06-24 22:32:05 +00:00
2002-11-05 22:58:28 +00:00
return priv - > animation ;
1999-12-17 21:42:47 +00:00
}
1999-10-26 03:42:14 +00:00
/**
* gdk_pixbuf_loader_close :
1999-10-27 17:31:07 +00:00
* @ loader : A pixbuf loader .
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
* @ error : return location for a # GError , or % NULL to ignore errors
*
* Informs a pixbuf loader that no further writes with
* gdk_pixbuf_loader_write ( ) will occur , so that it can free its
* internal loading structures . Also , tries to parse any data that
* hasn ' t yet been parsed ; if the remaining data is partial or
2001-12-12 22:11:37 +00:00
* corrupt , an error will be returned . If % FALSE is returned , @ error
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
* will be set to an error from the # GDK_PIXBUF_ERROR or # G_FILE_ERROR
* domains . If you ' re just cancelling a load rather than expecting it
* to be finished , passing % NULL for @ error to ignore it is
* reasonable .
1999-10-26 03:42:14 +00:00
*
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
* Returns : % TRUE if all image data written so far was successfully
passed out via the update_area signal
1999-10-26 03:42:14 +00:00
* */
Add built marshaller files to support GdkPixbufLoader signals
2001-01-22 Havoc Pennington <hp@redhat.com>
* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
* gdk-pixbuf.h: include gdk-pixbuf-loader.h
* gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.
* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
* io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.
* gdk-pixbuf-io.h: Add error reporting to stop_load function
* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.
* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
* gdk-pixbuf.h: nuke gdk_pixbuf_init()
* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here
* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here
2001-01-22 Havoc Pennington <hp@redhat.com>
* demos/testanimation.c: fix to reflect gdk-pixbuf changes
* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf
* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions
* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus
* gtk/testtext.c (fill_example_buffer): "justification"
* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"
* demos/gtk-demo/textview.c (create_tags): "justification"
* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
2001-01-22 23:09:48 +00:00
gboolean
gdk_pixbuf_loader_close ( GdkPixbufLoader * loader ,
GError * * error )
1999-10-26 03:42:14 +00:00
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv ;
gboolean retval = TRUE ;
g_return_val_if_fail ( loader ! = NULL , TRUE ) ;
g_return_val_if_fail ( GDK_IS_PIXBUF_LOADER ( loader ) , TRUE ) ;
2003-04-24 18:51:07 +00:00
g_return_val_if_fail ( error = = NULL | | * error = = NULL , TRUE ) ;
2002-11-05 22:58:28 +00:00
priv = loader - > priv ;
2006-12-19 20:45:04 +00:00
if ( priv - > closed )
return TRUE ;
2002-11-05 22:58:28 +00:00
2005-10-12 13:49:26 +00:00
/* We have less the LOADER_HEADER_SIZE bytes in the image.
* Flush it , and keep going .
*/
2002-11-05 22:58:28 +00:00
if ( priv - > image_module = = NULL )
{
GError * tmp = NULL ;
gdk_pixbuf_loader_load_module ( loader , NULL , & tmp ) ;
if ( tmp ! = NULL )
{
g_propagate_error ( error , tmp ) ;
retval = FALSE ;
}
}
if ( priv - > image_module & & priv - > image_module - > stop_load & & priv - > context )
{
2007-02-06 13:56:06 +00:00
GError * tmp = NULL ;
if ( ! priv - > image_module - > stop_load ( priv - > context , & tmp ) | | tmp )
2006-07-17 02:37:29 +00:00
{
2007-07-05 20:16:59 +00:00
/* don't call gdk_pixbuf_loader_ensure_error()
* here , since we might not get an error in the
* gdk_pixbuf_get_file_info ( ) case
*/
if ( tmp )
g_propagate_error ( error , tmp ) ;
2006-07-17 02:37:29 +00:00
retval = FALSE ;
}
2002-11-05 22:58:28 +00:00
}
priv - > closed = TRUE ;
2004-11-16 02:51:19 +00:00
if ( priv - > image_module & & priv - > holds_threadlock ) {
Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters):
2004-11-12 Matthias Clasen <mclasen@redhat.com>
Changes to make gdk-pixbuf threadsafe (#157310, #157306,
Colin Walters):
* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add
GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
is threadsafe.
* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module):
Use a lock to make initialization of global data structures
threadsafe.
* gdk-pixbuf-private.h:
* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock):
Auxiliary functions which use another lock to protect
threadunsafe image loaders.
* gdk-pixbuf-io.c (gdk_pixbuf_real_save):
(save_to_callback_with_tmp_file):
(gdk_pixbuf_real_save_to_callback):
(gdk_pixbuf_new_from_xpm_data):
(_gdk_pixbuf_generic_image_load):
* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file):
* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module):
(gdk_pixbuf_loader_close):
(gdk_pixbuf_loader_finalize):
Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().
* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
* io-xpm.c: Mark as threadsafe.
* io-tiff.c: Remove pointless locking, mark as
threadunsafe.
2004-11-12 05:34:31 +00:00
_gdk_pixbuf_unlock ( priv - > image_module ) ;
priv - > holds_threadlock = FALSE ;
}
2002-11-05 22:58:28 +00:00
if ( priv - > needs_scale )
{
2007-03-08 16:21:09 +00:00
2002-11-05 22:58:28 +00:00
g_signal_emit ( loader , pixbuf_loader_signals [ AREA_PREPARED ] , 0 ) ;
g_signal_emit ( loader , pixbuf_loader_signals [ AREA_UPDATED ] , 0 ,
0 , 0 , priv - > width , priv - > height ) ;
}
g_signal_emit ( loader , pixbuf_loader_signals [ CLOSED ] , 0 ) ;
return retval ;
1999-10-26 03:42:14 +00:00
}
2001-08-30 07:23:32 +00:00
2002-10-03 22:39:51 +00:00
/**
* gdk_pixbuf_loader_get_format :
* @ loader : A pixbuf loader .
*
* Obtains the available information about the format of the
* currently loading image file .
*
* Returns : A # GdkPixbufFormat or % NULL . The return value is owned
* by GdkPixbuf and should not be freed .
2002-11-28 00:33:17 +00:00
*
* Since : 2.2
2002-10-03 22:39:51 +00:00
*/
GdkPixbufFormat *
gdk_pixbuf_loader_get_format ( GdkPixbufLoader * loader )
{
2002-11-05 22:58:28 +00:00
GdkPixbufLoaderPrivate * priv ;
2002-10-03 22:39:51 +00:00
2002-11-05 22:58:28 +00:00
g_return_val_if_fail ( loader ! = NULL , NULL ) ;
g_return_val_if_fail ( GDK_IS_PIXBUF_LOADER ( loader ) , NULL ) ;
2002-10-03 22:39:51 +00:00
2002-11-05 22:58:28 +00:00
priv = loader - > priv ;
2001-08-30 07:23:32 +00:00
2002-11-05 22:58:28 +00:00
if ( priv - > image_module )
return _gdk_pixbuf_get_format ( priv - > image_module ) ;
else
return NULL ;
2002-10-03 22:39:51 +00:00
}
2002-07-06 23:10:46 +00:00
2005-03-14 19:37:00 +00:00
# define __GDK_PIXBUF_LOADER_C__
# include "gdk-pixbuf-aliasdef.c"
2002-07-06 23:10:46 +00:00