Hello,
I am having an issue with passing widgets to callback functions.
What I am trying to do is pass two widgets with one callback. One widget is a combo box and one is a status bar.
I prefer not to use global variables, so I figured my only way would be to create a structure and pass the structure.
I've tried this and it failed to work.
My structure look as such:
Code:
typedef struct status_and_widget {
GtkWidget *widget;
GtkWidget *status_bar;
} status_trans;
My declarations look like this in main:
Code:
GtkWidget *status_bar;
GtkWidget *combo_nearby_dev;
...
status_trans status_and_combo;
status_and_combo.widget = combo_nearby_dev;
status_and_combo.status_bar = status_bar;
g_signal_connect (G_OBJECT (button_nearby_dev), "clicked", G_CALLBACK (button_nearby_dev_callback), (gpointer)&status_and_combo);
...
And finally, my callback function:
Code:
static void button_nearby_dev_callback( GtkWidget *widget, gpointer data ) {
status_trans *status_and_combo = (status_trans*)data;
GList *list;
bt_node *head;
list = NULL;
head = NULL;
gtk_statusbar_push(GTK_STATUSBAR(status_and_combo->status_bar), 1, "Updating. Please Wait.");
/* Fills Combo Box */
bt_populate_list(&head);
list = g_list_append (list, "John");
/* Adds list to combo box */
gtk_combo_set_popdown_strings(GTK_COMBO(status_and_combo->widget), list);
gtk_statusbar_pop(GTK_STATUSBAR(status_and_combo->status_bar), 1);
}
It does update the combo box, but does not do anything for the status_bar.
Also, the bt_populate_list() function searches for local bluetooth devices which takes some time. So I don't believe that I'm not seeing it due to it being too quick but I'm not positive.
Any help would be appreciated.
Thanks
Brian