Commit bed0a9df authored by Dom Lachowicz's avatar Dom Lachowicz

ditch popt in favor of goption; bug 336089

parent a905f74e
2006-04-01 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-convert.c: Ditch popt in favor of GOption (#336090)
* rsvg-convert.c: Ditto
* test-display.c: Ditto
* test-performance.c: Ditto
* configure.in: Ditto, bump version number (2.15.0)
2006-03-22 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-base-file-util.c: rsvg_handle_set_base_uri() in rsvg_handle_new_from_file()
......
......@@ -99,7 +99,6 @@ LDADDS = \
$(LIBGSF_LIBS) \
$(LIBCROCO_LIBS) \
$(LIBRSVG_LIBS) \
$(POPT_LIBS) \
$(top_builddir)/librsvg-2.la
bin_SCRIPTS=rsvg
......
......@@ -4,24 +4,22 @@ dnl ===========================================================================
FONTCONFIG_REQUIRED=1.0.1 dnl Same as in Pango, ???
GDK_PIXBUF_REQUIRED=1.3.7
GLIB_REQUIRED=2.0.0
GLIB_REQUIRED=2.11.0
LIBXML_REQUIRED=2.4.7
CAIRO_REQUIRED=1.0.2
PANGOFT2_REQUIRED=1.2.0
POPT_REQUIRED=1.5
AC_SUBST(GDK_PIXBUF_REQUIRED)
AC_SUBST(GLIB_REQUIRED)
AC_SUBST(CAIRO_REQUIRED)
AC_SUBST(LIBXML_REQUIRED)
AC_SUBST(PANGOFT2_REQUIRED)
AC_SUBST(POPT_REQUIRED)
dnl ===========================================================================
LIBRSVG_MAJOR_VERSION=2
LIBRSVG_MINOR_VERSION=14
LIBRSVG_MICRO_VERSION=3
LIBRSVG_MINOR_VERSION=15
LIBRSVG_MICRO_VERSION=0
AC_SUBST(LIBRSVG_MAJOR_VERSION)
AC_SUBST(LIBRSVG_MINOR_VERSION)
AC_SUBST(LIBRSVG_MICRO_VERSION)
......@@ -96,13 +94,6 @@ AC_SUBST(LIBRSVG_CFLAGS)
dnl ===========================================================================
AC_CHECK_LIB(popt, poptParseArgvString, [POPT_LIBS="-lpopt"],
AC_MSG_ERROR([popt 1.5 or newer is required to build librsvg.
You can download the latest version from ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/]))
AC_SUBST(POPT_LIBS)
dnl ===========================================================================
LIBGSF_CFLAGS=""
LIBGSF_LIBS=""
......@@ -221,7 +212,7 @@ else
fi
have_gtk=no
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 1.3.12, have_gtk=yes,
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0, have_gtk=yes,
have_gtk=no)
GTK_VERSION=
......
......@@ -31,7 +31,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <popt.h>
#include "rsvg.h"
#include "rsvg-cairo.h"
......@@ -110,9 +109,9 @@ rsvg_cairo_write_func (void *closure,
}
int
main (int argc, const char **argv)
main (int argc, char **argv)
{
poptContext popt_context;
GOptionContext *g_option_context;
double x_zoom = 1.0;
double y_zoom = 1.0;
double zoom = 1.0;
......@@ -127,24 +126,8 @@ main (int argc, const char **argv)
char * base_uri = NULL;
gboolean using_stdin = FALSE;
struct poptOption options_table[] = {
{ "dpi-x", 'd', POPT_ARG_DOUBLE, &dpi_x, 0, N_("pixels per inch [optional; defaults to 90dpi]"), N_("<float>") },
{ "dpi-y", 'p', POPT_ARG_DOUBLE, &dpi_y, 0, N_("pixels per inch [optional; defaults to 90dpi]"), N_("<float>") },
{ "x-zoom", 'x', POPT_ARG_DOUBLE, &x_zoom, 0, N_("x zoom factor [optional; defaults to 1.0]"), N_("<float>") },
{ "y-zoom", 'y', POPT_ARG_DOUBLE, &y_zoom, 0, N_("y zoom factor [optional; defaults to 1.0]"), N_("<float>") },
{ "zoom", 'z', POPT_ARG_DOUBLE, &zoom, 0, N_("zoom factor [optional; defaults to 1.0]"), N_("<float>") },
{ "width", 'w', POPT_ARG_INT, &width, 0, N_("width [optional; defaults to the SVG's width]"), N_("<int>") },
{ "height", 'h', POPT_ARG_INT, &height, 0, N_("height [optional; defaults to the SVG's height]"), N_("<int>") },
{ "format", 'f', POPT_ARG_STRING, &format, 0, N_("save format [optional; defaults to 'png']"), N_("[png, pdf, ps, svg]") },
{ "output", 'o', POPT_ARG_STRING, &output, 0, N_("output filename [optional; defaults to stdout]"), NULL },
{ "keep-aspect-ratio", 'a', POPT_ARG_NONE, &keep_aspect_ratio, 0, N_("whether to preserve the aspect ratio [optional; defaults to FALSE]"), NULL },
{ "version", 'v', POPT_ARG_NONE, &bVersion, 0, N_("show version information"), NULL },
{ "base-uri", 'b', POPT_ARG_STRING, &base_uri, 0, N_("base uri"), NULL },
POPT_AUTOHELP
POPT_TABLEEND
};
int c, i;
const char * const *args;
int i;
char **args;
gint n_args = 0;
RsvgHandle *rsvg;
cairo_surface_t *surface = NULL;
......@@ -152,15 +135,35 @@ main (int argc, const char **argv)
RsvgDimensionData dimensions;
FILE * output_file = stdout;
popt_context = poptGetContext ("rsvg-cairo", argc, argv, options_table, 0);
poptSetOtherOptionHelp (popt_context, _("[OPTIONS...]"));
GOptionEntry options_table[] = {
{ "dpi-x", 'd', 0, G_OPTION_ARG_DOUBLE, &dpi_x, N_("pixels per inch [optional; defaults to 90dpi]"), N_("<float>") },
{ "dpi-y", 'p', 0, G_OPTION_ARG_DOUBLE, &dpi_y, N_("pixels per inch [optional; defaults to 90dpi]"), N_("<float>") },
{ "x-zoom", 'x', 0, G_OPTION_ARG_DOUBLE, &x_zoom, N_("x zoom factor [optional; defaults to 1.0]"), N_("<float>") },
{ "y-zoom", 'y', 0, G_OPTION_ARG_DOUBLE, &y_zoom, N_("y zoom factor [optional; defaults to 1.0]"), N_("<float>") },
{ "zoom", 'z', 0, G_OPTION_ARG_DOUBLE, &zoom, N_("zoom factor [optional; defaults to 1.0]"), N_("<float>") },
{ "width", 'w', 0, G_OPTION_ARG_INT, &width, N_("width [optional; defaults to the SVG's width]"), N_("<int>") },
{ "height", 'h', 0, G_OPTION_ARG_INT, &height, N_("height [optional; defaults to the SVG's height]"), N_("<int>") },
{ "format", 'f', 0, G_OPTION_ARG_STRING, &format, N_("save format [optional; defaults to 'png']"), N_("[png, pdf, ps, svg]") },
{ "output", 'o', 0, G_OPTION_ARG_STRING, &output, N_("output filename [optional; defaults to stdout]"), NULL },
{ "keep-aspect-ratio", 'a', 0, G_OPTION_ARG_NONE, &keep_aspect_ratio, N_("whether to preserve the aspect ratio [optional; defaults to FALSE]"), NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &bVersion, N_("show version information"), NULL },
{ "base-uri", 'b', 0, G_OPTION_ARG_STRING, &base_uri, N_("base uri"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, N_("[FILE...]") },
{ NULL }
};
g_option_context = g_option_context_new (_("- SVG Converter"));
g_option_context_add_main_entries (g_option_context, options_table, NULL);
g_option_context_set_help_enabled (g_option_context, TRUE);
if(!g_option_context_parse (g_option_context, &argc, &argv, NULL)) {
exit(1);
}
c = poptGetNextOpt (popt_context);
args = poptGetArgs (popt_context);
g_option_context_free (g_option_context);
if (bVersion != 0)
{
printf (_("rsvg-cairo version %s\n"), VERSION);
printf (_("rsvg-convert version %s\n"), VERSION);
return 0;
}
......@@ -308,7 +311,6 @@ main (int argc, const char **argv)
fclose (output_file);
poptFreeContext (popt_context);
rsvg_term();
return 0;
......
......@@ -22,7 +22,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <popt.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
......@@ -670,7 +669,7 @@ int
main (int argc, char **argv)
{
GError * err = NULL;
poptContext popt_context;
GOptionContext *g_option_context;
double x_zoom = 1.0;
double y_zoom = 1.0;
double dpi_x = -1.0;
......@@ -688,39 +687,43 @@ main (int argc, char **argv)
struct RsvgSizeCallbackData size_data;
struct poptOption options_table[] =
char **args;
gint n_args = 0;
GOptionEntry options_table[] =
{
#ifdef ENABLE_XEMBED
{ "xid", 'i', POPT_ARG_INT, &xid, 0, N_("XWindow ID [for X11 embedding]"), N_("<int>") },
{ "xid", 'i', 0, G_OPTION_ARG_INT, &xid, N_("XWindow ID [for X11 embedding]"), N_("<int>") },
#endif
{ "stdin", 's', POPT_ARG_NONE, &from_stdin, 0, N_("Read from stdin instead of a file"), NULL },
{ "dpi-x", 'd', POPT_ARG_DOUBLE, &dpi_x, 0, N_("Set the # of Pixels Per Inch"), N_("<float>") },
{ "dpi-y", 'p', POPT_ARG_DOUBLE, &dpi_y, 0, N_("Set the # of Pixels Per Inch"), N_("<float>") },
{ "x-zoom", 'x', POPT_ARG_DOUBLE, &x_zoom, 0, N_("Set the x zoom factor"), N_("<float>") },
{ "y-zoom", 'y', POPT_ARG_DOUBLE, &y_zoom, 0, N_("Set the y zoom factor"), N_("<float>") },
{ "width", 'w', POPT_ARG_INT, &width, 0, N_("Set the image's width"), N_("<int>") },
{ "height", 'h', POPT_ARG_INT, &height, 0, N_("Set the image's height"), N_("<int>") },
{ "bg-color", 'b', POPT_ARG_STRING, &bg_color, 0, N_("Set the image background color (default: transparent)"), N_("<string>") },
{ "base-uri", 'u', POPT_ARG_STRING, &base_uri, 0, N_("Set the base URI (default: none)"), N_("<string>") },
{ "keep-aspect", 'k', POPT_ARG_NONE, &bKeepAspect, 0, N_("Preserve the image's aspect ratio"), NULL },
{ "version", 'v', POPT_ARG_NONE, &bVersion, 0, N_("Show version information"), NULL },
POPT_AUTOHELP
POPT_TABLEEND
{ "stdin", 's', 0, G_OPTION_ARG_NONE, &from_stdin, N_("Read from stdin instead of a file"), NULL },
{ "dpi-x", 'd', 0, G_OPTION_ARG_DOUBLE, &dpi_x, N_("Set the # of Pixels Per Inch"), N_("<float>") },
{ "dpi-y", 'p', 0, G_OPTION_ARG_DOUBLE, &dpi_y, N_("Set the # of Pixels Per Inch"), N_("<float>") },
{ "x-zoom", 'x', 0, G_OPTION_ARG_DOUBLE, &x_zoom, N_("Set the x zoom factor"), N_("<float>") },
{ "y-zoom", 'y', 0, G_OPTION_ARG_DOUBLE, &y_zoom, N_("Set the y zoom factor"), N_("<float>") },
{ "width", 'w', 0, G_OPTION_ARG_INT, &width, N_("Set the image's width"), N_("<int>") },
{ "height", 'h', 0, G_OPTION_ARG_INT, &height, N_("Set the image's height"), N_("<int>") },
{ "bg-color", 'b', 0, G_OPTION_ARG_STRING, &bg_color, N_("Set the image background color (default: transparent)"), N_("<string>") },
{ "base-uri", 'u', 0, G_OPTION_ARG_STRING, &base_uri, N_("Set the base URI (default: none)"), N_("<string>") },
{ "keep-aspect", 'k', 0, G_OPTION_ARG_NONE, &bKeepAspect, N_("Preserve the image's aspect ratio"), NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &bVersion, N_("Show version information"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, N_("[FILE...]") },
{ NULL }
};
int c;
const char * const *args;
gint n_args = 0;
info.pixbuf = NULL;
info.svg_bytes = NULL;
info.window = NULL;
info.popup_menu = NULL;
popt_context = poptGetContext ("rsvg-view", argc, (const char **)argv, options_table, 0);
poptSetOtherOptionHelp (popt_context, _("[OPTIONS...] [file.svg]"));
c = poptGetNextOpt (popt_context);
args = poptGetArgs (popt_context);
g_option_context = g_option_context_new ("- SVG Viewer");
g_option_context_add_main_entries (g_option_context, options_table, NULL);
g_option_context_add_group (g_option_context, gtk_get_option_group (TRUE));
g_option_context_set_help_enabled (g_option_context, TRUE);
if(!g_option_context_parse (g_option_context, &argc, &argv, NULL)) {
exit(1);
}
g_option_context_free (g_option_context);
if (bVersion != 0)
{
......@@ -736,13 +739,11 @@ main (int argc, char **argv)
if ((!from_stdin) && (n_args != 1))
{
poptPrintHelp (popt_context, stderr, 0);
poptFreeContext (popt_context);
g_print (_("No files specified, and not using --stdin\n"));
return 1;
}
/* initialize gtk+ */
gtk_init (&argc, &argv) ;
/* initialize gtk+ and rsvg */
rsvg_init ();
rsvg_set_default_dpi_x_y (dpi_x, dpi_y);
......@@ -793,9 +794,8 @@ main (int argc, char **argv)
{
if (ferror (stdin))
{
g_critical (_("Error reading\n"));
g_print (_("Error reading\n"));
g_byte_array_free (info.svg_bytes, TRUE);
poptFreeContext (popt_context);
fclose(stdin);
return 1;
......@@ -810,16 +810,12 @@ main (int argc, char **argv)
if(!info.svg_bytes || !info.svg_bytes->len)
{
g_critical (_("Couldn't open %s\n"), args[0]);
poptFreeContext (popt_context);
g_print (_("Couldn't open %s\n"), args[0]);
return 1;
}
info.base_uri = base_uri;
poptFreeContext (popt_context);
info.pixbuf = rsvg_pixbuf_from_data_with_size_data (info.svg_bytes->data, info.svg_bytes->len, &size_data, base_uri, &err);
if (!info.pixbuf)
......
......@@ -28,17 +28,17 @@
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <popt.h>
#include "rsvg.h"
#include "rsvg-private.h"
int
main (int argc, const char **argv)
main (int argc, char **argv)
{
int i, count = 10;
GTimer *timer;
poptContext popt_context;
GOptionContext *g_option_context;
double x_zoom = 1.0;
double y_zoom = 1.0;
double dpi = -1.0;
......@@ -46,35 +46,30 @@ main (int argc, const char **argv)
int height = -1;
int bVersion = 0;
struct poptOption options_table[] = {
{ "dpi" , 'd', POPT_ARG_DOUBLE, NULL, 0, "pixels per inch", "<float>" },
{ "x-zoom", 'x', POPT_ARG_DOUBLE, NULL, 0, "x zoom factor", "<float>" },
{ "y-zoom", 'y', POPT_ARG_DOUBLE, NULL, 0, "y zoom factor", "<float>" },
{ "width", 'w', POPT_ARG_INT, NULL, 0, "width", "<int>" },
{ "height", 'h', POPT_ARG_INT, NULL, 0, "height", "<int>" },
{ "count", 'c', POPT_ARG_INT, NULL, 0, "number of times to render the SVG", "<int>" },
{ "version", 'v', POPT_ARG_NONE, NULL, 0, "show version information", NULL },
POPT_AUTOHELP
POPT_TABLEEND
};
int c;
const char * const *args;
char **args;
gint n_args = 0;
GdkPixbuf *pixbuf;
options_table[0].arg = &dpi;
options_table[1].arg = &x_zoom;
options_table[2].arg = &y_zoom;
options_table[3].arg = &width;
options_table[4].arg = &height;
options_table[5].arg = &count;
options_table[6].arg = &bVersion;
GOptionEntry options_table[] = {
{ "dpi" , 'd', 0, G_OPTION_ARG_DOUBLE, &dpi, "pixels per inch", "<float>" },
{ "x-zoom", 'x', 0, G_OPTION_ARG_DOUBLE, &x_zoom, "x zoom factor", "<float>" },
{ "y-zoom", 'y', 0, G_OPTION_ARG_DOUBLE, &y_zoom, "y zoom factor", "<float>" },
{ "width", 'w', 0, G_OPTION_ARG_INT, &width, "width", "<int>" },
{ "height", 'h', 0, G_OPTION_ARG_INT, &height, "height", "<int>" },
{ "count", 'c', 0, G_OPTION_ARG_INT, &count, "number of times to render the SVG", "<int>" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &bVersion, "show version information", NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, N_("[FILE...]") },
{ NULL }
};
popt_context = poptGetContext ("test-performance", argc, argv, options_table, 0);
poptSetOtherOptionHelp(popt_context, "[OPTIONS...] file.svg");
g_option_context = g_option_context_new (_("- SVG Performance Test"));
g_option_context_add_main_entries (g_option_context, options_table, NULL);
g_option_context_set_help_enabled (g_option_context, TRUE);
if(!g_option_context_parse (g_option_context, &argc, &argv, NULL)) {
exit(1);
}
c = poptGetNextOpt (popt_context);
args = poptGetArgs (popt_context);
g_option_context_free (g_option_context);
if (bVersion != 0)
{
......@@ -88,8 +83,7 @@ main (int argc, const char **argv)
if (n_args != 1)
{
poptPrintHelp (popt_context, stderr, 0);
poptFreeContext (popt_context);
g_print (_("Must specify a SVG file\n"));
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment