Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-08-19 21:04:58

gschwarz
Member
Registered: 2023-03-30
Posts: 27
MacintoshChrome 116.0

Two widgets in an XfceArrowButton?

The following is a question regarding the use of XfceArrowButton in C.
https://developer.xfce.org/xfce4-panel/ … utton.html says:

"Since 4.8 it is also possible to [...] pack additional widgets in the button, using gtk_container_add()."

Can anybody confirm that this actually works with more than one widget, e.g. an icon and a text label?
When I use gtk_container_add() two times only the first widget added gets displayed.
Is there any sample code I could refer to?

Offline

#2 2025-08-19 21:48:17

Tamaranch
Member
From: France
Registered: 2020-12-31
Posts: 392
Website
LinuxFirefox 141.0

Re: Two widgets in an XfceArrowButton?

It derives from GtkBin, so you have to pack the label, icon, etc. in a GtkBox or similar, and add it to the button using gtk_container_add().

Offline

#3 2025-08-19 22:19:16

gschwarz
Member
Registered: 2023-03-30
Posts: 27
MacintoshChrome 116.0

Re: Two widgets in an XfceArrowButton?

Thanks for your fast reply (which saved me even more hours of fruitless experiments); very much appreciated. So the sentence in the documentation can be a bit misleading for newbies since it uses plural...
Anyway, if one wants to display just either an icon or a label (and switch between those two states at runtime), is the best way then to simply use container_remove() on the currently added widget before adding the other one with container_add()?
Will container_remove() suffice, i.e. no need for hiding the to be removed widget first?
Also, am I right to assume that container_remove() does not affect the widget's data structures and it can be directly resumed being used again at any later point?
https://docs.gtk.org/gtk3/method.Container.remove.html seems to indicate differently. So is destroying the widget and at some later point, if it is to be used again, completely recreating it, the better choice?

Offline

#4 2025-08-19 22:30:39

Tamaranch
Member
From: France
Registered: 2020-12-31
Posts: 392
Website
LinuxFirefox 141.0

Re: Two widgets in an XfceArrowButton?

No need to hide a widget before removing or destroying it, however, as the gtk doc says, if you want it not to be destroyed when removing it, you have to keep a reference on it first using g_object_ref() (and then g_object_unref() it when it's added to a container again).

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.008 seconds, 7 queries executed - Memory usage: 539.91 KiB (Peak: 540.76 KiB) ]