commentIndex = index;
MarkMenu("View.Comments", CommentDlg);
if(GenericPopUp(commentOptions, title, CommentDlg, BoardWindow, NONMODAL, 1))
- AddHandler(&commentOptions[0], 1);
+ AddHandler(&commentOptions[0], CommentDlg, 1);
}
void
{
MarkMenu("View.ICSInputBox", InputBoxDlg);
if(GenericPopUp(boxOptions, _("ICS input box"), InputBoxDlg, BoardWindow, NONMODAL, 0))
- AddHandler(&boxOptions[0], 3);
+ AddHandler(&boxOptions[0], InputBoxDlg, 3);
}
void
static char buf[2];
buf[0] = firstchar; ASSIGN(icsText, buf);
if(GenericPopUp(typeOptions, _("Type a move"), TransientDlg, BoardWindow, MODAL, 0))
- AddHandler(&typeOptions[0], 2);
+ AddHandler(&typeOptions[0], TransientDlg, 2);
}
void
ASSIGN(answer, "");
askOptions[0].name = question;
if(GenericPopUp(askOptions, title, AskDlg, BoardWindow, MODAL, 0))
- AddHandler(&askOptions[1], 2);
+ AddHandler(&askOptions[1], AskDlg, 2);
}
//---------------------------- Promotion Popup --------------------------------------
ChatProc ()
{
if(GenericPopUp(chatOptions, _("Chat box"), ChatDlg, BoardWindow, NONMODAL, 0))
- AddHandler(&chatOptions[0], 2), AddHandler(&chatOptions[6], 2); // treats return as OK
+ AddHandler(&chatOptions[0], ChatDlg, 2), AddHandler(&chatOptions[6], ChatDlg, 2); // treats return as OK
MarkMenu("View.OpenChatWindow", ChatDlg);
}
void SetIconName P((DialogClass dlg, char *name));
int ReadScroll P((Option *opt, float *top, float *bottom));
void SetScroll P((Option *opt, float f));
-void AddHandler P((Option *opt, int nr));
+void AddHandler P((Option *opt, DialogClass dlg, int nr));
void SendText P((int n));
void DisplayLogos P((Option *left, Option *right));
void Browse P((DialogClass dlg, char *label, char *proposed, char *ext,
if (GenericPopUp(engoutOptions, _(title), EngOutDlg, BoardWindow, NONMODAL, 1)) {
if(engoutOptions[STRIDE-1].type != Break)
DisplayFatalError(_("Mismatch of STRIDE in nengineoutput.c\nChange and recompile!"), 0, 2);
- AddHandler(&engoutOptions[MEMO], 6);
- AddHandler(&engoutOptions[MEMO+STRIDE], 6);
+ AddHandler(&engoutOptions[MEMO], EngOutDlg, 6);
+ AddHandler(&engoutOptions[MEMO+STRIDE], EngOutDlg, 6);
if( needInit ) {
InitEngineOutput(&engoutOptions[0], &engoutOptions[MEMO]); // make icon bitmaps
needInit = FALSE;
static void GL_Button P((int n));
static Option gamesOptions[] = {
-{ 200, LR|TB, 400, NULL, (void*) list, "", NULL, ListBox, "" },
+{ 200, LR|TB, 400, NULL, (void*) list, NULL, NULL, ListBox, "" },
{ 0, 0, 100, NULL, (void*) &filterPtr, "", NULL, TextBox, "" },
{ 4, SAME_ROW, 0, NULL, (void*) &GL_Button, NULL, NULL, Button, N_("find position") },
{ 2, SAME_ROW, 0, NULL, (void*) &GL_Button, NULL, NULL, Button, N_("narrow") }, // buttons referred to by ID in value (=first) field!
{
int new;
if(new = GenericPopUp(gamesOptions, name, GameListDlg, BoardWindow, NONMODAL, 1))
- AddHandler(&gamesOptions[1], 4),
- AddHandler(&gamesOptions[0], 5);
+ AddHandler(&gamesOptions[1], GameListDlg, 4),
+ AddHandler(&gamesOptions[0], GameListDlg, 5);
FocusOnWidget(&gamesOptions[0], GameListDlg);
return new;
}
HistoryPopUp ()
{
if(GenericPopUp(historyOptions, _("Move list"), HistoryDlg, BoardWindow, NONMODAL, 1))
- AddHandler(&historyOptions[0], 0);
+ AddHandler(&historyOptions[0], HistoryDlg, 0);
MarkMenu("View.MoveHistory", HistoryDlg);
}
};
void
-AddHandler (Option *opt, int nr)
+AddHandler (Option *opt, DialogClass dlg, int nr)
{
XtOverrideTranslations(opt->handle, XtParseTranslationTable(translationTable[nr]));
}
}
void
-HighlightListBoxItem (Option *opt, int index)
+HighlightItem (Option *opt, int index, int scroll)
{
char *value, **data = (char **) (opt->target);
GtkWidget *list = (GtkWidget *) (opt->handle);
GtkListStore *store = GTK_LIST_STORE(model);
GtkTreePath *path = gtk_tree_path_new_from_indices(index, -1);
GtkTreeIter iter;
- gtk_tree_model_get_iter(GTK_TREE_MODEL (store), &iter, path);
+ gtk_tree_selection_select_path(selection, path);
+ if(scroll) gtk_tree_view_scroll_to_cell(list, path, NULL, 0, 0, 0);
gtk_tree_path_free(path);
- gtk_tree_selection_select_iter(selection, &iter);
}
void
-HighlightWithScroll (Option *opt, int sel, int max)
+HighlightListBoxItem (Option *opt, int index)
+{
+ HighlightItem (opt, index, FALSE);
+}
+
+void
+HighlightWithScroll (Option *opt, int index, int max)
{
- HighlightListBoxItem (opt, index); // just highlight, as GTK scrolls by itself
+ HighlightItem (opt, index, TRUE); // ignore max
}
int
}
static gboolean
+GameListEvent(GtkWidget *widget, GdkEvent *event, gpointer gdata)
+{
+ int n = (int) gdata;
+
+ if(n == 4) {
+ if(((GdkEventKey *) event)->keyval != GDK_Return) return FALSE;
+ SetFilter();
+ return TRUE;
+ }
+
+ if(event->type == GDK_KEY_PRESS) {
+ int ctrl = (((GdkEventKey *) event)->state & GDK_CONTROL_MASK) != 0;
+ switch(((GdkEventKey *) event)->keyval) {
+ case GDK_Up: GameListClicks(-1 - 2*ctrl); return TRUE;
+ case GDK_Left: GameListClicks(-1); return TRUE;
+ case GDK_Down: GameListClicks(1 + 2*ctrl); return TRUE;
+ case GDK_Right: GameListClicks(1); return TRUE;
+ case GDK_Prior: GameListClicks(-4); return TRUE;
+ case GDK_Next: GameListClicks(4); return TRUE;
+ case GDK_Home: GameListClicks(-2); return TRUE;
+ case GDK_End: GameListClicks(2); return TRUE;
+ case GDK_Return: GameListClicks(0); return TRUE;
+ default: return FALSE;
+ }
+ }
+ if(event->type != GDK_2BUTTON_PRESS || ((GdkEventButton *) event)->button != 1) return FALSE;
+ GameListClicks(0);
+ return TRUE;
+}
+
+static gboolean
MemoEvent(GtkWidget *widget, GdkEvent *event, gpointer gdata)
{ // handle mouse clicks on text widgets that need it
int w, h;
}
void
-AddHandler (Option *opt, int nr)
+AddHandler (Option *opt, DialogClass dlg, int nr)
{
switch(nr) {
case 0:
case 1:
case 2: break;
- case 3: g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (ICSKeyEvent), NULL); break; // Input Box
- case 4:
- case 5:
- case 6: break;
+ case 3: // input box
+ g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (ICSKeyEvent), NULL); break; // Input Box
+ case 5: // game list
+ g_signal_connect(opt->handle, "button-press-event", G_CALLBACK (GameListEvent), (gpointer) 0 );
+ case 4: // game-list filter
+ g_signal_connect(opt->handle, "key-press-event", G_CALLBACK (GameListEvent), (gpointer) nr );
+ break;
+ case 6:
+ break;
}
-#ifdef TODO_GTK
- XtOverrideTranslations(opt->handle, XtParseTranslationTable(translationTable[nr]));
-#endif
}
//----------------------------Generic dialog --------------------------------------------
xev.xclient.data.l[1] = CurrentTime;
XSendEvent (xDisplay,
- root, False,
+ root, False,static gboolean
+MemoEvent(GtkWidget *widget, GdkEvent *event, gpointer gdata)
+
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);