X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xhistory.c;h=fda729060980eebe0cf2cb798d73fd0544305ee5;hb=a0cb295983b04fd42e92f9e99da71917a1a2a97e;hp=6bf4ad016ca3246cd26c6653d0cd8f4da320d7e3;hpb=9be4b067e4e5d8026be07acd417b51b4ee377822;p=xboard.git diff --git a/xhistory.c b/xhistory.c index 6bf4ad0..fda7290 100644 --- a/xhistory.c +++ b/xhistory.c @@ -61,6 +61,7 @@ extern char *getenv(); extern GtkWidget *GUI_History; extern GtkListStore *LIST_MoveHistory; +extern GtkTreeView *TREE_History; String dots=" ... "; Position gameHistoryX, gameHistoryY; @@ -77,20 +78,52 @@ HistoryPopDown(object, user_data) return; } -void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data) +void +HistoryMoveProc(window, event, data) + GtkWindow *window; + GdkEvent *event; + gpointer data; { - int to; - /* - XawListReturnStruct *R = (XawListReturnStruct *) call_data; - if (w == hist->mvn || w == hist->mvw) { - to=2*R->list_index-1; - ToNrEvent(to); - } - else if (w == hist->mvb) { - to=2*R->list_index; - ToNrEvent(to); + int to; /* the move we want to go to */ + + /* check if the mouse was clicked */ + if(event->type == GDK_BUTTON_PRESS) + { + GtkTreeViewColumn *column; + GtkTreePath *path; + GList *cols; + gint *indices; + gint row,col; + + /* can we convert this into an element of the history list? */ + if(gtk_tree_view_get_path_at_pos(TREE_History, + (gint)event->button.x, (gint)event->button.y, + &path,&column,NULL,NULL)) + { + /* find out which row and column the user clicked on */ + indices = gtk_tree_path_get_indices(path); + row = indices[0]; + cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(column->tree_view)); + col = g_list_index(cols,(gpointer)column); + g_list_free(cols); + gtk_tree_path_free(path); + + printf("DEBUG: row %d col %d\n",row,col); + + + if(col) + { + /* user didn't click on the move number */ + + to = 2*row + col; + printf("DEBUG: going to %d\n",to);fflush(stdout); + + /* set board to that move */ + ToNrEvent(to); + } + } } - */ + return; } @@ -103,6 +136,9 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current) /* TODO need to add highlights for current move */ /* TODO need to add navigation by keyboard or mouse (double click on move) */ + strcpy(movewhite,""); + strcpy(moveblack,""); + /* first clear everything, do we need this? */ gtk_list_store_clear(LIST_MoveHistory); @@ -142,7 +178,7 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current) /* save move */ gtk_list_store_append (LIST_MoveHistory, &iter); gtk_list_store_set (LIST_MoveHistory, &iter, - 0, i, + 0, (i/2 +1), 1, movewhite, 2, moveblack, -1); @@ -155,17 +191,18 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current) /* check if there is a white move left */ if(movewhite[0]) { - i++; strcpy(moveblack,""); + /* save move */ gtk_list_store_append (LIST_MoveHistory, &iter); gtk_list_store_set (LIST_MoveHistory, &iter, - 0, i, + 0, (i/2 +1), 1, movewhite, 2, moveblack, -1); }; + //TODO // EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed