[gtk+] Make a few more code samples compile



commit 3f68475b6fa7afede6a929126ddf439498e6d53d
Author: Timm Bäder <mail baedert org>
Date:   Wed Jan 3 17:10:21 2018 +0100

    Make a few more code samples compile

 gtk/gtkdialog.c       |   10 +++++++---
 gtk/gtkinfobar.c      |   13 +++++++------
 gtk/gtkmain.c         |    5 +++--
 gtk/gtkprintcontext.c |    2 +-
 gtk/gtkradiobutton.c  |    8 ++++----
 gtk/gtktextview.c     |   10 +++++++---
 gtk/gtktoolpalette.c  |    2 +-
 7 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 67c3c40..151dc85 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -792,6 +792,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",
@@ -1168,14 +1169,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);
diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c
index b5ea643..11170b2 100644
--- a/gtk/gtkinfobar.c
+++ b/gtk/gtkinfobar.c
@@ -73,17 +73,18 @@
  * 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 ();
  *
  * 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);
@@ -98,10 +99,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);
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 146499d..48c3aae 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -59,9 +59,10 @@
  * int
  * main (int argc, char **argv)
  * {
+ *  GtkWidget *mainwin;
  *   // Initialize i18n support with bindtextdomain(), etc.
  *
- *   ...
+ *   // ...
  *
  *   // Initialize the widget set
  *   gtk_init ();
@@ -71,7 +72,7 @@
  *
  *   // Set up our GUI elements
  *
- *   ...
+ *   // ...
  *
  *   // Show the application window
  *   gtk_widget_show (mainwin);
diff --git a/gtk/gtkprintcontext.c b/gtk/gtkprintcontext.c
index d3c5a02..21d68bf 100644
--- a/gtk/gtkprintcontext.c
+++ b/gtk/gtkprintcontext.c
@@ -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);
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 652d878..a2cdaaa 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -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 (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;
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 1a9cae9..ac7ca5b 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -7741,13 +7741,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);
  * }
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index 1fa4c00..a30d869 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -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);
  * ]|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]