extern void HintSelect(GtkTreeSelection * selection, hintdata * phd) { CheckHintButtons(phd); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(phd->pwShow))) { int c = gtk_tree_selection_count_selected_rows(selection); switch (c) { case 0: case 1: ShowMove(phd, c); break; default: ShowMove(phd, FALSE); break; } } }
extern GtkWidget * CreateMoveList(moverecord * pmr, const int fButtonsValid, const int fDestroyOnMove, const int fDetails, int hist) { GtkWidget *pw; GtkWidget *pwVBox, *mlt; hintdata *phd = (hintdata *) malloc(sizeof(hintdata)); /* This function should only be called when the game state matches * the move list. */ g_assert(ms.fMove == 0 || ms.fMove == 1); if (pmr->n.iMove < pmr->ml.cMoves) phd->piHighlight = &pmr->n.iMove; else phd->piHighlight = NULL; phd->pmr = pmr; phd->pml = &pmr->ml; phd->fButtonsValid = fButtonsValid; phd->fDestroyOnMove = fDestroyOnMove; phd->pwMove = NULL; phd->fDetails = fDetails; phd->hist = hist; mlt = CreateMoveListTools(phd); MoveListCreate(phd); pw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(pw), phd->pwMoves); pwVBox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(pwVBox), pw, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(pwVBox), mlt, FALSE, FALSE, 0); g_object_set_data_full(G_OBJECT(pwVBox), "user_data", phd, free); CheckHintButtons(phd); return pwVBox; }
/* Select a moverecord as the "current" one. NOTE: This function must be called _after_ applying the moverecord. */ extern void GTKSetMoveRecord( moverecord *pmr ) { /* highlighted row/col in game record */ static int yCurrent = -1, xCurrent = -1; GtkCList *pcl = GTK_CLIST( pwGameList ); gamelistrow *pglr; int i; /* Avoid lots of screen updates */ if (!frozen) SetAnnotation( pmr ); #ifdef UNDEF { GtkWidget* pwWin = GetPanelWidget(WINDOW_HINT); if (pwWin) { hintdata *phd = g_object_get_data(G_OBJECT(pwWin), "user_data"); phd->fButtonsValid = FALSE; CheckHintButtons(phd); } } #endif if (yCurrent != -1 && xCurrent != -1) { moverecord *pmrLast = NULL; pglr = gtk_clist_get_row_data(pcl, yCurrent); if (pglr) { pmrLast = pglr->apmr[xCurrent - 1]; if (pmrLast) SetCellColour(yCurrent, xCurrent, pmrLast); } if (!pmrLast) gtk_clist_set_cell_style(pcl, yCurrent, xCurrent, psGameList); } yCurrent = xCurrent = -1; if( !pmr ) return; if( pmr == plGame->plNext->p ) { g_assert( pmr->mt == MOVE_GAMEINFO ); yCurrent = 0; if( plGame->plNext->plNext->p ) { moverecord *pmrNext = plGame->plNext->plNext->p; if( pmrNext->mt == MOVE_NORMAL && pmrNext->fPlayer == 1 ) xCurrent = 2; else xCurrent = 1; } else xCurrent = 1; } else { for( i = pcl->rows - 1; i >= 0; i-- ) { pglr = gtk_clist_get_row_data( pcl, i ); if( pglr->apmr[ 1 ] == pmr ) { xCurrent = 2; break; } else if( pglr->apmr[ 0 ] == pmr ) { xCurrent = 1; break; } } yCurrent = i; if( yCurrent >= 0 && !( pmr->mt == MOVE_SETDICE && yCurrent == pcl->rows - 1 ) ) { do { if( ++xCurrent > 2 ) { xCurrent = 1; yCurrent++; } pglr = gtk_clist_get_row_data( pcl, yCurrent ); } while( yCurrent < pcl->rows - 1 && !pglr->apmr[ xCurrent - 1 ] ); if( yCurrent >= pcl->rows ) AddMoveRecordRow(); } } /* Highlight current move */ gtk_clist_set_cell_style(pcl, yCurrent, xCurrent, psCurrent); if( gtk_clist_row_is_visible( pcl, yCurrent ) != GTK_VISIBILITY_FULL ) gtk_clist_moveto( pcl, yCurrent, xCurrent, 0.8f, 0.5f ); }