]> Pileus Git - ~andy/gtk/blobdiff - gdk-pixbuf/io-xbm.c
Remove check for winsock.h since it might show up on Linux+Wine. Instead
[~andy/gtk] / gdk-pixbuf / io-xbm.c
index c5589bc97923c2c00deaa191380532f437d80b4b..1a510183a36e787ef2bd195d28eee9db39c47b62 100644 (file)
@@ -1,3 +1,4 @@
+/* -*- mode: C; c-file-style: "linux" -*- */
 /* GdkPixbuf library - XBM image loader
  *
  * Copyright (C) 1999 Mark Crichton
@@ -33,7 +34,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <ctype.h>
 #include <errno.h>
 #include "gdk-pixbuf-private.h"
 #include "gdk-pixbuf-io.h"
@@ -43,8 +43,8 @@
 typedef struct _XBMData XBMData;
 struct _XBMData
 {
-       ModulePreparedNotifyFunc prepare_func;
-       ModuleUpdatedNotifyFunc update_func;
+       GdkPixbufModulePreparedFunc prepare_func;
+       GdkPixbufModuleUpdatedFunc update_func;
        gpointer user_data;
 
        gchar *tempname;
@@ -129,8 +129,8 @@ next_int (FILE *fstream)
                } else {
                        /* trim high bits, check type and accumulate */
                        ch &= 0xff;
-                       if (isascii (ch) && isxdigit (ch)) {
-                               value = (value << 4) + hex_table[ch];
+                       if (g_ascii_isxdigit (ch)) {
+                               value = (value << 4) + g_ascii_xdigit_value (ch);
                                gotone++;
                        } else if ((hex_table[ch]) < 0 && gotone) {
                                done++;
@@ -245,6 +245,7 @@ read_bitmap_file_data (FILE *fstream,
                                *ptr=value;
                        }
                }
+               break;
        }
 
        if (!bits)
@@ -295,6 +296,14 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
                 return NULL;
         }
         
+       if (x_hot != -1 && y_hot != -1) {
+               gchar hot[10];
+               g_snprintf (hot, 10, "%d", x_hot);
+               gdk_pixbuf_set_option (pixbuf, "x_hot", hot);
+               g_snprintf (hot, 10, "%d", y_hot);
+               gdk_pixbuf_set_option (pixbuf, "y_hot", hot);
+       }
+
        pixels = gdk_pixbuf_get_pixels (pixbuf);
        row_stride = gdk_pixbuf_get_rowstride (pixbuf);
 
@@ -324,6 +333,7 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
                }
                pixels += row_stride;
        }
+       g_free (data);
 
        if (context) {
                (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data);
@@ -352,8 +362,9 @@ gdk_pixbuf__xbm_image_load (FILE *f, GError **error)
  */
 
 static gpointer
-gdk_pixbuf__xbm_image_begin_load (ModulePreparedNotifyFunc prepare_func,
-                                 ModuleUpdatedNotifyFunc update_func,
+gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
+                                  GdkPixbufModulePreparedFunc prepare_func,
+                                 GdkPixbufModuleUpdatedFunc update_func,
                                  gpointer user_data,
                                  GError **error)
 {
@@ -433,10 +444,35 @@ gdk_pixbuf__xbm_image_load_increment (gpointer data,
 }
 
 void
-gdk_pixbuf__xbm_fill_vtable (GdkPixbufModule *module)
+MODULE_ENTRY (xbm, fill_vtable) (GdkPixbufModule *module)
+{
+       module->load = gdk_pixbuf__xbm_image_load;
+       module->begin_load = gdk_pixbuf__xbm_image_begin_load;
+       module->stop_load = gdk_pixbuf__xbm_image_stop_load;
+       module->load_increment = gdk_pixbuf__xbm_image_load_increment;
+}
+
+void
+MODULE_ENTRY (xbm, fill_info) (GdkPixbufFormat *info)
 {
-  module->load = gdk_pixbuf__xbm_image_load;
-  module->begin_load = gdk_pixbuf__xbm_image_begin_load;
-  module->stop_load = gdk_pixbuf__xbm_image_stop_load;
-  module->load_increment = gdk_pixbuf__xbm_image_load_increment;
+       static GdkPixbufModulePattern signature[] = {
+               { "#define ", NULL, 100 },
+               { "/*", NULL, 50 },
+               { NULL, NULL, 0 }
+       };
+       static gchar * mime_types[] = {
+               "image/x-xbitmap",
+               NULL
+       };
+       static gchar * extensions[] = {
+               "xbm",
+               NULL
+       };
+
+       info->name = "xbm";
+       info->signature = signature;
+       info->description = N_("The XBM image format");
+       info->mime_types = mime_types;
+       info->extensions = extensions;
+       info->flags = 0;
 }