Commit 579456e7 authored by Rui Matos's avatar Rui Matos
Browse files

gnome-xkb-info: Remove xkbfile dependency

This code was originally from gnome-settings-daemon but got moved here
so that we could be sure that all GnomeXkbInfo users were using the
same xkb rules file by getting it from the X server.

As we move towards wayland though, we find ourselves in a position to
specify how and where xkb data resides so we can drop this
dependency. Instead, for now, we'll just hardcode the path to the xkb
data from the xkeyboard-config XKB_DATA compile time variable.

https://bugzilla.gnome.org/show_bug.cgi?id=719942
parent eb752a07
......@@ -153,7 +153,6 @@ PKG_CHECK_MODULES(GNOME_DESKTOP, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED
xrandr >= $XRANDR_REQUIRED
xext >= $XEXT_REQUIRED
xkeyboard-config
xkbfile
iso-codes)
XKB_BASE=$($PKG_CONFIG --variable xkb_base xkeyboard-config)
......
......@@ -166,8 +166,7 @@ gnome_rr_debug_LDADD = \
noinst_PROGRAMS = test-xkb-info test-pnp-ids test-wall-clock test-desktop-thumbnail test-idle-monitor test-languages
test_xkb_info_LDADD = \
$(GNOME_DESKTOP_LIBS) \
$(lib_LTLIBRARIES) \
$(XLIB_LIBS)
$(lib_LTLIBRARIES)
test_pnp_ids_LDADD = $(test_xkb_info_LDADD)
......
......@@ -6,7 +6,6 @@ includedir=@includedir@
Name: gnome-desktop-3.0
Description: Utility library for loading .desktop files
Requires: gtk+-3.0 gsettings-desktop-schemas
Requires.private: xkbfile
Version: @VERSION@
Libs: -L${libdir} -lgnome-desktop-3
Cflags: -I${includedir}/gnome-desktop-3.0
......@@ -25,9 +25,6 @@
#include <stdlib.h>
#include <string.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
#include <gdk/gdkx.h>
#include <glib/gi18n-lib.h>
......@@ -40,12 +37,6 @@
#ifndef XKB_RULES_FILE
#define XKB_RULES_FILE "evdev"
#endif
#ifndef XKB_LAYOUT
#define XKB_LAYOUT "us"
#endif
#ifndef XKB_MODEL
#define XKB_MODEL "pc105+inet"
#endif
typedef struct _Layout Layout;
struct _Layout
......@@ -132,88 +123,13 @@ free_option_group (gpointer data)
g_slice_free (XkbOptionGroup, group);
}
/**
* gnome_xkb_info_get_var_defs: (skip)
* @rules: (out) (transfer full): location to store the rules file
* path. Use g_free() when it's no longer needed
* @var_defs: (out) (transfer full): location to store a
* #XkbRF_VarDefsRec pointer. Use gnome_xkb_info_free_var_defs() to
* free it
*
* Gets both the XKB rules file path and the current XKB parameters in
* use by the X server.
*
* Since: 3.6
*/
void
gnome_xkb_info_get_var_defs (gchar **rules,
XkbRF_VarDefsRec **var_defs)
{
Display *display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
char *tmp;
g_return_if_fail (rules != NULL);
g_return_if_fail (var_defs != NULL);
*rules = NULL;
*var_defs = g_new0 (XkbRF_VarDefsRec, 1);
gdk_error_trap_push ();
/* Get it from the X property or fallback on defaults */
if (!XkbRF_GetNamesProp (display, rules, *var_defs) || !*rules)
{
*rules = strdup (XKB_RULES_FILE);
(*var_defs)->model = strdup (XKB_MODEL);
(*var_defs)->layout = strdup (XKB_LAYOUT);
(*var_defs)->variant = NULL;
(*var_defs)->options = NULL;
}
gdk_error_trap_pop_ignored ();
tmp = *rules;
if (*rules[0] == '/')
*rules = g_strdup (*rules);
else
*rules = g_build_filename (XKB_BASE, "rules", *rules, NULL);
free (tmp);
}
/**
* gnome_xkb_info_free_var_defs: (skip)
* @var_defs: #XkbRF_VarDefsRec instance to free
*
* Frees an #XkbRF_VarDefsRec instance allocated by
* gnome_xkb_info_get_var_defs().
*
* Since: 3.6
*/
void
gnome_xkb_info_free_var_defs (XkbRF_VarDefsRec *var_defs)
{
g_return_if_fail (var_defs != NULL);
free (var_defs->model);
free (var_defs->layout);
free (var_defs->variant);
free (var_defs->options);
g_free (var_defs);
}
static gchar *
get_xml_rules_file_path (const gchar *suffix)
{
XkbRF_VarDefsRec *xkb_var_defs;
gchar *rules_file;
gchar *xml_rules_file;
gnome_xkb_info_get_var_defs (&rules_file, &xkb_var_defs);
gnome_xkb_info_free_var_defs (xkb_var_defs);
rules_file = g_build_filename (XKB_BASE, "rules", XKB_RULES_FILE, NULL);
xml_rules_file = g_strdup_printf ("%s%s", rules_file, suffix);
g_free (rules_file);
......
......@@ -30,9 +30,6 @@
#include <glib-object.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
G_BEGIN_DECLS
#define GNOME_TYPE_XKB_INFO (gnome_xkb_info_get_type ())
......@@ -80,10 +77,6 @@ GList *gnome_xkb_info_get_layouts_for_language (GnomeXkbInfo *s
GList *gnome_xkb_info_get_layouts_for_country (GnomeXkbInfo *self,
const gchar *country_code);
void gnome_xkb_info_get_var_defs (gchar **rules,
XkbRF_VarDefsRec **var_defs);
void gnome_xkb_info_free_var_defs (XkbRF_VarDefsRec *var_defs);
G_END_DECLS
#endif /* __GNOME_XKB_INFO_H__ */
#include <gtk/gtk.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-xkb-info.h>
int
......@@ -9,8 +8,6 @@ main (int argc, char **argv)
GList *option_groups, *g;
GList *options, *o;
gtk_init (&argc, &argv);
info = gnome_xkb_info_new ();
layouts = gnome_xkb_info_get_all_layouts (info);
......
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