示例#1
0
static void
ModifyClickButton ( GtkWidget *pw, movefilterwidget *pmfw ) {

  int fOK;
  GtkWidget *pwDialog;
  GtkWidget *pwMoveFilterSetup;
  movefilter aamf[ MAX_FILTER_PLIES ][ MAX_FILTER_PLIES ];

  memcpy ( aamf, pmfw->pmf, sizeof ( aamf ) );
  pwMoveFilterSetup = MoveFilterSetup( aamf, &fOK );

  pwDialog = GTKCreateDialog( _("GNU Backgammon - Move filter setup"), 
			DT_QUESTION, pw, DIALOG_FLAG_MODAL,
            G_CALLBACK( MoveFilterSetupOK ), pwMoveFilterSetup );

  gtk_container_add( GTK_CONTAINER( DialogArea( pwDialog, DA_MAIN ) ),
                     pwMoveFilterSetup );
  
  GTKRunDialog(pwDialog);

  if( fOK ) {
    memcpy ( pmfw->pmf, aamf, sizeof ( aamf ) );
    MoveFilterChanged ( pmfw );
  }

}
示例#2
0
文件: gtkmet.c 项目: bgnori/gnubg
extern void GTKShowMatchEquityTable( const unsigned int nMatchTo, const int anScore[ 2 ] )
{
  /* FIXME: Widget should update after 'Invert' or 'Load ...' */  
  int i;
  char sz[ 50 ];
  GtkWidget *pwDialog = GTKCreateDialog( _("GNU Backgammon - Match equity table"),
                                      DT_INFO, NULL, DIALOG_FLAG_MODAL, NULL, NULL );
  GtkWidget *pwNotebook = gtk_notebook_new ();
  GtkWidget *pwLoad = gtk_button_new_with_label(_("Load table..."));
    
  GtkWidget *pwInvertButton = 
    gtk_toggle_button_new_with_label(_("Invert table")); 
  metwidget mw;

  mw.nMatchTo = nMatchTo;
  mw.anAway[ 0 ] = (nMatchTo - (unsigned)anScore[ 0 ]) - 1;
  mw.anAway[ 1 ] = (nMatchTo - (unsigned)anScore[ 1 ]) - 1;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pwInvertButton),
                               fInvertMET); 
    
  gtk_container_set_border_width( GTK_CONTAINER( pwNotebook ), 4 );
    
  gtk_container_add( GTK_CONTAINER( DialogArea( pwDialog, DA_MAIN ) ),
                     pwNotebook );
  gtk_container_add( GTK_CONTAINER( DialogArea( pwDialog, DA_BUTTONS ) ),
                     pwInvertButton );
  gtk_container_add( GTK_CONTAINER( DialogArea( pwDialog, DA_BUTTONS ) ),
                     pwLoad );

  mw.pwPreCrawford = GTKWriteMET ( (unsigned)mw.nMatchTo, (unsigned)mw.nMatchTo, mw.anAway[ 0 ], mw.anAway[ 1 ] );
  gtk_notebook_append_page ( GTK_NOTEBOOK ( pwNotebook ),
                             mw.pwPreCrawford, 
                             gtk_label_new ( _("Pre-Crawford") ) );

  for ( i = 0; i < 2; i++ ) {
      
    sprintf ( sz, _("Post-Crawford for player %s"), ap[ i ].szName );

    mw.apwPostCrawford[ i ] = GTKWriteMET ( nMatchTo , 1, mw.anAway[ i ], mw.anAway[ !i ] );
    gtk_notebook_append_page ( GTK_NOTEBOOK ( pwNotebook ),
                               mw.apwPostCrawford[ i ],
                               gtk_label_new ( sz ) );
  }

  gtk_window_set_default_size( GTK_WINDOW( pwDialog ), 500, 300 );
  g_signal_connect( G_OBJECT( pwInvertButton ), "toggled",
                      G_CALLBACK( invertMETlocal ), &mw );
  g_signal_connect( G_OBJECT( pwLoad ), "clicked",
                      G_CALLBACK ( loadMET ), &mw );

  UpdateAllTables ( &mw );
    
  GTKRunDialog(pwDialog);
}
示例#3
0
static void
GTKViewRolloutStatistics(GtkWidget *UNUSED(widget), gpointer data){

  /* Rollout statistics information */
  
  rolloutprogress *prp = (rolloutprogress *) data;
  rolloutstat *prs = prp->prs;
  int cGames = prp->nGamesDone;
  int nRollouts = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(prp->pwRolloutResultList), NULL );
  int i;

  /* GTK Widgets */

  GtkWidget *pwDialog;
  GtkWidget *pwNotebook;

  /* Temporary variables */

  char *sz;

  /* Create dialog */

  pwDialog = GTKCreateDialog ( _("Rollout statistics"), DT_INFO, prp->pwRolloutDialog, DIALOG_FLAG_MODAL, NULL, NULL );
  gtk_window_set_default_size( GTK_WINDOW( pwDialog ), 0, 400 );

  /* Create notebook pages */

  pwNotebook = gtk_notebook_new ();

  gtk_container_set_border_width( GTK_CONTAINER( pwNotebook ), 4 );

  gtk_container_add( GTK_CONTAINER( DialogArea( pwDialog, DA_MAIN ) ), pwNotebook );

  for ( i = 0; i < nRollouts; i++ )
  {
	  GtkTreeIter iter;
	  gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(prp->pwRolloutResultList), &iter, NULL, i);
	  gtk_tree_model_get(GTK_TREE_MODEL(prp->pwRolloutResultList), &iter, 0, &sz, -1);
	  gtk_notebook_append_page ( GTK_NOTEBOOK ( pwNotebook ),
			  GTKRolloutStatPage ( &prs[ i * 2 ], cGames ), gtk_label_new ( sz ) );
	  g_free(sz);
  }

  GTKRunDialog(pwDialog);
}
示例#4
0
extern void
GTKShowRolls(const gint nDepth, evalcontext * pec, matchstate * pms)
{


    GtkWidget *vbox, *hbox, *vb2;
    GtkAdjustment *padj;
    int n;

    rollswidget *prw = (rollswidget *) g_malloc(sizeof(rollswidget));

    prw->closing = FALSE;
    prw->pDialog = GTKCreateDialog(_("Distribution of rolls"), DT_INFO, NULL, DIALOG_FLAG_MODAL, NULL, NULL);

    n = (nDepth < 1) ? 1 : nDepth;

    prw->pms = pms;
    prw->pec = pec;
    prw->nDepth = -1;           /* not yet calculated */

    /* vbox to hold tree widget and buttons */

    vbox = gtk_vbox_new(FALSE, 8);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
    gtk_container_add(GTK_CONTAINER(DialogArea(prw->pDialog, DA_MAIN)), vbox);

    /* hook to free rollswidget on widget destruction */
    g_object_set_data_full(G_OBJECT(vbox), "rollswidget", prw, g_free);

    /* scrolled window to hold tree widget */

    prw->psw = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(prw->psw), GTK_SHADOW_ETCHED_IN);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(prw->psw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(GTK_BOX(vbox), prw->psw, TRUE, TRUE, 0);

    /* buttons */

    gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);

    hbox = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 4);

    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Depth")), FALSE, FALSE, 4);

    /* Set page size to 1 */
    padj = GTK_ADJUSTMENT(gtk_adjustment_new(1., 1., 5., 1., 1., 0.));
    prw->pScale = gtk_hscale_new(padj);
    gtk_widget_set_size_request(prw->pScale, 100, -1);
    gtk_box_pack_start(GTK_BOX(hbox), prw->pScale, FALSE, FALSE, 4);
    gtk_scale_set_digits(GTK_SCALE(prw->pScale), 0);
    gtk_scale_set_draw_value(GTK_SCALE(prw->pScale), TRUE);

    /* Separate vbox to make button height correct */
    vb2 = gtk_vbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), vb2, FALSE, FALSE, 4);
    prw->pCancel = gtk_button_new_with_label(_("Cancel"));
    gtk_widget_set_size_request(prw->pCancel, -1, 27);
    gtk_widget_set_sensitive(prw->pCancel, FALSE);
    g_signal_connect(G_OBJECT(prw->pCancel), "clicked", G_CALLBACK(CancelRolls), NULL);
    gtk_box_pack_start(GTK_BOX(vb2), prw->pCancel, FALSE, FALSE, 4);

    g_signal_connect(G_OBJECT(prw->pScale), "button-press-event", G_CALLBACK(DepthEvent), prw);
    g_signal_connect(G_OBJECT(prw->pScale), "button-release-event", G_CALLBACK(DepthEvent), prw);
    g_signal_connect(G_OBJECT(prw->pScale), "value-changed", G_CALLBACK(DepthChanged), prw);

    /* tree  */

    if ((prw->ptv = RollsTree(n, pec, pms)) != 0) {
        gtk_container_add(GTK_CONTAINER(prw->psw), prw->ptv);
        prw->nDepth = n;
    }

    gtk_window_set_default_size(GTK_WINDOW(prw->pDialog), 560, 400);
    g_signal_connect(G_OBJECT(prw->pDialog), "delete_event", G_CALLBACK(RollsClose), prw);      /* In case closed mid calculation */

    GTKRunDialog(prw->pDialog);
}