Reputation: 21
Is there a way to find a GTKWidget by a control name / or id, from within the current window scope from a c/c++?
In Winforms, you had something like this:
public class Form1 : Form
{
public void Test()
{
this.Controls.Find("ControlName");
}
}
Upvotes: 2
Views: 1917
Reputation: 399833
You can set names on widgets, using gtk_widget_set_name()
, but I don't think there are built-in functions to find widgets in hierarchies based on the name.
That wouldn't be too hard to write if you had a need, though.
As Micah pointed out, it's not how GTK+ applications are generally structured, it's way more common to keep pointers to needed widgets from the time they were created, for manually built UI:s.
Upvotes: 2
Reputation: 10197
In GTK+ we store references to any widget we may need to access in later code using a variable (or struct/class/etc.) that is passed around as user data in the relevant callback functions. If you are using a UI builder (such as glade) then yes, there would be a way to reference the widget by the name you gave it in the UI builder. Otherwise, the answer is that there is not a way to "find" the widgets quite like that.
If you could provide a more specific example I could elaborate.
Upvotes: 1