[maemo-commits] [maemo-commits] r14460 - in projects/haf/branches/hildon-input-method-framework/styled-preedit: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Oct 16 14:52:48 EEST 2007
Author: tjunnone
Date: 2007-10-16 14:52:46 +0300 (Tue, 16 Oct 2007)
New Revision: 14460

Modified:
   projects/haf/branches/hildon-input-method-framework/styled-preedit/ChangeLog
   projects/haf/branches/hildon-input-method-framework/styled-preedit/src/hildon-im-context.c
Log:
2007-10-16  Tomas Junnonen  <tomas.junnonen at nokia.com>

        * src/hildon-im-context.c:
        - Implemented GtkIMContext get_preedit_string class function.
        - Changed the buffered mode so that it only modifies the
          preedit buffer without actually committing to the client,
          until commit_preedit_data is explicitly called.
        - Focus out now commits the preedit buffer to the client



Modified: projects/haf/branches/hildon-input-method-framework/styled-preedit/ChangeLog
===================================================================
--- projects/haf/branches/hildon-input-method-framework/styled-preedit/ChangeLog	2007-10-16 11:38:23 UTC (rev 14459)
+++ projects/haf/branches/hildon-input-method-framework/styled-preedit/ChangeLog	2007-10-16 11:52:46 UTC (rev 14460)
@@ -1,3 +1,12 @@
+2007-10-16  Tomas Junnonen  <tomas.junnonen at nokia.com>
+
+	* src/hildon-im-context.c:
+	- Implemented GtkIMContext get_preedit_string class function.
+	- Changed the buffered mode so that it only modifies the
+	  preedit buffer without actually committing to the client,
+	  until commit_preedit_data is explicitly called.
+	- Focus out now commits the preedit buffer to the client
+
 2007-09-28  Tomas Junnonen  <tomas.junnonen at nokia.com>
 
 	* src/hildon-im-context.c: Applied patch by Mohammad Anwari:

Modified: projects/haf/branches/hildon-input-method-framework/styled-preedit/src/hildon-im-context.c
===================================================================
--- projects/haf/branches/hildon-input-method-framework/styled-preedit/src/hildon-im-context.c	2007-10-16 11:38:23 UTC (rev 14459)
+++ projects/haf/branches/hildon-input-method-framework/styled-preedit/src/hildon-im-context.c	2007-10-16 11:52:46 UTC (rev 14460)
@@ -156,6 +156,12 @@
 static void       hildon_im_context_set_cursor_location (GtkIMContext *context,
                                                          GdkRectangle *area);
 
+static void       hildon_im_context_get_preedit_string  (GtkIMContext  *context,
+                                                         gchar         **str,
+                                                         PangoAttrList **attrs,
+                                                         gint          *cursor_pos);
+
+
 /* Private functions */
 static void       hildon_im_context_show_real           (GtkIMContext *context);
 static void       hildon_im_context_reset_real          (GtkIMContext *context);
@@ -421,6 +427,7 @@
   gtk_im_context_class->set_cursor_location = hildon_im_context_set_cursor_location;
   gtk_im_context_class->reset = hildon_im_context_reset;
   gtk_im_context_class->get_surrounding = hildon_im_context_get_surrounding;
+  gtk_im_context_class->get_preedit_string = hildon_im_context_get_preedit_string;
 
   signal_id = g_signal_lookup("grab-focus", GTK_TYPE_WIDGET);
   grab_focus_hook_id =
@@ -538,8 +545,17 @@
 static void 
 hildon_im_context_commit_preedit_data(HildonIMContext *self)
 {
+
   if (self->pre_edit_buffer != NULL)
+  {
+    if (self->pre_edit_buffer->len > 0)
+    {
+      g_signal_emit_by_name (self, "commit", self->pre_edit_buffer->str);
+    }
     g_string_truncate(self->pre_edit_buffer, 0);
+
+    g_signal_emit_by_name (self, "preedit_changed");
+  }
 }
 
 static void
@@ -1190,6 +1206,8 @@
   self = HILDON_IM_CONTEXT(context);
 
   self->has_focus = FALSE;
+
+  hildon_im_context_commit_preedit_data(self);
 }
 
 static gboolean
@@ -1918,7 +1936,6 @@
 hildon_im_context_insert_utf8(HildonIMContext *self, gint flag,
                               const char *text)
 {
-  gint char_count;
   gint cpos;
   gint to_copy;
   gchar *surrounding, *text_clean = (gchar*) text;
@@ -1964,14 +1981,7 @@
     {
       g_signal_emit_by_name(self, "commit","");
     }
-    else
-    {
-      char_count = g_utf8_strlen(self->pre_edit_buffer->str, -1);
 
-      gtk_im_context_delete_surrounding(GTK_IM_CONTEXT(self),
-                                        -char_count, char_count);
-    }
-
     if(flag == HILDON_IM_MSG_START)
     {
       g_string_assign(self->pre_edit_buffer, text_clean);
@@ -2004,7 +2014,15 @@
      as a result of the change, and we need to clear IM. */
   self->changed_count = 0;
   self->last_internal_change = TRUE;
+
+  if (self->pre_edit_buffer)
+  {
+    g_signal_emit_by_name (self, "preedit_changed");
+  }
+  else
+  {
   g_signal_emit_by_name(self, "commit", text_clean);
+  }
 
   if (free_text == TRUE)
   {
@@ -2358,3 +2376,39 @@
     hildon_im_context_reset_real(context);
   }  
 }
+
+static void     
+hildon_im_context_get_preedit_string (GtkIMContext   *context,
+                                      gchar         **str,
+                                      PangoAttrList **attrs,
+                                      gint           *cursor_pos)
+{
+  HildonIMContext *self = HILDON_IM_CONTEXT(context);
+
+  g_return_if_fail(OSSO_IS_IM_CONTEXT(self));
+
+  if (self->pre_edit_buffer == NULL)
+  {
+    if (str)
+      *str = g_strdup("\0");
+  }
+  else
+  {
+    if (str)
+      *str = g_strdup(self->pre_edit_buffer->str);
+
+    if (attrs)
+    {
+      PangoAttribute *attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
+
+      *attrs = pango_attr_list_new();
+      
+      attr->start_index = 0;
+      attr->end_index = self->pre_edit_buffer->len;
+      pango_attr_list_insert(*attrs, attr);
+    }
+
+    if (cursor_pos)
+      *cursor_pos = self->pre_edit_buffer->len;
+  }
+}


More information about the maemo-commits mailing list