[libgnomekbd] Improved keyboard drawing dialog
- From: Sergey V. Udaltsov <svu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnomekbd] Improved keyboard drawing dialog
- Date: Fri, 4 Feb 2011 19:55:17 +0000 (UTC)
commit 2634d5b50340a7cc3cfb86f1ec09f5d271551335
Author: Sergey V. Udaltsov <svu gnome org>
Date: Fri Feb 4 19:51:55 2011 +0000
Improved keyboard drawing dialog
API is fixed, proper title taken from libxklavier meta data
libgnomekbd/gkbd-keyboard-display.c | 14 ++++++--
libgnomekbd/gkbd-keyboard-drawing.c | 53 +++++++++++++++++++++++++---------
libgnomekbd/gkbd-keyboard-drawing.h | 2 +
3 files changed, 51 insertions(+), 18 deletions(-)
---
diff --git a/libgnomekbd/gkbd-keyboard-display.c b/libgnomekbd/gkbd-keyboard-display.c
index a9ee135..dcbdeec 100644
--- a/libgnomekbd/gkbd-keyboard-display.c
+++ b/libgnomekbd/gkbd-keyboard-display.c
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#include <libxklavier/xkl_engine.h>
+#include <libxklavier/xklavier.h>
#include <libgnomekbd/gkbd-keyboard-drawing.h>
static GMainLoop *loop;
@@ -69,15 +69,21 @@ main (int argc, char **argv)
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
engine = xkl_engine_get_instance (display);
+
if (group < 0 || group > xkl_engine_get_num_groups (engine)) {
g_critical ("The group number is invalid: %d", group);
exit (2);
}
dlg = gkbd_keyboard_drawing_dialog_new ();
- if (layout != NULL)
- gkbd_keyboard_drawing_dialog_set_layout (dlg, layout);
- else
+ if (layout != NULL) {
+ XklConfigRegistry *registry =
+ xkl_config_registry_get_instance (engine);
+ xkl_config_registry_load (registry, TRUE);
+ gkbd_keyboard_drawing_dialog_set_layout (dlg, registry,
+ layout);
+ g_object_unref (registry);
+ } else
gkbd_keyboard_drawing_dialog_set_group (dlg, group - 1);
g_signal_connect (G_OBJECT (dlg), "destroy", destroy_dialog, NULL);
diff --git a/libgnomekbd/gkbd-keyboard-drawing.c b/libgnomekbd/gkbd-keyboard-drawing.c
index 4dbe6bf..1d1cd60 100644
--- a/libgnomekbd/gkbd-keyboard-drawing.c
+++ b/libgnomekbd/gkbd-keyboard-drawing.c
@@ -27,7 +27,6 @@
#include <memory.h>
#include <math.h>
#include <glib/gi18n-lib.h>
-#include <libxklavier/xklavier.h>
#include <gkbd-keyboard-drawing.h>
#include <gkbd-keyboard-drawing-marshal.h>
@@ -2575,9 +2574,11 @@ gkbd_keyboard_drawing_dialog_set_group (GtkWidget * dialog, gint group)
if (xkl_xkb_config_native_prepare
(engine, xkl_data, &component_names)) {
- gkbd_keyboard_drawing_set_keyboard
+ if (!gkbd_keyboard_drawing_set_keyboard
(GKBD_KEYBOARD_DRAWING (kbdraw),
- &component_names);
+ &component_names))
+ gkbd_keyboard_drawing_set_keyboard
+ (GKBD_KEYBOARD_DRAWING (kbdraw), NULL);
xkl_xkb_config_native_cleanup (engine,
&component_names);
}
@@ -2682,11 +2683,15 @@ gkbd_keyboard_drawing_set_layout (GkbdKeyboardDrawing * drawing,
if (xkl_xkb_config_native_prepare
(engine, data, &component_names)) {
- gkbd_keyboard_drawing_set_keyboard
- (drawing, &component_names);
+ if (!gkbd_keyboard_drawing_set_keyboard (drawing, &component_names))
+ gkbd_keyboard_drawing_set_keyboard
+ (drawing, NULL);
xkl_xkb_config_native_cleanup
(engine, &component_names);
+ } else {
+ xkl_debug (0,
+ "Could not find the keyboard\n");
}
}
g_object_unref (G_OBJECT (data));
@@ -2698,21 +2703,41 @@ gkbd_keyboard_drawing_set_layout (GkbdKeyboardDrawing * drawing,
void
gkbd_keyboard_drawing_dialog_set_layout (GtkWidget * dialog,
- const gchar * layout)
+ XklConfigRegistry * registry,
+ const gchar * full_layout)
{
- Display *display;
- Atom atom;
- const gchar *group_name;
+ const gchar *group_name = "?";
+ XklConfigItem *xki = xkl_config_item_new ();
+ gchar *layout = NULL, *variant = NULL;
+
GkbdKeyboardDrawing *kbdraw =
GKBD_KEYBOARD_DRAWING (g_object_get_data
(G_OBJECT (dialog), "kbdraw"));
- if (layout == NULL || layout[0] == 0)
+ if (full_layout == NULL || full_layout[0] == 0)
return;
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- gkbd_keyboard_drawing_set_layout (kbdraw, layout);
- atom = kbdraw->xkb->names->groups[0];
- group_name = XGetAtomName (display, atom);
+ gkbd_keyboard_drawing_set_layout (kbdraw, full_layout);
+
+ if (gkbd_keyboard_config_split_items
+ (full_layout, &layout, &variant)) {
+ if (variant != NULL) {
+ strncpy (xki->name, variant,
+ XKL_MAX_CI_NAME_LENGTH);
+ xki->name[XKL_MAX_CI_NAME_LENGTH - 1] = 0;
+ if (xkl_config_registry_find_variant
+ (registry, layout, xki))
+ group_name = xki->description;
+ } else {
+ strncpy (xki->name, layout,
+ XKL_MAX_CI_NAME_LENGTH);
+ xki->name[XKL_MAX_CI_NAME_LENGTH - 1] = 0;
+ if (xkl_config_registry_find_layout
+ (registry, xki))
+ group_name = xki->description;
+ }
+ }
+
gkbd_keyboard_drawing_dialog_set_group_name (dialog, group_name);
+ g_object_unref (xki);
}
diff --git a/libgnomekbd/gkbd-keyboard-drawing.h b/libgnomekbd/gkbd-keyboard-drawing.h
index 5d75948..03c68fa 100644
--- a/libgnomekbd/gkbd-keyboard-drawing.h
+++ b/libgnomekbd/gkbd-keyboard-drawing.h
@@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBgeom.h>
+#include <libxklavier/xklavier.h>
G_BEGIN_DECLS
#define GKBD_KEYBOARD_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), gkbd_keyboard_drawing_get_type (), \
@@ -213,6 +214,7 @@ void gkbd_keyboard_drawing_dialog_set_group (GtkWidget * dialog,
gint group);
void gkbd_keyboard_drawing_dialog_set_layout (GtkWidget * dialog,
+ XklConfigRegistry * registry,
const gchar * layout);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]