]> Pileus Git - ~andy/gtk/blobdiff - gdk-pixbuf/gdk-pixbuf-csource.c
Make 3.0 parallel-installable to 2.x
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf-csource.c
index 05bb6852789332eb931505f93d76875eb556a1b5..c9b0d4f23895240361bea42e836e18c642c62b2f 100644 (file)
  */
 #include "config.h"
 
-#include "../gtk/gtkcompat.h"  /* versioning */
+#define __GTK_H_INSIDE__
+#include "../gtk/gtkversion.h" /* versioning */
+#undef __GTK_H_INSIDE__
 #include "gdk-pixbuf.h"
 #include "gdk-pixdata.h"
-#include <stdio.h>
+#include <glib/gprintf.h>
+#include <stdlib.h>
 #include <string.h>
 
 
 /* --- defines --- */
 #undef G_LOG_DOMAIN
 #define        G_LOG_DOMAIN    "Gdk-Pixbuf-CSource"
-#define PRG_NAME        "gdk-pixbuf-csource"
-#define PKG_NAME        "Gtk+"
+#define PRG_NAME        "gdk-pixbuf-csource-3.0"
+#define PKG_NAME        "GTK+"
 #define PKG_HTTP_HOME   "http://www.gtk.org"
 
 
@@ -63,7 +66,7 @@ print_csource (FILE *f_out,
                                    gen_type | gen_ctype |
                                    (with_decoder ? GDK_PIXDATA_DUMP_RLE_DECODER : 0));
 
-  fprintf (f_out, "%s\n", gstring->str);
+  g_fprintf (f_out, "%s\n", gstring->str);
 
   g_free (free_me);
 }
@@ -74,9 +77,10 @@ main (int   argc,
 {
   GdkPixbuf *pixbuf;
   GError *error = NULL;
+  gchar *infilename;
 
   /* initialize glib/GdkPixbuf */
-  g_type_init (0);
+  g_type_init ();
 
   /* parse args and do fast exits */
   parse_args (&argc, &argv);
@@ -89,10 +93,16 @@ main (int   argc,
          return 1;
        }
       
-      pixbuf = gdk_pixbuf_new_from_file (argv[1], &error);
+#ifdef G_OS_WIN32
+      infilename = g_locale_to_utf8 (argv[1], -1, NULL, NULL, NULL);
+#else
+      infilename = argv[1];
+#endif
+
+      pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
       if (!pixbuf)
        {
-         fprintf (stderr, "failed to load \"%s\": %s\n",
+         g_fprintf (stderr, "failed to load \"%s\": %s\n",
                   argv[1],
                   error->message);
          g_error_free (error);
@@ -100,7 +110,7 @@ main (int   argc,
        }
       
       print_csource (stdout, pixbuf);
-      gdk_pixbuf_unref (pixbuf);
+      g_object_unref (pixbuf);
     }
   else /* parse name, file pairs */
     {
@@ -110,21 +120,30 @@ main (int   argc,
 
       while (j--)
        {
+#ifdef G_OS_WIN32
+         infilename = g_locale_to_utf8 (*p, -1, NULL, NULL, NULL);
+#else
+         infilename = *p;
+#endif
+
          if (!toggle)
-           image_name = *p++;
+           {
+             image_name = infilename;
+             p++;
+           }
          else
            {
-             pixbuf = gdk_pixbuf_new_from_file (*p, &error);
+             pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
              if (!pixbuf)
                {
-                 fprintf (stderr, "failed to load \"%s\": %s\n",
+                 g_fprintf (stderr, "failed to load \"%s\": %s\n",
                           *p,
                           error->message);
                  g_error_free (error);
                  return 1;
                }
              print_csource (stdout, pixbuf);
-             gdk_pixbuf_unref (pixbuf);
+             g_object_unref (pixbuf);
              p++;
            }
          toggle = !toggle;
@@ -254,33 +273,32 @@ print_blurb (FILE    *bout,
 {
   if (!print_help)
     {
-      fprintf (bout, "%s version ", PRG_NAME);
-      fprintf (bout, "%u.%u.%u", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
-      fprintf (bout, "\n");
-      fprintf (bout, "%s comes with ABSOLUTELY NO WARRANTY.\n", PRG_NAME);
-      fprintf (bout, "You may redistribute copies of %s under the terms of\n", PRG_NAME);
-      fprintf (bout, "the GNU Lesser General Public License which can be found in the\n");
-      fprintf (bout, "%s source package. Sources, examples and contact\n", PKG_NAME);
-      fprintf (bout, "information are available at %s\n", PKG_HTTP_HOME);
+      g_fprintf (bout, "%s version ", PRG_NAME);
+      g_fprintf (bout, "%d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+      g_fprintf (bout, "\n");
+      g_fprintf (bout, "%s comes with ABSOLUTELY NO WARRANTY.\n", PRG_NAME);
+      g_fprintf (bout, "You may redistribute copies of %s under the terms of\n", PRG_NAME);
+      g_fprintf (bout, "the GNU Lesser General Public License which can be found in the\n");
+      g_fprintf (bout, "%s source package. Sources, examples and contact\n", PKG_NAME);
+      g_fprintf (bout, "information are available at %s\n", PKG_HTTP_HOME);
     }
   else
     {
-      fprintf (bout, "Usage: %s [options] [image]\n", PRG_NAME);
-      fprintf (bout, "       %s [options] --build-list [[name image]...]\n", PRG_NAME);
-      fprintf (bout, "  --stream                   generate pixbuf data stream\n");
-      fprintf (bout, "  --struct                   generate GdkPixdata structure\n");
-      fprintf (bout, "  --macros                   generate image size/pixel macros\n");
-      fprintf (bout, "  --rle                      use one byte run-length-encoding\n");
-      fprintf (bout, "  --raw                      provide raw image data copy\n");
-      fprintf (bout, "  --extern                   generate extern symbols\n");
-      fprintf (bout, "  --static                   generate static symbols\n");
-      fprintf (bout, "  --decoder                  provide rle decoder\n");
-      fprintf (bout, "  --name=identifier          C macro/variable name\n");
-      fprintf (bout, "  --build-list              parse (name, image) pairs\n");
-      fprintf (bout, "  -h, --help                 show this help message\n");
-      fprintf (bout, "  -v, --version              print version informations\n");
-      fprintf (bout, "  --g-fatal-warnings         make warnings fatal (abort)\n");
+      g_fprintf (bout, "Usage: %s [options] [image]\n", PRG_NAME);
+      g_fprintf (bout, "       %s [options] --build-list [[name image]...]\n", PRG_NAME);
+      g_fprintf (bout, "  --stream                   generate pixbuf data stream\n");
+      g_fprintf (bout, "  --struct                   generate GdkPixdata structure\n");
+      g_fprintf (bout, "  --macros                   generate image size/pixel macros\n");
+      g_fprintf (bout, "  --rle                      use one byte run-length-encoding\n");
+      g_fprintf (bout, "  --raw                      provide raw image data copy\n");
+      g_fprintf (bout, "  --extern                   generate extern symbols\n");
+      g_fprintf (bout, "  --static                   generate static symbols\n");
+      g_fprintf (bout, "  --decoder                  provide rle decoder\n");
+      g_fprintf (bout, "  --name=identifier          C macro/variable name\n");
+      g_fprintf (bout, "  --build-list               parse (name, image) pairs\n");
+      g_fprintf (bout, "  -h, --help                 show this help message\n");
+      g_fprintf (bout, "  -v, --version              print version informations\n");
+      g_fprintf (bout, "  --g-fatal-warnings         make warnings fatal (abort)\n");
     }
 }
 
-#include "x"