Merge branch 'wip/matthiasc/immodule-cleanup' into 'master'

Convert immodules to use an extension point

See merge request GNOME/gtk!34
This commit is contained in:
Matthias Clasen 2018-03-01 06:38:39 +00:00
commit 32873cc94b
33 changed files with 425 additions and 1936 deletions

View File

@ -15,9 +15,4 @@ if [ -z "$DESTDIR" ]; then
echo Updating icon cache...
gtk-update-icon-cache -q -t -f ${gtk_datadir}/icons/hicolor
echo Updating input method modules cache...
gtk_imdir=${gtk_libdir}/gtk-${gtk_api_version}/${gtk_abi_version}
mkdir -p ${gtk_imdir}
gtk4-query-immodules > ${gtk_imdir}/immodules.cache
fi

View File

@ -293,17 +293,6 @@ How to compile GTK+ itself
<cmdsynopsis>
<command>meson</command>
<sbr/>
<group>
<arg choice="plain">-Ddisable-modules=true</arg>
<arg choice="plain">-Ddisable-modules=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dwith-included-immodules=MODULE1,MODULE2,...</arg>
<arg choice="plain">-Dwith-included-immodules=all</arg>
<arg choice="plain">-Dwith-included-immodules=none</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Ddocumentation=true</arg>
<arg choice="plain">-Ddocumentation=false</arg>
@ -315,75 +304,59 @@ How to compile GTK+ itself
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-cups-print-backend=yes</arg>
<arg choice="plain">-Denable-cups-print-backend=no</arg>
<arg choice="plain">-Denable-cups-print-backend=auto</arg>
<arg choice="plain">-Dprint-backends=all</arg>
<arg choice="plain">-Dprint-backends=none</arg>
<arg choice="plain">-Dprint-backends=cups,lpr,...</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-papi-print-backend=yes</arg>
<arg choice="plain">-Denable-papi-print-backend=no</arg>
<arg choice="plain">-Denable-papi-print-backend=auto</arg>
<arg choice="plain">-Dcolord=yes</arg>
<arg choice="plain">-Dcolord=no</arg>
<arg choice="plain">-Dcolord=auto</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-cloudprint-print-backend=yes</arg>
<arg choice="plain">-Denable-cloudprint-print-backend=no</arg>
<arg choice="plain">-Denable-cloudprint-print-backend=auto</arg>
<arg choice="plain">-Dvulkan=yes</arg>
<arg choice="plain">-Dvulkan=no</arg>
<arg choice="plain">-Dvulkan=auto</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-test-print-backend=yes</arg>
<arg choice="plain">-Denable-test-print-backend=no</arg>
<arg choice="plain">-Denable-test-print-backend=auto</arg>
<arg choice="plain">-Dx11-backend=true</arg>
<arg choice="plain">-Dx11-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-colord=yes</arg>
<arg choice="plain">-Denable-colord=no</arg>
<arg choice="plain">-Denable-colord=auto</arg>
<arg choice="plain">-Dcloudproviders=true</arg>
<arg choice="plain">-Dcloudproviders=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-vulkan=yes</arg>
<arg choice="plain">-Denable-vulkan=no</arg>
<arg choice="plain">-Denable-vulkan=auto</arg>
<arg choice="plain">-Dxinerama=yes</arg>
<arg choice="plain">-Dxinerama=no</arg>
<arg choice="plain">-Dxinerama=auto</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-x11-backend=true</arg>
<arg choice="plain">-Denable-x11-backend=false</arg>
<arg choice="plain">-Dwin32-backend=true</arg>
<arg choice="plain">-Dwin32-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-xinerama=true</arg>
<arg choice="plain">-Denable-xinerama=false</arg>
<arg choice="plain">-Dquartz-backend=true</arg>
<arg choice="plain">-Dquartz-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-win32-backend=true</arg>
<arg choice="plain">-Denable-win32-backend=false</arg>
<arg choice="plain">-Dbroadway-backend=true</arg>
<arg choice="plain">-Dbroadway-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-quartz-backend=true</arg>
<arg choice="plain">-Denable-quartz-backend=false</arg>
<arg choice="plain">-Dwayland-backend=true</arg>
<arg choice="plain">-Dwayland-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-broadway-backend=true</arg>
<arg choice="plain">-Denable-broadway-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-wayland-backend=true</arg>
<arg choice="plain">-Denable-wayland-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Denable-mir-backend=true</arg>
<arg choice="plain">-Denable-mir-backend=false</arg>
</group>
<group>
<arg choice="plain">-Dintrospection=true</arg>
<arg choice="plain">-Dintrospection=false</arg>
@ -392,33 +365,7 @@ How to compile GTK+ itself
</para>
<formalpara>
<title><systemitem>disable-modules</systemitem></title>
<para>
Normally GTK+ will try to build the input method modules
as little shared libraries that are loaded on demand.
The <systemitem>disable-modules</systemitem> option
indicates that they should all be built statically
into the GTK+ library instead. This is useful for
people who need to produce statically-linked binaries.
If <systemitem>disable-modules</systemitem> is not specified,
then the <command>configure</command> script will try to
auto-detect whether shared modules work on your system.
</para>
</formalpara>
<formalpara>
<title><systemitem>with-included-immodules</systemitem></title>
<para>
This option allows you to specify which input method modules you
want to include directly into the GTK+ shared library, as opposed
to building them as loadable modules.
</para>
</formalpara>
<formalpara>
<title><systemitem>enable-xinerama</systemitem></title>
<title><systemitem>xinerama</systemitem></title>
<para>
By default GTK+ will try to link against the Xinerama libraries
@ -428,8 +375,8 @@ How to compile GTK+ itself
</formalpara>
<formalpara>
<title><systemitem>enable-documentation</systemitem> and
<systemitem>enable-man-pages</systemitem></title>
<title><systemitem>documentation</systemitem> and
<systemitem>man-pages</systemitem></title>
<para>
The <application>gtk-doc</application> package is
@ -440,38 +387,33 @@ How to compile GTK+ itself
<application>gtk-doc</application> installed and
are modifying GTK+, you may want to enable
<application>gtk-doc</application> support by passing
in <systemitem>enable-documentation</systemitem>.
in <systemitem>documentation</systemitem>.
</para>
<para>
Additionally, some tools provided by GTK+ have their own
manual pages generated using a similar set of dependencies;
if you have <application>xsltproc</application> then you
can generate manual pages by passing <systemitem>enable-man-pages</systemitem>
can generate manual pages by passing <systemitem>man-pages</systemitem>
when configuring the build.
</para>
</formalpara>
<formalpara>
<title><systemitem>enable-cups-print-backend</systemitem>,
<systemitem>enable-papi-print-backend</systemitem>,
<systemitem>enable-cloudprint-print-backend</systemitem>, and
<systemitem>enable-test-print-backend</systemitem></title>
<title><systemitem>print-backends</systemitem></title>
<para>
By default, GTK+ will try to build various print backends if
their dependencies are found. These options can be used to
explicitly control whether each print backend should be built
or not.
their dependencies are found. This option can be used to
explicitly control which print backends should be built.
</para>
</formalpara>
<formalpara>
<title><systemitem>enable-x11-backend</systemitem>,
<systemitem>enable-win32-backend</systemitem>,
<systemitem>enable-quartz-backend</systemitem>,
<systemitem>enable-broadway-backend</systemitem>,
<systemitem>enable-wayland-backend</systemitem>, and
<systemitem>enable-mir-backend</systemitem></title>
<title><systemitem>x11-backend</systemitem>,
<systemitem>win32-backend</systemitem>,
<systemitem>quartz-backend</systemitem>,
<systemitem>broadway-backend</systemitem> and
<systemitem>wayland-backend</systemitem></title>
<para>
Enable specific backends for GDK. If none of these options
@ -496,8 +438,9 @@ How to compile GTK+ itself
</formalpara>
<formalpara>
<title><systemitem>build-tests</systemitem>
<systemitem>demos</systemitem></title>
<title><systemitem>build-tests</systemitem>,
<systemitem>install-tests</systemitem>,
<systemitem>demos</systemitem></title>
<para>
By default, GTK+ will build quite a few tests and demos.

View File

@ -351,7 +351,6 @@
<xi:include href="gtk4-demo-application.xml" />
<xi:include href="gtk4-widget-factory.xml" />
<xi:include href="gtk4-icon-browser.xml" />
<xi:include href="gtk4-query-immodules.xml" />
<xi:include href="gtk4-update-icon-cache.xml" />
<xi:include href="gtk4-encode-symbolic-svg.xml" />
<xi:include href="gtk4-builder-tool.xml" />

View File

@ -1,96 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gtk4-query-immodules">
<refentryinfo>
<title>gtk4-query-immodules</title>
<productname>GTK+</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Matthias</firstname>
<surname>Clasen</surname>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>gtk4-query-immodules</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">User Commands</refmiscinfo>
</refmeta>
<refnamediv>
<refname>gtk4-query-immodules</refname>
<refpurpose>Input method module registration utility</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>gtk4-query-immodules</command>
<arg choice="opt">--update-cache</arg>
<arg choice="opt" rep="repeat">MODULE</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>
<command>gtk4-query-immodules</command> collects information about loadable
input method modules for GTK+ and writes it to the default cache file
location, or to <filename>stdout</filename>.
</para>
<para>
If called without arguments, it looks for modules in the GTK+ input method
module path.
</para>
<para>
If called with arguments, it looks for the specified modules. The arguments
may be absolute or relative paths.
</para>
<para>
Normally, the output of <command>gtk4-query-immodules</command> is written
to <filename><replaceable>libdir</replaceable>/gtk-4.0/4.0.0/immodules.cache</filename>,
where GTK+ looks for it by default. If it is written to some other location,
the <envar>GTK_IM_MODULE_FILE</envar> environment variable can be set to point
GTK+ at the file.
</para>
</refsect1>
<refsect1><title>Options</title>
<variablelist>
<varlistentry>
<term>--update-cache</term>
<listitem><para>Write the output to the default cache location instead of
<filename>stdout</filename></para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1><title>Files</title>
<variablelist>
<varlistentry>
<term><filename><replaceable>libdir</replaceable>/gtk-4.0/4.0.0/immodules.cache</filename></term>
<listitem><para>The default im cache file used by GTK+ applications</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1><title>Environment</title>
<variablelist>
<varlistentry>
<term><link linkend="gtk-path"><envar>GTK_PATH</envar></link></term>
<listitem><para>Prepends directories to the input method module path</para></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gtk-im-module-file"><envar>GTK_IM_MODULE_FILE</envar></link></term>
<listitem><para>Specifies an alternative im module cache for GTK+
applications</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>

View File

@ -1533,7 +1533,6 @@ GtkImageGIconData
<TITLE>GtkIMContext</TITLE>
GtkIMContext
GtkIMContextClass
GtkIMContextInfo
gtk_im_context_get_preedit_string
gtk_im_context_filter_keypress
gtk_im_context_focus_in

View File

@ -158,7 +158,6 @@ content_files = [
'gtk4-encode-symbolic-svg.xml',
'gtk4-icon-browser.xml',
'gtk4-launch.xml',
'gtk4-query-immodules.xml',
'gtk4-query-settings.xml',
'gtk4-update-icon-cache.xml',
'gtk4-widget-factory.xml',
@ -261,7 +260,6 @@ if get_option('man-pages') and xsltproc.found()
[ 'gtk4-encode-symbolic-svg', '1', ],
[ 'gtk4-icon-browser', '1', ],
[ 'gtk4-launch', '1', ],
[ 'gtk4-query-immodules', '1', ],
[ 'gtk4-query-settings', '1', ],
[ 'gtk4-update-icon-cache', '1', ],
[ 'gtk4-widget-factory', '1', ],

View File

@ -183,27 +183,6 @@ additional environment variables.
</para>
</formalpara>
<formalpara id="gtk-im-module-file">
<title><envar>GTK_IM_MODULE_FILE</envar></title>
<para>
Specifies the file listing the IM modules to load. This environment
variable the default value
<filename><replaceable>libdir</replaceable>/gtk-4.0/4.0.0/immodules.cache</filename>
(<replaceable>libdir</replaceable> has the same meaning here as explained for <envar>GTK_PATH</envar>).
</para>
<para>
The <filename>immodules.cache</filename> file is generated by the
<command>gtk-query-immodules-3.0</command> utility.
</para>
<warning>
Note that this environment variable is read by GTK+ 2.x too, which
makes it unsuitable for setting it system-wide (or session-wide),
since doing so will cause either GTK+ 2.x applications or GTK+ 3
applications to see the wrong list of IM modules.
</warning>
</formalpara>
<formalpara>
<title><envar>GTK_EXE_PREFIX</envar></title>

View File

@ -125,7 +125,6 @@
#include <gtk/gtkiconview.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkimcontext.h>
#include <gtk/gtkimcontextinfo.h>
#include <gtk/gtkimcontextsimple.h>
#include <gtk/gtkimmulticontext.h>
#include <gtk/gtkinfobar.h>

View File

@ -21,15 +21,15 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtk/gtkimcontextbroadway.h"
#include "gtk/gtkintl.h"
#include "gtk/gtkimmodule.h"
#include "gdk/broadway/gdkbroadway.h"
#define GTK_IM_CONTEXT_TYPE_BROADWAY (type_broadway)
#define GTK_IM_CONTEXT_BROADWAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_IM_CONTEXT_TYPE_BROADWAY, GtkIMContextBroadway))
#define GTK_IM_CONTEXT_BROADWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_IM_CONTEXT_TYPE_BROADWAY, GtkIMContextBroadwayClass))
#define GTK_TYPE_IM_CONTEXT_BROADWAY (gtk_im_context_broadway_get_type ())
#define GTK_IM_CONTEXT_BROADWAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_BROADWAY, GtkIMContextBroadway))
#define GTK_IM_CONTEXT_BROADWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_IM_CONTEXT_BROADWAY, GtkIMContextBroadwayClass))
typedef struct _GtkIMContextBroadway
{
@ -42,28 +42,11 @@ typedef struct _GtkIMContextBroadwayClass
GtkIMContextSimpleClass parent_class;
} GtkIMContextBroadwayClass;
GType type_broadway = 0;
static GObjectClass *parent_class;
static const GtkIMContextInfo imbroadway_info =
{
"broadway", /* ID */
NC_("input method menu", "Broadway"), /* Human readable name */
GETTEXT_PACKAGE, /* Translation domain */
GTK_LOCALEDIR, /* Dir for bindtextdomain (not strictly needed for "gtk+") */
"", /* Languages for which this module is the default */
};
static const GtkIMContextInfo *info_list[] =
{
&imbroadway_info,
};
#ifndef INCLUDE_IM_broadway
#define MODULE_ENTRY(type,function) G_MODULE_EXPORT type im_module_ ## function
#else
#define MODULE_ENTRY(type, function) type _gtk_immodule_broadway_ ## function
#endif
G_DEFINE_TYPE_WITH_CODE (GtkIMContextBroadway, gtk_im_context_broadway, GTK_TYPE_IM_CONTEXT_SIMPLE,
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
g_define_type_id,
"broadway",
10))
static void
broadway_set_client_widget (GtkIMContext *context, GtkWidget *widget)
@ -100,9 +83,9 @@ broadway_focus_out (GtkIMContext *context)
}
static void
gtk_im_context_broadway_class_init (GtkIMContextClass *klass)
gtk_im_context_broadway_class_init (GtkIMContextBroadwayClass *class)
{
parent_class = g_type_class_peek_parent (klass);
GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
klass->focus_in = broadway_focus_in;
klass->focus_out = broadway_focus_out;
@ -110,52 +93,6 @@ gtk_im_context_broadway_class_init (GtkIMContextClass *klass)
}
static void
gtk_im_context_broadway_init (GtkIMContext *im_context)
gtk_im_context_broadway_init (GtkIMContextBroadway *im_context)
{
}
static void
gtk_im_context_broadway_register_type (GTypeModule *module)
{
const GTypeInfo object_info =
{
sizeof (GtkIMContextBroadwayClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_im_context_broadway_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkIMContextBroadway),
0,
(GInstanceInitFunc) gtk_im_context_broadway_init,
};
type_broadway =
g_type_module_register_type (module,
GTK_TYPE_IM_CONTEXT_SIMPLE,
"GtkIMContextBroadway",
&object_info, 0);
}
MODULE_ENTRY (void, init) (GTypeModule * module)
{
gtk_im_context_broadway_register_type (module);
}
MODULE_ENTRY (void, exit) (void)
{
}
MODULE_ENTRY (void, list) (const GtkIMContextInfo *** contexts, int *n_contexts)
{
*contexts = info_list;
*n_contexts = G_N_ELEMENTS (info_list);
}
MODULE_ENTRY (GtkIMContext *, create) (const gchar * context_id)
{
if (!strcmp (context_id, "broadway"))
return g_object_new (type_broadway, NULL);
else
return NULL;
}

View File

@ -15,30 +15,15 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_IM_CONTEXT_INFO_H__
#define __GTK_IM_CONTEXT_INFO_H__
#ifndef __GTK_IM_CONTEXT_BROADWAY_H__
#define __GTK_IM_CONTEXT_BROADWAY_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <glib.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef struct _GtkIMContextInfo GtkIMContextInfo;
struct _GtkIMContextInfo
{
const gchar *context_id;
const gchar *context_name;
const gchar *domain;
const gchar *domain_dirname;
const gchar *default_locales;
};
GType gtk_im_context_broadway_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_IM_CONTEXT_INFO_H__ */
#endif /* __GTK_IM_CONTEXT_BROADWAY_H__ */

View File

@ -125,30 +125,14 @@ static void cb_client_widget_hierarchy_changed (GtkWidget *widget,
GtkWidget *widget2,
GtkIMContextIME *context_ime);
GType gtk_type_im_context_ime = 0;
static GObjectClass *parent_class;
#define GTK_TYPE_IM_CONTEXT_IME (gtk_im_context_ime_get_type ())
#define GTK_IM_CONTEXT_IME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_IME, GtkIMContextIME))
void
gtk_im_context_ime_register_type (GTypeModule *type_module)
{
const GTypeInfo im_context_ime_info = {
sizeof (GtkIMContextIMEClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_im_context_ime_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkIMContextIME),
0,
(GInstanceInitFunc) gtk_im_context_ime_init,
};
gtk_type_im_context_ime =
g_type_module_register_type (type_module,
GTK_TYPE_IM_CONTEXT,
"GtkIMContextIME", &im_context_ime_info, 0);
}
G_DEFINE_TYPE_WITH_CODE (GtkIMContextIME, gtk_im_context_ime, GTK_TYPE_IM_CONTEXT,
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
g_define_type_id,
"ime",
10))
static void
gtk_im_context_ime_class_init (GtkIMContextIMEClass *class)
@ -156,8 +140,6 @@ gtk_im_context_ime_class_init (GtkIMContextIMEClass *class)
GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class);
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
parent_class = g_type_class_peek_parent (class);
gobject_class->finalize = gtk_im_context_ime_finalize;
gobject_class->dispose = gtk_im_context_ime_dispose;
gobject_class->set_property = gtk_im_context_ime_set_property;
@ -173,7 +155,6 @@ gtk_im_context_ime_class_init (GtkIMContextIMEClass *class)
im_context_class->set_use_preedit = gtk_im_context_ime_set_use_preedit;
}
static void
gtk_im_context_ime_init (GtkIMContextIME *context_ime)
{
@ -501,7 +482,7 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret)
g_warning ("%s", error->message);
g_error_free (error);
}
if (pos_ret)
{
pos = ImmGetCompositionStringW (himc, GCS_CURSORPOS, NULL, 0);
@ -922,7 +903,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
/* Try to make sure we use a font that actually can show the
* language in question.
*/
*/
switch (PRIMARYLANGID (LOWORD (ime)))
{
@ -959,7 +940,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
&font_desc,
NULL);
gtk_style_context_restore (style);
if (lang[0])
{
/* We know what language it is. Look for a character, any

View File

@ -21,8 +21,6 @@
#include <gtk/gtk.h>
extern GType gtk_type_im_context_ime;
#define GTK_TYPE_IM_CONTEXT_IME gtk_type_im_context_ime
#define GTK_IM_CONTEXT_IME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_IME, GtkIMContextIME))
#define GTK_IM_CONTEXT_IME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IM_CONTEXT_IME, GtkIMContextIMEClass))

View File

@ -21,7 +21,7 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtk/gtkimcontextquartz.h"
#include "gtk/gtkintl.h"
#include "gtk/gtkimmodule.h"
@ -32,6 +32,7 @@
#define GTK_IM_CONTEXT_QUARTZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartz))
#define GTK_IM_CONTEXT_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartzClass))
typedef struct _GtkIMContextQuartz
{
GtkIMContext parent;
@ -49,28 +50,11 @@ typedef struct _GtkIMContextQuartzClass
GtkIMContextClass parent_class;
} GtkIMContextQuartzClass;
GType type_quartz = 0;
static GObjectClass *parent_class;
static const GtkIMContextInfo imquartz_info =
{
"quartz",
NC_("input method menu", "Mac OS X Quartz"),
GETTEXT_PACKAGE,
GTK_LOCALEDIR,
"ja:ko:zh:*",
};
static const GtkIMContextInfo *info_list[] =
{
&imquartz_info,
};
#ifndef INCLUDE_IM_quartz
#define MODULE_ENTRY(type,function) G_MODULE_EXPORT type im_module_ ## function
#else
#define MODULE_ENTRY(type, function) type _gtk_immodule_quartz_ ## function
#endif
G_DEFINE_TYPE_WITH_CODE (GtkIMContextQuartz, gtk_im_context_quartz, GTK_TYPE_IM_CONTEXT,
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
g_define_type_id,
"quartz",
10))
static void
quartz_get_preedit_string (GtkIMContext *context,
@ -359,16 +343,16 @@ imquartz_finalize (GObject *obj)
g_signal_handlers_disconnect_by_func (qc->slave, (gpointer)commit_cb, qc);
g_object_unref (qc->slave);
parent_class->finalize (obj);
gtk_im_context_quartz_parent_class->finalize (obj);
}
static void
gtk_im_context_quartz_class_init (GtkIMContextClass *klass)
gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
{
GTK_NOTE (MISC, g_print ("gtk_im_context_quartz_class_init\n"));
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
klass->get_preedit_string = quartz_get_preedit_string;
klass->filter_keypress = quartz_filter_keypress;
@ -383,11 +367,10 @@ gtk_im_context_quartz_class_init (GtkIMContextClass *klass)
}
static void
gtk_im_context_quartz_init (GtkIMContext *im_context)
gtk_im_context_quartz_init (GtkIMContextQuartz *qc)
{
GTK_NOTE (MISC, g_print ("gtk_im_context_quartz_init\n"));
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (im_context);
qc->preedit_str = g_strdup ("");
qc->cursor_index = 0;
qc->selected_len = 0;
@ -397,54 +380,3 @@ gtk_im_context_quartz_init (GtkIMContext *im_context)
qc->slave = g_object_new (GTK_TYPE_IM_CONTEXT_SIMPLE, NULL);
g_signal_connect (G_OBJECT (qc->slave), "commit", G_CALLBACK (commit_cb), qc);
}
static void
gtk_im_context_quartz_register_type (GTypeModule *module)
{
const GTypeInfo object_info =
{
sizeof (GtkIMContextQuartzClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_im_context_quartz_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkIMContextQuartz),
0,
(GInstanceInitFunc) gtk_im_context_quartz_init,
};
type_quartz =
g_type_module_register_type (module,
GTK_TYPE_IM_CONTEXT,
"GtkIMContextQuartz",
&object_info, 0);
}
MODULE_ENTRY (void, init) (GTypeModule * module)
{
gtk_im_context_quartz_register_type (module);
}
MODULE_ENTRY (void, exit) (void)
{
}
MODULE_ENTRY (void, list) (const GtkIMContextInfo *** contexts, int *n_contexts)
{
*contexts = info_list;
*n_contexts = G_N_ELEMENTS (info_list);
}
MODULE_ENTRY (GtkIMContext *, create) (const gchar * context_id)
{
g_return_val_if_fail (context_id, NULL);
if (!strcmp (context_id, "quartz"))
{
GTK_NOTE (MISC, g_print ("immodule_quartz create\n"));
return g_object_new (type_quartz, NULL);
}
else
return NULL;
}

29
gtk/gtkimcontextquartz.h Normal file
View File

@ -0,0 +1,29 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2018 Red Hat Software
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_IM_CONTEXT_QUARTZ_H__
#define __GTK_IM_CONTEXT_QUARTZ_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
GType gtk_im_context_quartz_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_IM_CONTEXT_QUARTZ_H__ */

View File

@ -40,6 +40,7 @@
#include "gtkdebug.h"
#include "gtkintl.h"
#include "gtkcomposetable.h"
#include "gtkimmodule.h"
#include "gtkimcontextsimpleprivate.h"
#include "gtkimcontextsimpleseqs.h"
@ -164,7 +165,12 @@ static void gtk_im_context_simple_get_preedit_string (GtkIMContext
static void gtk_im_context_simple_set_client_widget (GtkIMContext *context,
GtkWidget *widget);
G_DEFINE_TYPE_WITH_PRIVATE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT)
G_DEFINE_TYPE_WITH_CODE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT,
G_ADD_PRIVATE (GtkIMContextSimple)
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
g_define_type_id,
"gtk-im-context-simple",
10))
static void
gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class)

View File

@ -20,7 +20,7 @@
#include <string.h>
#include <wayland-client-protocol.h>
#include <gtk/gtk.h>
#include "gtk/gtkimcontextwayland.h"
#include "gtk/gtkintl.h"
#include "gtk/gtkimmodule.h"
@ -70,31 +70,15 @@ struct _GtkIMContextWayland
guint use_preedit : 1;
};
GType type_wayland = 0;
static GObjectClass *parent_class;
G_DEFINE_TYPE_WITH_CODE (GtkIMContextWayland, gtk_im_context_wayland, GTK_TYPE_IM_CONTEXT,
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
g_define_type_id,
"wayland",
10));
static GtkIMContextWaylandGlobal *global = NULL;
static const GtkIMContextInfo imwayland_info =
{
"wayland", /* ID */
NC_("input method menu", "Wayland"), /* Human readable name */
GETTEXT_PACKAGE, /* Translation domain */
GTK_LOCALEDIR, /* Dir for bindtextdomain (not strictly needed for "gtk+") */
"", /* Languages for which this module is the default */
};
static const GtkIMContextInfo *info_list[] =
{
&imwayland_info,
};
#define GTK_IM_CONTEXT_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), type_wayland, GtkIMContextWayland))
#ifndef INCLUDE_IM_wayland
#define MODULE_ENTRY(type,function) G_MODULE_EXPORT type im_module_ ## function
#else
#define MODULE_ENTRY(type, function) type _gtk_immodule_wayland_ ## function
#endif
#define GTK_IM_CONTEXT_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), gtk_im_context_wayland_get_type (), GtkIMContextWayland))
static void
reset_preedit (GtkIMContextWayland *context)
@ -237,7 +221,8 @@ static const struct wl_registry_listener registry_listener = {
static void
gtk_im_context_wayland_global_init (GdkDisplay *display)
{
g_return_if_fail (global == NULL);
if (global != NULL)
return;
global = g_new0 (GtkIMContextWaylandGlobal, 1);
global->display = gdk_wayland_display_get_wl_display (display);
@ -339,6 +324,8 @@ translate_purpose (GtkInputPurpose purpose)
return GTK_TEXT_INPUT_CONTENT_PURPOSE_PASSWORD;
case GTK_INPUT_PURPOSE_PIN:
return GTK_TEXT_INPUT_CONTENT_PURPOSE_PIN;
default:
g_assert_not_reached ();
}
return GTK_TEXT_INPUT_CONTENT_PURPOSE_NORMAL;
@ -395,7 +382,7 @@ gtk_im_context_wayland_finalize (GObject *object)
g_clear_object (&context->widget);
g_clear_object (&context->gesture);
G_OBJECT_CLASS (parent_class)->finalize (object);
G_OBJECT_CLASS (gtk_im_context_wayland_parent_class)->finalize (object);
}
static void
@ -470,9 +457,9 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
gint *cursor_pos)
{
GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
gchar *preedit_str;
const char *preedit_str;
GTK_IM_CONTEXT_CLASS (parent_class)->get_preedit_string (context, str, attrs, cursor_pos);
GTK_IM_CONTEXT_CLASS (gtk_im_context_wayland_parent_class)->get_preedit_string (context, str, attrs, cursor_pos);
/* If the parent implementation returns a len>0 string, go with it */
if (str && *str && **str)
@ -499,7 +486,7 @@ gtk_im_context_wayland_filter_keypress (GtkIMContext *context,
GdkEventKey *key)
{
/* This is done by the compositor */
return GTK_IM_CONTEXT_CLASS (parent_class)->filter_keypress (context, key);
return GTK_IM_CONTEXT_CLASS (gtk_im_context_wayland_parent_class)->filter_keypress (context, key);
}
static void
@ -535,7 +522,7 @@ gtk_im_context_wayland_reset (GtkIMContext *context)
{
reset_preedit (GTK_IM_CONTEXT_WAYLAND (context));
GTK_IM_CONTEXT_CLASS (parent_class)->reset (context);
GTK_IM_CONTEXT_CLASS (gtk_im_context_wayland_parent_class)->reset (context);
}
static void
@ -613,8 +600,6 @@ gtk_im_context_wayland_class_init (GtkIMContextWaylandClass *klass)
im_context_class->set_use_preedit = gtk_im_context_wayland_set_use_preedit;
im_context_class->set_surrounding = gtk_im_context_wayland_set_surrounding;
im_context_class->get_surrounding = gtk_im_context_wayland_get_surrounding;
parent_class = g_type_class_peek_parent (klass);
}
static void
@ -627,52 +612,11 @@ on_content_type_changed (GtkIMContextWayland *context)
static void
gtk_im_context_wayland_init (GtkIMContextWayland *context)
{
gtk_im_context_wayland_global_init (gdk_display_get_default ());
context->use_preedit = TRUE;
g_signal_connect_swapped (context, "notify::input-purpose",
G_CALLBACK (on_content_type_changed), context);
g_signal_connect_swapped (context, "notify::input-hints",
G_CALLBACK (on_content_type_changed), context);
}
static void
gtk_im_context_wayland_register_type (GTypeModule *module)
{
const GTypeInfo object_info = {
sizeof (GtkIMContextWaylandClass),
NULL, NULL,
(GClassInitFunc) gtk_im_context_wayland_class_init,
NULL, NULL,
sizeof (GtkIMContextWayland),
0,
(GInstanceInitFunc) gtk_im_context_wayland_init,
};
type_wayland = g_type_module_register_type (module,
GTK_TYPE_IM_CONTEXT_SIMPLE,
"GtkIMContextWayland",
&object_info, 0);
}
MODULE_ENTRY (void, init) (GTypeModule * module)
{
gtk_im_context_wayland_register_type (module);
gtk_im_context_wayland_global_init (gdk_display_get_default ());
}
MODULE_ENTRY (void, exit) (void)
{
}
MODULE_ENTRY (void, list) (const GtkIMContextInfo *** contexts, int *n_contexts)
{
*contexts = info_list;
*n_contexts = G_N_ELEMENTS (info_list);
}
MODULE_ENTRY (GtkIMContext *, create) (const gchar * context_id)
{
if (strcmp (context_id, "wayland") == 0)
return g_object_new (type_wayland, NULL);
else
return NULL;
}

29
gtk/gtkimcontextwayland.h Normal file
View File

@ -0,0 +1,29 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2018 Red Hat Software
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_IM_CONTEXT_WAYLAND_H__
#define __GTK_IM_CONTEXT_WAYLAND_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
GType gtk_im_context_wayland_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_IM_CONTEXT_WAYLAND_H__ */

View File

@ -21,6 +21,7 @@
#include <stdlib.h>
#include "gtkimcontextxim.h"
#include "gtkimmodule.h"
#include "gtk/gtkintl.h"
@ -51,7 +52,7 @@ struct _GtkIMContextXIM
XIMFeedback *feedbacks;
gint preedit_cursor;
XIMCallback preedit_start_callback;
XIMCallback preedit_done_callback;
XIMCallback preedit_draw_callback;
@ -95,7 +96,7 @@ struct _GtkXIMInfo
struct _StatusWindow
{
GtkWidget *window;
/* Toplevel window to which the status window corresponds */
GtkWidget *toplevel;
@ -103,8 +104,6 @@ struct _StatusWindow
GtkIMContextXIM *context;
};
static void gtk_im_context_xim_class_init (GtkIMContextXIMClass *class);
static void gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim);
static void gtk_im_context_xim_finalize (GObject *obj);
static void gtk_im_context_xim_set_client_widget (GtkIMContext *context,
GtkWidget *widget);
@ -145,38 +144,17 @@ static void xim_info_display_closed (GdkDisplay *display,
gboolean is_error,
GtkXIMInfo *info);
static GObjectClass *parent_class;
GType gtk_type_im_context_xim = 0;
G_DEFINE_TYPE_WITH_CODE (GtkIMContextXIM, gtk_im_context_xim, GTK_TYPE_IM_CONTEXT,
g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
g_define_type_id,
"xim",
10))
static GSList *open_ims = NULL;
/* List of status windows for different toplevels */
static GSList *status_windows = NULL;
void
gtk_im_context_xim_register_type (GTypeModule *type_module)
{
const GTypeInfo im_context_xim_info =
{
sizeof (GtkIMContextXIMClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gtk_im_context_xim_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkIMContextXIM),
0,
(GInstanceInitFunc) gtk_im_context_xim_init,
};
gtk_type_im_context_xim =
g_type_module_register_type (type_module,
GTK_TYPE_IM_CONTEXT,
"GtkIMContextXIM",
&im_context_xim_info, 0);
}
#define PREEDIT_MASK (XIMPreeditCallbacks | XIMPreeditPosition | \
XIMPreeditArea | XIMPreeditNothing | XIMPreeditNone)
#define STATUS_MASK (XIMStatusCallbacks | XIMStatusArea | \
@ -184,11 +162,11 @@ gtk_im_context_xim_register_type (GTypeModule *type_module)
#define ALLOWED_MASK (XIMPreeditCallbacks | XIMPreeditNothing | XIMPreeditNone | \
XIMStatusCallbacks | XIMStatusNothing | XIMStatusNone)
static XIMStyle
choose_better_style (XIMStyle style1, XIMStyle style2)
static XIMStyle
choose_better_style (XIMStyle style1, XIMStyle style2)
{
XIMStyle s1, s2, u;
XIMStyle s1, s2, u;
if (style1 == 0) return style2;
if (style2 == 0) return style1;
if ((style1 & (PREEDIT_MASK | STATUS_MASK))
@ -286,7 +264,7 @@ setup_im (GtkXIMInfo *info)
if (ic_values)
{
int i;
for (i = 0; i < ic_values->count_values; i++)
if (strcmp (ic_values->supported_values[i],
XNStringConversionCallback) == 0)
@ -301,7 +279,7 @@ setup_im (GtkXIMInfo *info)
for (i = 0; i < xim_styles->count_styles; i++)
g_print ("%#x\n", xim_styles->supported_styles[i]);
#endif
XFree (ic_values);
}
@ -415,7 +393,7 @@ xim_destroy_callback (XIM xim,
reinitialize_all_ics (info);
xim_info_try_im (info);
return;
}
}
static GtkXIMInfo *
get_im (GdkWindow *client_window,
@ -475,8 +453,6 @@ gtk_im_context_xim_class_init (GtkIMContextXIMClass *class)
GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class);
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
parent_class = g_type_class_peek_parent (class);
im_context_class->set_client_widget = gtk_im_context_xim_set_client_widget;
im_context_class->filter_keypress = gtk_im_context_xim_filter_keypress;
im_context_class->reset = gtk_im_context_xim_reset;
@ -505,7 +481,7 @@ gtk_im_context_xim_finalize (GObject *obj)
context_xim->finalizing = TRUE;
if (context_xim->im_info && !context_xim->im_info->ics->next)
if (context_xim->im_info && !context_xim->im_info->ics->next)
{
if (context_xim->im_info->reconnecting)
{
@ -534,7 +510,7 @@ gtk_im_context_xim_finalize (GObject *obj)
g_free (context_xim->locale);
g_free (context_xim->mb_charset);
G_OBJECT_CLASS (parent_class)->finalize (obj);
G_OBJECT_CLASS (gtk_im_context_xim_parent_class)->finalize (obj);
}
static void
@ -553,7 +529,7 @@ reinitialize_ic (GtkIMContextXIM *context_xim)
g_signal_emit_by_name (context_xim, "preedit-changed");
}
}
/*
/*
reset filter_key_release flag, otherwise keystrokes will be doubled
until reconnecting to XIM.
*/
@ -570,7 +546,7 @@ set_ic_client_window (GtkIMContextXIM *context_xim,
context_xim->im_info->ics = g_slist_remove (context_xim->im_info->ics, context_xim);
context_xim->im_info = NULL;
}
context_xim->client_window = client_window;
context_xim->client_window_xid = None;
@ -590,7 +566,7 @@ set_ic_client_window (GtkIMContextXIM *context_xim,
}
}
}
update_client_widget (context_xim);
}
@ -615,7 +591,7 @@ gtk_im_context_xim_new (void)
result = g_object_new (GTK_TYPE_IM_CONTEXT_XIM, NULL);
result->locale = g_strdup (setlocale (LC_CTYPE, NULL));
g_get_charset (&charset);
result->mb_charset = g_strdup (charset);
@ -642,7 +618,7 @@ mb_to_utf8 (GtkIMContextXIM *context_xim,
g_error_free (error);
}
}
return result;
}
@ -687,12 +663,12 @@ gtk_im_context_xim_filter_keypress (GtkIMContext *context,
xevent.state = state;
xevent.keycode = gdk_event_get_scancode ((GdkEvent *) event);
xevent.same_screen = True;
if (XFilterEvent ((XEvent *)&xevent, context_xim->client_window_xid))
return TRUE;
if (state &
(gtk_accelerator_get_default_mod_mask () & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK)))
(gtk_accelerator_get_default_mod_mask () & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK)))
return FALSE;
again:
@ -707,7 +683,7 @@ gtk_im_context_xim_filter_keypress (GtkIMContext *context,
if (status == XBufferOverflow)
{
buffer_size = num_bytes;
if (buffer != static_buffer)
if (buffer != static_buffer)
g_free (buffer);
buffer = g_malloc (num_bytes + 1);
goto again;
@ -734,12 +710,12 @@ gtk_im_context_xim_filter_keypress (GtkIMContext *context,
g_signal_emit_by_name (context, "commit", result_utf8);
result = TRUE;
}
g_free (result_utf8);
}
}
if (buffer != static_buffer)
if (buffer != static_buffer)
g_free (buffer);
return result;
@ -756,7 +732,7 @@ gtk_im_context_xim_focus_in (GtkIMContext *context)
context_xim->has_focus = TRUE;
update_status_window (context_xim);
if (ic)
XSetICFocus (ic);
}
@ -772,10 +748,10 @@ gtk_im_context_xim_focus_out (GtkIMContext *context)
if (context_xim->has_focus)
{
XIC ic = gtk_im_context_xim_get_ic (context_xim);
context_xim->has_focus = FALSE;
update_status_window (context_xim);
if (ic)
XUnsetICFocus (ic);
}
@ -841,7 +817,7 @@ gtk_im_context_xim_reset (GtkIMContext *context)
if (!ic)
return;
if (context_xim->preedit_length == 0)
return;
@ -899,7 +875,7 @@ add_feedback_attr (PangoAttrList *attrs,
gint end_pos)
{
PangoAttribute *attr;
gint start_index = g_utf8_offset_to_pointer (str, start_pos) - str;
gint end_index = g_utf8_offset_to_pointer (str, end_pos) - str;
@ -931,7 +907,7 @@ add_feedback_attr (PangoAttrList *attrs,
g_warning ("Unrendered feedback style: %#lx", feedback & ~FEEDBACK_MASK);
}
static void
static void
gtk_im_context_xim_get_preedit_string (GtkIMContext *context,
gchar **str,
PangoAttrList **attrs,
@ -945,7 +921,7 @@ gtk_im_context_xim_get_preedit_string (GtkIMContext *context,
int i;
XIMFeedback last_feedback = 0;
gint start = -1;
*attrs = pango_attr_list_new ();
for (i = 0; i < context_xim->preedit_length; i++)
@ -955,7 +931,7 @@ gtk_im_context_xim_get_preedit_string (GtkIMContext *context,
{
if (start >= 0)
add_feedback_attr (*attrs, utf8, last_feedback, start, i);
last_feedback = new_feedback;
start = i;
}
@ -981,12 +957,12 @@ preedit_start_callback (XIC xic,
{
GtkIMContext *context = GTK_IM_CONTEXT (client_data);
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
if (!context_xim->finalizing)
g_signal_emit_by_name (context, "preedit-start");
return -1; /* No length limit */
}
}
static void
preedit_done_callback (XIC xic,
@ -1005,7 +981,7 @@ preedit_done_callback (XIC xic,
if (!context_xim->finalizing)
g_signal_emit_by_name (context, "preedit-end");
}
}
static gint
xim_text_to_utf8 (GtkIMContextXIM *context, XIMText *xim_text, gchar **text)
@ -1031,11 +1007,11 @@ xim_text_to_utf8 (GtkIMContextXIM *context, XIMText *xim_text, gchar **text)
"UTF-8",
context->mb_charset,
NULL, NULL, &error);
if (result)
{
text_length = g_utf8_strlen (result, -1);
if (text_length != xim_text->length)
{
g_warning ("Size mismatch when converting text from input method: supplied length = %d\n, result length = %d", xim_text->length, text_length);
@ -1061,7 +1037,7 @@ xim_text_to_utf8 (GtkIMContextXIM *context, XIMText *xim_text, gchar **text)
}
static void
preedit_draw_callback (XIC xic,
preedit_draw_callback (XIC xic,
XPointer client_data,
XIMPreeditDrawCallbackStruct *call_data)
{
@ -1074,12 +1050,12 @@ preedit_draw_callback (XIC xic,
gint diff;
gint new_length;
gchar *tmp;
gint chg_first = CLAMP (call_data->chg_first, 0, context->preedit_length);
gint chg_length = CLAMP (call_data->chg_length, 0, context->preedit_length - chg_first);
context->preedit_cursor = call_data->caret;
if (chg_first != call_data->chg_first || chg_length != call_data->chg_length)
g_warning ("Invalid change to preedit string, first=%d length=%d (orig length == %d)",
call_data->chg_first, call_data->chg_length, context->preedit_length);
@ -1090,7 +1066,7 @@ preedit_draw_callback (XIC xic,
new_text = g_utf8_to_ucs4_fast (tmp, -1, NULL);
g_free (tmp);
}
diff = new_text_length - chg_length;
new_length = context->preedit_length + diff;
@ -1131,7 +1107,7 @@ preedit_draw_callback (XIC xic,
if (!context->finalizing)
g_signal_emit_by_name (context, "preedit-changed");
}
static void
preedit_caret_callback (XIC xic,
@ -1139,7 +1115,7 @@ preedit_caret_callback (XIC xic,
XIMPreeditCaretCallbackStruct *call_data)
{
GtkIMContextXIM *context = GTK_IM_CONTEXT_XIM (client_data);
if (call_data->direction == XIMAbsolutePosition)
{
context->preedit_cursor = call_data->position;
@ -1151,7 +1127,7 @@ preedit_caret_callback (XIC xic,
g_warning ("Caret movement command: %d %d %d not supported",
call_data->position, call_data->direction, call_data->style);
}
}
}
static void
status_start_callback (XIC xic,
@ -1159,7 +1135,7 @@ status_start_callback (XIC xic,
XPointer call_data)
{
return;
}
}
static void
status_done_callback (XIC xic,
@ -1332,7 +1308,7 @@ set_status_callback (GtkIMContextXIM *context_xim)
context_xim->status_done_callback.callback = (XIMProc)status_done_callback;
context_xim->status_draw_callback.client_data = (XPointer)context_xim;
context_xim->status_draw_callback.callback = (XIMProc)status_draw_callback;
return XVaCreateNestedList (0,
XNStatusStartCallback, &context_xim->status_start_callback,
XNStatusDoneCallback, &context_xim->status_done_callback,
@ -1346,10 +1322,10 @@ set_string_conversion_callback (GtkIMContextXIM *context_xim, XIC xic)
{
if (!context_xim->im_info->supports_string_conversion)
return;
context_xim->string_conversion_callback.client_data = (XPointer)context_xim;
context_xim->string_conversion_callback.callback = (XIMProc)string_conversion_callback;
XSetICValues (xic,
XNStringConversionCallback,
(XPointer)&context_xim->string_conversion_callback,
@ -1428,11 +1404,11 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim)
context_xim->filter_key_release = (mask & KeyReleaseMask) != 0;
set_string_conversion_callback (context_xim, xic);
}
context_xim->ic = xic;
update_status_window (context_xim);
if (xic && context_xim->has_focus)
XSetICFocus (xic);
}
@ -1484,7 +1460,7 @@ disclaim_status_window (GtkIMContextXIM *context_xim)
g_assert (context_xim->status_window->context == context_xim);
status_window_set_text (context_xim->status_window, "");
context_xim->status_window->context = NULL;
context_xim->status_window = NULL;
}
@ -1531,7 +1507,7 @@ update_in_toplevel (GtkIMContextXIM *context_xim)
if (context_xim->client_widget)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (context_xim->client_widget);
context_xim->in_toplevel = (toplevel && gtk_widget_is_toplevel (toplevel));
}
else
@ -1540,7 +1516,7 @@ update_in_toplevel (GtkIMContextXIM *context_xim)
/* Some paranoia, in case we don't get a focus out */
if (!context_xim->in_toplevel)
context_xim->has_focus = FALSE;
update_status_window (context_xim);
}
@ -1670,7 +1646,7 @@ status_window_free (StatusWindow *status_window)
if (status_window->context)
status_window->context->status_window = NULL;
g_signal_handlers_disconnect_by_func (status_window->toplevel,
G_CALLBACK (on_status_toplevel_destroy),
status_window);
@ -1683,9 +1659,9 @@ status_window_free (StatusWindow *status_window)
if (status_window->window)
gtk_widget_destroy (status_window->window);
g_object_set_data (G_OBJECT (status_window->toplevel), "gtk-im-xim-status-window", NULL);
g_free (status_window);
}
@ -1699,7 +1675,7 @@ status_window_get (GtkWidget *toplevel)
status_window = g_object_get_data (G_OBJECT (toplevel), "gtk-im-xim-status-window");
if (status_window)
return status_window;
status_window = g_new0 (StatusWindow, 1);
status_window->toplevel = toplevel;
@ -1714,7 +1690,7 @@ status_window_get (GtkWidget *toplevel)
g_signal_connect (toplevel, "notify::display",
G_CALLBACK (on_status_toplevel_notify_display),
status_window);
g_object_set_data (G_OBJECT (toplevel), "gtk-im-xim-status-window", status_window);
return status_window;
@ -1728,7 +1704,7 @@ status_window_make_window (StatusWindow *status_window)
{
GtkWidget *window;
GtkWidget *status_label;
status_window->window = gtk_window_new (GTK_WINDOW_POPUP);
window = status_window->window;
@ -1737,9 +1713,9 @@ status_window_make_window (StatusWindow *status_window)
status_label = gtk_label_new ("");
g_object_set (status_label, "margin", 1, NULL);
gtk_widget_show (status_label);
gtk_container_add (GTK_CONTAINER (window), status_label);
gtk_window_set_display (GTK_WINDOW (status_window->window),
gtk_widget_get_display (status_window->toplevel));
@ -1756,13 +1732,13 @@ status_window_set_text (StatusWindow *status_window,
if (text[0])
{
GtkWidget *label;
if (!status_window->window)
status_window_make_window (status_window);
label = gtk_bin_get_child (GTK_BIN (status_window->window));
gtk_label_set_text (GTK_LABEL (label), text);
gtk_widget_show (status_window->window);
}
else
@ -1774,7 +1750,7 @@ status_window_set_text (StatusWindow *status_window,
/**
* gtk_im_context_xim_shutdown:
*
*
* Destroys all the status windows that are kept by the XIM contexts. This
* function should only be called by the XIM module exit routine.
**/

View File

@ -23,9 +23,7 @@
G_BEGIN_DECLS
extern GType gtk_type_im_context_xim;
#define GTK_TYPE_IM_CONTEXT_XIM (gtk_type_im_context_xim)
#define GTK_TYPE_IM_CONTEXT_XIM (gtk_im_context_xim_get_type ())
#define GTK_IM_CONTEXT_XIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIM))
#define GTK_IM_CONTEXT_XIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIMClass))
#define GTK_IS_IM_CONTEXT_XIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IM_CONTEXT_XIM))
@ -41,10 +39,9 @@ struct _GtkIMContextXIMClass
GtkIMContextClass parent_class;
};
void gtk_im_context_xim_register_type (GTypeModule *type_module);
GtkIMContext *gtk_im_context_xim_new (void);
void gtk_im_context_xim_shutdown (void);
GType gtk_im_context_xim_get_type (void) G_GNUC_CONST;
GtkIMContext *gtk_im_context_xim_new (void);
void gtk_im_context_xim_shutdown (void);
G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@ -20,15 +20,12 @@
#include <gtk/gtk.h>
/* The following entry points are exported by each input method module
*/
G_BEGIN_DECLS
/*
void im_module_list (const GtkIMContextInfo ***contexts,
guint *n_contexts);
void im_module_init (GtkModule *module);
void im_module_exit (void);
GtkIMContext *im_module_create (const gchar *context_id);
*/
void gtk_im_modules_init (void);
#define GTK_IM_MODULE_EXTENSION_POINT_NAME "gtk-im-module"
G_END_DECLS
#endif /* __GTK_IM_MODULE_H__ */

View File

@ -20,21 +20,12 @@
#include <gdk/gdk.h>
#include "gtkimcontext.h"
#include "gtkimcontextinfo.h"
G_BEGIN_DECLS
void _gtk_im_module_list (const GtkIMContextInfo ***contexts,
guint *n_contexts);
GtkIMContext * _gtk_im_module_create (const gchar *context_id);
const gchar * _gtk_im_module_get_default_context_id (void);
/* Needs to be exported API for gtk-queryimmodules */
GDK_AVAILABLE_IN_ALL
gchar * gtk_get_im_module_path (void);
GDK_AVAILABLE_IN_ALL
gchar * gtk_get_im_module_file (void);
G_END_DECLS
#endif /* __GTK_IM_MODULE_PRIVATE_H__ */

View File

@ -130,6 +130,7 @@
#include "gtkwindowprivate.h"
#include "gtkwindowgroup.h"
#include "gtkprintbackend.h"
#include "gtkimmodule.h"
#include "a11y/gtkaccessibility.h"
@ -628,6 +629,8 @@ gettext_initialization (void)
static void
default_display_notify_cb (GdkDisplayManager *dm)
{
gtk_print_backends_init ();
gtk_im_modules_init ();
_gtk_accessibility_init ();
debug_flags[0].display = gdk_display_get_default ();
}
@ -656,8 +659,6 @@ do_post_parse_initialization (void)
_gtk_accel_map_init ();
gtk_print_backends_init ();
gtk_initialized = TRUE;
display_manager = gdk_display_manager_get ();

View File

@ -464,7 +464,6 @@ gtk_public_headers = files([
'gtkiconview.h',
'gtkimage.h',
'gtkimcontext.h',
'gtkimcontextinfo.h',
'gtkimcontextsimple.h',
'gtkimmodule.h',
'gtkimmulticontext.h',
@ -579,6 +578,48 @@ install_headers(gtk_public_headers, subdir: 'gtk-4.0/gtk/')
gtk_sources = gtk_public_sources + gtk_private_sources
proto_sources = [
['gtk-text-input', 'stable', ],
]
im_wayland_sources = files('gtkimcontextwayland.c')
wayland_scanner = find_program('wayland-scanner')
genprotocols = find_program('../gdk/wayland/genprotocolfiles.py')
foreach p: proto_sources
proto_name = p.get(0)
proto_stability = p.get(1)
if proto_stability == 'stable'
output_base = proto_name
input = '@0@.xml'.format(proto_name)
else
proto_version = p.get(2)
output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
input = join_paths(proto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))
endif
im_wayland_sources += custom_target('@0@ client header'.format(output_base),
input: input,
output: '@0@-client-protocol.h'.format(output_base),
command: [
genprotocols,
wayland_scanner,
'@INPUT@', '@OUTPUT@',
'client-header',
])
im_wayland_sources += custom_target('@0@ source'.format(output_base),
input: input,
output: '@0@-protocol.c'.format(output_base),
command: [
genprotocols,
wayland_scanner,
'@INPUT@', '@OUTPUT@',
'code',
])
endforeach
if os_unix
gtk_unix_print_headers = [
'gtkpagesetupunixdialog.h',
@ -617,6 +658,7 @@ if os_win32
])
gtk_sources += gtk_win32_print_sources
gtk_sources += ['gtkimcontextime.c']
if cc.has_header_symbol('windows.h', 'IPrintDialogCallback')
cdata.set('HAVE_IPRINTDIALOGCALLBACK', 1)
@ -625,10 +667,12 @@ endif
if x11_enabled
gtk_sources += ['gtkapplication-x11.c', 'gtkmountoperation-x11.c']
gtk_sources += ['gtkimcontextxim.c']
endif
if wayland_enabled
gtk_sources += ['gtkapplication-wayland.c']
gtk_sources += im_wayland_sources
endif
if x11_enabled or wayland_enabled
@ -648,6 +692,8 @@ if quartz_enabled
'gtkfilechoosernativequartz.c',
'gtkquartz.c',
])
gtk_sources += ['gtkimcontextquartz.c']
gtk_cargs += ['-xobjective-c'] # FIXME? maybe add_languages() instead?
endif
@ -825,6 +871,10 @@ if wayland_enabled
gtk_sources += gtk_wayland_sources
endif
if broadway_enabled
gtk_sources += ['gtkimcontextbroadway.c']
endif
if win32_enabled
gtk_cargs += ['-DGTK_PRINT_BACKENDS="file,lpr"']
gtk_deps += [ giowin32_dep ]
@ -869,39 +919,6 @@ if cc.has_header('langinfo.h')
endforeach
endif
# Input methods
gen_headers = [ gtk_gen_headers, gsk_gen_headers, gdk_gen_headers, ]
included_input_modules = []
foreach m: inc_im_method_defs # populated in modules/input/meson.build
im_name = m[0]
im_srcs = m[1]
im_args = m[2]
im_libs = m[3]
included_input_modules += static_library('im-@0@'.format(im_name),
im_srcs, gen_headers,
c_args: im_args,
include_directories: [confinc, gdkinc, gtkinc],
dependencies: gtk_deps + im_libs)
endforeach
foreach m: dyn_im_method_defs # populated in modules/input/meson.build
im_name = m[0]
im_srcs = m[1]
im_args = m[2]
im_libs = m[3]
shared_module('im-@0@'.format(im_name), im_srcs, gen_headers,
c_args: im_args,
include_directories: [confinc, gdkinc, gtkinc],
dependencies: gtk_deps + im_libs,
name_prefix: '', # we want im-foo.so not libim-foo.so
install_dir: immodules_install_dir,
install: true)
endforeach
# Library
libgtk = shared_library('gtk-4',
soversion: gtk_soversion,
@ -910,7 +927,6 @@ libgtk = shared_library('gtk-4',
include_directories: [confinc, gdkinc, gskinc, gtkinc],
dependencies: gtk_deps + [libgdk_dep, libgsk_dep],
link_with: [libgdk, libgsk, ],
link_whole: included_input_modules,
link_args: common_ldflags,
install: true)
@ -1045,7 +1061,6 @@ gtk_tools = [
['gtk4-builder-tool', ['gtk-builder-tool.c']],
['gtk4-update-icon-cache', ['updateiconcache.c', 'gtkiconcachevalidator.c']],
['gtk4-encode-symbolic-svg', ['encodesymbolic.c', 'gdkpixbufutils.c']],
['gtk4-query-immodules', ['queryimmodules.c', 'gtkutils.c']],
]
if os_unix

View File

@ -1,247 +0,0 @@
/* GTK+
* querymodules.c:
*
* Copyright (C) 2000-2010 Red Hat Software
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib.h>
#include <glib/gprintf.h>
#include <errno.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef USE_LA_MODULES
#define SOEXT ".la"
#else
#define SOEXT ("." G_MODULE_SUFFIX)
#endif
#include "gtk/gtkimcontextinfo.h"
#include "gtk/gtkimmoduleprivate.h"
#include "gtk/gtkversion.h"
#include "gtk/gtkutilsprivate.h"
static void
escape_string (GString *contents, const char *str)
{
while (TRUE)
{
char c = *str++;
switch (c)
{
case '\0':
goto done;
case '\n':
g_string_append (contents, "\\n");
break;
case '\"':
g_string_append (contents, "\\\"");
break;
#ifdef G_OS_WIN32
/* Replace backslashes in path with forward slashes, so that
* it reads in without problems.
*/
case '\\':
g_string_append (contents, "/");
break;
#endif
default:
g_string_append_c (contents, c);
}
}
done:;
}
static void
print_escaped (GString *contents, const char *str)
{
g_string_append_c (contents, '"');
escape_string (contents, str);
g_string_append_c (contents, '"');
g_string_append_c (contents, ' ');
}
static gboolean
query_module (const char *dir, const char *name, GString *contents)
{
void (*list) (const GtkIMContextInfo ***contexts,
guint *n_contexts);
gpointer list_ptr;
gpointer init_ptr;
gpointer exit_ptr;
gpointer create_ptr;
GModule *module;
gchar *path;
gboolean error = FALSE;
if (g_path_is_absolute (name))
path = g_strdup (name);
else
path = g_build_filename (dir, name, NULL);
module = g_module_open (path, 0);
if (!module)
{
g_fprintf (stderr, "Cannot load module %s: %s\n", path, g_module_error());
error = TRUE;
}
if (module &&
g_module_symbol (module, "im_module_list", &list_ptr) &&
g_module_symbol (module, "im_module_init", &init_ptr) &&
g_module_symbol (module, "im_module_exit", &exit_ptr) &&
g_module_symbol (module, "im_module_create", &create_ptr))
{
const GtkIMContextInfo **contexts;
guint n_contexts;
int i;
list = list_ptr;
print_escaped (contents, path);
g_string_append_c (contents, '\n');
(*list) (&contexts, &n_contexts);
for (i = 0; i < n_contexts; i++)
{
print_escaped (contents, contexts[i]->context_id);
print_escaped (contents, contexts[i]->context_name);
print_escaped (contents, contexts[i]->domain);
print_escaped (contents, contexts[i]->domain_dirname);
print_escaped (contents, contexts[i]->default_locales);
g_string_append_c (contents, '\n');
}
g_string_append_c (contents, '\n');
}
else
{
g_fprintf (stderr, "%s does not export GTK+ IM module API: %s\n", path,
g_module_error ());
error = TRUE;
}
g_free (path);
if (module)
g_module_close (module);
return error;
}
int main (int argc, char **argv)
{
char *cwd;
int i;
char *path;
gboolean error = FALSE;
gchar *cache_file = NULL;
gint first_file = 1;
GString *contents;
if (argc > 1 && strcmp (argv[1], "--update-cache") == 0)
{
cache_file = gtk_get_im_module_file ();
first_file = 2;
}
contents = g_string_new ("");
g_string_append_printf (contents,
"# GTK+ Input Method Modules file\n"
"# Automatically generated file, do not edit\n"
"# Created by %s from gtk+-%d.%d.%d\n"
"#\n",
argv[0],
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
if (argc == first_file) /* No file arguments given */
{
char **dirs;
GHashTable *dirs_done;
path = gtk_get_im_module_path ();
g_string_append_printf (contents, "# ModulesPath = %s\n#\n", path);
dirs = gtk_split_file_list (path);
dirs_done = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
for (i = 0; dirs[i]; i++)
if (!g_hash_table_lookup (dirs_done, dirs[i]))
{
GDir *dir = g_dir_open (dirs[i], 0, NULL);
if (dir)
{
const char *dent;
GList *list = NULL, *iterator = NULL;
while ((dent = g_dir_read_name (dir)))
list = g_list_prepend (list, g_strdup (dent));
list = g_list_sort (list, (GCompareFunc) strcmp);
for (iterator = list; iterator; iterator = iterator->next)
{
if (g_str_has_suffix (iterator->data, SOEXT))
error |= query_module (dirs[i], iterator->data, contents);
}
g_list_free_full (list, g_free);
g_dir_close (dir);
}
g_hash_table_insert (dirs_done, dirs[i], GUINT_TO_POINTER (TRUE));
}
g_hash_table_destroy (dirs_done);
}
else
{
cwd = g_get_current_dir ();
for (i = first_file; i < argc; i++)
error |= query_module (cwd, argv[i], contents);
g_free (cwd);
}
if (!error)
{
if (cache_file)
{
GError *err;
err = NULL;
if (!g_file_set_contents (cache_file, contents->str, -1, &err))
{
g_fprintf (stderr, "%s\n", err->message);
error = 1;
}
}
else
g_print ("%s\n", contents->str);
}
return error ? 1 : 0;
}

View File

@ -589,7 +589,6 @@ if cloudproviders_enabled
endif
endif
subdir('modules/input')
subdir('gdk')
subdir('gsk')
subdir('gtk')

View File

@ -24,12 +24,6 @@ option('print-backends', type : 'string', value : 'cups,file',
option('colord', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
description : 'Build colord support for the CUPS printing backend')
# Modules
option('dynamic-modules', type: 'boolean', value : true,
description : 'Allow dynamic module loading')
option('included-immodules', type: 'string', value : 'none',
description : 'Build the specified input methods (comma-separated list, "all", or "none")')
# Documentation and introspection
option('documentation', type: 'boolean', value: 'false',
description : 'Build API reference and tools documentation')

View File

@ -1,69 +0,0 @@
/*
* gtkimmoduleime
* Copyright (C) 2003 Takuro Ashie
*
* 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, see <http://www.gnu.org/licenses/>.
*
* $Id$
*/
#include "config.h"
#include <string.h>
#include "gtk/gtkintl.h"
#include "gtk/gtkimmodule.h"
#include "gtkimcontextime.h"
static const GtkIMContextInfo ime_info = {
"ime",
NC_("input method menu", "Windows IME"),
GETTEXT_PACKAGE,
"",
"ja:ko:zh",
};
static const GtkIMContextInfo *info_list[] = {
&ime_info,
};
#ifndef INCLUDE_IM_ime
#define MODULE_ENTRY(type,function) G_MODULE_EXPORT type im_module_ ## function
#else
#define MODULE_ENTRY(type, function) type _gtk_immodule_ime_ ## function
#endif
MODULE_ENTRY (void, init) (GTypeModule * module)
{
gtk_im_context_ime_register_type (module);
}
MODULE_ENTRY (void, exit) (void)
{
}
MODULE_ENTRY (void, list) (const GtkIMContextInfo *** contexts, int *n_contexts)
{
*contexts = info_list;
*n_contexts = G_N_ELEMENTS (info_list);
}
MODULE_ENTRY (GtkIMContext *, create) (const gchar * context_id)
{
g_return_val_if_fail (context_id, NULL);
if (!strcmp (context_id, "ime"))
return g_object_new (GTK_TYPE_IM_CONTEXT_IME, NULL);
else
return NULL;
}

View File

@ -1,65 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2000 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtk/gtkintl.h"
#include "gtk/gtkimmodule.h"
#include "gtkimcontextxim.h"
#include <string.h>
static const GtkIMContextInfo xim_ja_info = {
"xim", /* ID */
NC_("input method menu", "X Input Method"), /* Human readable name */
GETTEXT_PACKAGE, /* Translation domain */
GTK_LOCALEDIR, /* Dir for bindtextdomain (not strictly needed for "gtk+") */
"ko:ja:th:zh" /* Languages for which this module is the default */
};
static const GtkIMContextInfo *info_list[] = {
&xim_ja_info
};
#ifndef INCLUDE_IM_xim
#define MODULE_ENTRY(type, function) G_MODULE_EXPORT type im_module_ ## function
#else
#define MODULE_ENTRY(type, function) type _gtk_immodule_xim_ ## function
#endif
MODULE_ENTRY (void, init) (GTypeModule *type_module)
{
gtk_im_context_xim_register_type (type_module);
}
MODULE_ENTRY (void, exit) (void)
{
gtk_im_context_xim_shutdown ();
}
MODULE_ENTRY (void, list) (const GtkIMContextInfo ***contexts,
int *n_contexts)
{
*contexts = info_list;
*n_contexts = G_N_ELEMENTS (info_list);
}
MODULE_ENTRY (GtkIMContext *, create) (const gchar *context_id)
{
if (strcmp (context_id, "xim") == 0)
return gtk_im_context_xim_new ();
else
return NULL;
}

View File

@ -1,118 +0,0 @@
# Note: this file is included from the top-level before gtk/meson.build.
# The actual input modules are then built in gtk/meson.build based on the
# defs we provide here. It has to be that way because included input methods
# need to be built before libgtk-4.so is built, so before gtk/meson.build, but
# all input methods also rely on gtk generated headers to be created first, so
# there is a bit of an ordering problem which we solve by collecting all the
# information here but moving the actual build definitions to gtk/meson.build.
build_dynamic_modules = false
dynamic_modules = get_option('dynamic-modules')
if dynamic_modules
gmodule_supported = dependency('gmodule-no-export-2.0').get_pkgconfig_variable('gmodule_supported')
if gmodule_supported == 'true'
build_dynamic_modules = true
else
message('Modules are not supported according to gmodule-no-export-2.0.pc')
endif
endif
all_immodules = backend_immodules
# Allow building some or all immodules included
included_immodules = get_option('included-immodules').split(',')
if included_immodules.contains('none')
included_immodules = []
elif included_immodules.contains('all')
included_immodules = all_immodules
endif
have_included_immodules = included_immodules.length() > 0
foreach im: included_immodules
if not all_immodules.contains(im)
error('The specified input method "@0@" is not available (available methods: @1@)'.format(im, ', '.join(all_immodules)))
endif
endforeach
immodules_subdir = 'gtk-4.0/@0@/immodules'.format(gtk_binary_version)
immodules_install_dir = join_paths(gtk_libdir, immodules_subdir)
# Format:
# - protocol name
# - protocol stability ('stable' or 'unstable')
# - protocol version (if stability is 'unstable')
proto_sources = [
['gtk-text-input', 'stable', ],
]
im_wayland_gen_headers = []
im_wayland_sources = files('imwayland.c')
wayland_scanner = find_program('wayland-scanner')
genprotocols = find_program('../../gdk/wayland/genprotocolfiles.py')
foreach p: proto_sources
proto_name = p.get(0)
proto_stability = p.get(1)
if proto_stability == 'stable'
output_base = proto_name
input = '@0@.xml'.format(proto_name)
else
proto_version = p.get(2)
output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
input = join_paths(proto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))
endif
im_wayland_sources += custom_target('@0@ client header'.format(output_base),
input: input,
output: '@0@-client-protocol.h'.format(output_base),
command: [
genprotocols,
wayland_scanner,
'@INPUT@', '@OUTPUT@',
'client-header',
])
im_wayland_sources += custom_target('@0@ source'.format(output_base),
input: input,
output: '@0@-protocol.c'.format(output_base),
command: [
genprotocols,
wayland_scanner,
'@INPUT@', '@OUTPUT@',
'code',
])
endforeach
method_defs = [
['broadway', files('imbroadway.c')],
['quartz', ('imquartz.c'), [], ('-xobjective-c')],
['xim', files('gtkimcontextxim.c', 'imxim.c')],
['ime', files('gtkimcontextime.c', 'imime.c'), ['imm32']],
['wayland', im_wayland_sources],
]
inc_im_method_defs = []
dyn_im_method_defs = []
foreach m: method_defs
im = m.get(0)
srcs = m.get(1)
cargs = m.get(3, [])
libs = []
# only use backend-specific input methods for backends that are enabled
if all_immodules.contains(im)
# check for extra libs lazily
foreach libname: m.get(2, [])
libs += [cc.find_library(libname)]
endforeach
if included_immodules.contains(im)
cdata.set('INCLUDE_IM_@0@'.format(im.underscorify()), true)
inc_im_method_defs += [[im, srcs, cargs, libs]]
elif build_dynamic_modules
dyn_im_method_defs += [[im, srcs, cargs, libs]]
endif
endif
endforeach

View File

@ -1,5 +1,3 @@
# Note: 'input' subdir has already been included from top-level.
if os_unix
subdir('printbackends')
endif