someone can help me?



Title: someone can help me?

I want to create two button named "Lower Case"& "A" .
when I click the  "Lower Case" button,the "A" button should change to the "a" button,the button's name changed.
I do the following code,but the button's name doesn't  be changed.
In VC++,when I change something,I can redraw  the screen,and it would be shown.
someone can tell me how to do that in gtk library?


Thanks in advance.
you can get me by mail:
kasonhuang kinposh cm cn       
                                                                        kason



#include<gtk/gtk.h>

GtkWidget  *label_show(GtkWidget *object,gchar *label_string)
{
        GtkWidget *label;
       
        label=gtk_label_new(label_string);
        gtk_container_add(GTK_CONTAINER(object),label);
        gtk_widget_show(label);
        gtk_widget_show(object);

        return object;
               
}

void label_change(GtkWidget *object,GtkWidget *slot_object)
{
        g_print("Hello again!");
        slot_object=label_show(slot_object,"a");
        gtk_widget_show(slot_object);
}

int main(int argc,char *argv[])
{
        GtkWidget *window;
        GtkWidget *button1;
        GtkWidget *button2;
        GtkWidget *vbox;
       
        gtk_init(&argc,&argv);
       
        window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        vbox=gtk_vbox_new(FALSE,0);
       
        gtk_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(gtk_exit),NULL);
        gtk_signal_connect(GTK_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(gtk_exit),NULL);
        gtk_container_set_border_width(GTK_CONTAINER(window),10);
        gtk_widget_realize(window);
        gtk_container_add(GTK_CONTAINER(window),vbox);
        gtk_widget_show(vbox);

        button1=gtk_button_new();
        button2=gtk_button_new();
       
        button1=label_show(button1,"Lower Case");
        button2=label_show(button2,"A");

        gtk_box_pack_start(GTK_BOX(vbox),button1,FALSE,FALSE,0);
        gtk_box_pack_start(GTK_BOX(vbox),button2,FALSE,FALSE,0);

        gtk_signal_connect(GTK_OBJECT(button1),"clicked",GTK_SIGNAL_FUNC(label_change),
                                                                                                                                                                                                                                                                        GTK_OBJECT(button2));

        gtk_widget_show(window);

        gtk_main();
       
        return 0;

}




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