c - Gtk change multiple labels on button click -
how can change multible label values on single button click.normally on button click signal connect can give 1 user data. example code
void show_loop(gtkwidget *widget, gpointer user_data) { char buf[5]; int no = txbuf.plbuf[7]; sprintf(buf, "%d",no); gtk_label_set_text(gtk_label(user_data), buf); } id_label=gtk_widget (gtk_builder_get_object (builder, "label24")); dlc_label=gtk_widget (gtk_builder_get_object (builder, "label25")); check = gtk_widget (gtk_builder_get_object (builder, "button3")); g_signal_connect (check, "clicked", g_callback (show_loop), dlc_label);
i want change both labels on single button click.
typically define, allocate , fill struct contains widgets may have changed dynamically in initialization code:
typedef struct appdata { gtkwidget *id_label; gtkwidget *dlc_label; } appdata; ... appdata *app_data = g_new0 (appdata, 1); app_data->id_label = gtk_widget (gtk_builder_get_object (builder, "label24")); app_data->dlc_label = gtk_widget (gtk_builder_get_object (builder, "label25"));
the use app_data
userdata parameter , can access widgets inside signal handler e.g. app_data->id_label
.
Comments
Post a Comment