--- anjuta-1.2.0/scintilla/ScintillaGTK.cxx 2003-11-28 18:09:08.000000000 +0800 +++ anjuta-1.2.0/scintilla/ScintillaGTK.cxx 2003-12-10 15:29:50.000000000 +0800 @@ -52,9 +52,9 @@ #include "ExternalLexer.h" #endif -#if GTK_MAJOR_VERSION < 2 +//#if GTK_MAJOR_VERSION < 2 #define INTERNATIONAL_INPUT -#endif +//#endif #if !PLAT_GTK_WIN32 #include @@ -106,9 +106,13 @@ CLIPFORMAT cfColumnSelect; #endif #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 // Input context used for supporting internationalized key entry GdkIC *ic; GdkICAttr *ic_attr; +#else + GtkIMContext *im_context; +#endif #endif // Wheel mouse support unsigned int linesPerScroll; @@ -198,6 +202,10 @@ gint KeyThis(GdkEventKey *event); static gint KeyPress(GtkWidget *widget, GdkEventKey *event); static gint KeyRelease(GtkWidget *widget, GdkEventKey *event); +#if GTK_MAJOR_VERSION >= 2 + static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis); + void CommitThis(char *str); +#endif static void Destroy(GtkObject *object); static void SelectionReceived(GtkWidget *widget, GtkSelectionData *selection_data, guint time); @@ -264,8 +272,12 @@ capturedMouse(false), dragWasDropped(false), lastKey(0), parentClass(0), #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 ic(NULL), ic_attr(NULL), +#else + im_context(NULL), +#endif #endif lastWheelMouseDirection(0), wheelMouseIntensity(0) { @@ -323,6 +335,7 @@ gdk_window_show(widget->window); gdk_cursor_destroy(cursor); #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 if (gdk_im_ready() && (ic_attr = gdk_ic_attr_new()) != NULL) { gint width, height; GdkColormap *colormap; @@ -379,6 +392,12 @@ gdk_im_begin(ic, widget->window); } } +#else + im_context = gtk_im_multicontext_new(); + g_signal_connect(im_context, "commit", + G_CALLBACK(Commit), this); + gtk_im_context_set_client_window(im_context, widget->window); +#endif #endif gtk_widget_realize(PWidget(wText)); gtk_widget_realize(PWidget(scrollbarv)); @@ -399,6 +418,7 @@ gtk_widget_unrealize(PWidget(scrollbarv)); gtk_widget_unrealize(PWidget(scrollbarh)); #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 if (ic) { gdk_ic_destroy(ic); ic = NULL; @@ -407,6 +427,9 @@ gdk_ic_attr_destroy(ic_attr); ic_attr = NULL; } +#else + g_object_unref(im_context); +#endif #endif if (GTK_WIDGET_CLASS(parentClass)->unrealize) GTK_WIDGET_CLASS(parentClass)->unrealize(widget); @@ -474,12 +497,21 @@ #ifdef INTERNATIONAL_INPUT gint ScintillaGTK::CursorMoved(GtkWidget *widget, int xoffset, int yoffset, ScintillaGTK *sciThis) { +#if GTK_MAJOR_VERSION < 2 if (GTK_WIDGET_HAS_FOCUS(widget) && gdk_im_ready() && sciThis->ic && (gdk_ic_get_style (sciThis->ic) & GDK_IM_PREEDIT_POSITION)) { sciThis->ic_attr->spot_location.x = xoffset; sciThis->ic_attr->spot_location.y = yoffset; gdk_ic_set_attr (sciThis->ic, sciThis->ic_attr, GDK_IC_SPOT_LOCATION); } +#else + GdkRectangle area; + area.x = xoffset; + area.y = yoffset; + area.width = 1; + area.height = 1; + gtk_im_context_set_cursor_location(sciThis->im_context, &area); +#endif return FALSE; } #else @@ -495,10 +527,14 @@ sciThis->SetFocusState(true); #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 if (sciThis->ic) gdk_im_begin(sciThis->ic, widget->window); +#else + gtk_im_context_focus_in(sciThis->im_context); #endif - +#endif + return FALSE; } @@ -509,7 +545,11 @@ sciThis->SetFocusState(false); #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 gdk_im_end(); +#else + gtk_im_context_focus_out(sciThis->im_context); +#endif #endif return FALSE; @@ -537,6 +577,7 @@ sciThis->Resize(allocation->width, allocation->height); #ifdef INTERNATIONAL_INPUT +#if GTK_MAJOR_VERSION < 2 if (sciThis->ic && (gdk_ic_get_style (sciThis->ic) & GDK_IM_PREEDIT_POSITION)) { gint width, height; @@ -547,6 +588,7 @@ gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_PREEDIT_AREA); } #endif +#endif } void ScintillaGTK::Initialise() { @@ -966,6 +1008,7 @@ int ScintillaGTK::KeyDefault(int key, int modifiers) { if (!(modifiers & SCI_CTRL) && !(modifiers & SCI_ALT)) { +/* #if GTK_MAJOR_VERSION >= 2 char utfVal[4]="\0\0\0"; wchar_t wcs[2]; @@ -1007,6 +1050,7 @@ } } #endif +*/ if (key < 256) { AddChar(key); return 1; @@ -1707,6 +1751,10 @@ gint ScintillaGTK::KeyThis(GdkEventKey *event) { //Platform::DebugPrintf("SC-key: %d %x [%s]\n", // event->keyval, event->state, (event->length > 0) ? event->string : "empty"); +#if GTK_MAJOR_VERSION >= 2 + if (gtk_im_context_filter_keypress(im_context, event)) + return 1; +#endif if (!event->keyval) { return true; } @@ -1754,6 +1802,20 @@ return FALSE; } +#if GTK_MAJOR_VERSION >= 2 +void ScintillaGTK::Commit(GtkIMContext *context, + char *str, + ScintillaGTK *sciThis) +{ + sciThis->CommitThis(str); +} + +void ScintillaGTK::CommitThis(char *str) +{ + AddCharUTF(str, strlen(str)); +} +#endif + void ScintillaGTK::Destroy(GtkObject* object) { ScintillaObject *scio = reinterpret_cast(object); // This avoids a double destruction