I hope the code below may be useful to some people.
This method works, but I am new to GTK+ myself so I am not sure whether this is the best solution, however, but I believe it is one of the better ones. I would be interested to know if someone has a better way of achieving this :-)
Other solutions would be to use globals or possibly structs.
What the function does:
It is a simple callback function that has been connected to the GladeXML file by the following line:
glade_xml_signal_connect(gxml, "on_execute_recording_button_clicked", G_CALLBACK(on_execute_recording_button_clicked));
is the main GladeXML file that was created using Glade-3.
we can get hold of the GladeXML file inside the callback function without using globals. From there is it easy, we simply use the glade_xml_get_widget()
function to get hold of the widgets we want. In my case this is a GtkProgessBar widget and a GtkTreeView widget. Both widgets are then passed to a get_data()
function that manipulates them.Here is my code:
* Function aquires a handle on the GtkProgressBar and the GtkTreeView widget
* then calls a function that works on both widgets.
void on_execute_recording_button_clicked (GtkButton *button, GtkWidget *window, gpointer gptr)
GtkWidget *pbarWidget, *data_viewWidget;
gxml = glade_get_widget_tree(GTK_WIDGET(button));
pbarWidget = glade_xml_get_widget (gxml, "record_progressbar");
pbar = GTK_PROGRESS_BAR(pbarWidget);
data_viewWidget = glade_xml_get_widget (gxml, "data_view");
data_view = GTK_TREE_VIEW(data_viewWidget);