Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://www.youtube.com/user/thecplusplusguy
- //Thanks for the typed in code to Tapit85
- #include <gtk/gtk.h>
- #include <cstring>
- static void toggled_func(GtkWidget* widget, gpointer data)
- {
- if(strcmp((char*)data, "1") == 0)
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
- g_print("Button %s is set to active\n", (char*)data);
- else
- g_print("Button %s is set to deactive\n", (char*)data);
- if(strcmp((char*)data, "2") == 0)
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
- g_print("Button %s is set to active\n", (char*)data);
- else
- g_print("Button %s is set to deactive\n", (char*)data);
- if(strcmp((char*)data, "3") == 0)
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
- g_print("Button %s is set to active\n", (char*)data);
- else
- g_print("Button %s is set to deactive\n", (char*)data);
- if(strcmp((char*)data, "4") == 0)
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
- g_print("Button %s is set to active\n", (char*)data);
- else
- g_print("Button %s is set to deactive\n", (char*)data);
- }
- int main(int argc, char* argv[])
- {
- gtk_init(&argc, &argv);
- GtkWidget *window, *radio, *radio2, *hbox;
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
- hbox = gtk_hbox_new(0,0);
- radio = gtk_radio_button_new_with_label(NULL, "label 1");
- gtk_box_pack_start(GTK_BOX(hbox), radio, 0,0,0);
- g_signal_connect(radio, "toggled", G_CALLBACK(toggled_func), (gpointer)"1");
- radio2 = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio)), "label 2");
- gtk_box_pack_start(GTK_BOX(hbox), radio2, 0,0,0);
- g_signal_connect(radio2, "toggled", G_CALLBACK(toggled_func), (gpointer)"2");
- radio2 = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio)), "label 3");
- gtk_box_pack_start(GTK_BOX(hbox), radio2, 0,0,0);
- g_signal_connect(radio2, "toggled", G_CALLBACK(toggled_func), (gpointer)"3");
- radio2 = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio)), "label 4");
- gtk_container_add(GTK_CONTAINER(window),hbox);
- gtk_box_pack_start(GTK_BOX(hbox), radio2, 0,0,0);
- g_signal_connect(radio2, "toggled", G_CALLBACK(toggled_func), (gpointer)"4");
- // gtk_container_add(GTK_CONTAINER(window), hbox); // ? Runtime-Warning ?
- gtk_widget_show_all(window);
- gtk_main();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement