Debian Codegraph @

client/gtk4/ibusim.c

raw
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et ts=4: */
3 /* ibus - The Input Bus
4 * Copyright (C) 2008-2010 Peng Huang <[email protected]>
5 * Copyright (C) 2020 Takao Fujiwara <[email protected]>
6 * Copyright (C) 2008-2020 Red Hat, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21 * USA
22 */
23
24 #include <gtk/gtk.h>
25 #include <gtk/gtkimmodule.h>
26 #include <ibus.h>
27 #include "ibusimcontext.h"
28
29 G_MODULE_EXPORT void
30 g_io_im_ibus_load (GTypeModule *type_module)
31 {
32 static gboolean inited = FALSE;
33
34 if (!inited) {
35 ibus_init ();
36 ibus_im_context_register_type (type_module);
37 g_io_extension_point_implement ("gtk-im-module",
38 IBUS_TYPE_IM_CONTEXT,
39 "ibus",
40 50);
41 inited = TRUE;
42 }
43 /* make module resident */
44 g_type_module_use (type_module);
45 }
46
47 G_MODULE_EXPORT void
48 g_io_im_ibus_unload (GTypeModule *type_module)
49 {
50 g_type_module_unuse (type_module);
51 }
52
53 G_MODULE_EXPORT const char *
54 im_get_context_id (int *argc,
55 char ***argv)
56 {
57 GtkIMContext *context;
58 char *preedit_string = NULL;
59 PangoAttrList *preedit_attrs = NULL;
60 const char *context_id;
61
62 gtk_init ();
63 context = gtk_im_multicontext_new ();
64 gtk_im_context_get_preedit_string (context,
65 &preedit_string,
66 &preedit_attrs,
67 0);
68 context_id = gtk_im_multicontext_get_context_id (
69 GTK_IM_MULTICONTEXT (context));
70 return context_id;
71 }
72