Commit d15fbee3 authored by Timm Bäder's avatar Timm Bäder 👎 Committed by Daniel Boles

Make a few more code samples compile

parent fda98ba5
......@@ -937,6 +937,7 @@ gtk_dialog_new_empty (const gchar *title,
*
* Here’s a simple example:
* |[<!-- language="C" -->
* GtkWidget *main_app_window; // Window the dialog should show up on
* GtkWidget *dialog;
* GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
* dialog = gtk_dialog_new_with_buttons ("My dialog",
......@@ -1325,14 +1326,17 @@ run_destroy_handler (GtkDialog *dialog, gpointer data)
*
* Typical usage of this function might be:
* |[<!-- language="C" -->
* gint result = gtk_dialog_run (GTK_DIALOG (dialog));
* GtkWidget *dialog = gtk_dialog_new ();
* // Set up dialog...
*
* int result = gtk_dialog_run (GTK_DIALOG (dialog));
* switch (result)
* {
* case GTK_RESPONSE_ACCEPT:
* do_application_specific_something ();
* // do_application_specific_something ();
* break;
* default:
* do_nothing_since_dialog_was_cancelled ();
* // do_nothing_since_dialog_was_cancelled ();
* break;
* }
* gtk_widget_destroy (dialog);
......
......@@ -75,18 +75,19 @@
* by using gtk_info_bar_set_message_type(). GTK+ may use the message type
* to determine how the message is displayed.
*
* A simple example for using a GtkInfoBar:
* A simple example for using a #GtkInfoBar:
* |[<!-- language="C" -->
* // set up info bar
* GtkWidget *widget;
* GtkWidget *widget, *message_label, *content_area;
* GtkWidget *grid;
* GtkInfoBar *bar;
*
* // set up info bar
* widget = gtk_info_bar_new ();
* bar = GTK_INFO_BAR (widget);
* grid = gtk_grid_new ();
*
* gtk_widget_set_no_show_all (widget, TRUE);
* message_label = gtk_label_new ("");
* gtk_widget_show (message_label);
* content_area = gtk_info_bar_get_content_area (bar);
* gtk_container_add (GTK_CONTAINER (content_area),
* message_label);
......@@ -101,10 +102,10 @@
* widget,
* 0, 2, 1, 1);
*
* ...
* // ...
*
* // show an error message
* gtk_label_set_text (GTK_LABEL (message_label), message);
* gtk_label_set_text (GTK_LABEL (message_label), "An error occurred!");
* gtk_info_bar_set_message_type (bar,
* GTK_MESSAGE_ERROR);
* gtk_widget_show (bar);
......
......@@ -59,9 +59,10 @@
* int
* main (int argc, char **argv)
* {
* GtkWidget *mainwin;
* // Initialize i18n support with bindtextdomain(), etc.
*
* ...
* // ...
*
* // Initialize the widget set
* gtk_init (&argc, &argv);
......@@ -71,7 +72,7 @@
*
* // Set up our GUI elements
*
* ...
* // ...
*
* // Show the application window
* gtk_widget_show_all (mainwin);
......
......@@ -69,7 +69,7 @@
* cairo_stroke (cr);
*
* // Draw some text
* layout = gtk_print_context_create_layout (context);
* layout = gtk_print_context_create_pango_layout (context);
* pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
* desc = pango_font_description_from_string ("sans 28");
* pango_layout_set_font_description (layout, desc);
......
......@@ -114,8 +114,8 @@
* "I’m the second radio button.");
*
* // Pack them into a box, then show all the widgets
* gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2);
* gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
* gtk_box_pack_start (GTK_BOX (box), radio1);
* gtk_box_pack_start (GTK_BOX (box), radio2);
* gtk_container_add (GTK_CONTAINER (window), box);
* gtk_widget_show_all (window);
* return;
......@@ -383,9 +383,9 @@ gtk_radio_button_set_group (GtkRadioButton *radio_button,
* GtkRadioButton *radio_button;
* GtkRadioButton *last_button;
*
* while ( ...more buttons to add... )
* while (some_condition)
* {
* radio_button = gtk_radio_button_new (...);
* radio_button = gtk_radio_button_new (NULL);
*
* gtk_radio_button_join_group (radio_button, last_button);
* last_button = radio_button;
......
......@@ -8210,13 +8210,17 @@ gtk_text_view_reset_im_context (GtkTextView *text_view)
* gtk_foo_bar_key_press_event (GtkWidget *widget,
* GdkEventKey *event)
* {
* if ((key->keyval == GDK_KEY_Return || key->keyval == GDK_KEY_KP_Enter))
* guint keyval;
*
* gdk_event_get_keyval ((GdkEvent*)event, &keyval);
*
* if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter)
* {
* if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (view), event))
* if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (widget), event))
* return TRUE;
* }
*
* // Do some stuff
* // Do some stuff
*
* return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event);
* }
......
......@@ -61,7 +61,7 @@
* group = gtk_tool_item_group_new (_("Test Category"));
* gtk_container_add (GTK_CONTAINER (palette), group);
*
* item = gtk_tool_button_new_new (NULL, _("_Open"));
* item = gtk_tool_button_new (NULL, _("_Open"));
* gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "document-open");
* gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
* ]|
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment