ToggleButton: Actually show buttons in new snippet

Also, create a Window, instead of a Dialog without a transient parent,
which is (noisily) discouraged. Then s/content_area/box/g to match.
This commit is contained in:
Daniel Boles 2017-10-11 21:13:49 +01:00
parent b0fe89d85f
commit a54550db7b

View File

@ -72,14 +72,14 @@
* } * }
* *
* void make_toggles (void) { * void make_toggles (void) {
* GtkWidget *dialog, *toggle1, *toggle2; * GtkWidget *window, *toggle1, *toggle2;
* GtkWidget *content_area; * GtkWidget *box;
* const char *text; * const char *text;
* *
* dialog = gtk_dialog_new (); * window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
* content_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); * box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
* *
* text = "Hi, im a toggle button."; * text = "Hi, Im a toggle button.";
* toggle1 = gtk_toggle_button_new_with_label (text); * toggle1 = gtk_toggle_button_new_with_label (text);
* *
* // Makes this toggle button invisible * // Makes this toggle button invisible
@ -89,18 +89,19 @@
* g_signal_connect (toggle1, "toggled", * g_signal_connect (toggle1, "toggled",
* G_CALLBACK (output_state), * G_CALLBACK (output_state),
* NULL); * NULL);
* gtk_container_add (GTK_CONTAINER (content_area), toggle1); * gtk_container_add (GTK_CONTAINER (box), toggle1);
* *
* text = "Hi, im a toggle button."; * text = "Hi, Im a toggle button.";
* toggle2 = gtk_toggle_button_new_with_label (text); * toggle2 = gtk_toggle_button_new_with_label (text);
* gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2), * gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2),
* FALSE); * FALSE);
* g_signal_connect (toggle2, "toggled", * g_signal_connect (toggle2, "toggled",
* G_CALLBACK (output_state), * G_CALLBACK (output_state),
* NULL); * NULL);
* gtk_container_add (GTK_CONTAINER (content_area), toggle2); * gtk_container_add (GTK_CONTAINER (box), toggle2);
* *
* gtk_widget_show_all (dialog); * gtk_container_add (GTK_CONTAINER (window), box);
* gtk_widget_show_all (window);
* } * }
* ]| * ]|
*/ */