diff --git a/ChangeLog b/ChangeLog index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 168dd26aec..1287cfe64c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,7 @@ +Sat Aug 28 14:34:37 BST 1999 Tony Gale + + * docs/gtkfaq.sgml: FAQ update + 1999-08-27 Tor Lillqvist Win32: Philippe Colantoni suggests a diff --git a/docs/faq/gtkfaq.sgml b/docs/faq/gtkfaq.sgml index 10fa11581a..3596a29864 100644 --- a/docs/faq/gtkfaq.sgml +++ b/docs/faq/gtkfaq.sgml @@ -9,7 +9,7 @@ Nathan Froyd, Tony Gale, Shawn T. Amundson, Emmanuel Deloget -August 10th 1999 +August 28th 1999 This document is intended to answer questions that are likely to be frequently asked by programmers using GTK+ or people who are just looking at @@ -46,30 +46,31 @@ Thanks again (I know, it's really short :) Authors

-The authors of GTK+ are: +The original authors of GTK+ were: -Peter Mattis (petm@xcf.berkeley.edu) -Spencer Kimball (spencer@xcf.berkeley.edu) -Josh MacDonald (jmacd@xcf.berkeley.edu) +Peter Mattis +Spencer Kimball +Josh MacDonald -GTK+ is distributed under the GNU Library General Public License + +Since then, much has been added by others. Please see the AUTHORS +file in the distribution for the GTK+ Team. What is GTK+?

-GTK+ is a small and efficient widget set designed with the general look -and feel of Motif. In reality, it looks much better than Motif. It -contains common widgets and some more complex widgets such as a file -selection, and color selection widgets. +GTK+ is a small and efficient widget set designed with the general +look and feel of Motif. In reality, it looks much better than Motif. +It contains common widgets and some more complex widgets such as a +file selection, and color selection widgets. -GTK+ provides some unique features. (At least, I know of no other widget -library which provides them). For -example, a button does not contain a label, it contains a child widget, -which in most instances will be a label. -However, the child widget can also be a pixmap, image or any combination -possible the programmer desires. -This flexibility is adhered to throughout the library. +GTK+ provides some unique features. (At least, I know of no other +widget library which provides them). For example, a button does not +contain a label, it contains a child widget, which in most instances +will be a label. However, the child widget can also be a pixmap, +image or any combination possible the programmer desires. This +flexibility is adhered to throughout the library. What is the + in GTK+? @@ -86,14 +87,13 @@ enhancement to the original gtk that adds object oriented features." -Does the G in GTK+ stand for General, Gimp, or GNU? +Does the G in GTK+, GDK and GLib stand for?

-Peter Mattis informed the gtk mailing list that: - -"I think the last time Spencer and I talked about it we decided on -GTK = Gimp ToolKit. But I don't know for sure. Its definately not -GNU, though." - +GTK+ == Gimp Toolkit + +GDK == Gtk+ Drawing Kit + +GLib == G Library Where is the documentation for GTK+? @@ -121,28 +121,10 @@ name="http://www.bcpl.net/~eharlow/book"> Is there a mailing list (or mailing list archive) for GTK+?

-There are two mailing lists: - -A mailing list for discussion of development of GTK based applications -is hosted at gtk-app-devel-list@redhat.com. To subscribe send an -email message to -with subscribe in the subject. -

-A mailing list for discussion of development of GTK is hosted -at gtk-list@redhat.com. To subscribe send an -email message to -with subscribe in the subject. -

-An archive of the mailing list can be found at - - - -The gtk-list hasn't had any traffic for days, is it dead? -

-No, everyone's just busy coding. +Information on mailing lists relating to GTK+ can be found at: + + How to get help with GTK+ @@ -154,7 +136,56 @@ that case, the best place to post questions is to the GTK+ mailing list. How to report bugs in GTK+

-Bug reports should be sent to the GTK+ mailing list. +Bugs should be reported to the GNOME bug tracking +system (). To report a problem about GTK+, send +mail to submit@bugs.gnome.org. + +The subject of the mail should describe your problem. In the body of +the mail, you should first include a "pseudo-header" that gives the +package and version number. This should be separated by a blank line +from the actual headers. + + + Package: gtk+ + Version: 1.2.0 + + +Substitute 1.2.0 with the version of GTK+ that you have installed. + +Then describe the bug. Include: + + + Information about your system. For instance: + + What operating system and version + What version of X + For Linux, what version of the C library + + And anything else you think is relevant. + + How to reproduce the bug. + + If you can reproduce it with the testgtk program that is built + in the gtk/ subdirectory, that will be most convenient. Otherwise, + please include a short test program that exhibits the behavior. + As a last resort, you can also provide a pointer to a larger piece + of software that can be downloaded. + + (Bugs that can be reproduced within the GIMP are almost as good + as bugs that can be reproduced in testgtk. If you are reporting a + bug found with the GIMP, please include the version number of the GIMP + you are using) + + If the bug was a crash, the exact text that was printed out + when the crash occured. + + Further information such as stack traces may be useful, but + are not necessary. If you do send a stack trace, and the error + is an X error, it will be more useful if the stacktrace + is produced running the test program with the Is there a Windows version of GTK+? @@ -169,8 +200,13 @@ name="http://www.iki.fi/tml/gimp/win32"> for more information. What applications have been written with GTK+?

A list of some GTK+ based application can be found on the GTK+ web -server at and contains more than 350 applications. +server at and contains more than 350 +applications. + +Failing that, look for a project to work on for the GNOME project, + +Write a game. Write something that is useful. Some of these are: @@ -763,7 +799,7 @@ bit hard to get (here in The Netherlands, YMMV). -Development with GTK+: the programming part +Development with GTK+: general questions What widgets are in GTK? @@ -953,6 +989,70 @@ carefully. Regardless, it's especially not a priority since relatively good workarounds exist. --> + +Why do this strange 'x io error' occur when I +This is not really a GTK+ problem, and the problem is not related to + int pid = fork(); + + if(pid==-1) + { + perror("fork"); + exit(-1); + } + else if(pid==0) /* child */ + { + retval=system("a command"); /* can use exec* functions here */ + _exit(retval); /* notice _exit() instead of exit() */ + } + else /* parent */ + { + for(;;) + { + if(waitpid(pid, &status, WNOHANG) == pid) + { + waitpid(pid, &status, WUNTRACED); /* anti zombie code */ + break; + } + } + + return(WEXITSTATUS(status)); + } + + + +Why don't the contents of a button move when the button is pressed? Here's a patch to make it work that way... +

+From: Peter Mattis + + +The reason buttons don't move their child down and to the right when +they are depressed is because I don't think that's what is happening +visually. My view of buttons is that you are looking at them straight +on. That is, the user interface lies in a plane and you're above it +looking straight at it. When a button gets pressed it moves directly +away from you. To be absolutely correct I guess the child should +actually shrink a tiny amount. But I don't see why the child should +shift down and to the left. Remember, the child is supposed to be +attached to the buttons surface. Its not good for it to appear like +the child is slipping on the surface of the button. +

+On a more practical note, I did implement this at one point and +determined it didn't look good and removed it. + How to I identifiy a widgets top level window or other ancestor? @@ -984,159 +1084,7 @@ using the -How do I find out about the selection of a GtkList? -

-Get the selection something like this: - -GList *sel; -sel = GTK_LIST(list)->selection; - - -This is how GList is defined (quoting glist.h): - -typedef struct _GList GList; - -struct _GList -{ - gpointer data; - GList *next; - GList *prev; -}; - - -A GList structure is just a simple structure for doubly linked lists. -there exist several g_list_*() functions to modify a linked list in -glib.h. However the GTK_LIST(MyGtkList)->selection is maintained -by the gtk_list_*() functions and should not be modified. - -The selection_mode of the GtkList determines the selection -facilities of a GtkList and therefore the contents -of GTK_LIST(AnyGtkList)->selection: - - -selection_mode GTK_LIST()->selection contents ------------------------------------------------------- - -GTK_SELECTION_SINGLE) selection is either NULL - or contains a GList* pointer - for a single selected item. - -GTK_SELECTION_BROWSE) selection is NULL if the list - contains no widgets, otherwise - it contains a GList* pointer - for one GList structure. -GTK_SELECTION_MULTIPLE) selection is NULL if no listitems - are selected or a a GList* pointer - for the first selected item. that - in turn points to a GList structure - for the second selected item and so - on - -GTK_SELECTION_EXTENDED) selection is NULL. - - -The data field of the GList structure GTK_LIST(MyGtkList)->selection points -to the first GtkListItem that is selected. So if you would like to determine -which listitems are selected you should go like this: - -Upon Initialization: - -{ - gchar *list_items[]={ - "Item0", - "Item1", - "foo", - "last Item", - }; - guint nlist_items=sizeof(list_items)/sizeof(list_items[0]); - GtkWidget *list_item; - guint i; - - list=gtk_list_new(); - gtk_list_set_selection_mode(GTK_LIST(list), GTK_SELECTION_MULTIPLE); - gtk_container_add(GTK_CONTAINER(AnyGtkContainer), list); - gtk_widget_show (list); - - for (i = 0; i < nlist_items; i++) - { - list_item=gtk_list_item_new_with_label(list_items[i]); - gtk_object_set_user_data(GTK_OBJECT(list_item), (gpointer)i); - gtk_container_add(GTK_CONTAINER(list), list_item); - gtk_widget_show(list_item); - } -} - - -To get known about the selection: - -{ - GList *items; - - items=GTK_LIST(list)->selection; - - printf("Selected Items: "); - while (items) { - if (GTK_IS_LIST_ITEM(items->data)) - printf("%d ", (guint) - gtk_object_get_user_data(items->data)); - items=items->next; - } - printf("\n"); -} - - - -How can I prevent redrawing and resizing while I change multiple widgets? -

-Old versions of GTK+ used to provide the - - -I don't want the user of my applications to enter text into a GtkCombo. Any idea? -

-A GtkCombo has an associated entry which can be accessed using the -following expression: - - - GTK_COMBO(combo_widget)->entry - - -If you don't want the user to be able to modify the content of this -entry, you can use the gtk_entry_set_editable() function: - - - void gtk_entry_set_editable(GtkEntry *entry, - gboolean editable); - - -Set the editable parameter to FALSE to disable typing into the entry. - - -How do I catch a combo box change? -

-The entry which is associated to your GtkCombo send a "changed" signal when: - - some text is typed in - the selection of the combo box is changed - - -To catch any combo box change, simply connect your signal handler with - - - gtk_signal_connect(GTK_COMBO(cb)->entry, - "changed", - GTK_SIGNAL_FUNC(my_cb_change_handler), - NULL); - - - How do I catch a double click event (in a list widget, for example)?

Tim Janik wrote to gtk-list (slightly modified): @@ -1270,76 +1218,7 @@ copy gtkviewport.c and strip out the adjustment and shadow functionality (perhaps you could call it GtkClipper). -How can I define a separation line in a menu? -

-See the for information on how to create menus. -However, to create a separation line in a menu, just insert an -empty menu item: - -menuitem = gtk_menu_item_new(); -gtk_menu_append(GTK_MENU(menu), menuitem); -gtk_widget_show(menuitem); - - - -How can I right justify a menu, such as Help? -

-Depending on if you use the MenuFactory or not, there are two ways to proceed. -With the MenuFactory, use something like the following: - - -menu_path = gtk_menu_factory_find (factory, "/Help"); -gtk_menu_item_right_justify(menu_path->widget); - - -If you do not use the MenuFactory, you should simply use: - - -gtk_menu_item_right_justify(my_menu_item); - - - -How do I add some underlined accelerators to menu items? -

-Damon Chaplin, the technical force behind the Glade project, provided the -following code sample (this code is an output from Glade). It creates a -small - menubar1 = gtk_menu_bar_new (); - gtk_object_set_data (GTK_OBJECT (window1), "menubar1", menubar1); - gtk_widget_show (menubar1); - gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); - - file1 = gtk_menu_item_new_with_label (""); - tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (file1)->child), - _("_File")); - gtk_widget_add_accelerator (file1, "activate_item", accel_group, - tmp_key, GDK_MOD1_MASK, 0); - gtk_object_set_data (GTK_OBJECT (window1), "file1", file1); - gtk_widget_show (file1); - gtk_container_add (GTK_CONTAINER (menubar1), file1); - - file1_menu = gtk_menu_new (); - file1_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (file1_menu)); - gtk_object_set_data (GTK_OBJECT (window1), "file1_menu", file1_menu); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (file1), file1_menu); - - new1 = gtk_menu_item_new_with_label (""); - tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (new1)->child), - _("_New")); - gtk_widget_add_accelerator (new1, "activate_item", file1_menu_accels, - tmp_key, 0, 0); - gtk_object_set_data (GTK_OBJECT (window1), "new1", new1); - gtk_widget_show (new1); - gtk_container_add (GTK_CONTAINER (file1_menu), new1); - - - How do I make my window modal? / How do I make a single window active?

After you create your window, do -How do I right (or otherwise) justify a label? -

-Are you sure you want to justify the labels? The label class contains -the alignment of the label, ie right -align it, center it or left align it. If you want to do this, you -should use: - - -void gtk_misc_set_alignment (GtkMisc *misc, - gfloat xalign, - gfloat yalign); - - -where the -GtkWidget *label; - -/* horizontal : left align, vertical : top */ -gtk_misc_set_alignment(GTK_MISK(label), 0.0f, 0.0f); - -/* horizontal : centered, vertical : centered */ -gtk_misc_set_alignment(GTK_MISK(label), 0.5f, 0.5f); - -/* horizontal : right align, vertical : bottom */ -gtk_misc_set_alignment(GTK_MISK(label), 1.0f, 1.0f); - - - -How could I get any widget position? +How could I get any widgets position?

As Tim Janik pointed out, there are different cases, and each case requires a different solution. If you want the position of a widget relative to its parent, you should - use allocate.x/ and allocate.y/. + use allocation.x/ and allocation.y/. If you want the position of a window relative to the X root window, you should use -How do I set the position/size of a widget/window? +How do I set the size of a widget/window? How do I prevent the user resizing my window?

The -void gtk_window_set_policy (GtkWindow *window, - gint allow_shrink, - gint allow_grow, - gint auto_shrink); +void gtk_widget_set_usize (GtkWidget *widget, + gint width, + gint height); + +void gtk_window_set_policy (GtkWindow *window, + gint allow_shrink, + gint allow_grow, + gint auto_shrink); + +Shouldn't the text argument in the gtk_clist_* functions be declared const? +

+For example: + +gint gtk_clist_prepend (GtkCList *clist, + gchar *text[]); + + +Answer: No, while a type "gchar*" (pointer to char) can automatically +be cast into "const gchar*" (pointer to const char), this does not +apply for "gchar *[]" (array of an unspecified number of pointers to +char) into "const gchar *[]" (array of an unspecified number of +pointers to const char). + +The type qualifier "const" may be subject to automatic casting, but +in the array case, it is not the array itself that needs the (const) +qualified cast, but its members, thus changing the whole type. + + +Development with GTK+: widget specific questions + + + +How do I find out about the selection of a GtkList? +

+Get the selection something like this: + +GList *sel; +sel = GTK_LIST(list)->selection; + + +This is how GList is defined (quoting glist.h): + +typedef struct _GList GList; + +struct _GList +{ + gpointer data; + GList *next; + GList *prev; +}; + + +A GList structure is just a simple structure for doubly linked lists. +there exist several g_list_*() functions to modify a linked list in +glib.h. However the GTK_LIST(MyGtkList)->selection is maintained +by the gtk_list_*() functions and should not be modified. + +The selection_mode of the GtkList determines the selection +facilities of a GtkList and therefore the contents +of GTK_LIST(AnyGtkList)->selection: + + +selection_mode GTK_LIST()->selection contents +------------------------------------------------------ + +GTK_SELECTION_SINGLE) selection is either NULL + or contains a GList* pointer + for a single selected item. + +GTK_SELECTION_BROWSE) selection is NULL if the list + contains no widgets, otherwise + it contains a GList* pointer + for one GList structure. +GTK_SELECTION_MULTIPLE) selection is NULL if no listitems + are selected or a a GList* pointer + for the first selected item. that + in turn points to a GList structure + for the second selected item and so + on + +GTK_SELECTION_EXTENDED) selection is NULL. + + +The data field of the GList structure GTK_LIST(MyGtkList)->selection points +to the first GtkListItem that is selected. So if you would like to determine +which listitems are selected you should go like this: + +Upon Initialization: + +{ + gchar *list_items[]={ + "Item0", + "Item1", + "foo", + "last Item", + }; + guint nlist_items=sizeof(list_items)/sizeof(list_items[0]); + GtkWidget *list_item; + guint i; + + list=gtk_list_new(); + gtk_list_set_selection_mode(GTK_LIST(list), GTK_SELECTION_MULTIPLE); + gtk_container_add(GTK_CONTAINER(AnyGtkContainer), list); + gtk_widget_show (list); + + for (i = 0; i < nlist_items; i++) + { + list_item=gtk_list_item_new_with_label(list_items[i]); + gtk_object_set_user_data(GTK_OBJECT(list_item), (gpointer)i); + gtk_container_add(GTK_CONTAINER(list), list_item); + gtk_widget_show(list_item); + } +} + + +To get known about the selection: + +{ + GList *items; + + items=GTK_LIST(list)->selection; + + printf("Selected Items: "); + while (items) { + if (GTK_IS_LIST_ITEM(items->data)) + printf("%d ", (guint) + gtk_object_get_user_data(items->data)); + items=items->next; + } + printf("\n"); +} + + +

+I don't want the user of my applications to enter text into a GtkCombo. Any idea? +

+A GtkCombo has an associated entry which can be accessed using the +following expression: + + + GTK_COMBO(combo_widget)->entry + + +If you don't want the user to be able to modify the content of this +entry, you can use the gtk_entry_set_editable() function: + + + void gtk_entry_set_editable(GtkEntry *entry, + gboolean editable); + + +Set the editable parameter to FALSE to disable typing into the entry. + + +How do I catch a combo box change? +

+The entry which is associated to your GtkCombo send a "changed" signal when: + + some text is typed in + the selection of the combo box is changed + + +To catch any combo box change, simply connect your signal handler with + + + gtk_signal_connect(GTK_COMBO(cb)->entry, + "changed", + GTK_SIGNAL_FUNC(my_cb_change_handler), + NULL); + + + +How can I define a separation line in a menu? +

+See the for information on how to create menus. +However, to create a separation line in a menu, just insert an +empty menu item: + + +menuitem = gtk_menu_item_new(); +gtk_menu_append(GTK_MENU(menu), menuitem); +gtk_widget_show(menuitem); + + + +How can I right justify a menu, such as Help? +

+Depending on if you use the MenuFactory or not, there are two ways to proceed. +With the MenuFactory, use something like the following: + + +menu_path = gtk_menu_factory_find (factory, "/Help"); +gtk_menu_item_right_justify(menu_path->widget); + + +If you do not use the MenuFactory, you should simply use: + + +gtk_menu_item_right_justify(my_menu_item); + + + +How do I add some underlined accelerators to menu items? +

+Damon Chaplin, the technical force behind the Glade project, provided the +following code sample (this code is an output from Glade). It creates a +small + menubar1 = gtk_menu_bar_new (); + gtk_object_set_data (GTK_OBJECT (window1), "menubar1", menubar1); + gtk_widget_show (menubar1); + gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); + + file1 = gtk_menu_item_new_with_label (""); + tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (file1)->child), + _("_File")); + gtk_widget_add_accelerator (file1, "activate_item", accel_group, + tmp_key, GDK_MOD1_MASK, 0); + gtk_object_set_data (GTK_OBJECT (window1), "file1", file1); + gtk_widget_show (file1); + gtk_container_add (GTK_CONTAINER (menubar1), file1); + + file1_menu = gtk_menu_new (); + file1_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (file1_menu)); + gtk_object_set_data (GTK_OBJECT (window1), "file1_menu", file1_menu); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (file1), file1_menu); + + new1 = gtk_menu_item_new_with_label (""); + tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (new1)->child), + _("_New")); + gtk_widget_add_accelerator (new1, "activate_item", file1_menu_accels, + tmp_key, 0, 0); + gtk_object_set_data (GTK_OBJECT (window1), "new1", new1); + gtk_widget_show (new1); + gtk_container_add (GTK_CONTAINER (file1_menu), new1); + + + +How do I right (or otherwise) justify a GtkLabel? +

+Are you sure you want to justify the labels? The label class contains +the alignment of the label, ie right +align it, center it or left align it. If you want to do this, you +should use: + + +void gtk_misc_set_alignment (GtkMisc *misc, + gfloat xalign, + gfloat yalign); + + +where the +GtkWidget *label; + +/* horizontal : left align, vertical : top */ +gtk_misc_set_alignment(GTK_MISK(label), 0.0f, 0.0f); + +/* horizontal : centered, vertical : centered */ +gtk_misc_set_alignment(GTK_MISK(label), 0.5f, 0.5f); + +/* horizontal : right align, vertical : bottom */ +gtk_misc_set_alignment(GTK_MISK(label), 1.0f, 1.0f); + + + +How do I set the color and font of a GtkLabel using a Resource File? +

+The widget name path constructed for a Label consists of the widget +names of its object hierarchy as well, e.g. + + +window (name: humphrey) + hbox + label (name: mylabel) + + +The widget path your pattern needs to match would be: + +style "title" +{ + fg[NORMAL] = {1.0, 0.0, 0.0} + font = "-adobe-helvetica-bold-r-normal--*-140-*-*-*-*-*-*" +} +widget "*mylabel" style "title" + + +In your program, you would also need to give a name to the Label +widget, which can be done using: + + label = gtk_label_new("Some Label Text"); + gtk_widget_set_name(label, "mylabel"); + gtk_widget_show(label); + + + +How do I configure Tooltips in a Resource File? +

+The tooltip's window is named "gtk-tooltips", GtkTooltips in itself is not +a GtkWidget (though a GtkObject) and as such is not attempted to match any +widget styles. + +So, you resource file should look something like: + +style "postie" +{ + bg[NORMAL] = {1.0, 1.0, 0.0} +} +widget "gtk-tooltips*" style "postie" + How do I use horizontal scrollbars with a GtkText widget?

The short answer is that you can't. The current version of the GtkText @@ -1538,6 +1703,25 @@ widget does not support horizontal scrolling. There is an intention to completely rewrite the GtkText widget, at which time this limitation will be removed. + +I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong? +

+There is now a known problem in the GtkEntry widget. In the + + /* The algorithms here will work as long as, the text size (a + * multiple of 2), fits into a guint16 but we specify a shorter + * maximum length so that if the user pastes a very long text, there + * is not a long hang from the slow X_LOCALE functions. */ + + if (entry->text_max_length == 0) + max_length = 2047; + else + max_length = MIN (2047, entry->text_max_length); + + How do I change the font of a GtkText widget?

@@ -1623,93 +1807,6 @@ main (int argc, char *argv[]) Now, if you really want to change the cursor position, you should use the -Development with GTK+: misc questions - - -Why do this strange 'x io error' occur when I -This is not really a GTK+ problem, and the problem is not related to - int pid = fork(); - - if(pid==-1) - { - perror("fork"); - exit(-1); - } - else if(pid==0) /* child */ - { - retval=system("a command"); /* can use exec* functions here */ - _exit(retval); /* notice _exit() instead of exit() */ - } - else /* parent */ - { - for(;;) - { - if(waitpid(pid, &status, WNOHANG) == pid) - { - waitpid(pid, &status, WUNTRACED); /* anti zombie code */ - break; - } - } - - return(WEXITSTATUS(status)); - } - - - -I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong? -

-There is now a known problem in the GtkEntry widget. In the - - /* The algorithms here will work as long as, the text size (a - * multiple of 2), fits into a guint16 but we specify a shorter - * maximum length so that if the user pastes a very long text, there - * is not a long hang from the slow X_LOCALE functions. */ - - if (entry->text_max_length == 0) - max_length = 2047; - else - max_length = MIN (2047, entry->text_max_length); - - - -Why don't the contents of a button move when the button is pressed? Here's a patch to make it work that way... -

-From: Peter Mattis - - -The reason buttons don't move their child down and to the right when -they are depressed is because I don't think that's what is happening -visually. My view of buttons is that you are looking at them straight -on. That is, the user interface lies in a plane and you're above it -looking straight at it. When a button gets pressed it moves directly -away from you. To be absolutely correct I guess the child should -actually shrink a tiny amount. But I don't see why the child should -shift down and to the left. Remember, the child is supposed to be -attached to the buttons surface. Its not good for it to appear like -the child is slipping on the surface of the button. -

-On a more practical note, I did implement this at one point and -determined it didn't look good and removed it. - - About gdk diff --git a/docs/gtkfaq.sgml b/docs/gtkfaq.sgml index 10fa11581a..3596a29864 100644 --- a/docs/gtkfaq.sgml +++ b/docs/gtkfaq.sgml @@ -9,7 +9,7 @@ Nathan Froyd, Tony Gale, Shawn T. Amundson, Emmanuel Deloget -August 10th 1999 +August 28th 1999 This document is intended to answer questions that are likely to be frequently asked by programmers using GTK+ or people who are just looking at @@ -46,30 +46,31 @@ Thanks again (I know, it's really short :) Authors

-The authors of GTK+ are: +The original authors of GTK+ were: -Peter Mattis (petm@xcf.berkeley.edu) -Spencer Kimball (spencer@xcf.berkeley.edu) -Josh MacDonald (jmacd@xcf.berkeley.edu) +Peter Mattis +Spencer Kimball +Josh MacDonald -GTK+ is distributed under the GNU Library General Public License + +Since then, much has been added by others. Please see the AUTHORS +file in the distribution for the GTK+ Team. What is GTK+?

-GTK+ is a small and efficient widget set designed with the general look -and feel of Motif. In reality, it looks much better than Motif. It -contains common widgets and some more complex widgets such as a file -selection, and color selection widgets. +GTK+ is a small and efficient widget set designed with the general +look and feel of Motif. In reality, it looks much better than Motif. +It contains common widgets and some more complex widgets such as a +file selection, and color selection widgets. -GTK+ provides some unique features. (At least, I know of no other widget -library which provides them). For -example, a button does not contain a label, it contains a child widget, -which in most instances will be a label. -However, the child widget can also be a pixmap, image or any combination -possible the programmer desires. -This flexibility is adhered to throughout the library. +GTK+ provides some unique features. (At least, I know of no other +widget library which provides them). For example, a button does not +contain a label, it contains a child widget, which in most instances +will be a label. However, the child widget can also be a pixmap, +image or any combination possible the programmer desires. This +flexibility is adhered to throughout the library. What is the + in GTK+? @@ -86,14 +87,13 @@ enhancement to the original gtk that adds object oriented features." -Does the G in GTK+ stand for General, Gimp, or GNU? +Does the G in GTK+, GDK and GLib stand for?

-Peter Mattis informed the gtk mailing list that: - -"I think the last time Spencer and I talked about it we decided on -GTK = Gimp ToolKit. But I don't know for sure. Its definately not -GNU, though." - +GTK+ == Gimp Toolkit + +GDK == Gtk+ Drawing Kit + +GLib == G Library Where is the documentation for GTK+? @@ -121,28 +121,10 @@ name="http://www.bcpl.net/~eharlow/book"> Is there a mailing list (or mailing list archive) for GTK+?

-There are two mailing lists: - -A mailing list for discussion of development of GTK based applications -is hosted at gtk-app-devel-list@redhat.com. To subscribe send an -email message to -with subscribe in the subject. -

-A mailing list for discussion of development of GTK is hosted -at gtk-list@redhat.com. To subscribe send an -email message to -with subscribe in the subject. -

-An archive of the mailing list can be found at - - - -The gtk-list hasn't had any traffic for days, is it dead? -

-No, everyone's just busy coding. +Information on mailing lists relating to GTK+ can be found at: + + How to get help with GTK+ @@ -154,7 +136,56 @@ that case, the best place to post questions is to the GTK+ mailing list. How to report bugs in GTK+

-Bug reports should be sent to the GTK+ mailing list. +Bugs should be reported to the GNOME bug tracking +system (). To report a problem about GTK+, send +mail to submit@bugs.gnome.org. + +The subject of the mail should describe your problem. In the body of +the mail, you should first include a "pseudo-header" that gives the +package and version number. This should be separated by a blank line +from the actual headers. + + + Package: gtk+ + Version: 1.2.0 + + +Substitute 1.2.0 with the version of GTK+ that you have installed. + +Then describe the bug. Include: + + + Information about your system. For instance: + + What operating system and version + What version of X + For Linux, what version of the C library + + And anything else you think is relevant. + + How to reproduce the bug. + + If you can reproduce it with the testgtk program that is built + in the gtk/ subdirectory, that will be most convenient. Otherwise, + please include a short test program that exhibits the behavior. + As a last resort, you can also provide a pointer to a larger piece + of software that can be downloaded. + + (Bugs that can be reproduced within the GIMP are almost as good + as bugs that can be reproduced in testgtk. If you are reporting a + bug found with the GIMP, please include the version number of the GIMP + you are using) + + If the bug was a crash, the exact text that was printed out + when the crash occured. + + Further information such as stack traces may be useful, but + are not necessary. If you do send a stack trace, and the error + is an X error, it will be more useful if the stacktrace + is produced running the test program with the Is there a Windows version of GTK+? @@ -169,8 +200,13 @@ name="http://www.iki.fi/tml/gimp/win32"> for more information. What applications have been written with GTK+?

A list of some GTK+ based application can be found on the GTK+ web -server at and contains more than 350 applications. +server at and contains more than 350 +applications. + +Failing that, look for a project to work on for the GNOME project, + +Write a game. Write something that is useful. Some of these are: @@ -763,7 +799,7 @@ bit hard to get (here in The Netherlands, YMMV). -Development with GTK+: the programming part +Development with GTK+: general questions What widgets are in GTK? @@ -953,6 +989,70 @@ carefully. Regardless, it's especially not a priority since relatively good workarounds exist. --> + +Why do this strange 'x io error' occur when I +This is not really a GTK+ problem, and the problem is not related to + int pid = fork(); + + if(pid==-1) + { + perror("fork"); + exit(-1); + } + else if(pid==0) /* child */ + { + retval=system("a command"); /* can use exec* functions here */ + _exit(retval); /* notice _exit() instead of exit() */ + } + else /* parent */ + { + for(;;) + { + if(waitpid(pid, &status, WNOHANG) == pid) + { + waitpid(pid, &status, WUNTRACED); /* anti zombie code */ + break; + } + } + + return(WEXITSTATUS(status)); + } + + + +Why don't the contents of a button move when the button is pressed? Here's a patch to make it work that way... +

+From: Peter Mattis + + +The reason buttons don't move their child down and to the right when +they are depressed is because I don't think that's what is happening +visually. My view of buttons is that you are looking at them straight +on. That is, the user interface lies in a plane and you're above it +looking straight at it. When a button gets pressed it moves directly +away from you. To be absolutely correct I guess the child should +actually shrink a tiny amount. But I don't see why the child should +shift down and to the left. Remember, the child is supposed to be +attached to the buttons surface. Its not good for it to appear like +the child is slipping on the surface of the button. +

+On a more practical note, I did implement this at one point and +determined it didn't look good and removed it. + How to I identifiy a widgets top level window or other ancestor? @@ -984,159 +1084,7 @@ using the -How do I find out about the selection of a GtkList? -

-Get the selection something like this: - -GList *sel; -sel = GTK_LIST(list)->selection; - - -This is how GList is defined (quoting glist.h): - -typedef struct _GList GList; - -struct _GList -{ - gpointer data; - GList *next; - GList *prev; -}; - - -A GList structure is just a simple structure for doubly linked lists. -there exist several g_list_*() functions to modify a linked list in -glib.h. However the GTK_LIST(MyGtkList)->selection is maintained -by the gtk_list_*() functions and should not be modified. - -The selection_mode of the GtkList determines the selection -facilities of a GtkList and therefore the contents -of GTK_LIST(AnyGtkList)->selection: - - -selection_mode GTK_LIST()->selection contents ------------------------------------------------------- - -GTK_SELECTION_SINGLE) selection is either NULL - or contains a GList* pointer - for a single selected item. - -GTK_SELECTION_BROWSE) selection is NULL if the list - contains no widgets, otherwise - it contains a GList* pointer - for one GList structure. -GTK_SELECTION_MULTIPLE) selection is NULL if no listitems - are selected or a a GList* pointer - for the first selected item. that - in turn points to a GList structure - for the second selected item and so - on - -GTK_SELECTION_EXTENDED) selection is NULL. - - -The data field of the GList structure GTK_LIST(MyGtkList)->selection points -to the first GtkListItem that is selected. So if you would like to determine -which listitems are selected you should go like this: - -Upon Initialization: - -{ - gchar *list_items[]={ - "Item0", - "Item1", - "foo", - "last Item", - }; - guint nlist_items=sizeof(list_items)/sizeof(list_items[0]); - GtkWidget *list_item; - guint i; - - list=gtk_list_new(); - gtk_list_set_selection_mode(GTK_LIST(list), GTK_SELECTION_MULTIPLE); - gtk_container_add(GTK_CONTAINER(AnyGtkContainer), list); - gtk_widget_show (list); - - for (i = 0; i < nlist_items; i++) - { - list_item=gtk_list_item_new_with_label(list_items[i]); - gtk_object_set_user_data(GTK_OBJECT(list_item), (gpointer)i); - gtk_container_add(GTK_CONTAINER(list), list_item); - gtk_widget_show(list_item); - } -} - - -To get known about the selection: - -{ - GList *items; - - items=GTK_LIST(list)->selection; - - printf("Selected Items: "); - while (items) { - if (GTK_IS_LIST_ITEM(items->data)) - printf("%d ", (guint) - gtk_object_get_user_data(items->data)); - items=items->next; - } - printf("\n"); -} - - - -How can I prevent redrawing and resizing while I change multiple widgets? -

-Old versions of GTK+ used to provide the - - -I don't want the user of my applications to enter text into a GtkCombo. Any idea? -

-A GtkCombo has an associated entry which can be accessed using the -following expression: - - - GTK_COMBO(combo_widget)->entry - - -If you don't want the user to be able to modify the content of this -entry, you can use the gtk_entry_set_editable() function: - - - void gtk_entry_set_editable(GtkEntry *entry, - gboolean editable); - - -Set the editable parameter to FALSE to disable typing into the entry. - - -How do I catch a combo box change? -

-The entry which is associated to your GtkCombo send a "changed" signal when: - - some text is typed in - the selection of the combo box is changed - - -To catch any combo box change, simply connect your signal handler with - - - gtk_signal_connect(GTK_COMBO(cb)->entry, - "changed", - GTK_SIGNAL_FUNC(my_cb_change_handler), - NULL); - - - How do I catch a double click event (in a list widget, for example)?

Tim Janik wrote to gtk-list (slightly modified): @@ -1270,76 +1218,7 @@ copy gtkviewport.c and strip out the adjustment and shadow functionality (perhaps you could call it GtkClipper). -How can I define a separation line in a menu? -

-See the for information on how to create menus. -However, to create a separation line in a menu, just insert an -empty menu item: - -menuitem = gtk_menu_item_new(); -gtk_menu_append(GTK_MENU(menu), menuitem); -gtk_widget_show(menuitem); - - - -How can I right justify a menu, such as Help? -

-Depending on if you use the MenuFactory or not, there are two ways to proceed. -With the MenuFactory, use something like the following: - - -menu_path = gtk_menu_factory_find (factory, "/Help"); -gtk_menu_item_right_justify(menu_path->widget); - - -If you do not use the MenuFactory, you should simply use: - - -gtk_menu_item_right_justify(my_menu_item); - - - -How do I add some underlined accelerators to menu items? -

-Damon Chaplin, the technical force behind the Glade project, provided the -following code sample (this code is an output from Glade). It creates a -small - menubar1 = gtk_menu_bar_new (); - gtk_object_set_data (GTK_OBJECT (window1), "menubar1", menubar1); - gtk_widget_show (menubar1); - gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); - - file1 = gtk_menu_item_new_with_label (""); - tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (file1)->child), - _("_File")); - gtk_widget_add_accelerator (file1, "activate_item", accel_group, - tmp_key, GDK_MOD1_MASK, 0); - gtk_object_set_data (GTK_OBJECT (window1), "file1", file1); - gtk_widget_show (file1); - gtk_container_add (GTK_CONTAINER (menubar1), file1); - - file1_menu = gtk_menu_new (); - file1_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (file1_menu)); - gtk_object_set_data (GTK_OBJECT (window1), "file1_menu", file1_menu); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (file1), file1_menu); - - new1 = gtk_menu_item_new_with_label (""); - tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (new1)->child), - _("_New")); - gtk_widget_add_accelerator (new1, "activate_item", file1_menu_accels, - tmp_key, 0, 0); - gtk_object_set_data (GTK_OBJECT (window1), "new1", new1); - gtk_widget_show (new1); - gtk_container_add (GTK_CONTAINER (file1_menu), new1); - - - How do I make my window modal? / How do I make a single window active?

After you create your window, do -How do I right (or otherwise) justify a label? -

-Are you sure you want to justify the labels? The label class contains -the alignment of the label, ie right -align it, center it or left align it. If you want to do this, you -should use: - - -void gtk_misc_set_alignment (GtkMisc *misc, - gfloat xalign, - gfloat yalign); - - -where the -GtkWidget *label; - -/* horizontal : left align, vertical : top */ -gtk_misc_set_alignment(GTK_MISK(label), 0.0f, 0.0f); - -/* horizontal : centered, vertical : centered */ -gtk_misc_set_alignment(GTK_MISK(label), 0.5f, 0.5f); - -/* horizontal : right align, vertical : bottom */ -gtk_misc_set_alignment(GTK_MISK(label), 1.0f, 1.0f); - - - -How could I get any widget position? +How could I get any widgets position?

As Tim Janik pointed out, there are different cases, and each case requires a different solution. If you want the position of a widget relative to its parent, you should - use allocate.x/ and allocate.y/. + use allocation.x/ and allocation.y/. If you want the position of a window relative to the X root window, you should use -How do I set the position/size of a widget/window? +How do I set the size of a widget/window? How do I prevent the user resizing my window?

The -void gtk_window_set_policy (GtkWindow *window, - gint allow_shrink, - gint allow_grow, - gint auto_shrink); +void gtk_widget_set_usize (GtkWidget *widget, + gint width, + gint height); + +void gtk_window_set_policy (GtkWindow *window, + gint allow_shrink, + gint allow_grow, + gint auto_shrink); + +Shouldn't the text argument in the gtk_clist_* functions be declared const? +

+For example: + +gint gtk_clist_prepend (GtkCList *clist, + gchar *text[]); + + +Answer: No, while a type "gchar*" (pointer to char) can automatically +be cast into "const gchar*" (pointer to const char), this does not +apply for "gchar *[]" (array of an unspecified number of pointers to +char) into "const gchar *[]" (array of an unspecified number of +pointers to const char). + +The type qualifier "const" may be subject to automatic casting, but +in the array case, it is not the array itself that needs the (const) +qualified cast, but its members, thus changing the whole type. + + +Development with GTK+: widget specific questions + + + +How do I find out about the selection of a GtkList? +

+Get the selection something like this: + +GList *sel; +sel = GTK_LIST(list)->selection; + + +This is how GList is defined (quoting glist.h): + +typedef struct _GList GList; + +struct _GList +{ + gpointer data; + GList *next; + GList *prev; +}; + + +A GList structure is just a simple structure for doubly linked lists. +there exist several g_list_*() functions to modify a linked list in +glib.h. However the GTK_LIST(MyGtkList)->selection is maintained +by the gtk_list_*() functions and should not be modified. + +The selection_mode of the GtkList determines the selection +facilities of a GtkList and therefore the contents +of GTK_LIST(AnyGtkList)->selection: + + +selection_mode GTK_LIST()->selection contents +------------------------------------------------------ + +GTK_SELECTION_SINGLE) selection is either NULL + or contains a GList* pointer + for a single selected item. + +GTK_SELECTION_BROWSE) selection is NULL if the list + contains no widgets, otherwise + it contains a GList* pointer + for one GList structure. +GTK_SELECTION_MULTIPLE) selection is NULL if no listitems + are selected or a a GList* pointer + for the first selected item. that + in turn points to a GList structure + for the second selected item and so + on + +GTK_SELECTION_EXTENDED) selection is NULL. + + +The data field of the GList structure GTK_LIST(MyGtkList)->selection points +to the first GtkListItem that is selected. So if you would like to determine +which listitems are selected you should go like this: + +Upon Initialization: + +{ + gchar *list_items[]={ + "Item0", + "Item1", + "foo", + "last Item", + }; + guint nlist_items=sizeof(list_items)/sizeof(list_items[0]); + GtkWidget *list_item; + guint i; + + list=gtk_list_new(); + gtk_list_set_selection_mode(GTK_LIST(list), GTK_SELECTION_MULTIPLE); + gtk_container_add(GTK_CONTAINER(AnyGtkContainer), list); + gtk_widget_show (list); + + for (i = 0; i < nlist_items; i++) + { + list_item=gtk_list_item_new_with_label(list_items[i]); + gtk_object_set_user_data(GTK_OBJECT(list_item), (gpointer)i); + gtk_container_add(GTK_CONTAINER(list), list_item); + gtk_widget_show(list_item); + } +} + + +To get known about the selection: + +{ + GList *items; + + items=GTK_LIST(list)->selection; + + printf("Selected Items: "); + while (items) { + if (GTK_IS_LIST_ITEM(items->data)) + printf("%d ", (guint) + gtk_object_get_user_data(items->data)); + items=items->next; + } + printf("\n"); +} + + +

+I don't want the user of my applications to enter text into a GtkCombo. Any idea? +

+A GtkCombo has an associated entry which can be accessed using the +following expression: + + + GTK_COMBO(combo_widget)->entry + + +If you don't want the user to be able to modify the content of this +entry, you can use the gtk_entry_set_editable() function: + + + void gtk_entry_set_editable(GtkEntry *entry, + gboolean editable); + + +Set the editable parameter to FALSE to disable typing into the entry. + + +How do I catch a combo box change? +

+The entry which is associated to your GtkCombo send a "changed" signal when: + + some text is typed in + the selection of the combo box is changed + + +To catch any combo box change, simply connect your signal handler with + + + gtk_signal_connect(GTK_COMBO(cb)->entry, + "changed", + GTK_SIGNAL_FUNC(my_cb_change_handler), + NULL); + + + +How can I define a separation line in a menu? +

+See the for information on how to create menus. +However, to create a separation line in a menu, just insert an +empty menu item: + + +menuitem = gtk_menu_item_new(); +gtk_menu_append(GTK_MENU(menu), menuitem); +gtk_widget_show(menuitem); + + + +How can I right justify a menu, such as Help? +

+Depending on if you use the MenuFactory or not, there are two ways to proceed. +With the MenuFactory, use something like the following: + + +menu_path = gtk_menu_factory_find (factory, "/Help"); +gtk_menu_item_right_justify(menu_path->widget); + + +If you do not use the MenuFactory, you should simply use: + + +gtk_menu_item_right_justify(my_menu_item); + + + +How do I add some underlined accelerators to menu items? +

+Damon Chaplin, the technical force behind the Glade project, provided the +following code sample (this code is an output from Glade). It creates a +small + menubar1 = gtk_menu_bar_new (); + gtk_object_set_data (GTK_OBJECT (window1), "menubar1", menubar1); + gtk_widget_show (menubar1); + gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); + + file1 = gtk_menu_item_new_with_label (""); + tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (file1)->child), + _("_File")); + gtk_widget_add_accelerator (file1, "activate_item", accel_group, + tmp_key, GDK_MOD1_MASK, 0); + gtk_object_set_data (GTK_OBJECT (window1), "file1", file1); + gtk_widget_show (file1); + gtk_container_add (GTK_CONTAINER (menubar1), file1); + + file1_menu = gtk_menu_new (); + file1_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (file1_menu)); + gtk_object_set_data (GTK_OBJECT (window1), "file1_menu", file1_menu); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (file1), file1_menu); + + new1 = gtk_menu_item_new_with_label (""); + tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (new1)->child), + _("_New")); + gtk_widget_add_accelerator (new1, "activate_item", file1_menu_accels, + tmp_key, 0, 0); + gtk_object_set_data (GTK_OBJECT (window1), "new1", new1); + gtk_widget_show (new1); + gtk_container_add (GTK_CONTAINER (file1_menu), new1); + + + +How do I right (or otherwise) justify a GtkLabel? +

+Are you sure you want to justify the labels? The label class contains +the alignment of the label, ie right +align it, center it or left align it. If you want to do this, you +should use: + + +void gtk_misc_set_alignment (GtkMisc *misc, + gfloat xalign, + gfloat yalign); + + +where the +GtkWidget *label; + +/* horizontal : left align, vertical : top */ +gtk_misc_set_alignment(GTK_MISK(label), 0.0f, 0.0f); + +/* horizontal : centered, vertical : centered */ +gtk_misc_set_alignment(GTK_MISK(label), 0.5f, 0.5f); + +/* horizontal : right align, vertical : bottom */ +gtk_misc_set_alignment(GTK_MISK(label), 1.0f, 1.0f); + + + +How do I set the color and font of a GtkLabel using a Resource File? +

+The widget name path constructed for a Label consists of the widget +names of its object hierarchy as well, e.g. + + +window (name: humphrey) + hbox + label (name: mylabel) + + +The widget path your pattern needs to match would be: + +style "title" +{ + fg[NORMAL] = {1.0, 0.0, 0.0} + font = "-adobe-helvetica-bold-r-normal--*-140-*-*-*-*-*-*" +} +widget "*mylabel" style "title" + + +In your program, you would also need to give a name to the Label +widget, which can be done using: + + label = gtk_label_new("Some Label Text"); + gtk_widget_set_name(label, "mylabel"); + gtk_widget_show(label); + + + +How do I configure Tooltips in a Resource File? +

+The tooltip's window is named "gtk-tooltips", GtkTooltips in itself is not +a GtkWidget (though a GtkObject) and as such is not attempted to match any +widget styles. + +So, you resource file should look something like: + +style "postie" +{ + bg[NORMAL] = {1.0, 1.0, 0.0} +} +widget "gtk-tooltips*" style "postie" + How do I use horizontal scrollbars with a GtkText widget?

The short answer is that you can't. The current version of the GtkText @@ -1538,6 +1703,25 @@ widget does not support horizontal scrolling. There is an intention to completely rewrite the GtkText widget, at which time this limitation will be removed. + +I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong? +

+There is now a known problem in the GtkEntry widget. In the + + /* The algorithms here will work as long as, the text size (a + * multiple of 2), fits into a guint16 but we specify a shorter + * maximum length so that if the user pastes a very long text, there + * is not a long hang from the slow X_LOCALE functions. */ + + if (entry->text_max_length == 0) + max_length = 2047; + else + max_length = MIN (2047, entry->text_max_length); + + How do I change the font of a GtkText widget?

@@ -1623,93 +1807,6 @@ main (int argc, char *argv[]) Now, if you really want to change the cursor position, you should use the -Development with GTK+: misc questions - - -Why do this strange 'x io error' occur when I -This is not really a GTK+ problem, and the problem is not related to - int pid = fork(); - - if(pid==-1) - { - perror("fork"); - exit(-1); - } - else if(pid==0) /* child */ - { - retval=system("a command"); /* can use exec* functions here */ - _exit(retval); /* notice _exit() instead of exit() */ - } - else /* parent */ - { - for(;;) - { - if(waitpid(pid, &status, WNOHANG) == pid) - { - waitpid(pid, &status, WUNTRACED); /* anti zombie code */ - break; - } - } - - return(WEXITSTATUS(status)); - } - - - -I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong? -

-There is now a known problem in the GtkEntry widget. In the - - /* The algorithms here will work as long as, the text size (a - * multiple of 2), fits into a guint16 but we specify a shorter - * maximum length so that if the user pastes a very long text, there - * is not a long hang from the slow X_LOCALE functions. */ - - if (entry->text_max_length == 0) - max_length = 2047; - else - max_length = MIN (2047, entry->text_max_length); - - - -Why don't the contents of a button move when the button is pressed? Here's a patch to make it work that way... -

-From: Peter Mattis - - -The reason buttons don't move their child down and to the right when -they are depressed is because I don't think that's what is happening -visually. My view of buttons is that you are looking at them straight -on. That is, the user interface lies in a plane and you're above it -looking straight at it. When a button gets pressed it moves directly -away from you. To be absolutely correct I guess the child should -actually shrink a tiny amount. But I don't see why the child should -shift down and to the left. Remember, the child is supposed to be -attached to the buttons surface. Its not good for it to appear like -the child is slipping on the surface of the button. -

-On a more practical note, I did implement this at one point and -determined it didn't look good and removed it. - - About gdk