2001-09-14 22:04:55 +00:00
|
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
2000-10-05 21:40:37 +00:00
|
|
|
|
/* GdkPixbuf library - XPM image loader
|
1999-10-20 21:20:49 +00:00
|
|
|
|
*
|
1999-06-30 15:28:43 +00:00
|
|
|
|
* Copyright (C) 1999 Mark Crichton
|
1999-10-20 21:20:49 +00:00
|
|
|
|
* Copyright (C) 1999 The Free Software Foundation
|
|
|
|
|
*
|
|
|
|
|
* Authors: Mark Crichton <crichton@gimp.org>
|
|
|
|
|
* Federico Mena-Quintero <federico@gimp.org>
|
1999-06-30 15:28:43 +00:00
|
|
|
|
*
|
|
|
|
|
* 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-06-30 15:28:43 +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-06-30 15:28:43 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-10-20 21:20:49 +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.
|
1999-06-30 15:28:43 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <stdio.h>
|
2000-04-11 07:03:25 +00:00
|
|
|
|
#include <stdlib.h>
|
1999-06-30 15:28:43 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <glib.h>
|
2000-11-12 15:58:18 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
#include <unistd.h> /* for unlink */
|
|
|
|
|
#endif
|
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 <errno.h>
|
2000-04-11 07:03:25 +00:00
|
|
|
|
#include "gdk-pixbuf-private.h"
|
2000-10-09 17:22:20 +00:00
|
|
|
|
#include "gdk-pixbuf-io.h"
|
2004-12-05 12:43:47 +00:00
|
|
|
|
#include <glib/gstdio.h>
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
|
|
|
|
/* I have must have done something to deserve this.
|
|
|
|
|
* XPM is such a crappy format to handle.
|
|
|
|
|
* This code is an ugly hybred from gdkpixmap.c
|
|
|
|
|
* modified to respect transparent colors.
|
|
|
|
|
* It's still a mess, though.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
enum buf_op {
|
1999-10-18 19:29:45 +00:00
|
|
|
|
op_header,
|
|
|
|
|
op_cmap,
|
|
|
|
|
op_body
|
1999-06-30 15:28:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
1999-10-18 19:29:45 +00:00
|
|
|
|
gchar *color_string;
|
2000-06-21 20:47:22 +00:00
|
|
|
|
guint16 red;
|
|
|
|
|
guint16 green;
|
|
|
|
|
guint16 blue;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
gint transparent;
|
2000-06-21 20:47:22 +00:00
|
|
|
|
} XPMColor;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
|
|
|
|
struct file_handle {
|
1999-10-18 19:29:45 +00:00
|
|
|
|
FILE *infile;
|
|
|
|
|
gchar *buffer;
|
|
|
|
|
guint buffer_size;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
};
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
|
|
|
|
struct mem_handle {
|
1999-10-22 21:05:16 +00:00
|
|
|
|
const gchar **data;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
int offset;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
};
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
2000-06-21 20:47:22 +00:00
|
|
|
|
/* The following 2 routines (parse_color, find_color) come from Tk, via the Win32
|
|
|
|
|
* port of GDK. The licensing terms on these (longer than the functions) is:
|
|
|
|
|
*
|
|
|
|
|
* This software is copyrighted by the Regents of the University of
|
|
|
|
|
* California, Sun Microsystems, Inc., and other parties. The following
|
|
|
|
|
* terms apply to all files associated with the software unless explicitly
|
|
|
|
|
* disclaimed in individual files.
|
|
|
|
|
*
|
|
|
|
|
* The authors hereby grant permission to use, copy, modify, distribute,
|
|
|
|
|
* and license this software and its documentation for any purpose, provided
|
|
|
|
|
* that existing copyright notices are retained in all copies and that this
|
|
|
|
|
* notice is included verbatim in any distributions. No written agreement,
|
|
|
|
|
* license, or royalty fee is required for any of the authorized uses.
|
|
|
|
|
* Modifications to this software may be copyrighted by their authors
|
|
|
|
|
* and need not follow the licensing terms described here, provided that
|
|
|
|
|
* the new terms are clearly indicated on the first page of each file where
|
|
|
|
|
* they apply.
|
|
|
|
|
*
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
|
|
|
|
|
* FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
|
|
|
|
|
* DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
|
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*
|
|
|
|
|
* THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
|
|
|
|
|
* IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
|
|
|
|
|
* NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
|
|
|
|
|
* MODIFICATIONS.
|
|
|
|
|
*
|
|
|
|
|
* GOVERNMENT USE: If you are acquiring this software on behalf of the
|
|
|
|
|
* U.S. government, the Government shall have only "Restricted Rights"
|
|
|
|
|
* in the software and related documentation as defined in the Federal
|
|
|
|
|
* Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
|
|
|
|
|
* are acquiring the software on behalf of the Department of Defense, the
|
|
|
|
|
* software shall be classified as "Commercial Computer Software" and the
|
|
|
|
|
* Government shall have only "Restricted Rights" as defined in Clause
|
|
|
|
|
* 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
|
|
|
|
|
* authors grant the U.S. Government and others acting in its behalf
|
|
|
|
|
* permission to use and distribute the software in accordance with the
|
|
|
|
|
* terms specified in this license.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-03-08 03:59:45 +00:00
|
|
|
|
#include "xpm-color-table.h"
|
2000-06-21 20:47:22 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*----------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* find_color --
|
|
|
|
|
*
|
|
|
|
|
* This routine finds the color entry that corresponds to the
|
|
|
|
|
* specified color.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
|
|
|
|
* Returns non-zero on success. The RGB values of the XColor
|
|
|
|
|
* will be initialized to the proper values on success.
|
|
|
|
|
*
|
|
|
|
|
* Side effects:
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
*----------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
compare_xcolor_entries (const void *a, const void *b)
|
|
|
|
|
{
|
2001-12-14 09:40:20 +00:00
|
|
|
|
return g_ascii_strcasecmp ((const char *) a,
|
2005-03-08 03:59:45 +00:00
|
|
|
|
color_names + ((const XPMColorEntry *)b)->name_offset);
|
2000-06-21 20:47:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
find_color(const char *name,
|
|
|
|
|
XPMColor *colorPtr)
|
|
|
|
|
{
|
|
|
|
|
XPMColorEntry *found;
|
|
|
|
|
|
2005-03-08 03:59:45 +00:00
|
|
|
|
found = bsearch (name, xColors, G_N_ELEMENTS (xColors), sizeof (XPMColorEntry),
|
2000-06-21 20:47:22 +00:00
|
|
|
|
compare_xcolor_entries);
|
|
|
|
|
if (found == NULL)
|
2003-03-08 20:49:00 +00:00
|
|
|
|
return FALSE;
|
2000-06-21 20:47:22 +00:00
|
|
|
|
|
|
|
|
|
colorPtr->red = (found->red * 65535) / 255;
|
|
|
|
|
colorPtr->green = (found->green * 65535) / 255;
|
|
|
|
|
colorPtr->blue = (found->blue * 65535) / 255;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*----------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* parse_color --
|
|
|
|
|
*
|
|
|
|
|
* Partial implementation of X color name parsing interface.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
2001-09-14 22:04:55 +00:00
|
|
|
|
* Returns TRUE on success.
|
2000-06-21 20:47:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Side effects:
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
*----------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
parse_color (const char *spec,
|
|
|
|
|
XPMColor *colorPtr)
|
|
|
|
|
{
|
|
|
|
|
if (spec[0] == '#') {
|
|
|
|
|
char fmt[16];
|
|
|
|
|
int i, red, green, blue;
|
|
|
|
|
|
2001-09-21 21:39:42 +00:00
|
|
|
|
if ((i = strlen (spec + 1)) % 3) {
|
2000-06-21 20:47:22 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
i /= 3;
|
|
|
|
|
|
2001-09-14 22:04:55 +00:00
|
|
|
|
g_snprintf (fmt, 16, "%%%dx%%%dx%%%dx", i, i, i);
|
|
|
|
|
|
2001-09-21 21:39:42 +00:00
|
|
|
|
if (sscanf (spec + 1, fmt, &red, &green, &blue) != 3) {
|
2000-06-21 20:47:22 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (i == 4) {
|
|
|
|
|
colorPtr->red = red;
|
|
|
|
|
colorPtr->green = green;
|
|
|
|
|
colorPtr->blue = blue;
|
|
|
|
|
} else if (i == 1) {
|
|
|
|
|
colorPtr->red = (red * 65535) / 15;
|
|
|
|
|
colorPtr->green = (green * 65535) / 15;
|
|
|
|
|
colorPtr->blue = (blue * 65535) / 15;
|
|
|
|
|
} else if (i == 2)
|
|
|
|
|
{
|
|
|
|
|
colorPtr->red = (red * 65535) / 255;
|
|
|
|
|
colorPtr->green = (green * 65535) / 255;
|
|
|
|
|
colorPtr->blue = (blue * 65535) / 255;
|
|
|
|
|
} else /* if (i == 3) */ {
|
|
|
|
|
colorPtr->red = (red * 65535) / 4095;
|
|
|
|
|
colorPtr->green = (green * 65535) / 4095;
|
|
|
|
|
colorPtr->blue = (blue * 65535) / 4095;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!find_color(spec, colorPtr))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-30 15:28:43 +00:00
|
|
|
|
static gint
|
2001-09-14 22:04:55 +00:00
|
|
|
|
xpm_seek_string (FILE *infile, const gchar *str)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
1999-10-18 19:29:45 +00:00
|
|
|
|
char instr[1024];
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
while (!feof (infile)) {
|
2000-10-09 17:22:20 +00:00
|
|
|
|
if (fscanf (infile, "%1023s", instr) < 0)
|
|
|
|
|
return FALSE;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
if (strcmp (instr, str) == 0)
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return TRUE;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return FALSE;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
1999-10-20 21:20:49 +00:00
|
|
|
|
xpm_seek_char (FILE *infile, gchar c)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
1999-10-18 19:29:45 +00:00
|
|
|
|
gint b, oldb;
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
while ((b = getc (infile)) != EOF) {
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (c != b && b == '/') {
|
1999-10-20 21:20:49 +00:00
|
|
|
|
b = getc (infile);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (b == EOF)
|
|
|
|
|
return FALSE;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
else if (b == '*') { /* we have a comment */
|
|
|
|
|
b = -1;
|
|
|
|
|
do {
|
|
|
|
|
oldb = b;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
b = getc (infile);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (b == EOF)
|
|
|
|
|
return FALSE;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
} while (!(oldb == '*' && b == '/'));
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (c == b)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return FALSE;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
1999-10-20 21:20:49 +00:00
|
|
|
|
xpm_read_string (FILE *infile, gchar **buffer, guint *buffer_size)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
1999-10-18 19:29:45 +00:00
|
|
|
|
gint c;
|
|
|
|
|
guint cnt = 0, bufsiz, ret = FALSE;
|
|
|
|
|
gchar *buf;
|
|
|
|
|
|
|
|
|
|
buf = *buffer;
|
|
|
|
|
bufsiz = *buffer_size;
|
|
|
|
|
if (buf == NULL) {
|
1999-10-20 21:20:49 +00:00
|
|
|
|
bufsiz = 10 * sizeof (gchar);
|
|
|
|
|
buf = g_new (gchar, bufsiz);
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
|
|
|
|
do {
|
1999-10-20 21:20:49 +00:00
|
|
|
|
c = getc (infile);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
} while (c != EOF && c != '"');
|
|
|
|
|
|
1999-06-30 15:28:43 +00:00
|
|
|
|
if (c != '"')
|
1999-10-18 19:29:45 +00:00
|
|
|
|
goto out;
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
while ((c = getc (infile)) != EOF) {
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (cnt == bufsiz) {
|
|
|
|
|
guint new_size = bufsiz * 2;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (new_size > bufsiz)
|
|
|
|
|
bufsiz = new_size;
|
|
|
|
|
else
|
|
|
|
|
goto out;
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
buf = g_realloc (buf, bufsiz);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
buf[bufsiz - 1] = '\0';
|
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (c != '"')
|
|
|
|
|
buf[cnt++] = c;
|
|
|
|
|
else {
|
|
|
|
|
buf[cnt] = 0;
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
out:
|
|
|
|
|
buf[bufsiz - 1] = '\0'; /* ensure null termination for errors */
|
|
|
|
|
*buffer = buf;
|
|
|
|
|
*buffer_size = bufsiz;
|
|
|
|
|
return ret;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gchar *
|
1999-10-22 23:26:22 +00:00
|
|
|
|
xpm_extract_color (const gchar *buffer)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
2001-11-14 21:50:00 +00:00
|
|
|
|
const gchar *p = &buffer[0];
|
2001-09-21 21:39:42 +00:00
|
|
|
|
gint new_key = 0;
|
|
|
|
|
gint key = 0;
|
|
|
|
|
gint current_key = 1;
|
|
|
|
|
gint space = 128;
|
2004-09-15 14:33:00 +00:00
|
|
|
|
gchar word[129], color[129], current_color[129];
|
2001-11-14 21:50:00 +00:00
|
|
|
|
gchar *r;
|
|
|
|
|
|
2001-09-21 21:39:42 +00:00
|
|
|
|
word[0] = '\0';
|
|
|
|
|
color[0] = '\0';
|
|
|
|
|
current_color[0] = '\0';
|
|
|
|
|
while (1) {
|
|
|
|
|
/* skip whitespace */
|
|
|
|
|
for (; *p != '\0' && g_ascii_isspace (*p); p++) {
|
|
|
|
|
}
|
|
|
|
|
/* copy word */
|
|
|
|
|
for (r = word; *p != '\0' && !g_ascii_isspace (*p) && r - word < sizeof (word) - 1; p++, r++) {
|
|
|
|
|
*r = *p;
|
|
|
|
|
}
|
|
|
|
|
*r = '\0';
|
|
|
|
|
if (*word == '\0') {
|
|
|
|
|
if (color[0] == '\0') /* incomplete colormap entry */
|
|
|
|
|
return NULL;
|
|
|
|
|
else /* end of entry, still store the last color */
|
|
|
|
|
new_key = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (key > 0 && color[0] == '\0') /* next word must be a color name part */
|
|
|
|
|
new_key = 0;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
else {
|
2001-09-21 21:39:42 +00:00
|
|
|
|
if (strcmp (word, "c") == 0)
|
|
|
|
|
new_key = 5;
|
|
|
|
|
else if (strcmp (word, "g") == 0)
|
|
|
|
|
new_key = 4;
|
|
|
|
|
else if (strcmp (word, "g4") == 0)
|
|
|
|
|
new_key = 3;
|
|
|
|
|
else if (strcmp (word, "m") == 0)
|
|
|
|
|
new_key = 2;
|
|
|
|
|
else if (strcmp (word, "s") == 0)
|
|
|
|
|
new_key = 1;
|
|
|
|
|
else
|
|
|
|
|
new_key = 0;
|
|
|
|
|
}
|
|
|
|
|
if (new_key == 0) { /* word is a color name part */
|
|
|
|
|
if (key == 0) /* key expected */
|
|
|
|
|
return NULL;
|
|
|
|
|
/* accumulate color name */
|
|
|
|
|
if (color[0] != '\0') {
|
2004-09-15 14:33:00 +00:00
|
|
|
|
strncat (color, " ", space);
|
|
|
|
|
space -= MIN (space, 1);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
2001-09-21 21:39:42 +00:00
|
|
|
|
strncat (color, word, space);
|
|
|
|
|
space -= MIN (space, strlen (word));
|
|
|
|
|
}
|
|
|
|
|
else { /* word is a key */
|
|
|
|
|
if (key > current_key) {
|
|
|
|
|
current_key = key;
|
|
|
|
|
strcpy (current_color, color);
|
|
|
|
|
}
|
|
|
|
|
space = 128;
|
|
|
|
|
color[0] = '\0';
|
|
|
|
|
key = new_key;
|
|
|
|
|
if (*p == '\0') break;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
2001-09-21 21:39:42 +00:00
|
|
|
|
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
2001-09-21 21:39:42 +00:00
|
|
|
|
if (current_key > 1)
|
|
|
|
|
return g_strdup (current_color);
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* (almost) direct copy from gdkpixmap.c... loads an XPM from a file */
|
|
|
|
|
|
1999-10-22 23:26:22 +00:00
|
|
|
|
static const gchar *
|
1999-10-20 21:20:49 +00:00
|
|
|
|
file_buffer (enum buf_op op, gpointer handle)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
1999-10-18 19:29:45 +00:00
|
|
|
|
struct file_handle *h = handle;
|
|
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
|
case op_header:
|
2001-09-14 22:04:55 +00:00
|
|
|
|
if (xpm_seek_string (h->infile, "XPM") != TRUE)
|
1999-10-18 19:29:45 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
if (xpm_seek_char (h->infile, '{') != TRUE)
|
1999-10-18 19:29:45 +00:00
|
|
|
|
break;
|
|
|
|
|
/* Fall through to the next xpm_seek_char. */
|
|
|
|
|
|
|
|
|
|
case op_cmap:
|
1999-10-20 21:20:49 +00:00
|
|
|
|
xpm_seek_char (h->infile, '"');
|
|
|
|
|
fseek (h->infile, -1, SEEK_CUR);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
/* Fall through to the xpm_read_string. */
|
|
|
|
|
|
|
|
|
|
case op_body:
|
2005-11-15 15:59:05 +00:00
|
|
|
|
if(!xpm_read_string (h->infile, &h->buffer, &h->buffer_size))
|
|
|
|
|
return NULL;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return h->buffer;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
|
|
|
|
return NULL;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This reads from memory */
|
1999-10-22 23:26:22 +00:00
|
|
|
|
static const gchar *
|
1999-10-20 21:20:49 +00:00
|
|
|
|
mem_buffer (enum buf_op op, gpointer handle)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
1999-10-18 19:29:45 +00:00
|
|
|
|
struct mem_handle *h = handle;
|
|
|
|
|
switch (op) {
|
|
|
|
|
case op_header:
|
|
|
|
|
case op_cmap:
|
|
|
|
|
case op_body:
|
1999-10-22 23:26:22 +00:00
|
|
|
|
if (h->data[h->offset]) {
|
|
|
|
|
const gchar* retval;
|
|
|
|
|
|
|
|
|
|
retval = h->data[h->offset];
|
|
|
|
|
h->offset += 1;
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
1999-10-22 23:26:22 +00:00
|
|
|
|
break;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return NULL;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
/* This function does all the work. */
|
1999-10-18 19:29:45 +00:00
|
|
|
|
static GdkPixbuf *
|
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
|
|
|
|
pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handle), gpointer handle,
|
|
|
|
|
GError **error)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
2002-09-06 21:09:49 +00:00
|
|
|
|
gint w, h, n_col, cpp, x_hot, y_hot, items;
|
2002-05-22 18:13:44 +00:00
|
|
|
|
gint cnt, xcnt, ycnt, wbytes, n;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
gint is_trans = FALSE;
|
1999-10-22 23:26:22 +00:00
|
|
|
|
const gchar *buffer;
|
|
|
|
|
gchar *name_buf;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
gchar pixel_str[32];
|
|
|
|
|
GHashTable *color_hash;
|
2000-06-21 20:47:22 +00:00
|
|
|
|
XPMColor *colors, *color, *fallbackcolor;
|
2002-04-11 21:18:40 +00:00
|
|
|
|
guchar *pixtmp;
|
|
|
|
|
GdkPixbuf *pixbuf;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
2000-01-22 23:29:21 +00:00
|
|
|
|
fallbackcolor = NULL;
|
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
buffer = (*get_buf) (op_header, handle);
|
1999-06-30 15:28:43 +00:00
|
|
|
|
if (!buffer) {
|
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
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("No XPM header found"));
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return NULL;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
2002-09-06 21:09:49 +00:00
|
|
|
|
items = sscanf (buffer, "%d %d %d %d %d %d", &w, &h, &n_col, &cpp, &x_hot, &y_hot);
|
2005-03-03 14:02:59 +00:00
|
|
|
|
|
|
|
|
|
if (items != 4 && items != 6) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("Invalid XPM header"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-14 22:04:55 +00:00
|
|
|
|
if (w <= 0) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("XPM file has image width <= 0"));
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (h <= 0) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
|
|
|
|
_("XPM file has image height <= 0"));
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|
2004-09-15 14:33:00 +00:00
|
|
|
|
if (cpp <= 0 || cpp >= 32) {
|
2001-09-14 22:04:55 +00:00
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
2004-09-15 14:33:00 +00:00
|
|
|
|
_("XPM has invalid number of chars per pixel"));
|
2001-09-14 22:04:55 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-11-15 15:59:05 +00:00
|
|
|
|
if (n_col <= 0 ||
|
|
|
|
|
n_col >= G_MAXINT / (cpp + 1) ||
|
|
|
|
|
n_col >= G_MAXINT / sizeof (XPMColor)) {
|
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
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
2004-09-15 14:33:00 +00:00
|
|
|
|
_("XPM file has invalid number of colors"));
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return NULL;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
/* The hash is used for fast lookups of color from chars */
|
1999-10-20 21:20:49 +00:00
|
|
|
|
color_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
2004-09-15 14:33:00 +00:00
|
|
|
|
name_buf = g_try_malloc (n_col * (cpp + 1));
|
|
|
|
|
if (!name_buf) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Cannot allocate memory for loading XPM image"));
|
|
|
|
|
g_hash_table_destroy (color_hash);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
colors = (XPMColor *) g_try_malloc (sizeof (XPMColor) * n_col);
|
|
|
|
|
if (!colors) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
|
|
|
|
_("Cannot allocate memory for loading XPM image"));
|
|
|
|
|
g_hash_table_destroy (color_hash);
|
|
|
|
|
g_free (name_buf);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
|
|
|
|
for (cnt = 0; cnt < n_col; cnt++) {
|
|
|
|
|
gchar *color_name;
|
|
|
|
|
|
|
|
|
|
buffer = (*get_buf) (op_cmap, handle);
|
|
|
|
|
if (!buffer) {
|
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
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
2004-06-12 02:08:45 +00:00
|
|
|
|
_("Cannot read XPM colormap"));
|
1999-10-20 21:20:49 +00:00
|
|
|
|
g_hash_table_destroy (color_hash);
|
|
|
|
|
g_free (name_buf);
|
|
|
|
|
g_free (colors);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
color = &colors[cnt];
|
|
|
|
|
color->color_string = &name_buf[cnt * (cpp + 1)];
|
1999-10-20 21:20:49 +00:00
|
|
|
|
strncpy (color->color_string, buffer, cpp);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
color->color_string[cpp] = 0;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
buffer += strlen (color->color_string);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
color->transparent = FALSE;
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
color_name = xpm_extract_color (buffer);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
Remove assorted G_OBJECT casts where unnecessary.
2001-12-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gdk-pixbuf-animation.c, gdk-pixbuf-loader.c, gdk-pixpuf.c,
io-gif-animation.c, io-gif.c, io-tiff.c, test-loaders.c: Remove
assorted G_OBJECT casts where unnecessary.
* gdk-pixbuf-loader.c: Call g_object_ref and g_object_unref
instead of gdk_pixbuf_animation_ref and gdk_pixbuf_animation_unref
resp.
* gdk-pixbuf-csource.c, io-bmp.c, io-gif-animation.c, io-ico.c,
io-jpeg.c, io-png.c, io-pnm.c, io-ras.c, io-tga.c, io-wbmp.c,
io-xbm.c, io-xpm.c, test-gdk-pixbuf.c: Dito for gdk_pixbuf_ref and
gdk_pixbuf_unref.
* Makefile.am, pixops/Makefile.am: Compile everything with
-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
* gdk-pixdata.c: Use g_ascii_strup() instead of g_strup().
* io-xpm.c: Use g_ascii_strcasecmp() instead of g_strcasecmp().
* demos/testpixbuf-drawable.c, demos/testpixbuf-save.c,
demos/testpixbuf-scale.c, demos/testpixbuf.c: Call g_object_ref
and g_object_unref instead of gdk_pixbuf_ref and gdk_pixbuf_unref
resp.
2001-12-13 21:22:12 +00:00
|
|
|
|
if ((color_name == NULL) || (g_ascii_strcasecmp (color_name, "None") == 0)
|
2000-06-21 20:47:22 +00:00
|
|
|
|
|| (parse_color (color_name, color) == FALSE)) {
|
1999-10-18 19:29:45 +00:00
|
|
|
|
color->transparent = TRUE;
|
2001-12-04 16:47:49 +00:00
|
|
|
|
color->red = 0;
|
|
|
|
|
color->green = 0;
|
|
|
|
|
color->blue = 0;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
is_trans = TRUE;
|
|
|
|
|
}
|
1999-07-13 01:01:14 +00:00
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
g_free (color_name);
|
|
|
|
|
g_hash_table_insert (color_hash, color->color_string, color);
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
if (cnt == 0)
|
|
|
|
|
fallbackcolor = color;
|
|
|
|
|
}
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
2002-04-11 21:18:40 +00:00
|
|
|
|
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, is_trans, 8, w, h);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
2002-04-11 21:18:40 +00:00
|
|
|
|
if (!pixbuf) {
|
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
|
|
|
|
g_set_error (error,
|
|
|
|
|
GDK_PIXBUF_ERROR,
|
|
|
|
|
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
2004-06-12 02:08:45 +00:00
|
|
|
|
_("Cannot allocate memory for loading XPM image"));
|
1999-10-20 21:20:49 +00:00
|
|
|
|
g_hash_table_destroy (color_hash);
|
|
|
|
|
g_free (colors);
|
|
|
|
|
g_free (name_buf);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
wbytes = w * cpp;
|
|
|
|
|
|
|
|
|
|
for (ycnt = 0; ycnt < h; ycnt++) {
|
2002-05-22 18:13:44 +00:00
|
|
|
|
pixtmp = pixbuf->pixels + ycnt * pixbuf->rowstride;
|
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
buffer = (*get_buf) (op_body, handle);
|
1999-10-20 21:20:49 +00:00
|
|
|
|
if ((!buffer) || (strlen (buffer) < wbytes))
|
1999-10-18 19:29:45 +00:00
|
|
|
|
continue;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++) {
|
1999-10-20 21:20:49 +00:00
|
|
|
|
strncpy (pixel_str, &buffer[n], cpp);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
pixel_str[cpp] = 0;
|
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
color = g_hash_table_lookup (color_hash, pixel_str);
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
|
|
|
|
/* Bad XPM...punt */
|
|
|
|
|
if (!color)
|
|
|
|
|
color = fallbackcolor;
|
|
|
|
|
|
2000-06-21 20:47:22 +00:00
|
|
|
|
*pixtmp++ = color->red >> 8;
|
|
|
|
|
*pixtmp++ = color->green >> 8;
|
|
|
|
|
*pixtmp++ = color->blue >> 8;
|
1999-10-18 19:29:45 +00:00
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
if (is_trans && color->transparent)
|
1999-10-18 19:29:45 +00:00
|
|
|
|
*pixtmp++ = 0;
|
1999-10-20 21:20:49 +00:00
|
|
|
|
else if (is_trans)
|
1999-10-18 19:29:45 +00:00
|
|
|
|
*pixtmp++ = 0xFF;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-07-13 01:01:14 +00:00
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
g_hash_table_destroy (color_hash);
|
|
|
|
|
g_free (colors);
|
|
|
|
|
g_free (name_buf);
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
2002-09-06 21:09:49 +00:00
|
|
|
|
if (items == 6) {
|
|
|
|
|
gchar hot[10];
|
|
|
|
|
g_snprintf (hot, 10, "%d", x_hot);
|
2002-09-19 21:00:52 +00:00
|
|
|
|
gdk_pixbuf_set_option (pixbuf, "x_hot", hot);
|
2002-09-06 21:09:49 +00:00
|
|
|
|
g_snprintf (hot, 10, "%d", y_hot);
|
2002-09-19 21:00:52 +00:00
|
|
|
|
gdk_pixbuf_set_option (pixbuf, "y_hot", hot);
|
2002-09-06 21:09:49 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-11 21:18:40 +00:00
|
|
|
|
return pixbuf;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shared library entry point for file loading */
|
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
|
|
|
|
static GdkPixbuf *
|
|
|
|
|
gdk_pixbuf__xpm_image_load (FILE *f,
|
|
|
|
|
GError **error)
|
1999-06-30 15:28:43 +00:00
|
|
|
|
{
|
1999-10-18 19:29:45 +00:00
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
struct file_handle h;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
1999-10-20 21:20:49 +00:00
|
|
|
|
memset (&h, 0, sizeof (h));
|
1999-10-18 19:29:45 +00:00
|
|
|
|
h.infile = f;
|
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
|
|
|
|
pixbuf = pixbuf_create_from_xpm (file_buffer, &h, error);
|
1999-10-20 21:20:49 +00:00
|
|
|
|
g_free (h.buffer);
|
1999-06-30 15:28:43 +00:00
|
|
|
|
|
1999-10-18 19:29:45 +00:00
|
|
|
|
return pixbuf;
|
1999-06-30 15:28:43 +00:00
|
|
|
|
}
|
1999-10-22 21:05:16 +00:00
|
|
|
|
|
|
|
|
|
/* Shared library entry point for memory loading */
|
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
|
|
|
|
static GdkPixbuf *
|
2000-02-22 00:29:00 +00:00
|
|
|
|
gdk_pixbuf__xpm_image_load_xpm_data (const gchar **data)
|
1999-10-22 21:05:16 +00:00
|
|
|
|
{
|
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
struct mem_handle 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
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
1999-10-22 21:05:16 +00:00
|
|
|
|
h.data = data;
|
|
|
|
|
h.offset = 0;
|
|
|
|
|
|
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
|
|
|
|
pixbuf = pixbuf_create_from_xpm (mem_buffer, &h, &error);
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
g_warning ("Inline XPM data is broken: %s", error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
error = NULL;
|
|
|
|
|
}
|
1999-10-22 21:05:16 +00:00
|
|
|
|
|
|
|
|
|
return pixbuf;
|
|
|
|
|
}
|
2000-10-09 17:22:20 +00:00
|
|
|
|
|
|
|
|
|
/* Progressive loader */
|
|
|
|
|
typedef struct _XPMContext XPMContext;
|
|
|
|
|
struct _XPMContext
|
|
|
|
|
{
|
2002-10-03 22:39:51 +00:00
|
|
|
|
GdkPixbufModulePreparedFunc prepare_func;
|
|
|
|
|
GdkPixbufModuleUpdatedFunc update_func;
|
2000-10-09 17:22:20 +00:00
|
|
|
|
gpointer user_data;
|
|
|
|
|
|
|
|
|
|
gchar *tempname;
|
|
|
|
|
FILE *file;
|
|
|
|
|
gboolean all_okay;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* FIXME xpm loading progressively is not properly implemented.
|
|
|
|
|
* Instead we will buffer to a file then load that file when done.
|
|
|
|
|
* This is very broken but it should be relayively simple to fix
|
|
|
|
|
* in the future.
|
|
|
|
|
*/
|
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
|
|
|
|
static gpointer
|
2002-10-03 22:39:51 +00:00
|
|
|
|
gdk_pixbuf__xpm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
|
|
|
|
|
GdkPixbufModulePreparedFunc prepare_func,
|
|
|
|
|
GdkPixbufModuleUpdatedFunc update_func,
|
2000-10-18 18:42:54 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2000-10-09 17:22:20 +00:00
|
|
|
|
{
|
|
|
|
|
XPMContext *context;
|
|
|
|
|
gint fd;
|
|
|
|
|
|
|
|
|
|
context = g_new (XPMContext, 1);
|
|
|
|
|
context->prepare_func = prepare_func;
|
|
|
|
|
context->update_func = update_func;
|
|
|
|
|
context->user_data = user_data;
|
|
|
|
|
context->all_okay = TRUE;
|
2000-11-11 00:34:47 +00:00
|
|
|
|
fd = g_file_open_tmp ("gdkpixbuf-xpm-tmp.XXXXXX", &context->tempname,
|
|
|
|
|
NULL);
|
2000-10-09 17:22:20 +00:00
|
|
|
|
if (fd < 0) {
|
|
|
|
|
g_free (context);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context->file = fdopen (fd, "w+");
|
|
|
|
|
if (context->file == NULL) {
|
|
|
|
|
g_free (context->tempname);
|
|
|
|
|
g_free (context);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
static gboolean
|
|
|
|
|
gdk_pixbuf__xpm_image_stop_load (gpointer data,
|
|
|
|
|
GError **error)
|
2000-10-09 17:22:20 +00:00
|
|
|
|
{
|
|
|
|
|
XPMContext *context = (XPMContext*) data;
|
|
|
|
|
GdkPixbuf *pixbuf;
|
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 retval = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (data != NULL, FALSE);
|
2000-10-09 17:22:20 +00:00
|
|
|
|
|
|
|
|
|
fflush (context->file);
|
|
|
|
|
rewind (context->file);
|
|
|
|
|
if (context->all_okay) {
|
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
|
|
|
|
pixbuf = gdk_pixbuf__xpm_image_load (context->file, error);
|
|
|
|
|
|
|
|
|
|
if (pixbuf != NULL) {
|
2006-02-10 19:02:38 +00:00
|
|
|
|
if (context->prepare_func)
|
|
|
|
|
(* context->prepare_func) (pixbuf,
|
|
|
|
|
NULL,
|
|
|
|
|
context->user_data);
|
|
|
|
|
if (context->update_func)
|
|
|
|
|
(* context->update_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data);
|
Remove assorted G_OBJECT casts where unnecessary.
2001-12-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gdk-pixbuf-animation.c, gdk-pixbuf-loader.c, gdk-pixpuf.c,
io-gif-animation.c, io-gif.c, io-tiff.c, test-loaders.c: Remove
assorted G_OBJECT casts where unnecessary.
* gdk-pixbuf-loader.c: Call g_object_ref and g_object_unref
instead of gdk_pixbuf_animation_ref and gdk_pixbuf_animation_unref
resp.
* gdk-pixbuf-csource.c, io-bmp.c, io-gif-animation.c, io-ico.c,
io-jpeg.c, io-png.c, io-pnm.c, io-ras.c, io-tga.c, io-wbmp.c,
io-xbm.c, io-xpm.c, test-gdk-pixbuf.c: Dito for gdk_pixbuf_ref and
gdk_pixbuf_unref.
* Makefile.am, pixops/Makefile.am: Compile everything with
-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED
* gdk-pixdata.c: Use g_ascii_strup() instead of g_strup().
* io-xpm.c: Use g_ascii_strcasecmp() instead of g_strcasecmp().
* demos/testpixbuf-drawable.c, demos/testpixbuf-save.c,
demos/testpixbuf-scale.c, demos/testpixbuf.c: Call g_object_ref
and g_object_unref instead of gdk_pixbuf_ref and gdk_pixbuf_unref
resp.
2001-12-13 21:22:12 +00:00
|
|
|
|
g_object_unref (pixbuf);
|
2000-10-09 17:22:20 +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
|
|
|
|
retval = TRUE;
|
|
|
|
|
}
|
2000-10-09 17:22:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose (context->file);
|
2004-12-05 12:43:47 +00:00
|
|
|
|
g_unlink (context->tempname);
|
2000-10-09 17:22:20 +00:00
|
|
|
|
g_free (context->tempname);
|
|
|
|
|
g_free ((XPMContext *) context);
|
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
|
|
|
|
|
|
|
|
|
return retval;
|
2000-10-09 17:22:20 +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
|
|
|
|
static gboolean
|
|
|
|
|
gdk_pixbuf__xpm_image_load_increment (gpointer data,
|
|
|
|
|
const guchar *buf,
|
|
|
|
|
guint size,
|
|
|
|
|
GError **error)
|
2000-10-09 17:22:20 +00:00
|
|
|
|
{
|
|
|
|
|
XPMContext *context = (XPMContext *) data;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (data != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
|
2006-03-20 20:09:51 +00:00
|
|
|
|
gint save_errno = errno;
|
2000-10-09 17:22:20 +00:00
|
|
|
|
context->all_okay = FALSE;
|
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
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_FILE_ERROR,
|
2006-03-20 20:09:51 +00:00
|
|
|
|
g_file_error_from_errno (save_errno),
|
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
|
|
|
|
_("Failed to write to temporary file when loading XPM image"));
|
2000-10-09 17:22:20 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
void
|
2002-10-03 22:39:51 +00:00
|
|
|
|
MODULE_ENTRY (xpm, fill_vtable) (GdkPixbufModule *module)
|
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
|
|
|
|
{
|
2002-10-03 22:39:51 +00:00
|
|
|
|
module->load = gdk_pixbuf__xpm_image_load;
|
|
|
|
|
module->load_xpm_data = gdk_pixbuf__xpm_image_load_xpm_data;
|
|
|
|
|
module->begin_load = gdk_pixbuf__xpm_image_begin_load;
|
|
|
|
|
module->stop_load = gdk_pixbuf__xpm_image_stop_load;
|
|
|
|
|
module->load_increment = gdk_pixbuf__xpm_image_load_increment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
MODULE_ENTRY (xpm, fill_info) (GdkPixbufFormat *info)
|
|
|
|
|
{
|
|
|
|
|
static GdkPixbufModulePattern signature[] = {
|
|
|
|
|
{ "/* XPM */", NULL, 100 },
|
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
static gchar * mime_types[] = {
|
|
|
|
|
"image/x-xpixmap",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
static gchar * extensions[] = {
|
|
|
|
|
"xpm",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
info->name = "xpm";
|
|
|
|
|
info->signature = signature;
|
|
|
|
|
info->description = N_("The XPM image format");
|
|
|
|
|
info->mime_types = mime_types;
|
|
|
|
|
info->extensions = extensions;
|
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
|
|
|
|
info->flags = GDK_PIXBUF_FORMAT_THREADSAFE;
|
2004-07-08 03:56:36 +00:00
|
|
|
|
info->license = "LGPL";
|
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
|
|
|
|
}
|