widgets do not appear, due to "event"
- From: Saquib Malik <saquibfarooq yahoo com>
- To: gtk-list gnome org
- Subject: widgets do not appear, due to "event"
- Date: Thu, 11 Jul 2002 20:47:17 -0700 (PDT)
The following code is supposed draw a grid of buttons
on the screen, the buttons are being created using a
nested for loop, the whole thing is drawn perfectly
when i try to connect a signal and specifiy the signal
"clicked" but when i use the "event", the screen does
not show up, unless i expand the window to full screen
and then compress it to normal size !!!.
My aim is to make a grid of buttons, each when clicked
causes a pop up menu to be displayed, an option will
be chosed from the menu which will cause a change in
the 'nodes' data structure and then the change will
be visible when the screen is drawn again.
The problem is that whenever the screen is redrawn it
is empty unless I expand it to full screen and
compress it back normal.
void initialize(GtkWidget *);
/* snippet - start */
char nodes[10][10];
main(int argc, char **argv)
{
GtkWidget * win;
GtkWidget * button[10][10], * qbutton;
GtkWidget * table;
char label[6];
char name[2];
int i,j;
win = NULL;
gtk_init(&argc, &argv);
/* the following is an infinite while loop which will
cause the grid to be displayed repaeatedly
* and the changes being made in the background will
appear */
while(1)
{ // while 1
initialize(win); // if the win is not NULL then
destroy it b4 reusig it.
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
table = gtk_table_new( 11 ,10 , TRUE);
name[1]='\0';
for(i=0;i<10;i++) // for 1
for(j=0; j <10 ; j++) // for 2
{
sprintf(label,"%d_%d",i,j);
if( nodes[i][j]=='o')
{
button[i][j] = gtk_button_new();
gtk_signal_connect(GTK_OBJECT(button[i][j]),
"event", GTK_SIGNAL_FUNC(drop), NULL);
}
else
{
name[0]=nodes[i][j];
button[i][j] = gtk_button_new_with_label(name);
gtk_signal_connect(GTK_OBJECT(button[i][j]),
"event", GTK_SIGNAL_FUNC(handle), NULL);
}
gtk_widget_set_usize(GTK_WIDGET(button[i][j]), 20,20);
gtk_widget_set_name(button[i][j], label);
gtk_table_attach_defaults(GTK_TABLE(table),
button[i][j], j,j+1,i,i+1);
//gtk_widget_show(text);
gtk_widget_show(button[i][j]);
} // for 2 closed
qbutton = gtk_button_new_with_label("Quit");
gtk_container_add(GTK_CONTAINER(win), table);
gtk_signal_connect(GTK_OBJECT(qbutton), "clicked",
GTK_SIGNAL_FUNC(del_eve),(GtkWidget *) win);
gtk_table_attach_defaults(GTK_TABLE(table), qbutton,
0,10,10,11);
gtk_widget_show(qbutton);
gtk_widget_show(table);
gtk_widget_show_all(win);
} // while 1 closed
} //main closed
void initialize(GtkWidget * win)
{
/* settig all entries to o;*/
int i;
int j;
for(i=0; i<10 ; i++)
for(j=0; j<10; j++)
nodes[i][j]='o';
/* putting values in locations*/
if(win!=NULL)
gtk_widget_destroy(win);
nodes[1][2]='A';
nodes[2][4]='B';
nodes[1][5]='C';
nodes[3][5]='D';
nodes[2][7]='E';
}
/* snippet - end */
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]