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

Re: [PATCH] show preedit string



Sory, I noticed the patch which I sent before doesn't
include all diff. I attach a collect patch.

In <20040116.230007.111746271.kou@cozmixng.org>
  "[PATCH] show preedit string" on Fri, 16 Jan 2004 23:00:07 +0900 (JST),
  Kouhei Sutou <kou@cozmixng.org> wrote:
> I made a patch for showing preedit string when using input
> method.


Index: app/disp_callbacks.c
===================================================================
RCS file: /cvs/gnome/dia/app/disp_callbacks.c,v
retrieving revision 1.73
diff -u -r1.73 disp_callbacks.c
--- app/disp_callbacks.c	2 Nov 2003 10:58:30 -0000	1.73
+++ app/disp_callbacks.c	16 Jan 2004 14:26:21 -0000
@@ -364,11 +364,24 @@
          (the default IM on X should perform the local->UTF8 conversion)
       */
       
+  ddisplay_im_context_preedit_reset(ddisp, active_focus());
+
   handle_key_event(ddisp, active_focus(), 0, str, g_utf8_strlen(str,-1));
 }
 
 void ddisplay_im_context_preedit_changed(GtkIMContext *context,
                                          DDisplay *ddisp) {
+  gint cursor_pos;
+  Focus *focus = active_focus();
+
+  ddisplay_im_context_preedit_reset(ddisp, focus);
+  
+  gtk_im_context_get_preedit_string(context, &ddisp->preedit_string,
+                                    NULL, &cursor_pos);
+  if (ddisp->preedit_string != NULL) {
+    handle_key_event(ddisp, active_focus(), 0, ddisp->preedit_string,
+                     g_utf8_strlen(ddisp->preedit_string,-1));
+  }
 /*  char *str;
   PangoAttrList *attrs;
   gint cursor_pos;
Index: app/display.c
===================================================================
RCS file: /cvs/gnome/dia/app/display.c,v
retrieving revision 1.81
diff -u -r1.81 display.c
--- app/display.c	31 Dec 2003 11:44:37 -0000	1.81
+++ app/display.c	16 Jan 2004 14:26:22 -0000
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <math.h>
+#include <gdk/gdkkeysyms.h>
 
 #ifdef GNOME
 #include <gnome.h>
@@ -33,6 +34,7 @@
 #include "display.h"
 #include "group.h"
 #include "interface.h"
+#include "focus.h"
 #include "color.h"
 #include "handle_ops.h"
 #include "connectionpoint_ops.h"
@@ -173,6 +175,7 @@
   ddisp->im_context = gtk_im_multicontext_new();
   g_signal_connect (G_OBJECT (ddisp->im_context), "commit",
                     G_CALLBACK (ddisplay_im_context_commit), ddisp);
+  ddisp->preedit_string = NULL;
   g_signal_connect (G_OBJECT (ddisp->im_context), "preedit_changed",
                     G_CALLBACK (ddisplay_im_context_preedit_changed),
                     ddisp);
@@ -938,6 +941,8 @@
   g_object_unref (G_OBJECT (ddisp->im_context));
   ddisp->im_context = NULL;
 
+  ddisplay_im_context_preedit_reset(ddisp, active_focus());
+
   gtk_widget_destroy (ddisp->shell);
 }
 
@@ -1189,5 +1194,20 @@
                                      GTK_WINDOW(ddisp->shell));
       }
     }
+  }
+}
+
+void
+ddisplay_im_context_preedit_reset(DDisplay *ddisp, Focus *focus)
+{
+  if (ddisp->preedit_string != NULL) {
+    int i;
+    ObjectChange *change;
+    
+    for (i = 0; i < g_utf8_strlen(ddisp->preedit_string, -1); i++) {
+      (focus->key_event)(focus, GDK_BackSpace, NULL, 0, &change);
+    }
+		g_free(ddisp->preedit_string);
+    ddisp->preedit_string = NULL;
   }
 }
Index: app/display.h
===================================================================
RCS file: /cvs/gnome/dia/app/display.h,v
retrieving revision 1.29
diff -u -r1.29 display.h
--- app/display.h	10 Sep 2003 21:05:56 -0000	1.29
+++ app/display.h	16 Jan 2004 14:26:22 -0000
@@ -92,6 +92,9 @@
   guint update_id;                /* idle handler ID for redraws       */
 
   GtkIMContext *im_context;
+
+	/* Preedit String */
+	gchar* preedit_string;
 };
 
 extern GdkCursor *default_cursor;
@@ -154,5 +157,7 @@
 void ddisplay_do_update_menu_sensitivity (DDisplay *ddisp);
 
 void display_set_active(DDisplay *ddisp);
+
+void ddisplay_im_context_preedit_reset(DDisplay *ddisp, Focus *focus);
 
 #endif /* DDISPLAY_H */
Index: lib/text.c
===================================================================
RCS file: /cvs/gnome/dia/lib/text.c,v
retrieving revision 1.51
diff -u -r1.51 text.c
--- lib/text.c	30 Nov 2003 13:19:38 -0000	1.51
+++ lib/text.c	16 Jan 2004 14:26:23 -0000
@@ -872,9 +872,11 @@
       default:
         if (str || (strlen>0)) {
 
+          glong str_len = g_utf8_strlen(str, -1);
           return_val = TRUE;
           utf = str;
-          for (utf = str ; utf && *utf && (utf-str <= strlen) ; 
+          for (utf = str ; utf && *utf &&
+                 ((g_utf8_strlen(utf, -1) - str_len) <= strlen) ; 
 	       utf = g_utf8_next_char (utf)) {
             c = g_utf8_get_char (utf);
   
          
--
kou



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK