Which radio button is selected?



I have a group of radio buttons that all call the same callback for the
"toggled" signal.  In the dark days before Glade, I would just connect
the signal with a user-data of a simple integer (well any scalar value
of a size that could be cast to a pointer).  That way my signal handler
could easily determine which widget had activated it.

In Glade-3 I noticed in the signal editing dialog that there's a field
for "user data."  So I naively though I could just stick my number in
there.  However when I convert the glade file to a gtk-builder xml file,
and when I try to build the GUI using the gtk-builder api (in python,
but I doubt it matters), I get a GtkWarning that it can't find the
object 0 when attaching the signals.  Apparently the user-date field now
has special meaning, and refers to an object (another gtk object perhaps).

So how are things to be done nowadays?  How does one associate all the
radio buttons in a group with a single callback and have the callback
easily distinguish which radio button is selected?  I suppose I could
ask the radio button for it's name and do a string compare.  But I
already have an enumeration that I'm using for other pieces of non-GUI
logic that I'd like to just use here as well, for succinctness and
consistency.

Any ideas?


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