From 1eece68489c3dfe05ec448fce8f7179074281224 Mon Sep 17 00:00:00 2001
From: Akira TAGOH <akira@tagoh.org>
Date: Tue, 4 Sep 2012 14:03:14 +0900
Subject: [PATCH 1/2] Add the MATE-Desktop support
---
README | 4 ++
backends/Makefile.am | 9 ++-
backends/mateconf/Makefile.am | 47 +++++++++++++++
backends/mateconf/mateconf-module.c | 117 ++++++++++++++++++++++++++++++++++++
configure.ac | 25 ++++++--
data/xinput.sh.in.in | 8 +++
6 files changed, 201 insertions(+), 9 deletions(-)
create mode 100644 backends/mateconf/Makefile.am
create mode 100644 backends/mateconf/mateconf-module.c
diff --git a/README b/README
index 34c4fb0..58248a0 100644
--- a/README
+++ b/README
@@ -49,6 +49,7 @@ Supported Toolkits
======================
* GTK+
* LXDE
+* MATE
* Qt
* XFCE
* X (with IMSettings XIM server; require libgxim)
@@ -231,6 +232,9 @@ Backend modules
* libimsettings-lxde.so:
A LXDE backend to support LXDE Desktop.
+* libimsettings-mateconf.so:
+ A mateconf backend to support MATE Desktop.
+
* libimsettings-qt.so:
A Qt backend to support Qt applications.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 1b470b9..e60905c 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -7,15 +7,18 @@ endif
if ENABLE_GSETTINGS
SUBDIRS += gsettings
endif
+if ENABLE_LXDE
+SUBDIRS += lxde
+endif
+if ENABLE_MATE
+SUBDIRS += mateconf
+endif
if ENABLE_QT
SUBDIRS += qt
endif
if ENABLE_XFCE
SUBDIRS += xfce
endif
-if ENABLE_LXDE
-SUBDIRS += lxde
-endif
if ENABLE_XIM
SUBDIRS += xim
endif
diff --git a/backends/mateconf/Makefile.am b/backends/mateconf/Makefile.am
new file mode 100644
index 0000000..670e8e7
--- /dev/null
+++ b/backends/mateconf/Makefile.am
@@ -0,0 +1,47 @@
+##
+# Global definitions
+NULL =
+INCLUDES = \
+ -DIMSETTINGS_LOCALEDIR="\"$(datadir)/locale\"" \
+ -I$(top_srcdir)/imsettings \
+ $(MATE_CFLAGS) \
+ $(NULL)
+LIBS = \
+ @LDFLAGS@ \
+ $(top_builddir)/imsettings/libimsettings.la \
+ $(MATE_LIBS) \
+ $(NULL)
+EXTRA_DIST = \
+ $(NULL)
+
+
+##
+# Local definitions
+
+##
+# Local Rules
+
+##
+# Target platform
+imsettingsdir = $(IMSETTINGS_MODULEDIR)
+imsettings_LTLIBRARIES = \
+ libimsettings-mateconf.la \
+ $(NULL)
+#
+libimsettings_mateconf_la_SOURCES = \
+ mateconf-module.c \
+ $(NULL)
+libimsettings_mateconf_la_CFLAGS = \
+ -DG_LOG_DOMAIN="\"IMSettings-MATE-Conf backend\"" \
+ $(CFLAGS) \
+ $(NULL)
+libimsettings_mateconf_la_LDFLAGS = \
+ -avoid-version \
+ -module \
+ $(LDFLAGS) \
+ $(NULL)
+libimsettings_mateconf_la_LIBADD = \
+ $(LDADDS) \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/backends/mateconf/mateconf-module.c b/backends/mateconf/mateconf-module.c
new file mode 100644
index 0000000..bbbde21
--- /dev/null
+++ b/backends/mateconf/mateconf-module.c
@@ -0,0 +1,117 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * mateconf-module.c
+ * Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+ *
+ * Authors:
+ * Akira TAGOH <tagoh@redhat.com>
+ *
+ * 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.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <mateconf/mateconf-client.h>
+#include "imsettings-info.h"
+#include "imsettings-utils.h"
+
+#define MATECONF_SCHEMA_KEY "/desktop/mate/interface/gtk-im-module"
+
+void module_switch_im(IMSettingsInfo *info);
+gchar *module_dump_im (void);
+
+/*< private >*/
+
+/*< public >*/
+void
+module_switch_im(IMSettingsInfo *info)
+{
+ MateConfEngine *engine;
+ MateConfValue *val = NULL;
+ const gchar *gtkimm = imsettings_info_get_gtkimm(info);
+ GError *err = NULL;
+ gchar *v = NULL;
+
+ engine = mateconf_engine_get_default();
+ if (!engine) {
+ g_warning("Unable to obtain MateConfEngine instance.");
+ return;
+ }
+ if (!gtkimm || gtkimm[0] == 0) {
+ g_warning("Invalid gtk immodule in: %s",
+ imsettings_info_get_filename(info));
+ goto finalize;
+ }
+
+#ifdef ENABLE_FALLBACK_IM
+ v = g_strdup_printf("%s:xim", gtkimm);
+#else
+ v = g_strdup(gtkimm);
+#endif
+ val = mateconf_value_new_from_string(MATECONF_VALUE_STRING,
+ v, &err);
+ if (err)
+ goto error;
+ g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
+ "Setting up %s as gtk+ immodule",
+ v);
+ mateconf_engine_set(engine, MATECONF_SCHEMA_KEY,
+ val, &err);
+ if (err) {
+ error:
+ g_warning("%s", err->message);
+ g_error_free(err);
+ }
+ finalize:
+ g_free(v);
+ if (val)
+ mateconf_value_free(val);
+ if (engine) {
+ mateconf_engine_unref(engine);
+ }
+ g_print("%d\n", mateconf_debug_shutdown());
+}
+
+gchar *
+module_dump_im(void)
+{
+ MateConfEngine *engine;
+ MateConfValue *val = NULL;
+ GError *err = NULL;
+ gchar *retval = NULL;
+
+ engine = mateconf_engine_get_default();
+ if (!engine) {
+ g_warning("Unable to obtain MateConfEngine instance.");
+ return NULL;
+ }
+ val = mateconf_engine_get(engine, MATECONF_SCHEMA_KEY, &err);
+ if (err) {
+ g_warning("%s", err->message);
+ g_error_free(err);
+ } else {
+ retval = g_strdup(mateconf_value_get_string(val));
+ }
+ if (val)
+ mateconf_value_free(val);
+ if (engine) {
+ mateconf_engine_unref(engine);
+ }
+ g_print("%d\n", mateconf_debug_shutdown());
+
+ return retval;
+}
diff --git a/configure.ac b/configure.ac
index e1b858e..9241dfc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,6 +112,10 @@ PKG_CHECK_MODULES(GSETTINGS, gio-2.0 >= $GIO_REQUIRED,
PKG_CHECK_MODULES(LXDE, glib-2.0,
[use_lxde="yes"],
[use_lxde="no"])
+# for mate backend
+PKG_CHECK_MODULES(MATE, mateconf-2.0,
+ [use_mate="yes"],
+ [use_mate="no"])
# for xfce backend
PKG_CHECK_MODULES(XFCE, libxfconf-0,
[use_xfce="yes"],
@@ -143,6 +147,8 @@ AC_SUBST(XFCE_CFLAGS)
AC_SUBST(XFCE_LIBS)
AC_SUBST(LXDE_CFLAGS)
AC_SUBST(LXDE_LIBS)
+AC_SUBST(MATE_CFLAGS)
+AC_SUBST(MATE_LIBS)
AC_SUBST(XIM_CFLAGS)
AC_SUBST(XIM_LIBS)
AC_SUBST(CHECK_CFLAGS)
@@ -153,9 +159,10 @@ AC_SUBST(GTHREAD_LIBS)
AM_CONDITIONAL(ENABLE_UNIT_TEST, test x$use_check != xno)
AM_CONDITIONAL(ENABLE_GCONF, test x$use_gconf != xno)
AM_CONDITIONAL(ENABLE_GSETTINGS, test x$use_gsettings != xno)
+AM_CONDITIONAL(ENABLE_LXDE, test x$use_lxde != xno)
+AM_CONDITIONAL(ENABLE_MATE, test x$use_mate != xno)
AM_CONDITIONAL(ENABLE_QT, test x$use_qt != xno)
AM_CONDITIONAL(ENABLE_XFCE, test x$use_xfce != xno)
-AM_CONDITIONAL(ENABLE_LXDE, test x$use_lxde != xno)
AM_CONDITIONAL(ENABLE_XIM, test x$use_xim != xno)
dnl ======================================================================
@@ -306,6 +313,7 @@ AC_CONFIG_FILES([
backends/gconf/Makefile
backends/gsettings/Makefile
backends/lxde/Makefile
+ backends/mateconf/Makefile
backends/qt/Makefile
backends/xfce/Makefile
backends/xim/Makefile
@@ -343,6 +351,16 @@ if test "x$use_gconf" = "xyes"; then
echo " CFLAGS: $GSETTINGS_CFLAGS"
echo " LDFLAGS: $GSETTINGS_LIBS"
fi
+echo " MATE support: $use_mate"
+if test "x$use_mate" = "xyes"; then
+ echo " CFLAGS: $MATE_CFLAGS"
+ echo " LDFLAGS: $MATE_LIBS"
+fi
+echo " LXDE support: $use_lxde"
+if test "x$use_lxde" = "xyes"; then
+ echo " CFLAGS: $LXDE_CFLAGS"
+ echo " LDFLAGS: $LXDE_LIBS"
+fi
echo " Qt support: $use_qt"
if test "x$use_qt" = "xyes"; then
echo " CFLAGS: $GLIB_CFLAGS"
@@ -353,11 +371,6 @@ if test "x$use_xfce" = "xyes"; then
echo " CFLAGS: $XFCE_CFLAGS"
echo " LDFLAGS: $XFCE_LIBS"
fi
-echo " LXDE support: $use_lxde"
-if test "x$use_lxde" = "xyes"; then
- echo " CFLAGS: $LXDE_CFLAGS"
- echo " LDFLAGS: $LXDE_LIBS"
-fi
echo " XIM support: $use_xim"
if test "x$use_xim" = "xyes"; then
echo " CFLAGS: $XIM_CFLAGS"
diff --git a/data/xinput.sh.in.in b/data/xinput.sh.in.in
index 4f4baad..a402c26 100755
--- a/data/xinput.sh.in.in
+++ b/data/xinput.sh.in.in
@@ -56,6 +56,9 @@ function lookup_desktop() {
lxsession*)
echo "LXDE"
;;
+ mate*)
+ echo "mate"
+ ;;
xfce*)
echo "xfce"
;;
@@ -105,6 +108,11 @@ function is_gtk_supported() {
return 0
fi
;;
+ mate)
+ if check_imsettings_capability mateconf; then
+ return 0
+ fi
+ ;;
xfce*)
if check_imsettings_capability xfce; then
return 0
--
1.7.11.7