Question about widgets



Hi All,

 Following is a small upgraded hallo window program from the tutorial 
site at http://www.gtk.org/tutorial1.2/gtk_tut-3.html#ss3.3 

  It has an interesting thing which is, it has a single widget 'button' 
assigned to 2 different button instances "Button 1" and "Button 2". How 
is this possible? Is it possible to assign a single widget for multiple 
different buttons of the same characterstics? 

I would be glad if anybody can provide me the answer.

thanks in advance,

code is below:-
==============

int main( int   argc,char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *box1;
    
    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (delete_event), NULL);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

    box1 = gtk_hbox_new(FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), box1);

    button = gtk_button_new_with_label ("Button 1");
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                   GTK_SIGNAL_FUNC (callback), (gpointer) "button 1");
    gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
    gtk_widget_show(button);

    button = gtk_button_new_with_label ("Button 2");
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                   GTK_SIGNAL_FUNC (callback), (gpointer) "button 2");
    gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
    gtk_widget_show(button);

    gtk_widget_show(box1);
    gtk_widget_show (window);

    gtk_main ();
    return(0);
}


========================================
Vikram S Bartakke
Grad Student (CS Dept)
University of New Mexico
Albuquerque, NM 87131
========================================



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]