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

Re: chinese support glitches?



In <1078392352.1650.10.camel@debian>
  "chinese support glitches?" on Thu, 04 Mar 2004 17:25:52 +0800,
  Yao Heling <linux@800e.net> wrote:
> the title etc. using chinese). But when I try to use a DiaText object, I
> can't activate the XIM I'm using by pressing CTRL + Space (though I can

This means that you can't activate XIM rather than can't input
Chinese by XIM, doesn't it?

Uhm, I can activate XIMs (kinput2 and uim-xim). I suggest you
to use uim which can input many language included Chinese,
support gtk+'s immodule and XIM and is included in Debian
packages.
  http://www.freedesktop.org/bin/view/Software/uim

> doesn't allow me to use XIM and enter chinese directly onto the canvas

Please try an attached patch. If your problem is solved it
is solved in Dia 0.9.3 too. :D

  % apt-get source dia
  % cd dia
  % patch -p0 < preedit_dia20040301.diff # It's an attached patch
  % auto-apt run fakeroot debian/rules binary && sudo dpkg -i ../dia*.deb

--
kou
Index: app/disp_callbacks.c
===================================================================
RCS file: /cvs/gnome/dia/app/disp_callbacks.c,v
retrieving revision 1.75
diff -u -p -r1.75 disp_callbacks.c
--- app/disp_callbacks.c	27 Feb 2004 16:27:10 -0000	1.75
+++ app/disp_callbacks.c	2 Mar 2004 04:05:08 -0000
@@ -395,11 +395,31 @@ void ddisplay_im_context_commit(GtkIMCon
          (the default IM on X should perform the local->UTF8 conversion)
       */
       
-  handle_key_event(ddisp, active_focus(), 0, str, g_utf8_strlen(str,-1));
+  Focus *focus = active_focus();
+
+  ddisplay_im_context_preedit_reset(ddisp, focus);
+  
+  if (focus != NULL)
+    handle_key_event(ddisp, 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,
+                                    &ddisp->preedit_attrs, &cursor_pos);
+  if (ddisp->preedit_string != NULL) {
+    if (focus != NULL) {
+      handle_key_event(ddisp, focus, 0, ddisp->preedit_string,
+                       g_utf8_strlen(ddisp->preedit_string,-1));
+    } else {
+      ddisplay_im_context_preedit_reset(ddisp, focus);
+    }
+  }
 /*  char *str;
   PangoAttrList *attrs;
   gint cursor_pos;
Index: app/display.c
===================================================================
RCS file: /cvs/gnome/dia/app/display.c,v
retrieving revision 1.82
diff -u -p -r1.82 display.c
--- app/display.c	19 Feb 2004 16:51:05 -0000	1.82
+++ app/display.c	2 Mar 2004 04:05:09 -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,9 +175,11 @@ new_display(Diagram *dia)
   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);
+  ddisp->preedit_attrs = NULL;
   
   create_display_shell(ddisp, prefs.new_view.width, prefs.new_view.height,
 		       filename, prefs.new_view.use_menu_bar, !embedded);
@@ -938,6 +942,8 @@ ddisp_destroy(DDisplay *ddisp)
   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);
 }
 
@@ -1191,3 +1197,25 @@ display_set_active(DDisplay *ddisp)
     }
   }
 }
+
+void
+ddisplay_im_context_preedit_reset(DDisplay *ddisp, Focus *focus)
+{
+  if (ddisp->preedit_string != NULL) {
+    if (focus != 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;
+  }
+  if (ddisp->preedit_attrs != NULL) {
+    pango_attr_list_unref(ddisp->preedit_attrs);
+    ddisp->preedit_attrs = NULL;
+  }
+}
Index: app/display.h
===================================================================
RCS file: /cvs/gnome/dia/app/display.h,v
retrieving revision 1.29
diff -u -p -r1.29 display.h
--- app/display.h	10 Sep 2003 21:05:56 -0000	1.29
+++ app/display.h	2 Mar 2004 04:05:09 -0000
@@ -92,6 +92,10 @@ struct _DDisplay {
   guint update_id;                /* idle handler ID for redraws       */
 
   GtkIMContext *im_context;
+
+  /* Preedit String */
+  gchar *preedit_string;
+  PangoAttrList *preedit_attrs;
 };
 
 extern GdkCursor *default_cursor;
@@ -155,4 +159,6 @@ void ddisplay_do_update_menu_sensitivity
 
 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 -p -r1.51 text.c
--- lib/text.c	30 Nov 2003 13:19:38 -0000	1.51
+++ lib/text.c	2 Mar 2004 04:05:10 -0000
@@ -872,10 +872,12 @@ text_key_event(Focus *focus, guint keyva
       default:
         if (str || (strlen>0)) {
 
+          int str_len;
           return_val = TRUE;
           utf = str;
-          for (utf = str ; utf && *utf && (utf-str <= strlen) ; 
-	       utf = g_utf8_next_char (utf)) {
+          for (utf = str, str_len = strlen;
+               utf && *utf && str_len > 0;
+               utf = g_utf8_next_char (utf), str_len--) {
             c = g_utf8_get_char (utf);
             
             *change = text_create_change (text, TYPE_INSERT_CHAR, c,


[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