diff options
author | Sergey V. Udaltsov <svu@gnome.org> | 2011-02-03 00:09:21 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@gnome.org> | 2011-02-03 00:09:21 +0000 |
commit | b64ac23e5266646a856ed6b0dd0f8969389fde3e (patch) | |
tree | e543faab9b86db63f68bc5c74df9640ba95982cf /libgnomekbd | |
parent | e49eea4d56d44a221ceb30f835399bc3159385ff (diff) | |
download | libgnomekbd-b64ac23e5266646a856ed6b0dd0f8969389fde3e.tar.gz |
Added gkbd-keyboard-display utility
It is going to be used by the gnome-shell and gnome-control-center
Diffstat (limited to 'libgnomekbd')
-rw-r--r-- | libgnomekbd/.gitignore | 1 | ||||
-rw-r--r-- | libgnomekbd/Makefile.am | 16 | ||||
-rw-r--r-- | libgnomekbd/gkbd-keyboard-display.c | 82 | ||||
-rw-r--r-- | libgnomekbd/gkbd-keyboard-drawing.c | 2 | ||||
-rw-r--r-- | libgnomekbd/gkbd-keyboard-drawing.h | 2 |
5 files changed, 101 insertions, 2 deletions
diff --git a/libgnomekbd/.gitignore b/libgnomekbd/.gitignore index 11c6889..70c09b1 100644 --- a/libgnomekbd/.gitignore +++ b/libgnomekbd/.gitignore @@ -11,4 +11,5 @@ Makefile.in *.o org.gnome.libgnomekbd.*gschema.xml org.gnome.libgnomekbd.*gschema.xml.in +gkbd-keyboard-display diff --git a/libgnomekbd/Makefile.am b/libgnomekbd/Makefile.am index 86c627c..9be9576 100644 --- a/libgnomekbd/Makefile.am +++ b/libgnomekbd/Makefile.am @@ -1,3 +1,5 @@ +bin_PROGRAMS=gkbd-keyboard-display + lib_LTLIBRARIES = libgnomekbd.la libgnomekbdui.la uidir="$(pkgdatadir)/ui" @@ -66,6 +68,20 @@ libgnomekbdui_la_SOURCES = \ gkbd-keyboard-drawing-marshal.c \ gkbd-keyboard-drawing.c +gkbd_keyboard_display_SOURCES=gkbd-keyboard-display.c + +gkbd_keyboard_display_CFLAGS=$(common_CFLAGS) \ + -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) + +gkbd_keyboard_display_LDADD = \ + $(GCONF_LIBS) \ + $(GTK_LIBS) \ + $(LIBXKLAVIER_LIBS) \ + $(top_builddir)/libgnomekbd/libgnomekbd.la \ + $(top_builddir)/libgnomekbd/libgnomekbdui.la + BUILT_SOURCES = gkbd-indicator-marshal.c \ gkbd-indicator-marshal.h \ gkbd-keyboard-drawing-marshal.c \ diff --git a/libgnomekbd/gkbd-keyboard-display.c b/libgnomekbd/gkbd-keyboard-display.c new file mode 100644 index 0000000..f2db018 --- /dev/null +++ b/libgnomekbd/gkbd-keyboard-display.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <stdlib.h> +#include <config.h> + +#include <gtk/gtk.h> +#include <gdk/gdkx.h> + +#include <libxklavier/xkl_engine.h> +#include <libgnomekbd/gkbd-keyboard-drawing.h> + +static GMainLoop *loop; +static gint group = 0; +static GOptionEntry options[] = + { {"group", 'g', 0, G_OPTION_ARG_INT, &group, "Group to display", + "group number (1, 2, 3, 4)"}, NULL +}; + +static void +destroy_dialog () +{ + g_main_loop_quit (loop); +} + +int +main (int argc, char **argv) +{ + GError *error = NULL; + XklEngine *engine; + const gchar **names = NULL; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + gtk_init_with_args (&argc, &argv, NULL, options, NULL, &error); + + if (error != NULL) { + g_critical ("Error initializing GTK: %s", error->message); + exit (1); + } + + engine = + xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY + (gdk_display_get_default ())); + if (group < 0 || group > xkl_engine_get_num_groups (engine)) { + g_critical ("The group number is invalid: %d", group); + exit (2); + } + + names = xkl_engine_get_groups_names (engine); + + group--; + + GtkWidget *dlg = + gkbd_keyboard_drawing_new_dialog (group, names[group]); + g_signal_connect (G_OBJECT (dlg), "destroy", destroy_dialog, NULL); + + gtk_widget_set_visible (dlg, TRUE); + + loop = g_main_loop_new (NULL, TRUE); + + g_main_loop_run (loop); + + return 0; +} diff --git a/libgnomekbd/gkbd-keyboard-drawing.c b/libgnomekbd/gkbd-keyboard-drawing.c index 2845bcd..dbc812d 100644 --- a/libgnomekbd/gkbd-keyboard-drawing.c +++ b/libgnomekbd/gkbd-keyboard-drawing.c @@ -2502,7 +2502,7 @@ show_layout_response (GtkWidget * dialog, gint resp) } GtkWidget * -gkbd_keyboard_drawing_new_dialog (gint group, gchar * group_name) +gkbd_keyboard_drawing_new_dialog (gint group, const gchar * group_name) { static GkbdKeyboardDrawingGroupLevel groupsLevels[] = { { 0, 1}, { diff --git a/libgnomekbd/gkbd-keyboard-drawing.h b/libgnomekbd/gkbd-keyboard-drawing.h index 40f1176..740b1e5 100644 --- a/libgnomekbd/gkbd-keyboard-drawing.h +++ b/libgnomekbd/gkbd-keyboard-drawing.h @@ -206,7 +206,7 @@ void gkbd_keyboard_drawing_print (GkbdKeyboardDrawing * drawing, GtkWidget *gkbd_keyboard_drawing_new_dialog (gint group, - gchar * group_name); + const gchar * group_name); G_END_DECLS #endif /* #ifndef GKBD_KEYBOARD_DRAWING_H */ |