From 051d7caf9f3c639c227d3eaa8b9ec4b0dad1dfb9 Mon Sep 17 00:00:00 2001 From: GMT 2004 Tony Gale Date: Wed, 14 Jan 2004 13:08:55 +0000 Subject: [PATCH] Updates to Section 5 Wed Jan 14 13:07:30 GMT 2004 Tony Gale * docs/faq/gtk-faq.sgml: Updates to Section 5 --- ChangeLog | 4 ++++ ChangeLog.pre-2-10 | 4 ++++ ChangeLog.pre-2-4 | 4 ++++ ChangeLog.pre-2-6 | 4 ++++ ChangeLog.pre-2-8 | 4 ++++ docs/faq/gtk-faq.sgml | 55 +++++++++++++++++++++++-------------------- 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93d4e37abf..c7cce348f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Jan 14 13:07:30 GMT 2004 Tony Gale + + * docs/faq/gtk-faq.sgml: Updates to Section 5 + Wed Jan 14 02:34:57 2004 Matthias Clasen * gtk/gtkradioaction.c: Add a writable group property to align diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 93d4e37abf..c7cce348f5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,7 @@ +Wed Jan 14 13:07:30 GMT 2004 Tony Gale + + * docs/faq/gtk-faq.sgml: Updates to Section 5 + Wed Jan 14 02:34:57 2004 Matthias Clasen * gtk/gtkradioaction.c: Add a writable group property to align diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 93d4e37abf..c7cce348f5 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,7 @@ +Wed Jan 14 13:07:30 GMT 2004 Tony Gale + + * docs/faq/gtk-faq.sgml: Updates to Section 5 + Wed Jan 14 02:34:57 2004 Matthias Clasen * gtk/gtkradioaction.c: Add a writable group property to align diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 93d4e37abf..c7cce348f5 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,7 @@ +Wed Jan 14 13:07:30 GMT 2004 Tony Gale + + * docs/faq/gtk-faq.sgml: Updates to Section 5 + Wed Jan 14 02:34:57 2004 Matthias Clasen * gtk/gtkradioaction.c: Add a writable group property to align diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 93d4e37abf..c7cce348f5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,7 @@ +Wed Jan 14 13:07:30 GMT 2004 Tony Gale + + * docs/faq/gtk-faq.sgml: Updates to Section 5 + Wed Jan 14 02:34:57 2004 Matthias Clasen * gtk/gtkradioaction.c: Add a writable group property to align diff --git a/docs/faq/gtk-faq.sgml b/docs/faq/gtk-faq.sgml index 5c5a6ad1f8..e0389bbf67 100644 --- a/docs/faq/gtk-faq.sgml +++ b/docs/faq/gtk-faq.sgml @@ -2,7 +2,7 @@ - January 13th 2004 + January 14th 2004 GTK+ FAQ @@ -1469,7 +1469,7 @@ in a priority of G_PRIORITY_HIGH. Why does this strange 'x io error' occur when I -<literal>fork()</literal> in my GTK+ app? +fork() in my GTK+ app? [GTK 2.x] This is not really a GTK+ problem, and the problem is not related to fork() either. If the 'x io @@ -1490,13 +1490,15 @@ illustrate handling fork() and exit(). /*------------------------------------------------------------------------- * Filename: gtk-fork.c - * Version: 0.99.1 + * Version: 0.99.2 * Copyright: Copyright (C) 1999, Erik Mouw * Author: Erik Mouw <J.A.K.Mouw@its.tudelft.nl> * Description: GTK+ fork example * Created at: Thu Sep 23 21:37:55 1999 * Modified by: Erik Mouw <J.A.K.Mouw@its.tudelft.nl> * Modified at: Thu Sep 23 22:39:39 1999 + * Modified by: Tony Gale <gale@gtk.org> + * Modified at: Wed Jan 14 12:38:00 2004 *-----------------------------------------------------------------------*/ /* * Compile with: @@ -1525,7 +1527,7 @@ void sigchld_handler(int num) sigprocmask(SIG_BLOCK, &set, &oldset); /* wait for child */ - while((pid = waitpid((pid_t)-1, &status, WNOHANG)) > 0) + while((pid = waitpid((pid_t)-1, &status, WNOHANG)) > 0) { if(WIFEXITED(status)) { @@ -1622,13 +1624,13 @@ int main(int argc, char *argv[]) */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_signal_connect(GTK_OBJECT (window), "delete_event", - GTK_SIGNAL_FUNC(delete_event), NULL); + g_signal_connect(G_OBJECT (window), "delete_event", + G_CALLBACK(delete_event), NULL); - gtk_signal_connect(GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC(destroy), NULL); + g_signal_connect(G_OBJECT (window), "destroy", + G_CALLBACK(destroy), NULL); -#if (GTK_MAJOR_VERSION == 1) && (GTK_MINOR_VERSION == 0) +#if (GTK_MAJOR_VERSION == 1) && (GTK_MINOR_VERSION == 0) gtk_container_border_width(GTK_CONTAINER (window), 10); #else gtk_container_set_border_width(GTK_CONTAINER (window), 10); @@ -1637,8 +1639,8 @@ int main(int argc, char *argv[]) /* add a button to do something usefull */ button = gtk_button_new_with_label("Fork me!"); - gtk_signal_connect(GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC(fork_me), NULL); + g_signal_connect(G_OBJECT (button), "clicked", + G_CALLBACK(fork_me), NULL); gtk_container_add(GTK_CONTAINER(window), button); @@ -1663,7 +1665,7 @@ int main(int argc, char *argv[]) Why don't the contents of a button move when the button -is pressed? Here's a patch to make it work that way... +is pressed? Here's a patch to make it work that way... [GTK 2.x] From: Peter Mattis @@ -1689,12 +1691,12 @@ and determined it didn't look good and removed it. How do I identifiy a widgets top level window or other -ancestor? +ancestor? [GTK 2.x] There are a couple of ways to find the top level parent -of a widget. The easier way is to call the +of a widget. The easiest way is to call the gtk_widget_get_toplevel() function that -returns pointer to a GtkWidget that is the top level +returns a pointer to a GtkWidget that is the top level window. A more complicated way to do this (but less limited, as @@ -1718,12 +1720,16 @@ widget (entry, label, etc. To find the master hbox using the hbox = gtk_widget_get_ancestor(w, GTK_TYPE_HBOX); +You can also follow the a widgets ancestry by using the function +gtk_widget_get_parent() that returns a pointer +to a widgets parent widget. + -How do I get the Window ID of a GtkWindow? +How do I get the Window ID of a GtkWindow? <emphasis>[GTK 2.x]</emphasis> The actual Gdk/X window will be created when the widget gets realized. You can get the Window ID with: @@ -1738,8 +1744,7 @@ Window xwin = GDK_WINDOW_XWINDOW (GTK_WIDGET (my_window)->window); -How do I catch a double click event (in a list widget, -for example)? +How do I catch a double click event? <emphasis>[GTK 2.x]</emphasis> Tim Janik wrote to gtk-list (slightly modified): @@ -1749,10 +1754,10 @@ for example)? gint signal_handler_event(GtkWidget *widget, GdkEventButton *event, gpointer func_data) { - if (GTK_IS_LIST_ITEM(widget) && + if (GTK_IS_BUTTON(widget) && (event->type==GDK_2BUTTON_PRESS || event->type==GDK_3BUTTON_PRESS) ) { - printf("I feel %s clicked on button %d\n", + printf("I feel %s clicked with button %d\n", event->type==GDK_2BUTTON_PRESS ? "double" : "triple", event->button); } @@ -1764,18 +1769,18 @@ signal_handler_event(GtkWidget *widget, GdkEventButton *event, gpointer func_dat { - /* list, list item init stuff */ + /* button init stuff */ - gtk_signal_connect(GTK_OBJECT(list_item), + g_signal_connect(G_OBJECT(button), "button_press_event", - GTK_SIGNAL_FUNC(signal_handler_event), + G_CALLBACK(signal_handler_event), NULL); /* and/or */ - gtk_signal_connect(GTK_OBJECT(list_item), + g_signal_connect(G_OBJECT(button), "button_release_event", - GTK_SIGNAL_FUNC(signal_handler_event), + G_CALLBACK(signal_handler_event), NULL); /* something else */