[gnome-devel-docs] Ran through Message Board in C



commit cb58c09f9581cdbf05b027d23f6dfbe0d8a9abf7
Author: P. F. Chimento <philip chimento gmail com>
Date:   Tue Mar 22 19:45:42 2011 +0100

    Ran through Message Board in C
    
    One thing was that Anjuta doesn't autogenerate a "destroy" function
    anymore; the tutorial connected it to "delete-event", but now I simply
    connected "gtk_main_quit".

 platform-demos/C/message-board.c.page          |   13 ++++++-------
 platform-demos/C/message-board/message-board.c |   21 +--------------------
 2 files changed, 7 insertions(+), 27 deletions(-)
---
diff --git a/platform-demos/C/message-board.c.page b/platform-demos/C/message-board.c.page
index 497705c..f9e4b40 100644
--- a/platform-demos/C/message-board.c.page
+++ b/platform-demos/C/message-board.c.page
@@ -52,7 +52,7 @@
   <steps>
     <item><p>In Anjuta, click <guiseq><gui>File</gui><gui>New</gui>
     <gui>Project</gui></guiseq> to open the new project assistant.</p></item>
-    <item><p>Select <gui>GTK+ (Simple)</gui> on the <gui>C</gui> tab,
+    <item><p>Select <gui>GTK+ (simple)</gui> on the <gui>C</gui> tab,
     and click <gui>Forward</gui>.</p></item>
     <item><p>Fill out your details on the <gui>Basic information</gui> page.
     Use <input>message-board</input> for the project name.
@@ -103,7 +103,7 @@ create_window (void)
     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
     gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
     gtk_window_set_title (GTK_WINDOW (window), "Message Board");
-    g_signal_connect (window, "delete-event", G_CALLBACK (destroy), NULL);
+    g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
 
     box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
     gtk_container_set_border_width (GTK_CONTAINER (box), 6);
@@ -130,11 +130,10 @@ create_window (void)
 ]]></code>
 
   <p>You first create a <code>GtkWindow</code> object and set its title and
-  default size. You also connect the <code>destroy</code> function to the
+  default size. You also connect the <code>gtk_main_quit</code> function to the
   <code>delete-event</code> signal. The <code>delete-event</code> signal is
-  emitted when the window is closed. The <code>destroy</code> function is
-  already provided in <file>main.c</file>. It just calls
-  <code>gtk_main_quit</code> to quit the application.</p>
+  emitted when the window is closed. The <code>gtk_main_quit</code> function is
+  part of GTK, and it quits the application.</p>
 
   <p>You then create a vertical box and add it to the window. A window can only
   hold a single child widget, so you need to use a box to add multiple widgets.
@@ -158,7 +157,7 @@ create_window (void)
 
   <p>Finally, you create a <code>WebKitWebView</code> and add it to the scrolled
   window. Then load a very basic HTML page into the web view by calling
-  <code>webkit_web_view_load_string</code> with the follow arguments:</p>
+  <code>webkit_web_view_load_string</code> with the following arguments:</p>
 
   <terms>
     <item>
diff --git a/platform-demos/C/message-board/message-board.c b/platform-demos/C/message-board/message-board.c
index 6738337..6da56bf 100644
--- a/platform-demos/C/message-board/message-board.c
+++ b/platform-demos/C/message-board/message-board.c
@@ -7,16 +7,6 @@
 
 #include <glib/gi18n.h>
 
-
-/* For testing propose use the local (not installed) ui file */
-/* #define UI_FILE PACKAGE_DATA_DIR"/message_board/ui/message_board.ui" */
-#define UI_FILE "src/message_board.ui"
-
-/* Signal handlers */
-/* Note: These may not be declared static because signal autoconnection
- * only works with non-static methods
- */
-
 static const guchar CSS[] =
 "body { margin: 0; padding: 0; }\n"
 "div { "
@@ -28,13 +18,6 @@ static const guchar CSS[] =
 " margin: 12px; padding: 6px;"
 "}";
 
-/* Called when the window is closed */
-void
-destroy (GtkWidget *widget, gpointer data)
-{
-	gtk_main_quit ();
-}
-
 static void
 entry_activate_cb (GtkEntry *entry, WebKitWebView *view)
 {
@@ -67,7 +50,7 @@ create_window (void)
     gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
     gtk_window_set_title (GTK_WINDOW (window), "Message Board");
 	g_signal_connect (window, "delete-event",
-	                  G_CALLBACK (destroy), NULL);
+	                  G_CALLBACK (gtk_main_quit), NULL);
 
     box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
     gtk_container_set_border_width (GTK_CONTAINER (box), 6);
@@ -115,8 +98,6 @@ main (int argc, char *argv[])
 	textdomain (GETTEXT_PACKAGE);
 #endif
 
-	
-	gtk_set_locale ();
 	gtk_init (&argc, &argv);
 
 	window = create_window ();



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