[gtk+] GtkIMMultcontext: Propagate input purpose and hints



commit 870c39fafea46c87ce5b8d6df4c9b9144562afad
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 25 15:40:50 2012 -0400

    GtkIMMultcontext: Propagate input purpose and hints
    
    The lack of this was pointed out by Carlos Garnacho in
    https://bugzilla.gnome.org/show_bug.cgi?id=651244

 gtk/gtkimmulticontext.c |   39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c
index 8ff04da..66e47b9 100644
--- a/gtk/gtkimmulticontext.c
+++ b/gtk/gtkimmulticontext.c
@@ -55,6 +55,8 @@ struct _GtkIMMulticontextPrivate
   guint                  focus_in             : 1;
 };
 
+static void     gtk_im_multicontext_notify             (GObject                 *object,
+                                                        GParamSpec              *pspec);
 static void     gtk_im_multicontext_finalize           (GObject                 *object);
 
 static void     gtk_im_multicontext_set_slave          (GtkIMMulticontext       *multicontext,
@@ -100,6 +102,8 @@ static gboolean gtk_im_multicontext_delete_surrounding_cb   (GtkIMContext      *
 							     gint               n_chars,
 							     GtkIMMulticontext *multicontext);
 
+static void propagate_purpose (GtkIMMulticontext *context);
+
 static const gchar *global_context_id = NULL;
 
 G_DEFINE_TYPE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT)
@@ -109,7 +113,9 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
   GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class);
-  
+
+  gobject_class->notify = gtk_im_multicontext_notify;
+
   im_context_class->set_client_window = gtk_im_multicontext_set_client_window;
   im_context_class->get_preedit_string = gtk_im_multicontext_get_preedit_string;
   im_context_class->filter_keypress = gtk_im_multicontext_filter_keypress;
@@ -198,13 +204,15 @@ gtk_im_multicontext_set_slave (GtkIMMulticontext *multicontext,
       if (!finalizing)
 	need_preedit_changed = TRUE;
     }
-  
+
   priv->slave = slave;
 
   if (priv->slave)
     {
       g_object_ref (priv->slave);
 
+      propagate_purpose (multicontext);
+
       g_signal_connect (priv->slave, "preedit-start",
 			G_CALLBACK (gtk_im_multicontext_preedit_start_cb),
 			multicontext);
@@ -223,7 +231,7 @@ gtk_im_multicontext_set_slave (GtkIMMulticontext *multicontext,
       g_signal_connect (priv->slave, "delete-surrounding",
 			G_CALLBACK (gtk_im_multicontext_delete_surrounding_cb),
 			multicontext);
-      
+
       if (!priv->use_preedit)	/* Default is TRUE */
 	gtk_im_context_set_use_preedit (slave, FALSE);
       if (priv->client_window)
@@ -754,3 +762,28 @@ gtk_im_multicontext_set_context_id (GtkIMMulticontext *context,
   priv->context_id_aux = g_strdup (context_id);
   gtk_im_multicontext_set_slave (context, NULL, FALSE);
 }
+
+static void
+propagate_purpose (GtkIMMulticontext *context)
+{
+  GtkInputPurpose purpose;
+  GtkInputHints hints;
+
+g_print ("propagate purpose to %p\n", context->priv->slave);
+
+  if (context->priv->slave == NULL)
+    return;
+
+  g_object_get (context, "input-purpose", &purpose, NULL);
+  g_object_set (context->priv->slave, "input-purpose", purpose, NULL);
+
+  g_object_get (context, "input-hints", &hints, NULL);
+  g_object_set (context->priv->slave, "input-hints", hints, NULL);
+}
+
+static void
+gtk_im_multicontext_notify (GObject      *object,
+                            GParamSpec   *pspec)
+{
+  propagate_purpose (GTK_IM_MULTICONTEXT (object));
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]