mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-11-16 07:48:07 +01:00
first checked in
This commit is contained in:
parent
1116117410
commit
183eb9e283
2 changed files with 120 additions and 0 deletions
89
xwords4/linux/gtkntilesask.c
Normal file
89
xwords4/linux/gtkntilesask.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2003 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gtkntilesask.h"
|
||||
|
||||
static void
|
||||
button_event( GtkWidget* widget, void* closure )
|
||||
{
|
||||
XP_Bool* result = (XP_Bool*)closure;
|
||||
*result = XP_TRUE;
|
||||
gtk_main_quit();
|
||||
} /* button_event */
|
||||
|
||||
XP_U16
|
||||
askNTiles( GtkAppGlobals* globals, XP_U16 max, XP_U16 deflt )
|
||||
{
|
||||
XP_U16 result = 0;
|
||||
XP_Bool results[MAX_TRAY_TILES];
|
||||
GtkWidget* dialog;
|
||||
GtkWidget* label;
|
||||
GtkWidget* hbox = NULL;
|
||||
XP_U16 i;
|
||||
GtkWidget* button;
|
||||
XP_UCHAR defbuf[48];
|
||||
|
||||
XP_MEMSET( results, 0, sizeof(results) );
|
||||
|
||||
dialog = gtk_dialog_new();
|
||||
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
||||
|
||||
sprintf( defbuf, "Limit hint to how many tiles (deflt=%d)?", deflt );
|
||||
label = gtk_label_new( defbuf );
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
|
||||
label);
|
||||
|
||||
hbox = gtk_hbox_new( FALSE, 0 );
|
||||
for ( i = 0; i < max; ++i ) {
|
||||
XP_UCHAR buf[3];
|
||||
|
||||
sprintf( buf, "%d", i+1 );
|
||||
button = gtk_button_new_with_label( buf );
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
|
||||
gtk_signal_connect( GTK_OBJECT(button), "clicked", button_event,
|
||||
&results[i] );
|
||||
gtk_widget_show( button );
|
||||
}
|
||||
gtk_widget_show( hbox );
|
||||
gtk_box_pack_start( GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox,
|
||||
FALSE, TRUE, 0 );
|
||||
|
||||
sprintf( defbuf, "Default (%d)", deflt );
|
||||
button = gtk_button_new_with_label( defbuf );
|
||||
gtk_box_pack_start( GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, TRUE, 0 );
|
||||
gtk_signal_connect( GTK_OBJECT(button), "clicked", button_event,
|
||||
&results[deflt-1] );
|
||||
gtk_widget_show( button );
|
||||
|
||||
gtk_widget_show_all( dialog );
|
||||
|
||||
gtk_main();
|
||||
|
||||
gtk_widget_destroy( dialog );
|
||||
|
||||
for ( i = 0; i < MAX_TRAY_TILES; ++i ) {
|
||||
if ( results[i] ) {
|
||||
result = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} /* askNTiles */
|
31
xwords4/linux/gtkntilesask.h
Normal file
31
xwords4/linux/gtkntilesask.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2003 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _GTKNTILESASK_H_
|
||||
#define _GTKNTILESASK_H_
|
||||
|
||||
#include "gtkmain.h"
|
||||
|
||||
XP_U16 askNTiles( GtkAppGlobals* globals, XP_U16 nTilesMax, XP_U16 deflt );
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue