Re: nameless instances of objects



Whoaa.... I don't believe you guys are on the same track but if you are then please disregard.  When Azrael speaks of a "name", I believe what he means is the name of the variable.  Like in his example
                widget = gtk_button_new(...);
                   ^^  (he is calling this the "name" when it's actually the variable)

If I'm right, then yes you can use multiple buttons with the same "variable name".   Like this:

    widget = gtk_button_new();
    g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(MyCallBack), "First Button");
    gtk_box_pack_start(GTK_BOX(abox), widget, TRUE, FALSE, 0);
     /* Now we have a button added to a container that will be unique. */

    widget = gtk_button_new();  /*  A new button using the same variable name, this will WORK! */
    g_signal_connect(G_OBJECT(widget, "clicked", G_CALLBACK(MyCallBack), "Second Button");
    gtk_box_pack_start(GTK_BOX(abox), widget, TRUE, FALSE, 0);
    /* Now we have a second button using the same widget name and the same callback but
     * passing different data! */

After you add widget to some sort of container (window, box, etc.) the container becomes the widget's parent and manages it from this point on.  You no longer have to worry about the widget that was created.

If Azrael, you are talking about the "Name" property of a widget, then Tristan is correct and widgets do not have to have these unless you plan on theming them.

Cheers,
Michael H.



On Wed, 2002-12-11 at 16:46, Tristan Van Berkom wrote:
*** WIDGETS DONT HAVE TO HAVE NAMES ***

> But when I do:
> widget = gtk_button_new(...);
> I won't know the widget name.. are you telling me that I don't need to
> give it a unique name? 

Yes.

> That I can reuse the same name for each button I
> create and add?

maybe, probably undefined behaviour in
gtk_rc_parse(); 
widgets can be named but dont _have_ to be:

http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-set-name

exept for theeming; I dont see why you would _need_ your
widgets to have names. (in order to tell them apart ? 
see g_object_set_data())

Cheers,
			-Tristan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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