summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--configure.in10
-rw-r--r--test/Makefile.am8
-rw-r--r--test/gkbd-keyboard-drawing-test.c97
4 files changed, 60 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index e9ee42c..6609af1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* libgnomekbd/gkbd-keyboard-drawing.c,
libgnomekbd/gkbd-keyboard-drawing.h: draw to cairo, to make printing
possible, http://bugzilla.gnome.org/show_bug.cgi?id=502962
+ * test/Makefile.am, test/gkbd-keyboard-drawing-test.c, configure.in:
+ make test apps using GOption,
+ http://bugzilla.gnome.org/show_bug.cgi?id=502993
2007-12-05 svu
diff --git a/configure.in b/configure.in
index b230b4b..5cd30cb 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
dnl ***************************************************************************
dnl *** configure.in for libgnomekbd ***
dnl ***************************************************************************
-AC_INIT(libgnomekbd, 2.21.1, [http://bugzilla.gnome.org/enter_bug.cgi?product=libgnomekbd])
+AC_INIT(libgnomekbd, 2.21.4, [http://bugzilla.gnome.org/enter_bug.cgi?product=libgnomekbd])
AC_PREREQ(2.59)
VERSION_INFO=2:0:0
@@ -14,6 +14,7 @@ AC_CONFIG_MACRO_DIR(m4)
dnl ***************************************************************************
dnl *** Minimum library versions for libgnomekbd ***
dnl ***************************************************************************
+GLIB_REQUIRED=2.6
DBUS_REQUIRED=0.92
DBUS_GLIB_REQUIRED=0.34
GCONF_REQUIRED=2.14.0
@@ -59,7 +60,12 @@ IT_PROG_INTLTOOL([0.35.0])
# *****************************************************************************
AC_CHECK_FUNCS(setlocale)
-
+
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED)
+
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
PKG_CHECK_MODULES(DBUS, dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
AC_SUBST(DBUS_CFLAGS)
diff --git a/test/Makefile.am b/test/Makefile.am
index cf543b9..0904ae2 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -19,13 +19,13 @@ gkbd_indicator_test_LDFLAGS= \
$(top_builddir)/libgnomekbd/libgnomekbd.la \
$(top_builddir)/libgnomekbd/libgnomekbdui.la
-gkbd_keyboard_drawing_test_CFLAGS= \
+gkbd_keyboard_drawing_test_CFLAGS= \
$(WARN_CFLAGS) -I$(top_srcdir) \
- $(GTK_CFLAGS)
+ $(GTK_CFLAGS) $(GLIB_CFLAGS)
-gkbd_keyboard_drawing_test_LDFLAGS= \
+gkbd_keyboard_drawing_test_LDFLAGS= \
+ $(GLIB_LIBS) \
$(GTK_LIBS) \
- -lpopt \
$(LIBXKLAVIER_LIBS) \
$(top_builddir)/libgnomekbd/libgnomekbd.la \
$(top_builddir)/libgnomekbd/libgnomekbdui.la
diff --git a/test/gkbd-keyboard-drawing-test.c b/test/gkbd-keyboard-drawing-test.c
index 1b0e6d8..f855ca3 100644
--- a/test/gkbd-keyboard-drawing-test.c
+++ b/test/gkbd-keyboard-drawing-test.c
@@ -22,9 +22,9 @@
#endif
#include <gtk/gtk.h>
-#include <popt.h>
#include <stdlib.h>
#include <string.h>
+#include <glib/goption.h>
#include "libgnomekbd/gkbd-keyboard-drawing.h"
@@ -33,31 +33,41 @@ static gchar *levels = NULL;
static gchar *symbols = NULL;
static gchar *keycodes = NULL;
static gchar *geometry = NULL;
-static struct poptOption options[] = {
- {"groups", '\0', POPT_ARG_STRING, &groups, 0,
- "Keyboard groups to display, from 1-4. Up to four groups only may be displayed. Examples: --groups=3 or --groups=1,2,1,2",
- "group1[,group2[,group3[,group4]]]"},
- {"levels", '\0', POPT_ARG_STRING, &levels, 0,
- "Keyboard shift levels to display, from 1-64. Up to four shift levels only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
- "level1[,level2[,level3[,level4]]]"},
- {"symbols", '\0', POPT_ARG_STRING, &symbols, 0,
- "Symbols component of the keyboard. If you omit this option, it is obtained from the X server; that is, the keyboard that is currently configured is drawn. Examples: --symbols=us or --symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)",
- NULL},
- {"keycodes", '\0', POPT_ARG_STRING, &keycodes, 0,
- "Keycodes component of the keyboard. If you omit this option, it is obtained from the X server; that is, the keyboard that is currently configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
- NULL},
- {"geometry", '\0', POPT_ARG_STRING, &geometry, 0,
- "Geometry xkb component. If you omit this option, it is obtained from the X server; that is, the keyboard that is currently configured is drawn. Example: --geometry=kinesis",
- NULL},
- {"track-modifiers", '\0', POPT_ARG_NONE, NULL, 3,
- "Track the current modifiers", NULL},
- {"track-config", '\0', POPT_ARG_NONE, NULL, 4,
- "Track the server XKB configuration", NULL},
- {"version", 'v', POPT_ARG_NONE, NULL, 1, "Show current version",
- NULL},
- POPT_AUTOHELP {NULL, '\0', 0, NULL, 0}
-};
+static gboolean track_config = FALSE;
+static gboolean track_modifiers = FALSE;
+static gboolean program_version = FALSE;
+
+static const GOptionEntry options[] = {
+ { "groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
+ "Keyboard groups to display, from 1-4. Up to four groups only may be "
+ "displayed. Examples: --groups=3 or --groups=1,2,1,2",
+ "group1[,group2[,group3[,group4]]]" },
+ { "levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
+ "Keyboard shift levels to display, from 1-64. Up to four shift levels "
+ "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
+ "level1[,level2[,level3[,level4]]]" },
+ { "symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
+ "Symbols component of the keyboard. If you omit this option, it is "
+ "obtained from the X server; that is, the keyboard that is currently "
+ "configured is drawn. Examples: --symbols=us or "
+ "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL },
+ { "keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
+ "Keycodes component of the keyboard. If you omit this option, it is "
+ "obtained from the X server; that is, the keyboard that is currently"
+ " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)", NULL },
+ { "geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
+ "Geometry xkb component. If you omit this option, it is obtained from the"
+ " X server; that is, the keyboard that is currently configured is drawn. "
+ "Example: --geometry=kinesis", NULL },
+ { "track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
+ "Track the current modifiers", NULL },
+ { "track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
+ "Track the server XKB configuration", NULL },
+ { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
+ "Show current version", NULL },
+ { NULL },
+};
static gboolean
set_groups (gchar * groups_option,
@@ -152,7 +162,7 @@ main (gint argc, gchar ** argv)
GdkScreen *screen;
gint monitor;
GdkRectangle rect;
- poptContext popt_context;
+ GOptionContext *context;
gint rc;
GkbdKeyboardDrawingGroupLevel groupLevels[4] =
{ {0, 0}, {1, 0}, {0, 1}, {1, 1} };
@@ -160,36 +170,19 @@ main (gint argc, gchar ** argv)
{ &groupLevels[0], &groupLevels[1], &groupLevels[2],
&groupLevels[3]
};
- gboolean track_config = False, track_modifiers = False;
-
- gtk_init (&argc, &argv);
- popt_context =
- poptGetContext ("kbdraw", argc, (const gchar **) argv, options,
- 0);
-
- for (rc = poptGetNextOpt (popt_context); rc > 0;
- rc = poptGetNextOpt (popt_context))
- switch (rc) {
- case 1:
- g_print ("kbdraw %s\n", VERSION);
- exit (0);
- case 3:
- track_modifiers = True;
- break;
- case 4:
- track_config = True;
- break;
- }
+ context = g_option_context_new ("kbdraw");
+ g_option_context_add_main_entries (context, options, NULL);
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
- if (rc != -1) {
- g_printerr ("%s: %s\n",
- poptBadOption (popt_context,
- POPT_BADOPTION_NOALIAS),
- poptStrerror (rc));
- exit (1);
+ if (program_version) {
+ g_print("kbdraw %s\n", VERSION);
+ exit (0);
}
+ gtk_init (&argc, &argv);
+
if (!set_groups (groups, groupLevels)) {
g_printerr ("--groups: invalid argument\n");
exit (1);