diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-02-19 18:29:00 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-02-24 21:34:40 -0500 |
commit | 29bcc38ae62e73b76f0f663e2ecc5e85bfe4ca46 (patch) | |
tree | cff130d8b76d27418228ece1187d98d79133e7c6 /modules | |
parent | e6bf832514c04a224c799413bdac7489c7fe9186 (diff) | |
download | gtk+-29bcc38ae62e73b76f0f663e2ecc5e85bfe4ca46.tar.gz |
Convert immodules to use an extension point
Add an extension point called gtk-im-module, which requires
the type GtkIMContext. Simplify the loading by using GIO
infrastructure. Drop the locale filtering for now, I don't
think it is really necessary nowadays.
Convert existing platform modules to gio modules.
Sill to do: Drop the conditional build machinery.
Either always include them, or never.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/input/gtkimcontextime.c | 49 | ||||
-rw-r--r-- | modules/input/gtkimcontextime.h | 2 | ||||
-rw-r--r-- | modules/input/gtkimcontextxim.c | 59 | ||||
-rw-r--r-- | modules/input/gtkimcontextxim.h | 5 | ||||
-rw-r--r-- | modules/input/imbroadway.c | 101 | ||||
-rw-r--r-- | modules/input/imime.c | 69 | ||||
-rw-r--r-- | modules/input/imquartz.c | 117 | ||||
-rw-r--r-- | modules/input/imwayland.c | 111 | ||||
-rw-r--r-- | modules/input/imxim.c | 65 | ||||
-rw-r--r-- | modules/input/meson.build | 4 |
10 files changed, 188 insertions, 394 deletions
diff --git a/modules/input/gtkimcontextime.c b/modules/input/gtkimcontextime.c index b11f601965..212a17b669 100644 --- a/modules/input/gtkimcontextime.c +++ b/modules/input/gtkimcontextime.c @@ -125,29 +125,38 @@ 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)) +G_DEFINE_DYNAMIC_TYPE (GtkIMContextIME, gtk_im_context_ime, GTK_TYPE_IM_CONTEXT) void -gtk_im_context_ime_register_type (GTypeModule *type_module) +g_io_module_load (GIOModule *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, + g_type_module_use (G_TYPE_MODULE (module)); + + gtk_im_context_ime_register_type (G_TYPE_MODULE (module)); + + g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME, + GTK_TYPE_IM_CONTEXT_IME, + "ime", + 10); +} + +void +g_io_module_unload (GIOModule *module) +{ +} + +char ** +g_io_module_query (void) +{ + char *eps[] = { + GTK_IM_MODULE_EXTENSION_POINT_NAME, + NULL }; - gtk_type_im_context_ime = - g_type_module_register_type (type_module, - GTK_TYPE_IM_CONTEXT, - "GtkIMContextIME", &im_context_ime_info, 0); + return g_strdupv (eps); } static void @@ -156,8 +165,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,6 +180,10 @@ 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_class_finalize (GtkIMContextIMEClass *class) +{ +} static void gtk_im_context_ime_init (GtkIMContextIME *context_ime) diff --git a/modules/input/gtkimcontextime.h b/modules/input/gtkimcontextime.h index c8858cb0b0..6bb036558f 100644 --- a/modules/input/gtkimcontextime.h +++ b/modules/input/gtkimcontextime.h @@ -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)) diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c index 05e98f051a..03ce3e727c 100644 --- a/modules/input/gtkimcontextxim.c +++ b/modules/input/gtkimcontextxim.c @@ -20,6 +20,7 @@ #include <string.h> #include <stdlib.h> +#include "gtkimmodule.h" #include "gtkimcontextxim.h" #include "gtk/gtkintl.h" @@ -145,38 +146,43 @@ static void xim_info_display_closed (GdkDisplay *display, gboolean is_error, GtkXIMInfo *info); -static GObjectClass *parent_class; +G_DEFINE_DYNAMIC_TYPE (GtkIMContextXIM, gtk_im_context_xim, GTK_TYPE_IM_CONTEXT) -GType gtk_type_im_context_xim = 0; +void +g_io_module_load (GIOModule *module) +{ + g_type_module_use (G_TYPE_MODULE (module)); -static GSList *open_ims = NULL; + g_print ("load io module for x11\n"); + gtk_im_context_xim_register_type (G_TYPE_MODULE (module)); -/* List of status windows for different toplevels */ -static GSList *status_windows = NULL; + g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME, + GTK_TYPE_IM_CONTEXT_XIM, + "xim", + 10); +} void -gtk_im_context_xim_register_type (GTypeModule *type_module) +g_io_module_unload (GIOModule *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, +} + +char ** +g_io_module_query (void) +{ + char *eps[] = { + GTK_IM_MODULE_EXTENSION_POINT_NAME, + NULL }; - gtk_type_im_context_xim = - g_type_module_register_type (type_module, - GTK_TYPE_IM_CONTEXT, - "GtkIMContextXIM", - &im_context_xim_info, 0); + return g_strdupv (eps); } +static GSList *open_ims = NULL; + +/* List of status windows for different toplevels */ +static GSList *status_windows = NULL; + #define PREEDIT_MASK (XIMPreeditCallbacks | XIMPreeditPosition | \ XIMPreeditArea | XIMPreeditNothing | XIMPreeditNone) #define STATUS_MASK (XIMStatusCallbacks | XIMStatusArea | \ @@ -475,8 +481,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; @@ -489,6 +493,11 @@ gtk_im_context_xim_class_init (GtkIMContextXIMClass *class) } static void +gtk_im_context_xim_class_finalize (GtkIMContextXIMClass *class) +{ +} + +static void gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim) { im_context_xim->use_preedit = TRUE; @@ -534,7 +543,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 diff --git a/modules/input/gtkimcontextxim.h b/modules/input/gtkimcontextxim.h index a4c98a3c6f..d81a7ff2d1 100644 --- a/modules/input/gtkimcontextxim.h +++ b/modules/input/gtkimcontextxim.h @@ -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,7 +39,6 @@ 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); diff --git a/modules/input/imbroadway.c b/modules/input/imbroadway.c index 6a15999428..2fb40d471e 100644 --- a/modules/input/imbroadway.c +++ b/modules/input/imbroadway.c @@ -27,9 +27,9 @@ #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,38 @@ typedef struct _GtkIMContextBroadwayClass GtkIMContextSimpleClass parent_class; } GtkIMContextBroadwayClass; -GType type_broadway = 0; -static GObjectClass *parent_class; +G_DEFINE_DYNAMIC_TYPE (GtkIMContextBroadway, gtk_im_context_broadway, GTK_TYPE_IM_CONTEXT_SIMPLE) -static const GtkIMContextInfo imbroadway_info = +void +g_io_module_load (GIOModule *module) { - "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[] = + g_type_module_use (G_TYPE_MODULE (module)); + + g_print ("load io module for broadway\n"); + gtk_im_context_broadway_register_type (G_TYPE_MODULE (module)); + + g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME, + GTK_TYPE_IM_CONTEXT_BROADWAY, + "broadway", + 10); +} + +void +g_io_module_unload (GIOModule *module) +{ +} + +char ** +g_io_module_query (void) { - &imbroadway_info, -}; + char *eps[] = { + GTK_IM_MODULE_EXTENSION_POINT_NAME, + NULL + }; + + return g_strdupv (eps); +} -#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 static void broadway_set_client_widget (GtkIMContext *context, GtkWidget *widget) @@ -100,9 +110,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 +120,11 @@ gtk_im_context_broadway_class_init (GtkIMContextClass *klass) } static void -gtk_im_context_broadway_init (GtkIMContext *im_context) +gtk_im_context_broadway_class_finalize (GtkIMContextBroadwayClass *class) { } 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) +gtk_im_context_broadway_init (GtkIMContextBroadway *im_context) { - if (!strcmp (context_id, "broadway")) - return g_object_new (type_broadway, NULL); - else - return NULL; } diff --git a/modules/input/imime.c b/modules/input/imime.c deleted file mode 100644 index d2943cf9cd..0000000000 --- a/modules/input/imime.c +++ /dev/null @@ -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; -} diff --git a/modules/input/imquartz.c b/modules/input/imquartz.c index c7bc5d2067..9d1a1cc9f8 100644 --- a/modules/input/imquartz.c +++ b/modules/input/imquartz.c @@ -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,41 @@ typedef struct _GtkIMContextQuartzClass GtkIMContextClass parent_class; } GtkIMContextQuartzClass; -GType type_quartz = 0; -static GObjectClass *parent_class; +G_DEFINE_DYNAMIC_TYPE (GtkIMContextQuartz, gtk_im_context_quartz, GTK_TYPE_IM_CONTEXT) + +void +g_io_module_load (GIOModule *module) +{ + g_type_module_use (G_TYPE_MODULE (module)); + + g_print ("load io module for quartz\n"); + gtk_im_context_quartz_register_type (G_TYPE_MODULE (module)); + + g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME, + GTK_TYPE_IM_CONTEXT_BROADWAY, + "quartz", + 10); +} -static const GtkIMContextInfo imquartz_info = +void +g_io_module_unload (GIOModule *module) { - "quartz", - NC_("input method menu", "Mac OS X Quartz"), - GETTEXT_PACKAGE, - GTK_LOCALEDIR, - "ja:ko:zh:*", -}; - -static const GtkIMContextInfo *info_list[] = +} + +char ** +g_io_module_query (void) { - &imquartz_info, -}; + char *eps[] = { + GTK_IM_MODULE_EXTENSION_POINT_NAME, + NULL + }; + + return g_strdupv (eps); +} + + + -#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 static void quartz_get_preedit_string (GtkIMContext *context, @@ -359,16 +373,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 +397,15 @@ gtk_im_context_quartz_class_init (GtkIMContextClass *klass) } static void -gtk_im_context_quartz_init (GtkIMContext *im_context) +gtk_im_context_quartz_class_finalize (GtkIMContextQuartzClass *class) +{ +} + +static void +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 +415,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; -} diff --git a/modules/input/imwayland.c b/modules/input/imwayland.c index 9395380339..24f4f397dd 100644 --- a/modules/input/imwayland.c +++ b/modules/input/imwayland.c @@ -70,31 +70,47 @@ struct _GtkIMContextWayland guint use_preedit : 1; }; -GType type_wayland = 0; -static GObjectClass *parent_class; static GtkIMContextWaylandGlobal *global = NULL; -static const GtkIMContextInfo imwayland_info = +static void gtk_im_context_wayland_global_init (GdkDisplay *display); + +#define GTK_TYPE_IM_CONTEXT_WAYLAND (gtk_im_context_wayland_get_type ()) +#define GTK_IM_CONTEXT_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_WAYLAND, GtkIMContextWayland)) + +G_DEFINE_DYNAMIC_TYPE (GtkIMContextWayland, gtk_im_context_wayland, GTK_TYPE_IM_CONTEXT_SIMPLE) + +void +g_io_module_load (GIOModule *module) { - "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 */ -}; + g_type_module_use (G_TYPE_MODULE (module)); + + g_print ("load io module for wayland\n"); + gtk_im_context_wayland_register_type (G_TYPE_MODULE (module)); + gtk_im_context_wayland_global_init (gdk_display_get_default ()); + + g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME, + GTK_TYPE_IM_CONTEXT_WAYLAND, + "wayland", + 10); +} -static const GtkIMContextInfo *info_list[] = +void +g_io_module_unload (GIOModule *module) { - &imwayland_info, -}; +} + +char ** +g_io_module_query (void) +{ + char *eps[] = { + GTK_IM_MODULE_EXTENSION_POINT_NAME, + NULL + }; + + return g_strdupv (eps); +} -#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 static void reset_preedit (GtkIMContextWayland *context) @@ -237,7 +253,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) + return; global = g_new0 (GtkIMContextWaylandGlobal, 1); global->display = gdk_wayland_display_get_wl_display (display); @@ -395,7 +412,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 @@ -472,7 +489,7 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context, GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context); gchar *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 +516,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 +552,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 +630,11 @@ 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 +gtk_im_context_wayland_class_finalize (GtkIMContextWaylandClass *class) +{ } static void @@ -633,46 +653,3 @@ gtk_im_context_wayland_init (GtkIMContextWayland *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; -} diff --git a/modules/input/imxim.c b/modules/input/imxim.c deleted file mode 100644 index aff332bdf1..0000000000 --- a/modules/input/imxim.c +++ /dev/null @@ -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; -} diff --git a/modules/input/meson.build b/modules/input/meson.build index ac13c8c193..ae904b8e8d 100644 --- a/modules/input/meson.build +++ b/modules/input/meson.build @@ -87,8 +87,8 @@ 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']], + ['xim', files('gtkimcontextxim.c')], + ['ime', files('gtkimcontextime.c'), ['imm32']], ['wayland', im_wayland_sources], ] |