GNOME Bugzilla – Bug 317520
gtk_image_new/set_from_gtk_image
Last modified: 2014-01-25 02:37:03 UTC
There is currently no reliable way to "clone" a generic GtkImage. Suppose you have a composite widget with two images that must stay in sync and you have a set_image(GtkImage) method: you need a way to build another copy of the image since the same widget cannot be packed in two containers. All you have now is switch (gtk_image_get_storage_type(image)) { case foo: gtk_image_new_from_foo; case bar: gtk_image_new_from_bar; ... } Which not only sucks, but it is also not robust to the addition of new stoarge types.
It's quite unclear to me what the use case is here.
the use case is the following: I have a widget that which contains a notebook and a title; each page of the notebook contains an image and a name on its label and the title contains the image and the name of the current page; pages can be added dinamically by plugin. When a plugin uses my .set_image() method to set a GtkImage on its page label, I also need to make an exact copy of the GtkImage in order to display it in the title. There is no reliable way to set the image in the title starting from the image passed to set_image. I'm currently using the above 'switch', but that it's going to break if/when a new storage_method is added.