togglebutton: Fix code snippet
Remove gtk_box_pack_start usage, gtk_dialog_get_content_area, fix wrong gtk_dialog_new parameters and actually add a output_state callback.
This commit is contained in:
@ -67,13 +67,17 @@
|
|||||||
* ## Creating two #GtkToggleButton widgets.
|
* ## Creating two #GtkToggleButton widgets.
|
||||||
*
|
*
|
||||||
* |[<!-- language="C" -->
|
* |[<!-- language="C" -->
|
||||||
|
* static void output_state (GtkToggleButton *source, gpointer user_data) {
|
||||||
|
* printf ("Active: %d\n", gtk_toggle_button_get_active (source));
|
||||||
|
* }
|
||||||
|
*
|
||||||
* void make_toggles (void) {
|
* void make_toggles (void) {
|
||||||
* GtkWidget *dialog, *toggle1, *toggle2;
|
* GtkWidget *dialog, *toggle1, *toggle2;
|
||||||
* GtkWidget *content_area;
|
* GtkWidget *content_area;
|
||||||
* const char *text;
|
* const char *text;
|
||||||
*
|
*
|
||||||
* dialog = gtk_dialog_new (text);
|
* dialog = gtk_dialog_new ();
|
||||||
* content_area = gtk_dialog_get_content_area ();
|
* content_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||||
*
|
*
|
||||||
* text = "Hi, i’m a toggle button.";
|
* text = "Hi, i’m a toggle button.";
|
||||||
* toggle1 = gtk_toggle_button_new_with_label (text);
|
* toggle1 = gtk_toggle_button_new_with_label (text);
|
||||||
@ -85,8 +89,7 @@
|
|||||||
* g_signal_connect (toggle1, "toggled",
|
* g_signal_connect (toggle1, "toggled",
|
||||||
* G_CALLBACK (output_state),
|
* G_CALLBACK (output_state),
|
||||||
* NULL);
|
* NULL);
|
||||||
* gtk_box_pack_start (GTK_BOX (content_area),
|
* gtk_container_add (GTK_CONTAINER (content_area), toggle1);
|
||||||
* toggle1, FALSE, FALSE, 2);
|
|
||||||
*
|
*
|
||||||
* text = "Hi, i’m a toggle button.";
|
* text = "Hi, i’m a toggle button.";
|
||||||
* toggle2 = gtk_toggle_button_new_with_label (text);
|
* toggle2 = gtk_toggle_button_new_with_label (text);
|
||||||
@ -95,8 +98,7 @@
|
|||||||
* g_signal_connect (toggle2, "toggled",
|
* g_signal_connect (toggle2, "toggled",
|
||||||
* G_CALLBACK (output_state),
|
* G_CALLBACK (output_state),
|
||||||
* NULL);
|
* NULL);
|
||||||
* gtk_box_pack_start (GTK_BOX (content_area),
|
* gtk_container_add (GTK_CONTAINER (content_area), toggle2);
|
||||||
* toggle2, FALSE, FALSE, 2);
|
|
||||||
*
|
*
|
||||||
* gtk_widget_show_all (dialog);
|
* gtk_widget_show_all (dialog);
|
||||||
* }
|
* }
|
||||||
|
|||||||
Reference in New Issue
Block a user