Re: gchar * properties

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

 



-----BEGIN PGP SIGNED MESSAGE-----Hash: SHA1
Hi
> As far as I my experience go, it is usually safe to assume that> g_object_set( widget, "prop", value, NULL ) does the same thing as> gtk_widget_set_prop( widget, value ). In the case of gchar * values,> the value gets it's own copy of a string via g_strdup.
thanks, I've checked the original pointer with the returning pointer and they were different. So it seems that a copy isalways done.
> This is a copy from gtkwidget.h file. I cannot say if it is safe to> change that, but you can always try and see what happens;)
I've made a test with a glade file:

GtkWindow *setting_window;setting_window = g_object_new(GTK_TYPE_WINDOW,        "title", "Settings",        "border-width", 6,        "window-position", GTK_WIN_POS_MOUSE,        NULL);
g_printf("win name = %s\n", gtk_widget_get_name(GTK_WIDGET(setting_window)));
GtkVBox *vbox = GTK_VBOX(glade_xml_get_widget(new_xml, "mainwin_vbox"));
g_printf("vbox name = %s\n", gtk_widget_get_name(GTK_WIDGET(vbox)));
gtk_container_add(GTK_CONTAINER(setting_window), GTK_WIDGET(vbox));
button = GTK_BUTTON(glade_xml_get_widget(new_xml, "mainwin_close"));g_signal_connect(button, "clicked", G_CALLBACK(close_me), setting_window);
image = GTK_IMAGE(glade_xml_get_widget(new_xml, "image1"));g_object_set(image,        "file", "supertux.gif",        NULL);
g_printf("image name = %s\n", gtk_widget_get_name(GTK_WIDGET(image)));
This was the result:win name = GtkWindowvbox name = mainwin_vboximage name = image1
it seems to me that it's safe to use the name property since glade uses it too. You can set any widget name withinglade-3 and I've never had problems with it.
I know that I can get an answer for some things directly out from the code but sometimes I don't know whether the pieceof code I've looked into is just a exception or if there's a policy for suchs things, that's why I've asked in the firstplace ;)
It's seems great if I'm able to save "custom data" in the 'name' property. Sometimes it's handy to do that.
RegardsPablo

- --Pablo Yánez Trujillohttp://klingsor.informatik.uni-freiburg.de/My public key: http://klingsor.informatik.uni-freiburg.de/gpg/supertux.asc-----BEGIN PGP SIGNATURE-----Version: GnuPG v2.0.9 (GNU/Linux)
iEYEARECAAYFAkj3ieQACgkQDzf8xo+0xRXrFQCfTKLeEmUdAJIOBRLulKEc5N6nm6MAoL9542p8W1VbcNbMeTNXwLvYV4W0=KAPa-----END PGP SIGNATURE-----_______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux