[maemo-commits] [maemo-commits] r8840 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gtk
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Dec 20 18:04:51 EET 2006
- Previous message: [maemo-commits] r8839 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . background-manager
- Next message: [maemo-commits] r8841 - projects/haf/trunk/osso-gnomevfs-extra
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kris Date: 2006-12-20 18:04:49 +0200 (Wed, 20 Dec 2006) New Revision: 8840 Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimcontext.c projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmodule.h projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.c projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.h Log: 2006-12-20 Kristian Rietveld <kris at imendio.com> * gtk/gtkimmulticontext.[ch] * gtk/gtkimcontext.c * gtk/gtkimmodule.h: Ported over code from maemo-gtk-2-6 to get the virtual keyboards running. Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog =================================================================== --- projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog 2006-12-20 13:02:10 UTC (rev 8839) +++ projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog 2006-12-20 16:04:49 UTC (rev 8840) @@ -1,5 +1,12 @@ 2006-12-20 Kristian Rietveld <kris at imendio.com> + * gtk/gtkimmulticontext.[ch] + * gtk/gtkimcontext.c + * gtk/gtkimmodule.h: Ported over code from maemo-gtk-2-6 to get + the virtual keyboards running. + +2006-12-20 Kristian Rietveld <kris at imendio.com> + * gdk/gdkwindow.h: move GDK_WINDOW_TYPE_HINT_MESSAGE to the same position in the enum as in maemo-gtk-2-6 to restore binary compatibility. Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimcontext.c =================================================================== --- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimcontext.c 2006-12-20 13:02:10 UTC (rev 8839) +++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimcontext.c 2006-12-20 16:04:49 UTC (rev 8840) @@ -25,18 +25,55 @@ #include "gtkintl.h" #include "gtkalias.h" +/* MAEMO START */ +typedef struct _GtkIMContextPrivate GtkIMContextPrivate; + +#define GTK_IM_CONTEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + GTK_TYPE_IM_CONTEXT, GtkIMContextPrivate)) + enum { + PROP_HILDON_INPUT_MODE = 1 +}; +/* MAEMO END */ + +enum { PREEDIT_START, PREEDIT_END, PREEDIT_CHANGED, COMMIT, RETRIEVE_SURROUNDING, DELETE_SURROUNDING, +/* MAEMO START */ + HAS_SELECTION, + CLIPBOARD_OPERATION, +/* MAEMO END */ LAST_SIGNAL }; +/* MAEMO START */ +struct _GtkIMContextPrivate { + HildonGtkInputMode mode; +}; +/* MAEMO END */ + static guint im_context_signals[LAST_SIGNAL] = { 0 }; +/* MAEMO START */ +static void gtk_im_context_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_im_context_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static gboolean gtk_im_context_real_filter_event (GtkIMContext *context, + GdkEvent *event); + +/* MAEMO END */ + static void gtk_im_context_real_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, @@ -56,11 +93,24 @@ static void gtk_im_context_class_init (GtkIMContextClass *klass) { + /* MAEMO START */ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + /* MAEMO END */ + klass->get_preedit_string = gtk_im_context_real_get_preedit_string; klass->filter_keypress = gtk_im_context_real_filter_keypress; klass->get_surrounding = gtk_im_context_real_get_surrounding; klass->set_surrounding = gtk_im_context_real_set_surrounding; + /* MAEMO START */ + klass->filter_event = gtk_im_context_real_filter_event; + + gobject_class->set_property = gtk_im_context_set_property; + gobject_class->get_property = gtk_im_context_get_property; + + g_type_class_add_private (klass, sizeof(GtkIMContextPrivate)); + /* MAEMO END */ + im_context_signals[PREEDIT_START] = g_signal_new (I_("preedit_start"), G_TYPE_FROM_CLASS (klass), @@ -116,14 +166,115 @@ G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT); + + /* MAEMO START */ + + /** + * GtkIMContext::has-selection: + * @context: a #GtkIMContext + * + * This signal is emitted when input context needs to know if there is + * any text selected in the widget. Return TRUE if there is. + * + * Since: maemo 2.0 + **/ + im_context_signals[HAS_SELECTION] = + g_signal_new ("has_selection", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkIMContextClass, has_selection), + NULL, NULL, + _gtk_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, 0); + /** + * GtkIMContext::clipboard-operation: + * @context: a #GtkIMContext + * @operation: a #GtkIMContextClipboardOperation + * + * This signal is emitted when input context wants to copy, cut or paste + * text. The widget needs to implement these operations. + * + * Since: maemo 2.0 + **/ + im_context_signals[CLIPBOARD_OPERATION] = + g_signal_new ("clipboard_operation", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkIMContextClass, clipboard_operation), + NULL, NULL, + _gtk_marshal_VOID__ENUM, + G_TYPE_NONE, 1, GTK_TYPE_IM_CONTEXT_CLIPBOARD_OPERATION); + + /** + * GtkIMContext:hildon-input-mode: + * + * Allowed characters and input mode for this IM context. + * See #HildonGtkInputMode. + * + * Since: maemo 2.0 + **/ + g_object_class_install_property (gobject_class, + PROP_HILDON_INPUT_MODE, + g_param_spec_flags ("hildon-input-mode", + "Hildon input mode", + "Allowed characters and input mode", + GTK_TYPE_GTK_INPUT_MODE, + HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP, + G_PARAM_READWRITE)); + /* MAEMO END */ } static void gtk_im_context_init (GtkIMContext *im_context) { + /* MAEMO START */ + GtkIMContextPrivate *priv = GTK_IM_CONTEXT_GET_PRIVATE (im_context); + + priv->mode = HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP; + /* MAEMO END */ } +/* MAEMO START */ static void +gtk_im_context_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkIMContextPrivate *priv = GTK_IM_CONTEXT_GET_PRIVATE (object); + + switch (property_id) + { + case PROP_HILDON_INPUT_MODE: + priv->mode = g_value_get_flags (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gtk_im_context_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GtkIMContextPrivate *priv = GTK_IM_CONTEXT_GET_PRIVATE (object); + + switch (property_id) + { + case PROP_HILDON_INPUT_MODE: + g_value_set_flags (value, priv->mode); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} +/* MAEMO END */ + +static void gtk_im_context_real_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, @@ -144,6 +295,15 @@ return FALSE; } +/* MAEMO START */ +static gboolean +gtk_im_context_real_filter_event (GtkIMContext *context, + GdkEvent *event) +{ + return FALSE; +} +/* MAEMO END */ + typedef struct { gchar *text; @@ -527,43 +687,199 @@ /* MAEMO START */ +/** + * hildon_gtk_im_context_filter_event: + * @context: a #GtkIMContext + * @event: the event + * + * Allow an input method to internally handle an event. + * If this function returns %TRUE, then no further processing + * should be done for this event. + * + * <note><para> + * Input methods must be able to accept all types of events (simply + * returning %FALSE if the event was not handled), but there is no + * obligation for a widget to submit any events to this function. + * </para><para> + * Widget events that are recommended to be run through this function + * are %GDK_BUTTON_PRESS, %GDK_BUTTON_RELEASE, %GDK_2BUTTON_PRESS, + * %GDK_3BUTTON_PRESS, %GDK_KEY_PRESS and %GDK_KEY_RELEASE. + * </para><para> + * Note that if the event passes the filter with the function returning + * %FALSE, the widget still needs to process the event itself, this can + * include calling gtk_im_context_focus_in(), gtk_im_context_focus_out() + * or gtk_im_context_filter_keypress() for focus and keypress events + * where applicable. + * </para></note> + * </para></note> + * + * Return value: %TRUE if the input method handled the event. + * + * Since: maemo 2.0 + */ gboolean hildon_gtk_im_context_filter_event (GtkIMContext *context, GdkEvent *event) { - return FALSE; + GtkIMContextClass *klass; + + g_return_val_if_fail (GTK_IS_IM_CONTEXT (context), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + klass = GTK_IM_CONTEXT_GET_CLASS (context); + return klass->filter_event (context, event); } -void gtk_im_context_show (GtkIMContext *context) +/** + * gtk_im_context_show: + * @context: a #GtkIMContext + * + * Notify the input method that widget thinks the actual + * input method show be opened. + * + * Since: maemo 1.0 + * + * Deprecated: Use hildon_gtk_im_context_show() instead. + **/ +void +gtk_im_context_show (GtkIMContext *context) { + hildon_gtk_im_context_show (context); } -void gtk_im_context_hide (GtkIMContext *context) +/** + * gtk_im_context_hide: + * @context: a #GtkIMContext + * + * Notify the input method that widget thinks the actual + * input method show be closed. + * + * Since: maemo 1.0 + * + * Deprecated: Use hildon_gtk_im_context_hide() instead. + **/ +void +gtk_im_context_hide (GtkIMContext *context) { + hildon_gtk_im_context_hide (context); } -void hildon_gtk_im_context_show (GtkIMContext *context) +/** + * hildon_gtk_im_context_show: + * @context: a #GtkIMContext + * + * Notify the input method that widget thinks the actual + * input method show be opened. + * + * Since: maemo 2.0 + **/ +void +hildon_gtk_im_context_show (GtkIMContext *context) { + GtkIMContextClass *klass; + + g_return_if_fail (GTK_IS_IM_CONTEXT (context)); + + klass = GTK_IM_CONTEXT_GET_CLASS (context); + if (klass->show) + klass->show (context); } -void hildon_gtk_im_context_hide (GtkIMContext *context) +/** + * hildon_gtk_im_context_hide: + * @context: a #GtkIMContext + * + * Notify the input method that widget thinks the actual + * input method show be closed. + * + * Since: maemo 2.0 + **/ +void +hildon_gtk_im_context_hide (GtkIMContext *context) { + GtkIMContextClass *klass; + + g_return_if_fail (GTK_IS_IM_CONTEXT (context)); + + klass = GTK_IM_CONTEXT_GET_CLASS (context); + if (klass->hide) + klass->hide (context); } -gboolean hildon_gtk_im_context_has_selection(GtkIMContext *context) +/** + * hildon_gtk_im_context_has_selection: + * @context: a #GtkIMContext + * + * Returns TRUE if the widget attached to this input context has some + * text selected in it. + * + * Since: maemo 2.0 + **/ +gboolean +hildon_gtk_im_context_has_selection (GtkIMContext *context) { - return FALSE; + gboolean result = FALSE; + + g_return_val_if_fail (GTK_IS_IM_CONTEXT (context), 0); + + g_signal_emit (context, + im_context_signals[HAS_SELECTION], 0, + &result); + + return result; } -void hildon_gtk_im_context_copy (GtkIMContext *context) +/** + * hildon_gtk_im_context_copy: + * @context: a #GtkIMContext + * + * Requests from the widget attached to this input context that the + * selected text in it is copied to clipboard. + * + * Since: maemo 2.0 + **/ +void +hildon_gtk_im_context_copy (GtkIMContext *context) { + g_return_if_fail (GTK_IS_IM_CONTEXT (context)); + + g_signal_emit (context, im_context_signals[CLIPBOARD_OPERATION], 0, + GTK_IM_CONTEXT_CLIPBOARD_OP_COPY); } -void hildon_gtk_im_context_cut (GtkIMContext *context) +/** + * hildon_gtk_im_context_cut: + * @context: a #GtkIMContext + * + * Requests from the widget attached to this input context that the + * selected text is cut and copied to clipboard. + * + * Since: maemo 2.0 + **/ +void +hildon_gtk_im_context_cut (GtkIMContext *context) { + g_return_if_fail (GTK_IS_IM_CONTEXT (context)); + + g_signal_emit (context, im_context_signals[CLIPBOARD_OPERATION], 0, + GTK_IM_CONTEXT_CLIPBOARD_OP_CUT); } -void hildon_gtk_im_context_paste (GtkIMContext *context) +/** + * hildon_gtk_im_context_paste: + * @context: a #GtkIMContext + * + * Requests from the widget attached to this input context that the + * text in clipboard is pasted to it. + * + * Since: maemo 2.0 + **/ +void +hildon_gtk_im_context_paste (GtkIMContext *context) { + g_return_if_fail (GTK_IS_IM_CONTEXT (context)); + + g_signal_emit (context, im_context_signals[CLIPBOARD_OPERATION], 0, + GTK_IM_CONTEXT_CLIPBOARD_OP_PASTE); } /* MAEMO END */ Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmodule.h =================================================================== --- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmodule.h 2006-12-20 13:02:10 UTC (rev 8839) +++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmodule.h 2006-12-20 16:04:49 UTC (rev 8840) @@ -41,7 +41,8 @@ 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 (const gchar *lang); +/* MAEMO CHANGE: dropped const */ +gchar * _gtk_im_module_get_default_context_id (const gchar *lang); /* The following entry points are exported by each input method module */ Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.c =================================================================== --- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.c 2006-12-20 13:02:10 UTC (rev 8839) +++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.c 2006-12-20 16:04:49 UTC (rev 8840) @@ -85,11 +85,95 @@ gint n_chars, GtkIMMulticontext *multicontext); -static const gchar *global_context_id = NULL; +/* MAEMO START */ +static gboolean hildon_gtk_im_multicontext_filter_event (GtkIMContext *context, + GdkEvent *event); +static void gtk_im_multicontext_show (GtkIMContext *context); +static void gtk_im_multicontext_hide (GtkIMContext *context); + +static void gtk_im_multicontext_notify (GObject *object, + GParamSpec *pspec); + +static gboolean gtk_im_multicontext_has_selection_cb (GtkIMContext *slave, + GtkIMMulticontext *multicontext); +static void gtk_im_multicontext_clipboard_operation_cb (GtkIMContext *slave, + GtkIMContextClipboardOperation op, + GtkIMMulticontext *multicontext); +static void gtk_im_multicontext_slave_input_mode_changed_cb (GtkIMContext *slave, + GParamSpec *pspec, + GtkIMMulticontext *multicontext); + +static GtkIMContext *gtk_im_multicontext_get_slave (GtkIMMulticontext *multicontext); + + +static gchar * +get_global_context_id (void) +{ + gint actual_format, actual_length; + guchar *context_id; + GdkAtom atom, type, actual_type; + gboolean succeeded; + + atom = gdk_atom_intern ("gtk-global-immodule", FALSE); + type = gdk_atom_intern ("STRING", FALSE); + + succeeded = gdk_property_get (gdk_screen_get_root_window (gdk_screen_get_default ()), + atom, + type, + 0, + G_MAXLONG, + FALSE, + &actual_type, + &actual_format, + &actual_length, + &context_id); + + if (!succeeded) + { + /* Fall back to default locale */ + gchar *locale = _gtk_get_lc_ctype (); + context_id = _gtk_im_module_get_default_context_id (locale); + g_free (locale); + } + + return context_id; +} +/* MAEMO END */ + + G_DEFINE_TYPE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT) +/* MAEMO START */ static void +gtk_im_multicontext_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GtkIMContext *slave = gtk_im_multicontext_get_slave (GTK_IM_MULTICONTEXT (object)); + GParamSpec *param_spec; + + param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (slave), + pspec->name); + + if (param_spec != NULL) + g_object_set_property (G_OBJECT(slave), pspec->name, value); +} + +static void +gtk_im_multicontext_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GtkIMContext *slave = gtk_im_multicontext_get_slave (GTK_IM_MULTICONTEXT(object)); + + g_object_get_property (G_OBJECT (slave), pspec->name, value); +} +/* MAEMO END */ + +static void gtk_im_multicontext_class_init (GtkIMMulticontextClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); @@ -108,6 +192,17 @@ gobject_class->finalize = gtk_im_multicontext_finalize; + /* MAEMO START */ + im_context_class->filter_event = hildon_gtk_im_multicontext_filter_event; + im_context_class->show = gtk_im_multicontext_show; + im_context_class->hide = gtk_im_multicontext_hide; + + gobject_class->notify = gtk_im_multicontext_notify; + + gobject_class->set_property = gtk_im_multicontext_set_property; + gobject_class->get_property = gtk_im_multicontext_get_property; + /* MAEMO END */ + g_type_class_add_private (gobject_class, sizeof (GtkIMMulticontextPrivate)); } @@ -152,6 +247,9 @@ { GtkIMMulticontextPrivate *priv = multicontext->priv; gboolean need_preedit_changed = FALSE; + /* MAEMO START */ + HildonGtkInputMode input_mode; + /* MAEMO END */ if (multicontext->slave) { @@ -171,9 +269,32 @@ gtk_im_multicontext_commit_cb, multicontext); + /* MAEMO START */ + g_signal_handlers_disconnect_by_func (multicontext->slave, + gtk_im_multicontext_retrieve_surrounding_cb, + multicontext); + g_signal_handlers_disconnect_by_func (multicontext->slave, + gtk_im_multicontext_delete_surrounding_cb, + multicontext); + g_signal_handlers_disconnect_by_func (multicontext->slave, + gtk_im_multicontext_has_selection_cb, + multicontext); + g_signal_handlers_disconnect_by_func (multicontext->slave, + gtk_im_multicontext_clipboard_operation_cb, + multicontext); + g_signal_handlers_disconnect_by_func (multicontext->slave, + gtk_im_multicontext_slave_input_mode_changed_cb, + multicontext); + /* MAEMO END */ + g_object_unref (multicontext->slave); multicontext->slave = NULL; + /* MAEMO START */ + g_free (multicontext->context_id); + multicontext->context_id = NULL; + /* MAEMO END */ + if (!finalizing) need_preedit_changed = TRUE; } @@ -202,6 +323,21 @@ g_signal_connect (multicontext->slave, "delete_surrounding", G_CALLBACK (gtk_im_multicontext_delete_surrounding_cb), multicontext); + + /* MAEMO START */ + g_signal_connect (multicontext->slave, "has_selection", + G_CALLBACK (gtk_im_multicontext_has_selection_cb), + multicontext); + g_signal_connect (multicontext->slave, "clipboard_operation", + G_CALLBACK (gtk_im_multicontext_clipboard_operation_cb), + multicontext); + g_signal_connect (multicontext->slave, "notify::hildon-input-mode", + G_CALLBACK (gtk_im_multicontext_slave_input_mode_changed_cb), + multicontext); + + g_object_get(multicontext, "hildon-input-mode", &input_mode, NULL); + g_object_set(multicontext->slave, "hildon-input-mode", input_mode, NULL); + /* MAEMO END */ if (!priv->use_preedit) /* Default is TRUE */ gtk_im_context_set_use_preedit (slave, FALSE); @@ -224,17 +360,17 @@ { GtkIMContext *slave; - if (!global_context_id) - { - gchar *locale = _gtk_get_lc_ctype (); - global_context_id = _gtk_im_module_get_default_context_id (locale); - g_free (locale); - } + /* MAEMO START */ + gchar *global_context_id = get_global_context_id(); + /* MAEMO END */ slave = _gtk_im_module_create (global_context_id); gtk_im_multicontext_set_slave (multicontext, slave, FALSE); g_object_unref (slave); + /* MAEMO START */ + g_free (multicontext->context_id); + /* MAEMO END */ multicontext->context_id = global_context_id; } @@ -288,11 +424,29 @@ return FALSE; } +/* MAEMO START */ +static gboolean +hildon_gtk_im_multicontext_filter_event (GtkIMContext *context, + GdkEvent *event) +{ + GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context); + GtkIMContext *slave = gtk_im_multicontext_get_slave (multicontext); + + if (slave) + return hildon_gtk_im_context_filter_event (slave, event); + else + return FALSE; +} +/* MAEMO END */ + static void gtk_im_multicontext_focus_in (GtkIMContext *context) { GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context); GtkIMContext *slave; + /* MAEMO START */ + gchar *global_context_id = get_global_context_id (); + /* MAEMO END */ /* If the global context type is different from the context we were * using before, get rid of the old slave and create a new one @@ -308,6 +462,10 @@ if (slave) gtk_im_context_focus_in (slave); + + /* MAEMO START */ + g_free (global_context_id); + /* MAEMO END */ } static void @@ -395,7 +553,34 @@ gtk_im_context_set_surrounding (slave, text, len, cursor_index); } +/* MAEMO START */ static void +gtk_im_multicontext_notify (GObject *object, + GParamSpec *pspec) +{ + GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (object); + HildonGtkInputMode input_mode_slave, input_mode_multi; + + if (multicontext->slave != NULL && + strcmp (pspec->name, "hildon-input-mode") == 0) + { + g_object_get (multicontext->slave, + "hildon-input-mode", &input_mode_slave, + NULL); + g_object_get (multicontext, + "hildon-input-mode", &input_mode_multi, + NULL); + + /* don't change without comparing, or we'll get to infinite loop */ + if (input_mode_slave != input_mode_multi) + g_object_set (multicontext->slave, + "hildon-input-mode", input_mode_multi, + NULL); + } +} +/* MAEMO END */ + +static void gtk_im_multicontext_preedit_start_cb (GtkIMContext *slave, GtkIMMulticontext *multicontext) { @@ -449,17 +634,52 @@ return result; } +/* MAEMO START */ +static gboolean +gtk_im_multicontext_has_selection_cb (GtkIMContext *slave, + GtkIMMulticontext *multicontext) +{ + gboolean result; + + g_signal_emit_by_name (multicontext, "has_selection", + &result); + + return result; +} + static void +gtk_im_multicontext_clipboard_operation_cb (GtkIMContext *slave, + GtkIMContextClipboardOperation op, + GtkIMMulticontext *multicontext) +{ + g_signal_emit_by_name (multicontext, "clipboard_operation", op); +} + +static void +gtk_im_multicontext_slave_input_mode_changed_cb (GtkIMContext *slave, + GParamSpec *pspec, + GtkIMMulticontext *multicontext) +{ + HildonGtkInputMode input_mode_slave, input_mode_multi; + + g_object_get (slave, "hildon-input-mode", &input_mode_slave, NULL); + g_object_get (multicontext, "hildon-input-mode", &input_mode_multi, NULL); + + /* don't change without comparing, or we'll get to infinite loop */ + if (input_mode_slave != input_mode_multi) + g_object_set (multicontext, "hildon-input-mode", input_mode_slave, NULL); +} +/* MAEMO END */ + +static void activate_cb (GtkWidget *menuitem, GtkIMMulticontext *context) { if (GTK_CHECK_MENU_ITEM (menuitem)->active) { - const gchar *id = g_object_get_data (G_OBJECT (menuitem), "gtk-context-id"); - + /* MAEMO CHANGE: code which overwrote global_context_id has been removed */ gtk_im_context_reset (GTK_IM_CONTEXT (context)); - global_context_id = id; gtk_im_multicontext_set_slave (context, NULL, FALSE); } } @@ -480,6 +700,9 @@ const GtkIMContextInfo **contexts; guint n_contexts, i; GSList *group = NULL; + /* MAEMO START */ + gchar *global_context_id = get_global_context_id(); + /* MAEMO END */ _gtk_im_module_list (&contexts, &n_contexts); @@ -534,8 +757,50 @@ gtk_menu_shell_append (menushell, menuitem); } + /* MAEMO START */ + g_free (global_context_id); + /* MAEMO END */ g_free (contexts); } +/* MAEMO START */ +static void +gtk_im_multicontext_show (GtkIMContext *context) +{ + GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context); + GtkIMContext *slave; + gchar *global_context_id = get_global_context_id (); + + /* If the global context type is different from the context we were + * using before, get rid of the old slave and create a new one + * for the new global context type. + */ + if (!multicontext->context_id || + strcmp (global_context_id, multicontext->context_id) != 0) + gtk_im_multicontext_set_slave (multicontext, NULL, FALSE); + + slave = gtk_im_multicontext_get_slave (multicontext); + + multicontext->priv->focus_in = TRUE; + + if (slave) + gtk_im_context_show (slave); + + g_free (global_context_id); +} + +static void +gtk_im_multicontext_hide (GtkIMContext *context) +{ + GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context); + GtkIMContext *slave = gtk_im_multicontext_get_slave (multicontext); + + multicontext->priv->focus_in = FALSE; + + if (slave) + gtk_im_context_hide (slave); +} +/* MAEMO END */ + #define __GTK_IM_MULTICONTEXT_C__ #include "gtkaliasdef.c" Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.h =================================================================== --- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.h 2006-12-20 13:02:10 UTC (rev 8839) +++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkimmulticontext.h 2006-12-20 16:04:49 UTC (rev 8840) @@ -45,7 +45,8 @@ GtkIMMulticontextPrivate *priv; - const gchar *context_id; + /* MAEMO CHANGE: dropped const */ + gchar *context_id; }; struct _GtkIMMulticontextClass
- Previous message: [maemo-commits] r8839 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . background-manager
- Next message: [maemo-commits] r8841 - projects/haf/trunk/osso-gnomevfs-extra
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]