* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
*/
/*
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
+#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <glib/gstdio.h>
#include <gmodule.h>
-#include <pango/pango-utils.h>
-#include "gtkimmodule.h"
+#include "gtkimmoduleprivate.h"
#include "gtkimcontextsimple.h"
#include "gtksettings.h"
-#include "gtkmain.h"
-#include "gtkrc.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
-#include "gtkalias.h"
-/* Do *not* include "gtkprivate.h" in this file. If you do, the
- * correct_libdir_prefix() and correct_localedir_prefix() functions
- * below will have to move somewhere else.
- */
+#undef GDK_DEPRECATED
+#undef GDK_DEPRECATED_FOR
+#define GDK_DEPRECATED
+#define GDK_DEPRECATED_FOR(f)
-#ifdef __GTK_PRIVATE_H__
-#error gtkprivate.h should not be included in this file
-#endif
+#include "deprecated/gtkrc.h"
#define SIMPLE_ID "gtk-im-context-simple"
+/**
+ * GtkIMContextInfo:
+ * @context_id: The unique identification string of the input method.
+ * @context_name: The human-readable name of the input method.
+ * @domain: Translation domain to be used with dgettext()
+ * @domain_dirname: Name of locale directory for use with bindtextdomain()
+ * @default_locales: A colon-separated list of locales where this input method
+ * should be the default. The asterisk "*" sets the default for all locales.
+ *
+ * Bookkeeping information about a loadable input method.
+ */
+
typedef struct _GtkIMModule GtkIMModule;
typedef struct _GtkIMModuleClass GtkIMModuleClass;
im_module->library = g_module_open (im_module->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
if (!im_module->library)
{
- g_warning (g_module_error());
+ g_warning ("%s", g_module_error());
return FALSE;
}
!g_module_symbol (im_module->library, "im_module_create",
(gpointer *)&im_module->create))
{
- g_warning (g_module_error());
+ g_warning ("%s", g_module_error());
g_module_close (im_module->library);
return FALSE;
static void
correct_libdir_prefix (gchar **path)
{
- /* GTK_LIBDIR here is supposed to still have the definition from
- * Makefile.am, i.e. the build-time value. Do *not* include gtkprivate.h
- * in this file.
- */
+ /* GTK_LIBDIR is the build-time libdir */
if (strncmp (*path, GTK_LIBDIR, strlen (GTK_LIBDIR)) == 0)
{
/* This is an entry put there by make install on the
* builder's machine. Replace the path with the real
* one on this machine.
*/
- extern const gchar *_gtk_get_libdir ();
gchar *tem = *path;
*path = g_strconcat (_gtk_get_libdir (), tem + strlen (GTK_LIBDIR), NULL);
g_free (tem);
static void
correct_localedir_prefix (gchar **path)
{
- /* As above, but for GTK_LOCALEDIR. Use separate function in case
- * GTK_LOCALEDIR isn't a subfolder of GTK_LIBDIR.
- */
+ /* See above */
if (strncmp (*path, GTK_LOCALEDIR, strlen (GTK_LOCALEDIR)) == 0)
{
- extern const gchar *_gtk_get_localedir ();
gchar *tem = *path;
*path = g_strconcat (_gtk_get_localedir (), tem + strlen (GTK_LOCALEDIR), NULL);
g_free (tem);
#endif
-static GtkIMModule *
+G_GNUC_UNUSED static GtkIMModule *
add_builtin_module (const gchar *module_name,
const GtkIMContextInfo **contexts,
int n_contexts)
* @n_contexts: the length of the array stored in @contexts
*
* List all available types of input method context
- **/
+ */
void
_gtk_im_module_list (const GtkIMContextInfo ***contexts,
guint *n_contexts)
* ID @context_id.
*
* Return value: a newly created input context of or @context_id, or
- * if that could not be created, a newly created GtkIMContextSimple.
- **/
+ * if that could not be created, a newly created GtkIMContextSimple.
+ */
GtkIMContext *
_gtk_im_module_create (const gchar *context_id)
{
return 0;
}
+static const gchar *
+lookup_immodule (gchar **immodules_list)
+{
+ while (immodules_list && *immodules_list)
+ {
+ if (g_strcmp0 (*immodules_list, SIMPLE_ID) == 0)
+ return SIMPLE_ID;
+ else
+ {
+ GtkIMModule *module;
+ module = g_hash_table_lookup (contexts_hash, *immodules_list);
+ if (module)
+ return module->contexts[0]->context_id;
+ }
+ immodules_list++;
+ }
+
+ return NULL;
+}
+
/**
* _gtk_im_module_get_default_context_id:
* @client_window: a window
* for the given window.
*
* Return value: the context ID (will never be %NULL)
- **/
+ */
const gchar *
_gtk_im_module_get_default_context_id (GdkWindow *client_window)
{
const gchar *context_id = NULL;
gint best_goodness = 0;
gint i;
- gchar *tmp_locale, *tmp;
+ gchar *tmp_locale, *tmp, **immodules;
const gchar *envvar;
GdkScreen *screen;
GtkSettings *settings;
if (!contexts_hash)
gtk_im_module_initialize ();
- envvar = g_getenv ("GTK_IM_MODULE");
- if (envvar &&
- (strcmp (envvar, SIMPLE_ID) == 0 ||
- g_hash_table_lookup (contexts_hash, envvar)))
- return envvar;
+ envvar = g_getenv("GTK_IM_MODULE");
+ if (envvar)
+ {
+ immodules = g_strsplit(envvar, ":", 0);
+ context_id = lookup_immodule(immodules);
+ g_strfreev(immodules);
+
+ if (context_id)
+ return context_id;
+ }
/* Check if the certain immodule is set in XSETTINGS.
*/
- if (client_window != NULL && GDK_IS_DRAWABLE (client_window))
+ if (GDK_IS_WINDOW (client_window))
{
- screen = gdk_drawable_get_screen (GDK_DRAWABLE (client_window));
- if (screen)
- settings = gtk_settings_get_for_screen (screen);
- else
- settings = gtk_settings_get_default ();
-
+ screen = gdk_window_get_screen (client_window);
+ settings = gtk_settings_get_for_screen (screen);
g_object_get (G_OBJECT (settings), "gtk-im-module", &tmp, NULL);
if (tmp)
{
- if (strcmp (tmp, SIMPLE_ID) == 0)
- context_id = SIMPLE_ID;
- else
- {
- GtkIMModule *module;
- module = g_hash_table_lookup (contexts_hash, tmp);
- if (module)
- context_id = module->contexts[0]->context_id;
- }
+ immodules = g_strsplit(tmp, ":", 0);
+ context_id = lookup_immodule(immodules);
+ g_strfreev(immodules);
g_free (tmp);
- if (context_id)
+ if (context_id)
return context_id;
}
}