? autom4te.cache
? stamp-h1
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libzvt/ChangeLog,v
retrieving revision 1.337
diff -u -r1.337 ChangeLog
--- ChangeLog	14 May 2002 16:55:14 -0000	1.337
+++ ChangeLog	19 May 2002 09:09:08 -0000
@@ -1,3 +1,8 @@
+2002-05-19  Gustavo Giráldez  <gustavo.giraldez@gmx.net>
+
+	* libzvt/zvtterm.h, libzvt/zvtterm.c: Added GtkIMContextSimple
+	input context object to the widget.
+
 2002-05-14  Michael Meeks  <michael@ximian.com>
 
 	* libzvt/zvtterm.c (zvt_term_set_color_scheme): setup
Index: libzvt/libzvt.h
===================================================================
RCS file: /cvs/gnome/libzvt/libzvt/libzvt.h,v
retrieving revision 1.13
diff -u -r1.13 libzvt.h
--- libzvt/libzvt.h	14 May 2002 04:04:07 -0000	1.13
+++ libzvt/libzvt.h	19 May 2002 09:09:08 -0000
@@ -37,6 +37,7 @@
 #include <gtk/gtkadjustment.h>
 #include <gtk/gtkwidget.h>
 #include <gtk/gtksignal.h>
+#include <gtk/gtkimcontextsimple.h>
 #include <libzvt/vtx.h>
 #include <libzvt/background.h>
 
@@ -119,8 +120,10 @@
   /*GdkColorContext *color_ctx;*/	/* Color context in use, where we allocate our colors */
   /* gulong colors [18];*/	/* Our colors, pixel values. */
   GdkColor colors [18];		/* GdkColor for colormap support */
-  /* GdkIC depecated, needto be substituted with GtkIMContext, not yet done */
-  /* GdkIC *ic;*/		/* input context */
+
+  /* input context */
+  GtkIMContext *ic;
+  gboolean      need_im_reset;
 
  /* file name of a pixmap, if NULL, none is loaded
   * and normal mode is used
Index: libzvt/zvtterm.c
===================================================================
RCS file: /cvs/gnome/libzvt/libzvt/zvtterm.c,v
retrieving revision 1.186
diff -u -r1.186 zvtterm.c
--- libzvt/zvtterm.c	14 May 2002 16:55:21 -0000	1.186
+++ libzvt/zvtterm.c	19 May 2002 09:09:12 -0000
@@ -388,9 +388,9 @@
   /* Deprecated */
   /*
   term->color_ctx = 0;
-  term->ic = NULL;
   */
-
+  term->ic = NULL;
+  
   /* grid sizing */
   term->grid_width = term->vx->vt.width;
   term->grid_height = term->vx->vt.height;
@@ -407,10 +407,6 @@
   term->scroll_on_keystroke = 0;
   term->scroll_on_output = 0;
   term->blink_enabled = 1;
-  /* Deprecated */
-  /*
-  term->ic = NULL;
-  */
   term->in_expose = 0;
   term->transparent = 0;
   term->shaded = 0;
@@ -759,14 +755,12 @@
     term->adjustment = NULL;
   }
 
-  /* Deprecated */
-  /*
+  /* destroy input context */
   if (term->ic) {
-    gdk_ic_destroy(term->ic);
+    g_object_unref (term->ic);
     term->ic = NULL;
   }
-  */
-
+    
   /* release private data */
   if (zp) {
     if (zp->text_expand)
@@ -964,6 +958,30 @@
 }
 
 static void
+zvt_term_commit_handler (GtkIMContext  *context,
+			 const gchar   *str,
+			 ZvtTerm       *term)
+{
+  gint   length = 0;
+  gchar *locstr = g_locale_from_utf8 (str, -1, NULL, &length, NULL);
+
+  if (length > 0) {
+    vt_writechild (&term->vx->vt, locstr, length);
+    if (term->scroll_on_keystroke) zvt_term_scroll (term, 0);
+  }
+  g_free (locstr);
+}
+
+static void
+zvt_term_im_reset (ZvtTerm *term)
+{
+  if (term->ic && term->need_im_reset) {
+    term->need_im_reset = FALSE;
+    gtk_im_context_reset (term->ic);
+  }
+}
+
+static void
 zvt_term_realize (GtkWidget *widget)
 {
   ZvtTerm *term;
@@ -1066,20 +1084,15 @@
   term_force_size(term);
 
   /* input context */
-#ifdef UNDEF
-  if (gdk_im_ready () && !term->ic) {
-    GdkICAttr attr;
-    
-    /* FIXME: do we have any window yet? */
-    attr.style = GDK_IM_PREEDIT_NOTHING | GDK_IM_STATUS_NOTHING;
-    attr.client_window = attr.focus_window = widget->window;
-    term->ic = gdk_ic_new(&attr, GDK_IC_ALL_REQ);
-    
-    if (!term->ic) {
-      g_warning("Can't create input context.");
-    }
+  if (!term->ic) {
+    term->ic = gtk_im_context_simple_new ();
+    g_signal_connect (term->ic, "commit",
+		      G_CALLBACK (zvt_term_commit_handler), term);
   }
-#endif /* UNDEF */
+  
+  if (term->ic)
+    gtk_im_context_set_client_window (term->ic, widget->window);
+  
   /* if we have a delayed background set, set it here? */
   if (zp->background_queue) {
     zvt_term_background_load(term, zp->background_queue);
@@ -1129,6 +1142,9 @@
   g_object_unref (term->fore_gc);
   term->fore_gc = NULL;
 
+  if (term->ic)
+    gtk_im_context_set_client_window (term->ic, NULL);
+  
   if (GTK_WIDGET_CLASS (parent_class)->unrealize)
     (*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
 }
@@ -1190,12 +1206,11 @@
   if (term->blink_enabled && term->timeout_id == -1)
     term->timeout_id = gtk_timeout_add (500, zvt_term_cursor_blink, term);
 
-  /* Deprecated */
-  /*
-  if (term->ic)
-    gdk_im_begin (term->ic, widget->window);
-  */
-
+  if (term->ic) {
+    term->need_im_reset = TRUE;
+    gtk_im_context_focus_in (term->ic);
+  }
+  
   return FALSE;
 }
 
@@ -1222,12 +1237,11 @@
     term->timeout_id = -1;
   }
   
-  /* Deprecated */
-  /*
-  if (term->ic)
-    gdk_im_end ();
-  */
-
+  if (term->ic) {
+    term->need_im_reset = TRUE;
+    gtk_im_context_focus_out (term->ic);
+  }
+  
   return FALSE;
 }
 
@@ -1690,6 +1704,7 @@
 
   zvt_term_show_pointer (term);
 
+  zvt_term_im_reset (term);
 
   gdk_window_get_pointer(widget->window, &x, &y, &mask);
   x /= term->charwidth;
@@ -2511,6 +2526,13 @@
                             event->keyval,
                             event->state)){
   
+    if (term->ic) {
+      if (gtk_im_context_filter_keypress (term->ic, event)) {
+	term->need_im_reset = TRUE;
+	return TRUE;
+      }
+    }
+    
   switch (event->keyval) {
   case GDK_BackSpace:
     if (term->backspace_binding == ZVT_ERASE_CONTROL_H ||
@@ -2711,6 +2733,7 @@
   if (handled && p>buffer) {
     vt_writechild(&vx->vt, buffer, (p-buffer));
     if (term->scroll_on_keystroke) zvt_term_scroll (term, 0);
+    zvt_term_im_reset (term);
   }
   }
 
