From 9f047d862ad5c6dc91a42646730cf59fe56e455d Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 30 Oct 2012 10:59:45 +0100 Subject: [PATCH] Fix Chat Box The genric TypeInProc is re-instated, and replaces ICSKeyEvent as primary handler for special keys in one-liner text edits. --- dialogs.c | 1 + gtk/xoptions.c | 35 ++++++++++++----------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/dialogs.c b/dialogs.c index 475f6e6..690eb2a 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1640,6 +1640,7 @@ int ChatOK (int n) { // can only be called through in chat-partner text-edit, as there is no OK button char buf[MSG_SIZ]; + if(!partner || strcmp(partner, chatPartner[activePartner])) { safeStrCpy(chatPartner[activePartner], partner, MSG_SIZ); SetWidgetText(&chatOptions[5], "", -1); // clear text if we alter partner diff --git a/gtk/xoptions.c b/gtk/xoptions.c index d5ade4c..c7e7535 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -244,7 +244,10 @@ SetWidgetState (Option *opt, int state) void SetWidgetLabel (Option *opt, char *buf) { - gtk_label_set_text(opt->handle, buf); + if(opt->type == Button) // Chat window uses this routine for changing button labels + gtk_button_set_label(opt->handle, buf); + else + gtk_label_set_text(opt->handle, buf); } void @@ -438,7 +441,7 @@ CreateMenuPopup (Option *opt, int n, int def) return menu; } -Option *typeIn; // kludge to distinguish type-in callback from input-box callback +Option *icsBox; // kludge to distinguish type-in callback from input-box callback void CursorAtEnd (Option *opt) @@ -447,21 +450,9 @@ CursorAtEnd (Option *opt) } static gboolean -ICSKeyEvent(GtkWidget *widget, GdkEventKey *event, gpointer g) -{ - Option *opt = (Option *) g; - if(opt == typeIn) { - if(event->keyval == GDK_Return) { - char *val; - GetWidgetText(opt, &val); - TypeInDoneEvent(val); - PopDown(TransientDlg); - return TRUE; - } - return FALSE; - } - - switch(event->keyval) { +ICSKeyEvent (int keyval) +{ // TODO_GTK: arrow-handling should really be integrated in type-in proc, and this should be a backe-end OK handler + switch(keyval) { case GDK_Return: IcsKey(0); return TRUE; case GDK_Up: IcsKey(1); return TRUE; case GDK_Down: IcsKey(-1); return TRUE; @@ -613,10 +604,10 @@ AddHandler (Option *opt, DialogClass dlg, int nr) case 0: // history (now uses generic textview callback) case 1: // comment (likewise) break; - case 2: // move type-in - typeIn = opt; case 3: // input box - g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (ICSKeyEvent), (gpointer) opt); + icsBox = opt; + case 2: // move type-in + g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (TypeInProc), (gpointer) (dlg<<16 | (opt - dialogOptions[dlg]))); break; case 5: // game list g_signal_connect(opt->handle, "button-press-event", G_CALLBACK (GameListEvent), (gpointer) 0 ); @@ -1566,9 +1557,7 @@ SetInsertPos (Option *opt, int pos) void HardSetFocus (Option *opt) { -#ifdef TODO_GTK - XSetInputFocus(xDisplay, XtWindow(opt->handle), RevertToPointerRoot, CurrentTime); -#endif + FocusOnWidget(opt, 0); // second arg not used in GDK } -- 1.7.0.4