user interface - Changing GTK label in C using signal_connect -
hello making gui in gtk have menu items, , trying change main label after clicking mouse on specific menu element.
widgets[i][0] = gtk_menu_item_new_with_label(arrayofstrings[i]); //arrayofstrings : char** arrayofstrings gtk_menu_shell_append(gtk_menu_shell(indicator_menu), widgets[i][0]);
i trying this:
void set_main_label(gtkwidget *widget) { app_indicator_set_label(indicator, arrayofstring[2],arrayofstring[2]); }
and after call like:
g_signal_connect(widgets[i][0], "activate",g_callback(set_main_label), widgets[i][0]);
but problem void set_main_label(void) must have void argument. , need pass there string (char*) stored in arrayofstrings. suggest? can change label 1 specific string set in set_main_label function, cannot pass argument function, suggest? .
this user_data
parameter for. set_main_label()
not have void
argument list - check documentation:
void user_function (gtkmenuitem *widget, gpointer user_data)
you can pass argument callback via user_data
parameter. must known @ time connect signal.
so this:
void set_main_label(gtkmenuitem *widget, gpointer user_data) { const char *label = (const char *)user_data; app_indicator_set_label(indicator, label, label); } g_signal_connect(widgets[i][0], "activate", g_callback(set_main_label), arrayofstring[2]);
Comments
Post a Comment