From 9f1363013fe5e3def58a007b6c109be93d4e5702 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 25 Feb 2002 01:47:44 +0000 Subject: [PATCH] More GTK+ 2.0 updates. * docs/tutorial/gtk-tut.sgml, docs/tutorial/images/*, examples/*: More GTK+ 2.0 updates. * docs/tutorial/Makefile.am: build and dist the new tutorial, not the old Linuxdoc one. --- docs/tutorial/Makefile.am | 204 +-- docs/tutorial/gtk-tut.sgml | 1961 ++++++++------------------ docs/tutorial/images/buttons.png | Bin 5269 -> 4063 bytes examples/base/base.c | 2 +- examples/buttons/Makefile | 2 +- examples/buttons/buttons.c | 48 +- examples/gtkdial/dial_test.c | 1 + examples/gtkdial/gtkdial.c | 93 +- examples/list/list.c | 3 - examples/packbox/packbox.c | 12 +- examples/pixmap/pixmap.c | 4 +- examples/radiobuttons/radiobuttons.c | 7 +- examples/spinbutton/spinbutton.c | 1 + examples/text/text.c | 2 - 14 files changed, 740 insertions(+), 1600 deletions(-) diff --git a/docs/tutorial/Makefile.am b/docs/tutorial/Makefile.am index 94826e5efe..3954b4b4d3 100644 --- a/docs/tutorial/Makefile.am +++ b/docs/tutorial/Makefile.am @@ -1,156 +1,68 @@ -TUTORIAL_FR_FILES=html/gtk_tut_fr-1.html \ -html/gtk_tut_fr-2.html \ -html/gtk_tut_fr-3.html \ -html/gtk_tut_fr-4.html \ -html/gtk_tut_fr-5.html \ -html/gtk_tut_fr-6.html \ -html/gtk_tut_fr-7.html \ -html/gtk_tut_fr-8.html \ -html/gtk_tut_fr-9.html \ -html/gtk_tut_fr-10.html \ -html/gtk_tut_fr-11.html \ -html/gtk_tut_fr-12.html \ -html/gtk_tut_fr-13.html \ -html/gtk_tut_fr-14.html \ -html/gtk_tut_fr-15.html \ -html/gtk_tut_fr-16.html \ -html/gtk_tut_fr-17.html \ -html/gtk_tut_fr-18.html \ -html/gtk_tut_fr-19.html \ -html/gtk_tut_fr-20.html \ -html/gtk_tut_fr-21.html \ -html/gtk_tut_fr-22.html \ -html/gtk_tut_fr-23.html \ -html/gtk_tut_fr-24.html \ -html/gtk_tut_fr.html text/gtk_tut_fr.txt - -TUTORIAL_FILES=text/gtk_tut.txt html/gtk_tut.html \ -html/gtk_tut.html \ -html/gtk_tut-1.html \ -html/gtk_tut-2.html \ -html/gtk_tut-3.html \ -html/gtk_tut-4.html \ -html/gtk_tut-5.html \ -html/gtk_tut-6.html \ -html/gtk_tut-7.html \ -html/gtk_tut-8.html \ -html/gtk_tut-9.html \ -html/gtk_tut-10.html \ -html/gtk_tut-11.html \ -html/gtk_tut-12.html \ -html/gtk_tut-13.html \ -html/gtk_tut-14.html \ -html/gtk_tut-15.html \ -html/gtk_tut-16.html \ -html/gtk_tut-17.html \ -html/gtk_tut-18.html \ -html/gtk_tut-19.html \ -html/gtk_tut-20.html \ -html/gtk_tut-21.html \ -html/gtk_tut-22.html \ -html/gtk_tut-23.html \ -html/gtk_tut-24.html \ -html/gtk_tut-25.html \ -html/gtk_tut-26.html \ -html/gtk_tut-27.html \ -html/gtk_tut-28.html \ -html/gtk_tut-29.html \ -html/gtk_tut-30.html \ -html/gtk_tut-31.html - -TUTORIAL_IT_FILES= html/gtk_tut_it.html \ - html/gtk_tut_it-1.html \ - html/gtk_tut_it-2.html \ - html/gtk_tut_it-3.html \ - html/gtk_tut_it-4.html \ - html/gtk_tut_it-5.html \ - html/gtk_tut_it-6.html \ - html/gtk_tut_it-7.html \ - html/gtk_tut_it-8.html \ - html/gtk_tut_it-9.html \ - html/gtk_tut_it-10.html \ - html/gtk_tut_it-11.html \ - html/gtk_tut_it-12.html \ - html/gtk_tut_it-13.html \ - html/gtk_tut_it-14.html \ - html/gtk_tut_it-15.html \ - html/gtk_tut_it-16.html \ - html/gtk_tut_it-17.html \ - html/gtk_tut_it-18.html \ - html/gtk_tut_it-19.html \ - html/gtk_tut_it-20.html \ - html/gtk_tut_it-21.html \ - html/gtk_tut_it-22.html \ - html/gtk_tut_it-23.html \ - html/gtk_tut_it-24.html \ - text/gtk_tut_it.txt - -GTKDOCS_FIX=$(srcdir)/../gtkdocs_fix - -.PHONY: htmldir textdir tutorial tutorial_it tutorial_fr - -htmldir: - (cd $(srcdir); mkdir -p html; cp gtk_tut*gif html) - -textdir: - mkdir -p $(srcdir)/text - -$(TUTORIAL_FILES): tutorial - -$(TUTORIAL_FR_FILES): tutorial_fr - -$(TUTORIAL_IT_FILES): tutorial_it - -tutorial: htmldir textdir - (cd $(srcdir); sgml2html gtk_tut.sgml; \ - perl $(GTKDOCS_FIX) gtk_tut*html; \ - mv gtk_tut*html html/; \ - sgml2txt gtk_tut.sgml; \ - mv gtk_tut.txt text/) - -tutorial_it: htmldir textdir - (cd $(srcdir); sgml2html --language=it gtk_tut_it.sgml; \ - perl $(GTKDOCS_FIX) gtk_tut_it*html; \ - mv gtk_tut_it*html html/; \ - sgml2txt --language=it gtk_tut_it.sgml; \ - mv gtk_tut_it.txt text/) - -tutorial_fr: htmldir textdir - (cd $(srcdir); sgml2html --language=fr gtk_tut_fr.sgml; \ - perl $(GTKDOCS_FIX) gtk_tut_fr*html; \ - mv gtk_tut_fr*html html/; \ - sgml2txt --language=fr gtk_tut_fr.sgml; \ - mv gtk_tut_fr.txt text/) - +.PHONY: html pdf EXTRA_DIST = \ - gtk_tut.sgml \ - gtk_tut_12.es.sgml \ - gtk_tut_it.sgml \ - gtk_tut_fr.sgml \ - gtk_tut_packbox1.gif \ - gtk_tut_packbox1.eps \ - gtk_tut_packbox1.jpg \ - gtk_tut_packbox2.gif \ - gtk_tut_packbox2.eps \ - gtk_tut_packbox2.jpg \ - gtk_tut_table.gif \ - gtk_tut_table.eps \ - gtk_tut_table.jpg \ - package_tutorial.sh \ - package-db-tutorial.sh + gtk-tut.sgml \ + images/arrow.png \ + images/aspectframe.png \ + images/base.png \ + images/buttonbox.png \ + images/buttons.png \ + images/calendar.png \ + images/colorsel.png \ + images/entry.png \ + images/eventbox.png \ + images/filesel.png \ + images/fixed.png \ + images/frame.png \ + images/gtkdial.png \ + images/helloworld.png \ + images/helloworld2.png \ + images/label.png \ + images/menu.png \ + images/notebook.png \ + images/packbox1.png \ + images/packbox2.png \ + images/paned.png \ + images/progressbar.png \ + images/radiobuttons.png \ + images/rangewidgets.png \ + images/rulers.png \ + images/scribble.png \ + images/scrolledwin.png \ + images/spinbutton.png \ + images/statusbar.png \ + images/table.png \ + images/tictactoe.png -if HAVE_SGML2HTML -dist-hook: tutorial tutorial_it tutorial_fr - mkdir $(distdir)/html - cp -p $(srcdir)/html/*.html $(distdir)/html - cp -p $(srcdir)/html/*.gif $(distdir)/html - mkdir $(distdir)/text - cp -p $(srcdir)/text/*.txt $(distdir)/text +if HAVE_DOCBOOK +html: + (cd $(srcdir); \ + db2html gtk-tut.sgml; \ + mv gtk-tut html; \ + mkdir html/images; \ + cp images/*.png html/images) + +pdf: + (cd $(srcdir); db2pdf gtk-tut.sgml) + +dist-hook: html pdf + cp -Rp $(srcdir)/html $(distdir) + cp -p $(srcdir)/gtk-tut.pdf $(distdir) else +html: + echo "***" + echo "*** Warning: Tutorial not built" + echo "***" + +pdf: + echo "***" + echo "*** Warning: Tutorial not built" + echo "***" + dist-hook: echo "***" echo "*** Warning: Tutorial not built" echo "*** DISTRIBUTION IS INCOMPLETE" echo "***" endif + diff --git a/docs/tutorial/gtk-tut.sgml b/docs/tutorial/gtk-tut.sgml index 0261a65e03..7b4a4305a6 100755 --- a/docs/tutorial/gtk-tut.sgml +++ b/docs/tutorial/gtk-tut.sgml @@ -162,7 +162,7 @@ has no way of exiting except to be killed by using the shell. - + @@ -277,7 +277,7 @@ hello world a la GTK. - + @@ -1040,7 +1040,7 @@ topic, packing widgets. - + @@ -1212,7 +1212,7 @@ different styles. - + @@ -1271,7 +1271,7 @@ following figure should make it clearer: - + @@ -1756,7 +1756,7 @@ Which means it should look something like this: - + @@ -2101,8 +2101,6 @@ is the testgtk program that comes with GTK. It can be found i - - The Button Widget @@ -2112,23 +2110,24 @@ is the testgtk program that comes with GTK. It can be found i Normal Buttons We've almost seen all there is to see of the button widget. It's -pretty simple. There are however two ways to create a button. You can -use the gtk_button_new_with_label() to create a button with a label, -or use gtk_button_new() to create a blank button. It's then up to you -to pack a label or pixmap into this new button. To do this, create a -new box, and then pack your objects into this box using the usual -gtk_box_pack_start, and then use gtk_container_add to pack the box -into the button. +pretty simple. There is however more than one way to create a button. You can +use the gtk_button_new_with_label() or gtk_button_new_with_mnemonic() to create +a button with a label, use gtk_button_new_from_stock() to create a button +containing the image and text from a stock item or use gtk_button_new() to +create a blank button. It's then up to you to pack a label or pixmap into +this new button. To do this, create a new box, and then pack your objects into +this box using the usual gtk_box_pack_start(), and then use gtk_container_add() +to pack the box into the button. -Here's an example of using gtk_button_new to create a button with a -picture and a label in it. I've broken up the code to create a box -from the rest so you can use it in your programs. There are further -examples of using pixmaps later in the tutorial. +Here's an example of using gtk_button_new() to create a button with a +image and a label in it. I've broken up the code to create a box from the rest +so you can use it in your programs. There are further examples of using images +later in the tutorial. - + @@ -2142,44 +2141,31 @@ examples of using pixmaps later in the tutorial. /* Create a new hbox with an image and a label packed into it * and return the box. */ -GtkWidget *xpm_label_box( GtkWidget *parent, - gchar *xpm_filename, +GtkWidget *xpm_label_box( gchar *xpm_filename, gchar *label_text ) { - GtkWidget *box1; + GtkWidget *box; GtkWidget *label; - GtkWidget *pixmapwid; - GdkPixmap *pixmap; - GdkBitmap *mask; - GtkStyle *style; + GtkWidget *image; - /* Create box for xpm and label */ - box1 = gtk_hbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (box1), 2); + /* Create box for image and label */ + box = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (box), 2); - /* Get the style of the button to get the - * background color. */ - style = gtk_widget_get_style (parent); - - /* Now on to the xpm stuff */ - pixmap = gdk_pixmap_create_from_xpm (parent->window, &mask, - &style->bg[GTK_STATE_NORMAL], - xpm_filename); - pixmapwid = gtk_image_new_from_file (xpm_filename); + /* Now on to the image stuff */ + image = gtk_image_new_from_file (xpm_filename); /* Create a label for the button */ label = gtk_label_new (label_text); - /* Pack the pixmap and label into the box */ - gtk_box_pack_start (GTK_BOX (box1), - pixmapwid, FALSE, FALSE, 3); + /* Pack the image and label into the box */ + gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3); + gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3); - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 3); - - gtk_widget_show (pixmapwid); + gtk_widget_show (image); gtk_widget_show (label); - return box1; + return box; } /* Our usual callback function */ @@ -2195,7 +2181,7 @@ int main( int argc, /* GtkWidget is the storage type for widgets */ GtkWidget *window; GtkWidget *button; - GtkWidget *box1; + GtkWidget *box; gtk_init (&argc, &argv); @@ -2213,7 +2199,6 @@ int main( int argc, /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_widget_realize (window); /* Create a new button */ button = gtk_button_new (); @@ -2223,12 +2208,12 @@ int main( int argc, G_CALLBACK (callback), (gpointer) "cool button"); /* This calls our box creating function */ - box1 = xpm_label_box(window, "info.xpm", "cool button"); + box = xpm_label_box ("info.xpm", "cool button"); /* Pack and show all our widgets */ - gtk_widget_show (box1); + gtk_widget_show (box); - gtk_container_add (GTK_CONTAINER (button), box1); + gtk_container_add (GTK_CONTAINER (button), box); gtk_widget_show (button); @@ -2244,27 +2229,9 @@ int main( int argc, -The xpm_label_box function could be used to pack xpm's and labels into +The xpm_label_box() function could be used to pack images and labels into any widget that can be a container. -Notice in xpm_label_box how there is a call to -gtk_widget_get_style. Every widget has a "style", consisting of -foreground and background colors for a variety of situations, font -selection, and other graphics data relevant to a widget. These style -values are defaulted in each widget, and are required by many GDK -function calls, such as gdk_pixmap_create_from_xpm, which here is -given the "normal" background color. The style data of widgets may -be customized, using GTK's rc files. - -Also notice the call to gtk_widget_realize after setting the -window's border width. This function uses GDK to create the X -windows related to the widget. The function is automatically called -when you invoke gtk_widget_show for a widget, and so has not been -shown in earlier examples. But the call to -gdk_pixmap_create_from_xpm requires that its window argument -refer to a real X window, so it is necessary to realize the widget -before this GDK call. - The Button widget has the following signals: @@ -2303,16 +2270,19 @@ and check buttons. I will point these out when we come to them. GtkWidget *gtk_toggle_button_new( void ); -GtkWidget *gtk_toggle_button_new_with_label( gchar *label ); +GtkWidget *gtk_toggle_button_new_with_label( const gchar *label ); + +GtkWidget *gtk_toggle_button_new_with_mnemonic( const gchar *label ); As you can imagine, these work identically to the normal button widget -calls. The first creates a blank toggle button, and the second, a -button with a label widget already packed into it. +calls. The first creates a blank toggle button, and the last two, a +button with a label widget already packed into it. The _mnemonic() variant +additionally parses the label for '_'-prefixed mnemonic characters. To retrieve the state of the toggle widget, including radio and check buttons, we use a construct as shown in our example below. This tests -the state of the toggle, by accessing the active field of the +the state of the toggle button, by accessing the active field of the toggle widget's structure, after first using the GTK_TOGGLE_BUTTON macro to cast the widget pointer into a toggle widget pointer. The signal of interest to us emitted by toggle @@ -2324,7 +2294,7 @@ to determine its state. The callback will look something like: void toggle_button_callback (GtkWidget *widget, gpointer data) { - if (GTK_TOGGLE_BUTTON (widget)->active) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { /* If control reaches here, the toggle button is down */ @@ -2340,7 +2310,7 @@ check buttons, use this function: void gtk_toggle_button_set_active( GtkToggleButton *toggle_button, - gint state ); + gboolean is_active ); The above call can be used to set the state of the toggle button, and @@ -2372,16 +2342,18 @@ buttons with text inside them, they are small squares with the text to the right of them. These are often used for toggling options on and off in applications. -The two creation functions are similar to those of the normal button. +The creation functions are similar to those of the normal button. GtkWidget *gtk_check_button_new( void ); -GtkWidget *gtk_check_button_new_with_label ( gchar *label ); +GtkWidget *gtk_check_button_new_with_label ( const gchar *label ); + +GtkWidget *gtk_check_button_new_with_mnemonic ( const gchar *label ); -The new_with_label function creates a check button with a label beside -it. +The gtk_check_button_new_with_label() function creates a check button +with a label beside it. Checking the state of the check button is identical to that of the toggle button. @@ -2402,33 +2374,55 @@ of options. GtkWidget *gtk_radio_button_new( GSList *group ); +GtkWidget *gtk_radio_button_new_from_widget( GtkRadioButton *group ); + GtkWidget *gtk_radio_button_new_with_label( GSList *group, - gchar *label ); + const gchar *label ); + +GtkWidget* gtk_radio_button_new_with_label_from_widget( GtkRadioButton *group, + const gchar *label ); + +GtkWidget *gtk_radio_button_new_with_mnemonic( GSList *group, + const gchar *label ); + +GtkWidget *gtk_radio_button_new_with_mnemonic_from_widget( GtkRadioButton *group, + const gchar *label ); + You'll notice the extra argument to these calls. They require a group -to perform their duty properly. The first call to -gtk_radio_button_new or gtk_radio_button_new_with_label -should pass NULL as the first argument. Then create a group using: +to perform their duty properly. The first call to gtk_radio_button_new() or +gtk_radio_button_new_with_label() should pass NULL as the first argument. +Then create a group using: -GSList *gtk_radio_button_group( GtkRadioButton *radio_button ); +GSList *gtk_radio_button_get_group( GtkRadioButton *radio_button ); -The important thing to remember is that gtk_radio_button_group must be -called for each new button added to the group, with the previous -button passed in as an argument. The result is then passed into the -next call to gtk_radio_button_new or -gtk_radio_button_new_with_label. This allows a chain of buttons to be -established. The example below should make this clear. +The important thing to remember is that gtk_radio_button_get_group() must be +called for each new button added to the group, with the previous button passed +in as an argument. The result is then passed into the next call to +gtk_radio_button_new() or gtk_radio_button_new_with_label(). This allows a +chain of buttons to be established. The example below should make this clear. You can shorten this slightly by using the following syntax, which -removes the need for a variable to hold the list of buttons. This form -is used in the example to create the third button: +removes the need for a variable to hold the list of buttons: button2 = gtk_radio_button_new_with_label( - gtk_radio_button_group (GTK_RADIO_BUTTON (button1)), + gtk_radio_button_get_group (GTK_RADIO_BUTTON (button1)), + "button2"); + + + +The _from_widget() variants of the creation functions allow you to shorten this +further, by omitting the gtk_radio_button_get_group() call. This form is used +in the example to create the third button: + + + + button2 = gtk_radio_button_new_with_label_from_widget( + GTK_RADIO_BUTTON (button1), "button2"); @@ -2437,7 +2431,7 @@ default depressed button with: void gtk_toggle_button_set_active( GtkToggleButton *toggle_button, - gint state ); + gboolean state ); This is described in the section on toggle buttons, and works in @@ -2452,7 +2446,7 @@ the second will emit its "toggled" signal (to report becoming active). - + @@ -2511,9 +2505,8 @@ int main( int argc, gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); - button = gtk_radio_button_new_with_label( - gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)), - "button3"); + button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), + "button3"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); @@ -2543,8 +2536,6 @@ int main( int argc, - - @@ -2599,12 +2590,12 @@ but some cases will be shown in later examples where you may need to create one yourself. You create an adjustment using: -GtkObject *gtk_adjustment_new( gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - gfloat page_size ); +GtkObject *gtk_adjustment_new( gdouble value, + gdouble lower, + gdouble upper, + gdouble step_increment, + gdouble page_increment, + gdouble page_size ); The value argument is the initial value you want to give to the @@ -2651,16 +2642,16 @@ find out, and it may be different from widget to widget). Now, you're probably thinking, since text widgets and viewports insist on setting everything except the value of their adjustments, -while scrollbars will only touch the adjustment's value, if -you share an adjustment object between a scrollbar and a text -widget, manipulating the scrollbar will automagically adjust the text -widget? Of course it will! Just like this: +while scrollbars will only touch the adjustment's +value, if you share an adjustment +object between a scrollbar and a text widget, manipulating the scrollbar will +automagically adjust the viewport widget? Of course it will! Just like this: /* creates its own adjustments */ - text = gtk_text_new (NULL, NULL); + viewport = gtk_viewport_new (NULL, NULL); /* uses the newly-created adjustment for the scrollbar as well */ - vscrollbar = gtk_vscrollbar_new (GTK_TEXT(text)->vadj); + vscrollbar = gtk_vscrollbar_new (gtk_viewport_get_vadjustment (viewport)); @@ -2678,31 +2669,32 @@ answer these questions and more, let's start by taking a look at struct _GtkAdjustment { - GtkData data; + GtkObject parent_instance; - gfloat lower; - gfloat upper; - gfloat value; - gfloat step_increment; - gfloat page_increment; - gfloat page_size; + gdouble lower; + gdouble upper; + gdouble value; + gdouble step_increment; + gdouble page_increment; + gdouble page_size; }; -The first thing you should know is that there aren't any handy-dandy -macros or accessor functions for getting the value out of an -Adjustment, so you'll have to (horror of horrors) do it like a -real C programmer. Don't worry - the GTK_ADJUSTMENT -(Object) macro does run-time type checking (as do all the GTK -type-casting macros, actually). +If you don't like to poke directly at struct internals like a +real C programmer, you can use the following accessor to +inspect the value of an adjustment: -Since, when you set the value of an adjustment, you generally + +gdouble gtk_adjustment_get_value( GtkAdjustment *adjustment); + + +Since, when you set the value of an Adjustment, you generally want the change to be reflected by every widget that uses this adjustment, GTK provides this convenience function to do this: void gtk_adjustment_set_value( GtkAdjustment *adjustment, - gfloat value ); + gdouble value ); As mentioned earlier, Adjustment is a subclass of Object just @@ -2721,22 +2713,22 @@ of this signal in struct _GtkAdjustmentClass: signal on an adjustment whenever they change its value. This happens both when user input causes the slider to move on a range widget, as well as when the program explicitly changes the value with -gtk_adjustment_set_value(). So, for example, if you have a scale +gtk_adjustment_set_value(). So, for example, if you have a scale widget, and you want to change the rotation of a picture whenever its value changes, you would create a callback like this: void cb_rotate_picture (GtkAdjustment *adj, GtkWidget *picture) { - set_picture_rotation (picture, adj->value); + set_picture_rotation (picture, gtk_adjustment_get_value (adj)); ... and connect it to the scale widget's adjustment like this: -gtk_signal_connect (GTK_OBJECT (adj), "value_changed", - GTK_SIGNAL_FUNC (cb_rotate_picture), picture); +g_signal_connect (G_OBJECT (adj), "value_changed", + G_CALLBACK (cb_rotate_picture), picture); What about when a widget reconfigures the upper or lower @@ -2761,7 +2753,7 @@ this signal on it to reconfigure whatever widgets are using it, like this: -gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "changed"); +g_signal_emit_by_name (G_OBJECT (adjustment), "changed"); Now go forth and adjust! @@ -2774,7 +2766,7 @@ gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "changed"); Range Widgets The category of range widgets includes the ubiquitous scrollbar widget -and the less common "scale" widget. Though these two types of widgets +and the less common scale widget. Though these two types of widgets are generally used for different purposes, they are quite similar in function and implementation. All range widgets share a set of common graphic elements, each of which has its own X window and receives @@ -2803,8 +2795,7 @@ widgets, as they are friendlier and more featureful. There are separate types for horizontal and vertical scrollbars. There really isn't much to say about these. You create them with the -following functions, defined in <gtk/gtkhscrollbar.h> -and <gtk/gtkvscrollbar.h>: +following functions: GtkWidget *gtk_hscrollbar_new( GtkAdjustment *adjustment ); @@ -2840,27 +2831,35 @@ takes over the screen. As with scrollbars, there are separate widget types for horizontal and vertical scale widgets. (Most programmers seem to favour horizontal scale widgets.) Since they work essentially the same way, there's no -need to treat them separately here. The following functions, defined -in <gtk/gtkvscale.h> and -<gtk/gtkhscale.h>, create vertical and horizontal scale -widgets, respectively: +need to treat them separately here. The following functions create vertical and +horizontal scale widgets, respectively: GtkWidget *gtk_vscale_new( GtkAdjustment *adjustment ); +GtkWidget *gtk_vscale_new_with_range( gdouble min, + gdouble max, + gdouble step ); + GtkWidget *gtk_hscale_new( GtkAdjustment *adjustment ); + +GtkWidget *gtk_hscale_new_with_range( gdouble min, + gdouble max, + gdouble step ); The adjustment argument can either be an adjustment which has -already been created with gtk_adjustment_new(), or NULL, in +already been created with gtk_adjustment_new(), or NULL, in which case, an anonymous Adjustment is created with all of its -values set to 0.0 (which isn't very useful in this case). In -order to avoid confusing yourself, you probably want to create your -adjustment with a page_size of 0.0 so that its upper -value actually corresponds to the highest value the user can select. -(If you're already thoroughly confused, read the section on Adjustments again for an explanation of -what exactly adjustments do and how to create and manipulate them.) +values set to 0.0 (which isn't very useful in this case). +In order to avoid confusing yourself, you probably want to create your +adjustment with a page_size of 0.0 so +that its upper value actually corresponds to the highest +value the user can select. The _new_with_range() variants take care of creating +a suitable adjustment. (If you're already thoroughly +confused, read the section on Adjustments +again for an explanation of what exactly adjustments do and how to create and +manipulate them.) @@ -2874,14 +2873,14 @@ this with this function: void gtk_scale_set_draw_value( GtkScale *scale, - gint draw_value ); + gboolean draw_value ); As you might have guessed, draw_value is either TRUE or FALSE, with predictable consequences for either one. The value displayed by a scale widget is rounded to one decimal point -by default, as is the value field in its GtkAdjustment. You can +by default, as is the value field in its Adjustment. You can change this with: @@ -2901,9 +2900,8 @@ void gtk_scale_set_value_pos( GtkScale *scale, GtkPositionType pos ); -The argument pos is of type GtkPositionType, which is -defined in <gtk/gtkenums.h>, and can take one of the -following values: +The argument pos is of type GtkPositionType, +which can take one of the following values: GTK_POS_LEFT @@ -2920,7 +2918,8 @@ slider up and down the trough. <gtk/gtkscale.h>. The header files for all GTK widgets are automatically included when you include <gtk/gtk.h>. But you should look over the header files -of all widgets that interest you, +of all widgets that interest you, in order to learn more about their functions +and features. @@ -2948,25 +2947,32 @@ Adjustment. The update policies, defined in <gtk/gtkenums.h> as type enum GtkUpdateType, are: - -GTK_UPDATE_CONTINUOUS - This is the default. The + + +GTK_UPDATE_CONTINUOUS +This is the default. The "value_changed" signal is emitted continuously, i.e., whenever the -slider is moved by even the tiniest amount. +slider is moved by even the tiniest amount. - -GTK_UPDATE_DISCONTINUOUS - The "value_changed" signal is + + +GTK_UPDATE_DISCONTINUOUS +The "value_changed" signal is only emitted once the slider has stopped moving and the user has -released the mouse button. +released the mouse button. - -GTK_UPDATE_DELAYED - The "value_changed" signal is emitted + + +GTK_UPDATE_DELAYED +The "value_changed" signal is emitted when the user releases the mouse button, or if the slider stops moving -for a short period of time. +for a short period of time. - + + The update policy of a range widget can be set by casting it using the -GTK_RANGE (Widget) macro and passing it to this function: +GTK_RANGE(widget) macro and passing it to this function: void gtk_range_set_update_policy( GtkRange *range, @@ -3005,7 +3011,7 @@ when you modify its values directly, you should emit the "changed" signal on it, like this: -gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "changed"); +g_signal_emit_by_name (G_OBJECT (adjustment), "changed"); @@ -3020,57 +3026,25 @@ the same way. Clicking button-1 in the trough will cause its adjustment's page_increment to be added or subtracted from its value, and the slider to be moved accordingly. Clicking mouse button-2 in the trough will jump the slider to the point at which the -button was clicked. Clicking any button on a scrollbar's arrows will -cause its adjustment's value to change step_increment at a time. +button was clicked. Clicking button-3 in the trough of a range or any button on +a scrollbar's arrows will cause its adjustment's value to change by +step_increment at a time. -It may take a little while to get used to, but by default, scrollbars -as well as scale widgets can take the keyboard focus in GTK. If you -think your users will find this too confusing, you can always disable -this by unsetting the GTK_CAN_FOCUS flag on the scrollbar, like -this: +Scrollbars are not focusable, thus have no key bindings. The key bindings +for the other range widgets (which are, of course, only active when the widget +has focus) are do not differentiate between horizontal and +vertical range widgets. - -GTK_WIDGET_UNSET_FLAGS (scrollbar, GTK_CAN_FOCUS); - - -The key bindings (which are, of course, only active when the widget -has focus) are slightly different between horizontal and vertical -range widgets, for obvious reasons. They are also not quite the same -for scale widgets as they are for scrollbars, for somewhat less -obvious reasons (possibly to avoid confusion between the keys for -horizontal and vertical scrollbars in scrolled windows, where both -operate on the same area). - - - -Vertical Range Widgets - -All vertical range widgets can be operated with the up and down arrow -keys, as well as with the Page Up and Page Down keys. The -arrows move the slider up and down by step_increment, while -Page Up and Page Down move it by page_increment. +All range widgets can be operated with the left, right, up and down arrow +keys, as well as with the Page Up and Page Down +keys. The arrows move the slider up and down by step_increment, while +Page Up and Page Down move it by +page_increment. The user can also move the slider all the way to one end or the other -of the trough using the keyboard. With the VScale widget, this is -done with the Home and End keys, whereas with the -VScrollbar widget, this is done by typing Control-Page Up -and Control-Page Down. +of the trough using the keyboard. This is done with the Home +and End keys. - - - - -Horizontal Range Widgets - -The left and right arrow keys work as you might expect in these -widgets, moving the slider back and forth by step_increment. The -Home and End keys move the slider to the ends of the trough. -For the HScale widget, moving the slider by page_increment is -accomplished with Control-Left and Control-Right, -while for HScrollbar, it's done with Control-Home and -Control-End. - - @@ -3078,7 +3052,7 @@ while for HScrollbar, it's done with Control-Home and Example This example is a somewhat modified version of the "range controls" -test from testgtk.c. It basically puts up a window with three +test from testgtk.c. It basically puts up a window with three range widgets all connected to the same adjustment, and a couple of controls for adjusting some of the parameters mentioned above and in the section on adjustments, so you can see how they affect the way @@ -3087,7 +3061,7 @@ these widgets work for the user. - + @@ -3389,7 +3363,7 @@ int main( int argc, -You will notice that the program does not call gtk_signal_connect +You will notice that the program does not call g_signal_connect() for the "delete_event", but only for the "destroy" signal. This will still perform the desired function, because an unhandled "delete_event" will result in a "destroy" signal being given to the @@ -3414,7 +3388,9 @@ EventBox widget or a Button widget. To create a new label, use: -GtkWidget *gtk_label_new( char *str ); +GtkWidget *gtk_label_new( const char *str ); + +GtkWidget *gtk_label_new_with_mnemonic( const char *str ); The sole argument is the string you wish the label to display. @@ -3422,8 +3398,8 @@ GtkWidget *gtk_label_new( char *str ); To change the label's text after creation, use the function: -void gtk_label_set_text( GtkLabel *label, - char *str ); +void gtk_label_set_text( GtkLabel *label, + const char *str ); The first argument is the label you created previously (cast @@ -3436,13 +3412,10 @@ the label string. To retrieve the current string, use: -void gtk_label_get( GtkLabel *label, - char **str ); +const gchar* gtk_label_get_text( GtkLabel *label ); -The first argument is the label you've created, and the second, -the return for the string. Do not free the return string, as it is -used internally by GTK. +Do not free the returned string, as it is used internally by GTK. The label text can be justified using: @@ -3483,14 +3456,24 @@ indicates that the corresponding character in the label should be underlined. For example, the string "__ __" would underline the first two characters and eight and ninth characters. +If you simply want to have an underlined accelerator ("mnemonic") +in your label, you should use gtk_label_new_with_mnemonic() or +gtk_label_set_text_with_mnemonic(), not gtk_label_set_pattern(). + + Below is a short example to illustrate these functions. This example makes use of the Frame widget to better demonstrate the label -styles. You can ignore this for now as the Frame widget is explained later on. +styles. You can ignore this for now as the Frame +widget is explained later on. + +In GTK+ 2.0, label texts can contain markup for font and other text attribute +changes, and labels may be selectable (for copy-and-paste). These advanced features +won't be explained here. - + @@ -3649,7 +3632,7 @@ point. The shadow_type argument may take one of these values: - + @@ -3740,7 +3723,7 @@ int main( int argc, These are the little text strings that pop up when you leave your pointer over a button or other widget for a few seconds. They are easy to use, so I will just explain them without giving an example. If you -want to see some code, take a look at the testgtk.c program +want to see some code, take a look at the testgtk.c program distributed with GTK. Widgets that do not receive events (widgets that do not have their @@ -3803,23 +3786,6 @@ void gtk_tooltips_disable( GtkTooltips *tooltips ); Disable an enabled set of tooltips. - -void gtk_tooltips_set_delay( GtkTooltips *tooltips, - gint delay ); - - -Sets how many milliseconds you have to hold your pointer over the -widget before the tooltip will pop up. The default is 500 -milliseconds (half a second). - - -void gtk_tooltips_set_colors( GtkTooltips *tooltips, - GdkColor *background, - GdkColor *foreground ); - - -Set the foreground and background color of the tooltips. - And that's all the functions associated with tooltips. More than you'll ever want to know :-) @@ -3833,32 +3799,15 @@ you'll ever want to know :-) pretty easy to use, as you will see with the code below. But first lets start out with the calls to create a new progress bar. -There are two ways to create a progress bar, one simple that takes -no arguments, and one that takes an Adjustment object as an -argument. If the former is used, the progress bar creates its own -adjustment object. - GtkWidget *gtk_progress_bar_new( void ); - -GtkWidget *gtk_progress_bar_new_with_adjustment( GtkAdjustment *adjustment ); - - -The second method has the advantage that we can use the adjustment -object to specify our own range parameters for the progress bar. - -The adjustment of a progress object can be changed dynamically using: - - -void gtk_progress_set_adjustment( GtkProgress *progress, - GtkAdjustment *adjustment ); Now that the progress bar has been created we can use it. -void gtk_progress_bar_update( GtkProgressBar *pbar, - gfloat percentage ); +void gtk_progress_bar_set_fraction ( GtkProgressBar *pbar, + gdouble fraction ); The first argument is the progress bar you wish to operate on, and the @@ -3888,155 +3837,51 @@ values to indicate the direction in which the progress bar moves: GTK_PROGRESS_TOP_TO_BOTTOM -When used as a measure of how far a process has progressed, the -ProgressBar can be set to display its value in either a continuous -or discrete mode. In continuous mode, the progress bar is updated for -each value. In discrete mode, the progress bar is updated in a number -of discrete blocks. The number of blocks is also configurable. - -The style of a progress bar can be set using the following function. - - -void gtk_progress_bar_set_bar_style( GtkProgressBar *pbar, - GtkProgressBarStyle style ); - - -The style parameter can take one of two values: - - - GTK_PROGRESS_CONTINUOUS - GTK_PROGRESS_DISCRETE - - -The number of discrete blocks can be set by calling - - -void gtk_progress_bar_set_discrete_blocks( GtkProgressBar *pbar, - guint blocks ); - - As well as indicating the amount of progress that has occured, the -progress bar may be set to just indicate that there is some -activity. This can be useful in situations where progress cannot be -measured against a value range. Activity mode is not effected by the -bar style that is described above, and overrides it. This mode is -either TRUE or FALSE, and is selected by the following function. +progress bar may be set to just indicate that there is some activity. +This can be useful in situations where progress cannot be measured against +a value range. To following function indicates that some progress has been +made. -void gtk_progress_set_activity_mode( GtkProgress *progress, - guint activity_mode ); +void gtk_progress_bar_pulse ( GtkProgressBar *progress ); -The step size of the activity indicator, and the number of blocks are -set using the following functions. +The step size of the activity indicator is set using the following +function. -void gtk_progress_bar_set_activity_step( GtkProgressBar *pbar, - guint step ); - -void gtk_progress_bar_set_activity_blocks( GtkProgressBar *pbar, - guint blocks ); +void gtk_progress_bar_set_pulse_step( GtkProgressBar *pbar, + gdouble fraction ); -When in continuous mode, the progress bar can also display a +When not in activity mode, the progress bar can also display a configurable text string within its trough, using the following function. -void gtk_progress_set_format_string( GtkProgress *progress, - gchar *format); +void gtk_progress_bar_set_text( GtkProgressBar *progress, + const gchar *text ); -The format argument is similiar to one that would be used in a C -printf statement. The following directives may be used within the -format string: +Note that gtk_progress_set_text() doesn't support the printf()-like formatting +of the GTK+ 1.2 Progressbar. - - %p - percentage - - %v - value - - %l - lower range value - - %u - upper range value - - +You can turn off the display of the string by calling gtk_progess_bar_set_text() +again with NULL as second argument. -The displaying of this text string can be toggled using: +The current text setting of a progressbar can be retrieved with the +following function. Do not free the returned string. -void gtk_progress_set_show_text( GtkProgress *progress, - gint show_text ); +const gchar *gtk_progress_bar_get_text( GtkProgressBar *pbar ); -The show_text argument is a boolean TRUE/FALSE value. The -appearance of the text can be modified further using: - - -void gtk_progress_set_text_alignment( GtkProgress *progress, - gfloat x_align, - gfloat y_align ); - - -The x_align and y_align arguments take values between 0.0 -and 1.0. Their values indicate the position of the text string within -the trough. Values of 0.0 for both would place the string in the top -left hand corner; values of 0.5 (the default) centres the text, and -values of 1.0 places the text in the lower right hand corner. - -The current text setting of a progress object can be retrieved using -the current or a specified adjustment value using the following two -functions. The character string returned by these functions should be -freed by the application (using the g_free() function). These -functions return the formatted string that would be displayed within -the trough. - - -gchar *gtk_progress_get_current_text( GtkProgress *progress ); - -gchar *gtk_progress_get_text_from_value( GtkProgress *progress, - gfloat value ); - - -There is yet another way to change the range and value of a progress -object using the following function: - - -void gtk_progress_configure( GtkProgress *progress, - gfloat value, - gfloat min, - gfloat max ); - - -This function provides quite a simple interface to the range and value -of a progress object. - -The remaining functions can be used to get and set the current value -of a progess object in various types and formats: - - -void gtk_progress_set_percentage( GtkProgress *progress, - gfloat percentage ); - -void gtk_progress_set_value( GtkProgress *progress, - gfloat value ); - -gfloat gtk_progress_get_value( GtkProgress *progress ); - -gfloat gtk_progress_get_current_percentage( GtkProgress *progress ); - -gfloat gtk_progress_get_percentage_from_value( GtkProgress *progress, - gfloat value ); - - -These functions are pretty self explanatory. The last function uses -the the adjustment of the specified progess object to compute the -percentage value of the given range value. - Progress Bars are usually used with timeouts or other such functions -(see section on Timeouts, I/O and Idle Functions) to give -the illusion of multitasking. All will employ the -gtk_progress_bar_update function in the same manner. +(see section on Timeouts, I/O and Idle Functions) +to give the illusion of multitasking. All will employ the +gtk_progress_bar_set_fraction() or gtk_progress_bar_pulse() functions in the +same manner. Here is an example of the progress bar, updated using timeouts. This code also shows you how to reset the Progress Bar. @@ -4044,7 +3889,7 @@ code also shows you how to reset the Progress Bar. - + @@ -4275,22 +4120,20 @@ top, which contains a separator and then an hbox called the "action_area". The Dialog widget can be used for pop-up messages to the user, and -other similar tasks. It is really basic, and there is only one -function for the dialog box, which is: +other similar tasks. There are two functions to create a new Dialog. GtkWidget *gtk_dialog_new( void ); + +GtkWidget *gtk_dialog_new_with_buttons( const gchar *title, + GtkWindow *parent, + GtkDialogFlags flags, + const gchar *first_button_text, + ... ); -So to create a new dialog box, use, - - - GtkWidget *window; - window = gtk_dialog_new (); - - -This will create the dialog box, and it is now up to you to use it. -You could pack a button in the action_area by doing something like this: +The first function will create an empty dialog, and it is now up to you to use + it. You could pack a button in the action_area by doing something like this: button = ... @@ -4321,462 +4164,26 @@ your application, then you can simply pack another layout widget into the boxes provided. For example, you could pack a table into the vertical box. - - - - -Pixmaps - -Pixmaps are data structures that contain pictures. These pictures can -be used in various places, but most commonly as icons on the X -desktop, or as cursors. - -A pixmap which only has 2 colors is called a bitmap, and there are a -few additional routines for handling this common special case. - -To understand pixmaps, it would help to understand how X window -system works. Under X, applications do not need to be running on the -same computer that is interacting with the user. Instead, the various -applications, called "clients", all communicate with a program which -displays the graphics and handles the keyboard and mouse. This -program which interacts directly with the user is called a "display -server" or "X server." Since the communication might take place over -a network, it's important to keep some information with the X server. -Pixmaps, for example, are stored in the memory of the X server. This -means that once pixmap values are set, they don't need to keep getting -transmitted over the network; instead a command is sent to "display -pixmap number XYZ here." Even if you aren't using X with GTK -currently, using constructs such as Pixmaps will make your programs -work acceptably under X. - -To use pixmaps in GTK, we must first build a GdkPixmap structure using -routines from the GDK layer. Pixmaps can either be created from -in-memory data, or from data read from a file. We'll go through each -of the calls to create a pixmap. - - -GdkPixmap *gdk_bitmap_create_from_data( GdkWindow *window, - gchar *data, - gint width, - gint height ); - - -This routine is used to create a single-plane pixmap (2 colors) from -data in memory. Each bit of the data represents whether that pixel is -off or on. Width and height are in pixels. The GdkWindow pointer is to -the current window, since a pixmap's resources are meaningful only in -the context of the screen where it is to be displayed. - - -GdkPixmap *gdk_pixmap_create_from_data( GdkWindow *window, - gchar *data, - gint width, - gint height, - gint depth, - GdkColor *fg, - GdkColor *bg ); - - -This is used to create a pixmap of the given depth (number of colors) from -the bitmap data specified. fg and bg are the foreground and -background color to use. - - -GdkPixmap *gdk_pixmap_create_from_xpm( GdkWindow *window, - GdkBitmap **mask, - GdkColor *transparent_color, - const gchar *filename ); - - -XPM format is a readable pixmap representation for the X Window -System. It is widely used and many different utilities are available -for creating image files in this format. The file specified by -filename must contain an image in that format and it is loaded into -the pixmap structure. The mask specifies which bits of the pixmap are -opaque. All other bits are colored using the color specified by -transparent_color. An example using this follows below. - - -GdkPixmap *gdk_pixmap_create_from_xpm_d( GdkWindow *window, - GdkBitmap **mask, - GdkColor *transparent_color, - gchar **data ); - - -Small images can be incorporated into a program as data in the XPM -format. A pixmap is created using this data, instead of reading it -from a file. An example of such data is - - -/* XPM */ -static const char * xpm_data[] = { -"16 16 3 1", -" c None", -". c #000000000000", -"X c #FFFFFFFFFFFF", -" ", -" ...... ", -" .XXX.X. ", -" .XXX.XX. ", -" .XXX.XXX. ", -" .XXX..... ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" ......... ", -" ", -" "}; - - -When we're done using a pixmap and not likely to reuse it again soon, -it is a good idea to release the resource using -gdk_pixmap_unref(). Pixmaps should be considered a precious resource, -because they take up memory in the end-user's X server process. Even -though the X client you write may run on a powerful "server" computer, -the user may be running the X server on a small personal computer. - -Once we've created a pixmap, we can display it as a GTK widget. We -must create a GTK pixmap widget to contain the GDK pixmap. This is -done using - - -GtkWidget *gtk_pixmap_new( GdkPixmap *pixmap, - GdkBitmap *mask ); - - -The other pixmap widget calls are - - -guint gtk_pixmap_get_type( void ); - -void gtk_pixmap_set( GtkPixmap *pixmap, - GdkPixmap *val, - GdkBitmap *mask ); - -void gtk_pixmap_get( GtkPixmap *pixmap, - GdkPixmap **val, - GdkBitmap **mask); - - -gtk_pixmap_set is used to change the pixmap that the widget is currently -managing. Val is the pixmap created using GDK. - -The following is an example of using a pixmap in a button. - - - - -#include <gtk/gtk.h> - - -/* XPM data of Open-File icon */ -static const char * xpm_data[] = { -"16 16 3 1", -" c None", -". c #000000000000", -"X c #FFFFFFFFFFFF", -" ", -" ...... ", -" .XXX.X. ", -" .XXX.XX. ", -" .XXX.XXX. ", -" .XXX..... ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" .XXXXXXX. ", -" ......... ", -" ", -" "}; - - -/* when invoked (via signal delete_event), terminates the application. - */ -gint close_application( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit (); - return FALSE; -} - - -/* is invoked when the button is clicked. It just prints a message. - */ -void button_clicked( GtkWidget *widget, - gpointer data ) { - g_print ("button clicked\n"); -} - -int main( int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window, *pixmapwid, *button; - GdkPixmap *pixmap; - GdkBitmap *mask; - GtkStyle *style; - - /* create the main window, and attach delete_event signal to terminating - the application */ - gtk_init (&argc, &argv); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (close_application), NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_widget_show (window); - - /* now for the pixmap from gdk */ - style = gtk_widget_get_style (window); - pixmap = gdk_pixmap_create_from_xpm_d (window->window, &mask, - &style->bg[GTK_STATE_NORMAL], - (gchar **)xpm_data); - - /* a pixmap widget to contain the pixmap */ - pixmapwid = gtk_pixmap_new (pixmap, mask); - gtk_widget_show (pixmapwid); - - /* a button to contain the pixmap widget */ - button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (button), pixmapwid); - gtk_container_add (GTK_CONTAINER (window), button); - gtk_widget_show (button); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (button_clicked), NULL); - - /* show the window */ - gtk_main (); - - return 0; -} - - - -To load a file from an XPM data file called icon0.xpm in the current -directory, we would have created the pixmap thus - - - /* load a pixmap from a file */ - pixmap = gdk_pixmap_create_from_xpm( window->window, &mask, - &style->bg[GTK_STATE_NORMAL], - "./icon0.xpm" ); - pixmapwid = gtk_pixmap_new( pixmap, mask ); - gtk_widget_show( pixmapwid ); - gtk_container_add( GTK_CONTAINER(window), pixmapwid ); - - -A disadvantage of using pixmaps is that the displayed object is always -rectangular, regardless of the image. We would like to create desktops -and applications with icons that have more natural shapes. For -example, for a game interface, we would like to have round buttons to -push. The way to do this is using shaped windows. - -A shaped window is simply a pixmap where the background pixels are -transparent. This way, when the background image is multi-colored, we -don't overwrite it with a rectangular, non-matching border around our -icon. The following example displays a full wheelbarrow image on the -desktop. - - - - -#include <gtk/gtk.h> - -/* XPM */ -static char * WheelbarrowFull_xpm[] = { -"48 48 64 1", -" c None", -". c #DF7DCF3CC71B", -"X c #965875D669A6", -"o c #71C671C671C6", -"O c #A699A289A699", -"+ c #965892489658", -"@ c #8E38410330C2", -"# c #D75C7DF769A6", -"$ c #F7DECF3CC71B", -"% c #96588A288E38", -"& c #A69992489E79", -"* c #8E3886178E38", -"= c #104008200820", -"- c #596510401040", -"; c #C71B30C230C2", -": c #C71B9A699658", -"> c #618561856185", -", c #20811C712081", -"< c #104000000000", -"1 c #861720812081", -"2 c #DF7D4D344103", -"3 c #79E769A671C6", -"4 c #861782078617", -"5 c #41033CF34103", -"6 c #000000000000", -"7 c #49241C711040", -"8 c #492445144924", -"9 c #082008200820", -"0 c #69A618611861", -"q c #B6DA71C65144", -"w c #410330C238E3", -"e c #CF3CBAEAB6DA", -"r c #71C6451430C2", -"t c #EFBEDB6CD75C", -"y c #28A208200820", -"u c #186110401040", -"i c #596528A21861", -"p c #71C661855965", -"a c #A69996589658", -"s c #30C228A230C2", -"d c #BEFBA289AEBA", -"f c #596545145144", -"g c #30C230C230C2", -"h c #8E3882078617", -"j c #208118612081", -"k c #38E30C300820", -"l c #30C2208128A2", -"z c #38E328A238E3", -"x c #514438E34924", -"c c #618555555965", -"v c #30C2208130C2", -"b c #38E328A230C2", -"n c #28A228A228A2", -"m c #41032CB228A2", -"M c #104010401040", -"N c #492438E34103", -"B c #28A2208128A2", -"V c #A699596538E3", -"C c #30C21C711040", -"Z c #30C218611040", -"A c #965865955965", -"S c #618534D32081", -"D c #38E31C711040", -"F c #082000000820", -" ", -" .XoO ", -" +@#$%o& ", -" *=-;#::o+ ", -" >,<12#:34 ", -" 45671#:X3 ", -" +89<02qwo ", -"e* >,67;ro ", -"ty> 459@>+&& ", -"$2u+ ><ipas8* ", -"%$;=* *3:.Xa.dfg> ", -"Oh$;ya *3d.a8j,Xe.d3g8+ ", -" Oh$;ka *3d$a8lz,,xxc:.e3g54 ", -" Oh$;kO *pd$%svbzz,sxxxxfX..&wn> ", -" Oh$@mO *3dthwlsslszjzxxxxxxx3:td8M4 ", -" Oh$@g& *3d$XNlvvvlllm,mNwxxxxxxxfa.:,B* ", -" Oh$@,Od.czlllllzlmmqV@V#V@fxxxxxxxf:%j5& ", -" Oh$1hd5lllslllCCZrV#r#:#2AxxxxxxxxxcdwM* ", -" OXq6c.%8vvvllZZiqqApA:mq:Xxcpcxxxxxfdc9* ", -" 2r<6gde3bllZZrVi7S@SV77A::qApxxxxxxfdcM ", -" :,q-6MN.dfmZZrrSS:#riirDSAX@Af5xxxxxfevo", -" +A26jguXtAZZZC7iDiCCrVVii7Cmmmxxxxxx%3g", -" *#16jszN..3DZZZZrCVSA2rZrV7Dmmwxxxx&en", -" p2yFvzssXe:fCZZCiiD7iiZDiDSSZwwxx8e*>", -" OA1<jzxwwc:$d%NDZZZZCCCZCCZZCmxxfd.B ", -" 3206Bwxxszx%et.eaAp77m77mmmf3&eeeg* ", -" @26MvzxNzvlbwfpdettttttttttt.c,n& ", -" *;16=lsNwwNwgsvslbwwvccc3pcfu<o ", -" p;<69BvwwsszslllbBlllllllu<5+ ", -" OS0y6FBlvvvzvzss,u=Blllj=54 ", -" c1-699Blvlllllu7k96MMMg4 ", -" *10y8n6FjvllllB<166668 ", -" S-kg+>666<M<996-y6n<8* ", -" p71=4 m69996kD8Z-66698&& ", -" &i0ycm6n4 ogk17,0<6666g ", -" N-k-<> >=01-kuu666> ", -" ,6ky& &46-10ul,66, ", -" Ou0<> o66y<ulw<66& ", -" *kk5 >66By7=xu664 ", -" <<M4 466lj<Mxu66o ", -" *>> +66uv,zN666* ", -" 566,xxj669 ", -" 4666FF666> ", -" >966666M ", -" oM6668+ ", -" *4 ", -" ", -" "}; - - -/* When invoked (via signal delete_event), terminates the application */ -gint close_application( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit(); - return(FALSE); -} - -int main (int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window, *pixmap, *fixed; - GdkPixmap *gdk_pixmap; - GdkBitmap *mask; - GtkStyle *style; - GdkGC *gc; - - /* Create the main window, and attach delete_event signal to terminate - * the application. Note that the main window will not have a titlebar - * since we're making it a popup. */ - gtk_init (&argc, &argv); - window = gtk_window_new (GTK_WINDOW_POPUP); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (close_application), NULL); - gtk_widget_show (window); - - /* Now for the pixmap and the pixmap widget */ - style = gtk_widget_get_default_style(); - gc = style->black_gc; - gdk_pixmap = gdk_pixmap_create_from_xpm_d (window->window, &mask, - &style->bg[GTK_STATE_NORMAL], - WheelbarrowFull_xpm); - pixmap = gtk_image_new_from_pixmap (gdk_pixmap, mask); - gtk_widget_show (pixmap); - - /* To display the pixmap, we use a fixed widget to place the pixmap */ - fixed = gtk_fixed_new (); - gtk_widget_set_size_request (fixed, 200, 200); - gtk_fixed_put (GTK_FIXED (fixed), pixmap, 0, 0); - gtk_container_add (GTK_CONTAINER (window), fixed); - gtk_widget_show (fixed); - - /* This masks out everything except for the image itself */ - gtk_widget_shape_combine_mask (window, mask, 0, 0); - - /* show the window */ - gtk_widget_show (window); - gtk_main (); - - return 0; -} - - - -To make the wheelbarrow image sensitive, we could attach the button -press event signal to make it do something. The following few lines -would make the picture sensitive to a mouse button being pressed which -makes the application terminate. - - - gtk_widget_set_events( window, - gtk_widget_get_events( window ) | - GDK_BUTTON_PRESS_MASK ); - - gtk_signal_connect( GTK_OBJECT(window), "button_press_event", - GTK_SIGNAL_FUNC(close_application), NULL ); - +The more complicated _new_with_buttons() variant allows to set one or +more of the following flags. + + +GTK_DIALOG_MODAL +make the dialog modal. + + + +GTK_DIALOG_DESTROY_WITH_PARENTS +ensures that the dialog window is destroyed together with the specified +parent. + + +GTK_DIALOG_NO_SEPARATOR +omits the separator between the vbox and the action_area. + + + @@ -4819,10 +4226,10 @@ are set for a ruler using void gtk_ruler_set_range( GtkRuler *ruler, - gfloat lower, - gfloat upper, - gfloat position, - gfloat max_size ); + gdouble lower, + gdouble upper, + gdouble position, + gdouble max_size ); The lower and upper arguments define the extent of the ruler, and @@ -4853,9 +4260,9 @@ To follow all mouse movements within a window area, we would use #define EVENT_METHOD(i, x) GTK_WIDGET_GET_CLASS(i)->x - gtk_signal_connect_object( GTK_OBJECT(area), "motion_notify_event", - (GtkSignalFunc)EVENT_METHOD(ruler, motion_notify_event), - GTK_OBJECT(ruler) ); + g_signal_connect_swapped (G_OBJECT (area), "motion_notify_event", + G_CALLBACK (EVENT_METHOD (ruler, motion_notify_event)), + G_OBJECT (ruler)); The following example creates a drawing area with a horizontal ruler @@ -4868,7 +4275,7 @@ Placement of the drawing area and the rulers is done using a table. - + @@ -4989,7 +4396,7 @@ guint gtk_statusbar_get_context_id( GtkStatusbar *statusbar, guint gtk_statusbar_push( GtkStatusbar *statusbar, guint context_id, - gchar *text ); + const gchar *text ); void gtk_statusbar_pop( GtkStatusbar *statusbar) guint context_id ); @@ -4999,14 +4406,26 @@ void gtk_statusbar_remove( GtkStatusbar *statusbar, guint message_id ); -The first, gtk_statusbar_push, is used to add a new message to the +The first, gtk_statusbar_push(), is used to add a new message to the statusbar. It returns a Message Identifier, which can be passed later to the function gtk_statusbar_remove to remove the message with the given Message and Context Identifiers from the statusbar's stack. -The function gtk_statusbar_pop removes the message highest in the +The function gtk_statusbar_pop() removes the message highest in the stack with the given Context Identifier. +In addition to messages, statusbars may also display a resize grip, which +can be dragged with the mouse to resize the toplevel window containing the statusbar, +similar to dragging the window frame. The following functions control the display +of the resize grip. + + +void gtk_statusbar_set_has_resize_grip( GtkStatusbar *statusbar, + gboolean setting ); + +gboolean gtk_statusbar_get_has_resize_grip( GtkStatusbar *statusbar ); + + The following example creates a statusbar and two buttons, one for pushing items onto the statusbar, and one for popping the last item back off. @@ -5014,7 +4433,7 @@ back off. - + @@ -5110,59 +4529,42 @@ int main( int argc, text box. The text may be set with function calls that allow new text to replace, prepend or append the current contents of the Entry widget. -There are two functions for creating Entry widgets: +Create a new Entry widget with the following function. GtkWidget *gtk_entry_new( void ); - -GtkWidget *gtk_entry_new_with_max_length( guint16 max ); -The first just creates a new Entry widget, whilst the second creates a -new Entry and sets a limit on the length of the text within the Entry. - -There are several functions for altering the text which is currently +The next function alters the text which is currently within the Entry widget. void gtk_entry_set_text( GtkEntry *entry, const gchar *text ); - -void gtk_entry_append_text( GtkEntry *entry, - const gchar *text ); - -void gtk_entry_prepend_text( GtkEntry *entry, - const gchar *text ); -The function gtk_entry_set_text sets the contents of the Entry widget, -replacing the current contents. The functions gtk_entry_append_text -and gtk_entry_prepend_text allow the current contents to be appended -and prepended to. - -The next function allows the current insertion point to be set. - - -void gtk_entry_set_position( GtkEntry *entry, - gint position ); - +The function gtk_entry_set_text() sets the contents of the Entry widget, +replacing the current contents. Note that the class Entry implements the Editable +interface (yes, gobject supports Java-like interfaces) which contains some more +functions for manipulating the contents. + The contents of the Entry can be retrieved by using a call to the following function. This is useful in the callback functions described below. -gchar *gtk_entry_get_text( GtkEntry *entry ); +const gchar *gtk_entry_get_text( GtkEntry *entry ); The value returned by this function is used internally, and must not -be freed using either free() or g_free() +be freed using either free() or g_free(). If we don't want the contents of the Entry to be changed by someone typing into it, we can change its editable state. -void gtk_entry_set_editable( GtkEntry *entry, - gboolean editable ); +void gtk_editable_set_editable( GtkEditable *entry, + gboolean editable ); The function above allows us to toggle the editable state of the @@ -5183,9 +4585,9 @@ function. This would most often be used after setting some default text in an Entry, making it easy for the user to remove it. -void gtk_entry_select_region( GtkEntry *entry, - gint start, - gint end ); +void gtk_editable_select_region( GtkEditable *entry, + gint start, + gint end ); If we want to catch when the user has entered text, we can connect to @@ -5199,7 +4601,7 @@ removed. - + @@ -5336,12 +4738,12 @@ button can take. This makes for a powerful Spin Button widget. function, which illustrates the information that it holds: -GtkObject *gtk_adjustment_new( gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - gfloat page_size ); +GtkObject *gtk_adjustment_new( gdouble value, + gdouble lower, + gdouble upper, + gdouble step_increment, + gdouble page_increment, + gdouble page_size ); These attributes of an Adjustment are used by the Spin Button in the @@ -5370,7 +4772,7 @@ buttons. Lets look at how to create a Spin Button: GtkWidget *gtk_spin_button_new( GtkAdjustment *adjustment, - gfloat climb_rate, + gdouble climb_rate, guint digits ); @@ -5385,7 +4787,7 @@ function: void gtk_spin_button_configure( GtkSpinButton *spin_button, GtkAdjustment *adjustment, - gfloat climb_rate, + gdouble climb_rate, guint digits ); @@ -5414,25 +4816,25 @@ using the following function: void gtk_spin_button_set_value( GtkSpinButton *spin_button, - gfloat value ); + gdouble value ); The current value of a Spin Button can be retrieved as either a floating point or integer value with the following functions: -gfloat gtk_spin_button_get_value_as_float( GtkSpinButton *spin_button ); +gdouble gtk_spin_button_get_value ( GtkSpinButton *spin_button ); gint gtk_spin_button_get_value_as_int( GtkSpinButton *spin_button ); -If you want to alter the value of a Spin Value relative to its current +If you want to alter the value of a Spin Button relative to its current value, then the following function can be used: void gtk_spin_button_spin( GtkSpinButton *spin_button, GtkSpinType direction, - gfloat increment ); + gdouble increment ); The direction parameter can take one of the following values: @@ -5508,8 +4910,6 @@ void gtk_spin_button_set_update_policy( GtkSpinButton *spin_button, GtkSpinButtonUpdatePolicy policy ); - - The possible values of policy are either GTK_UPDATE_ALWAYS or GTK_UPDATE_IF_VALID. @@ -5525,23 +4925,6 @@ current value. In case of GTK_UPDATE_ALWAYS we ignore errors while converting text into a numeric value. -The appearance of the buttons used in a Spin Button can be changed -using the following function: - - -void gtk_spin_button_set_shadow_type( GtkSpinButton *spin_button, - GtkShadowType shadow_type ); - - -As usual, the shadow_type can be one of: - - - GTK_SHADOW_IN - GTK_SHADOW_OUT - GTK_SHADOW_ETCHED_IN - GTK_SHADOW_ETCHED_OUT - - Finally, you can explicitly request that a Spin Button update itself: @@ -5553,7 +4936,7 @@ void gtk_spin_button_update( GtkSpinButton *spin_button ); - + @@ -5822,7 +5205,7 @@ GtkWidget *gtk_combo_new( void ); box, this is done by manipulating the entry widget directly: - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), "My String."); + gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combo)->entry), "My String."); To set the values in the popdown list, one uses the function: @@ -5834,7 +5217,7 @@ void gtk_combo_set_popdown_strings( GtkCombo *combo, Before you can do this, you have to assemble a GList of the strings that you want. GList is a linked list implementation that is part of -GLib, a library supporing GTK. For the +GLib, a library supporting GTK. For the moment, the quick and dirty explanation is that you need to set up a GList pointer, set it equal to NULL, then append strings to it with @@ -5844,20 +5227,20 @@ GList *g_list_append( GList *glist, It is important that you set the initial GList pointer to NULL. The -value returned from the g_list_append function must be used as the new +value returned from the g_list_append() function must be used as the new pointer to the GList. Here's a typical code segment for creating a set of options: - GList *glist=NULL; + GList *glist = NULL; - glist = g_list_append(glist, "String 1"); - glist = g_list_append(glist, "String 2"); - glist = g_list_append(glist, "String 3"); - glist = g_list_append(glist, "String 4"); + glist = g_list_append (glist, "String 1"); + glist = g_list_append (glist, "String 2"); + glist = g_list_append (glist, "String 3"); + glist = g_list_append (glist, "String 4"); - gtk_combo_set_popdown_strings( GTK_COMBO(combo), glist) ; + gtk_combo_set_popdown_strings (GTK_COMBO (combo), glist); /* can free glist now, combo takes a copy */ @@ -5872,16 +5255,16 @@ are accomplished with the functions: void gtk_combo_set_use_arrows( GtkCombo *combo, - gint val ); + gboolean val ); void gtk_combo_set_use_arrows_always( GtkCombo *combo, - gint val ); + gboolean val ); void gtk_combo_set_case_sensitive( GtkCombo *combo, - gint val ); + gboolean val ); -gtk_combo_set_use_arrows() lets the user change the value in the +gtk_combo_set_use_arrows() lets the user change the value in the entry using the up/down arrow keys. This doesn't bring up the list, but rather replaces the current text in the entry with the next list entry (up or down, as your key choice indicates). It does this by searching @@ -5893,14 +5276,14 @@ and you press arrow-down it changes the focus (the same applies with the first item and arrow-up). If the current value in the entry is not in the list, then the -function of gtk_combo_set_use_arrows() is disabled. +function of gtk_combo_set_use_arrows() is disabled. -gtk_combo_set_use_arrows_always() similarly allows the use the +gtk_combo_set_use_arrows_always() similarly allows the use the the up/down arrow keys to cycle through the choices in the dropdown list, except that it wraps around the values in the list, completely disabling the use of the up and down arrow keys for changing focus. -gtk_combo_set_case_sensitive() toggles whether or not GTK +gtk_combo_set_case_sensitive() toggles whether or not GTK searches for entries in a case sensitive manner. This is used when the Combo widget is asked to find a value from the list using the current entry in the text box. This completion can be performed in either a @@ -5915,36 +5298,36 @@ will override its use within GTK. all that remains is being able to get data from the combo box. This is relatively straightforward. The majority of the time, all you are going to care about getting data from is the entry. The entry is -accessed simply by GTK_ENTRY(GTK_COMBO(combo)->entry). The +accessed simply by GTK_ENTRY (GTK_COMBO (combo)->entry). The two principal things that you are going to want to do with it are -attach to the activate signal, which indicates that the user has +connect to the activate signal, which indicates that the user has pressed the Return or Enter key, and read the text. The first is accomplished using something like: - gtk_signal_connect(GTK_OBJECT(GTK_COMB(combo)->entry), "activate", - GTK_SIGNAL_FUNC (my_callback_function), my_data); + g_signal_connect (G_OBJECT (GTK_COMBO (combo)->entry), "activate", + G_CALLBACK (my_callback_function), my_data); Getting the text at any arbitrary time is accomplished by simply using the entry function: -gchar *gtk_entry_get_text(GtkEntry *entry); +gchar *gtk_entry_get_text( GtkEntry *entry ); Such as: - char *string; + gchar *string; - string = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); + string = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (combo)->entry)); That's about all there is to it. There is a function -void gtk_combo_disable_activate(GtkCombo *combo); +void gtk_combo_disable_activate( GtkCombo *combo ); that will disable the activate signal on the entry widget in the combo @@ -5970,7 +5353,7 @@ and work with. Creating a GtkCalendar widget is a simple as: -GtkWidget *gtk_calendar_new(); +GtkWidget *gtk_calendar_new( void ); There might be times where you need to change a lot of information @@ -5981,7 +5364,7 @@ on-screen updates. void gtk_calendar_freeze( GtkCalendar *Calendar ); -void gtk_calendar_thaw ( GtkCalendar *Calendar ); +void gtk_calendar_thaw( GtkCalendar *Calendar ); They work just like the freeze/thaw functions of every other @@ -5998,34 +5381,44 @@ void gtk_calendar_display_options( GtkCalendar *calendar, The flags argument can be formed by combining either of the following five options using the logical bitwise OR (|) operation: - - GTK_CALENDAR_SHOW_HEADING - this option specifies that -the month and year should be shown when drawing the calendar. + + +GTK_CALENDAR_SHOW_HEADING +this option specifies that the month and year should be shown +when drawing the calendar. - - GTK_CALENDAR_SHOW_DAY_NAMES - this option specifies that the -three letter descriptions should be displayed for each day (eg -Mon,Tue, etc.). + + +GTK_CALENDAR_SHOW_DAY_NAMES +this option specifies that the three letter descriptions should +be displayed for each day (eg Mon,Tue, etc.). - - GTK_CALENDAR_NO_MONTH_CHANGE - this option states that the user + + +GTK_CALENDAR_NO_MONTH_CHANGE +this option states that the user should not and can not change the currently displayed month. This can be good if you only need to display a particular month such as if you are displaying 12 calendar widgets for every month in a particular -year. +year. - - GTK_CALENDAR_SHOW_WEEK_NUMBERS - this option specifies that the + + +GTK_CALENDAR_SHOW_WEEK_NUMBERS +this option specifies that the number for each week should be displayed down the left side of the -calendar. (eg. Jan 1 = Week 1,Dec 31 = Week 52). +calendar. (eg. Jan 1 = Week 1,Dec 31 = Week 52). - - GTK_CALENDAR_WEEK_START_MONDAY - this option states that the + + +GTK_CALENDAR_WEEK_START_MONDAY +this option states that the calander week will start on Monday instead of Sunday which is the default. This only affects the order in which days are displayed from -left to right. +left to right. - + + The following functions are used to set the the currently displayed date: @@ -6069,7 +5462,7 @@ elements are numbered 0 to n-1). For example: GtkCalendar *calendar; - calendar = gtk_calendar_new(); + calendar = gtk_calendar_new (); ... @@ -6121,7 +5514,7 @@ example code. - + @@ -6573,8 +5966,8 @@ widget changes, either when the user changes it or if it's set explicitly through gtk_color_selection_set_color(). Lets have a look at what the color selection widget has to offer -us. The widget comes in two flavours: gtk_color_selection and -gtk_color_selection_dialog. +us. The widget comes in two flavours: GtkColorSelection and +GtkColorSelectionDialog. GtkWidget *gtk_color_selection_new( void ); @@ -6595,53 +5988,43 @@ ColorSelection widget, an HSeparator and an HBox with three buttons, "Ok", "Cancel" and "Help". You can reach these buttons by accessing the "ok_button", "cancel_button" and "help_button" widgets in the ColorSelectionDialog structure, -(i.e., GTK_COLOR_SELECTION_DIALOG(colorseldialog)->ok_button)). +(i.e., GTK_COLOR_SELECTION_DIALOG (colorseldialog)->ok_button)). -void gtk_color_selection_set_update_policy( GtkColorSelection *colorsel, - GtkUpdateType policy ); - - -This function sets the update policy. The default policy is -GTK_UPDATE_CONTINUOUS which means that the current color is -updated continuously when the user drags the sliders or presses the -mouse and drags in the hue-saturation wheel or value bar. If you -experience performance problems, you may want to set the policy to -GTK_UPDATE_DISCONTINUOUS or GTK_UPDATE_DELAYED. - - -void gtk_color_selection_set_opacity( GtkColorSelection *colorsel, - gint use_opacity ); +void gtk_color_selection_set_has_opacity_control( GtkColorSelection *colorsel, + gboolean has_opacity ); The color selection widget supports adjusting the opacity of a color (also known as the alpha channel). This is disabled by -default. Calling this function with use_opacity set to TRUE enables -opacity. Likewise, use_opacity set to FALSE will disable opacity. +default. Calling this function with has_opacity set to TRUE enables +opacity. Likewise, has_opacity set to FALSE will disable opacity. -void gtk_color_selection_set_color( GtkColorSelection *colorsel, - gdouble *color ); +void gtk_color_selection_set_current_color( GtkColorSelection *colorsel, + GdkColor *color ); + +void gtk_color_selection_set_current_alpha( GtkColorSelection *colorsel, + guint16 alpha ); -You can set the current color explicitly by calling this function with -a pointer to an array of colors (gdouble). The length of the array -depends on whether opacity is enabled or not. Position 0 contains the -red component, 1 is green, 2 is blue and opacity is at position 3 -(only if opacity is enabled, see -gtk_color_selection_set_opacity()). All values are between 0.0 and -1.0. +You can set the current color explicitly by calling +gtk_color_selection_set_current_color() with a pointer to a GdkColor. +Setting the opacity (alpha channel) is done with +gtk_color_selection_set_current_alpha(). The alpha value should be between +0 (fully transparent) and 65636 (fully opaque). + -void gtk_color_selection_get_color( GtkColorSelection *colorsel, - gdouble *color ); +void gtk_color_selection_get_current_color( GtkColorSelection *colorsel, + GdkColor *color ); + +void gtk_color_selection_get_current_alpha( GtkColorSelection *colorsel, + guint16 *alpha ); When you need to query the current color, typically when you've -received a "color_changed" signal, you use this function. Color is a -pointer to the array of colors to fill in. See the -gtk_color_selection_set_color() function for the description of this -array. +received a "color_changed" signal, you use these functions. + Managing Selections @@ -11457,7 +10688,7 @@ depressed. - + @@ -11984,7 +11215,7 @@ set the value. - + @@ -12912,7 +12143,7 @@ pressure and tilt, from such devices quite easy. - + diff --git a/docs/tutorial/images/buttons.png b/docs/tutorial/images/buttons.png index edd6422f370e8f1e05258fb64ef04c29272e1bfe..24e85cfbd6c7cc65b2215f4010ef940b818f0b22 100644 GIT binary patch literal 4063 zcmZu!cQD-F`u-r|8zM~!maiUl^-lC|qlXY(^cKBENqiAy)v#9Y62xj75~~w!S6M;y zE=rVGU3Oi$GrzgNnS1{@@B7Yk$~-gYIp>)-PG47plAM7Y002rYO;y9|oP0e@?h#){ zp28#>0JvMOrK)5cG_#xM<;>_5-q$|szSZ#YcEhsIGndcBd01c#3lslgKa;*o$e>FL@R!0O!Hw#sfuC&&ydD=PA-j#M_4c&K^5Bvcl1o=pK zFwyBeN85CxZEk|>)Db)HgUs(c`kQ6Jhx!P7zGnGagVu(|%uhE2sBcMED{0(}Exe?6 z(=9>2ol#E>XnpZ7kG2yimavQx_9k>xa$5KUtcjeNnNNv{P)s(DyiQSIf2 zZ2F~hKSs6moCcH5via4q94$T7GshYQ7nA>`rTtba1ArOb2VCDs9lh_>;RE%$pf%~; z=|=fIP^M|@y1DT^ovy?XZ9a$EqIb(f=qis8-{EW$AsvF7p6^0<`NoZla@DzZrkx*6 zdU%80#MkzqR@ZNgbe6n)2f@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X4MA@90%00h7&x-kl%d;MU@N3cS=$-mL=ymI%7sSy@9M*$`} znHwql3^@Z3=;T$9bQWo~Y9Llu5Y5EW6~RfUrMg0xyS z5YJ6*?-7qJBQ4cFMXn)~NZNv2Lnx87h5N{A?S(C2p6I=Kl@huj#Q z+>K8n*$cE?T5^0Pxj$*6v_w}>dIcr-Cvux`iKHz^X-On)K}t&^X$w+X5=mQ-(vnEp zf|Qm-(iWt&B$Bour6rNH1t~3wq%CZ+8bdBql1R2k9clH)R66v)JHxwOJV_@gKk<-C zCPpW}uG0Qk->>^)y`=YCF9{#*zZ{=Y>Cgk?Bkc$;cBOH5MXUV=t}h~WtycMRNbU#3 zV??HAYIm=gG*9ToJV6>SAPwNM^KO!rjgKAeM0kq_hb&Gw=_UKBy*bj_cnKu;Cj})N zUp$hH71D)g3u&s;RjP~Q%$on)mwindow, &mask, - &style->bg[GTK_STATE_NORMAL], - xpm_filename); - pixmapwid = gtk_image_new_from_file (xpm_filename); + /* Now on to the image stuff */ + image = gtk_image_new_from_file (xpm_filename); /* Create a label for the button */ label = gtk_label_new (label_text); - /* Pack the pixmap and label into the box */ - gtk_box_pack_start (GTK_BOX (box1), - pixmapwid, FALSE, FALSE, 3); + /* Pack the image and label into the box */ + gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3); + gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3); - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 3); - - gtk_widget_show (pixmapwid); + gtk_widget_show (image); gtk_widget_show (label); - return box1; + return box; } /* Our usual callback function */ @@ -58,7 +45,7 @@ int main( int argc, /* GtkWidget is the storage type for widgets */ GtkWidget *window; GtkWidget *button; - GtkWidget *box1; + GtkWidget *box; gtk_init (&argc, &argv); @@ -76,7 +63,6 @@ int main( int argc, /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_widget_realize (window); /* Create a new button */ button = gtk_button_new (); @@ -86,12 +72,12 @@ int main( int argc, G_CALLBACK (callback), (gpointer) "cool button"); /* This calls our box creating function */ - box1 = xpm_label_box(window, "info.xpm", "cool button"); + box = xpm_label_box ("info.xpm", "cool button"); /* Pack and show all our widgets */ - gtk_widget_show (box1); + gtk_widget_show (box); - gtk_container_add (GTK_CONTAINER (button), box1); + gtk_container_add (GTK_CONTAINER (button), box); gtk_widget_show (button); diff --git a/examples/gtkdial/dial_test.c b/examples/gtkdial/dial_test.c index 3c2a93a9be..3d02c79565 100644 --- a/examples/gtkdial/dial_test.c +++ b/examples/gtkdial/dial_test.c @@ -1,3 +1,4 @@ + #include #include #include diff --git a/examples/gtkdial/gtkdial.c b/examples/gtkdial/gtkdial.c index 0c0fc8bad9..f535081bdb 100644 --- a/examples/gtkdial/gtkdial.c +++ b/examples/gtkdial/gtkdial.c @@ -1,3 +1,4 @@ + /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * @@ -28,30 +29,30 @@ /* Forward declarations */ -static void gtk_dial_class_init (GtkDialClass *klass); -static void gtk_dial_init (GtkDial *dial); -static void gtk_dial_destroy (GtkObject *object); -static void gtk_dial_realize (GtkWidget *widget); +static void gtk_dial_class_init (GtkDialClass *klass); +static void gtk_dial_init (GtkDial *dial); +static void gtk_dial_destroy (GtkObject *object); +static void gtk_dial_realize (GtkWidget *widget); static void gtk_dial_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void gtk_dial_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint gtk_dial_expose (GtkWidget *widget, - GdkEventExpose *event); -static gint gtk_dial_button_press (GtkWidget *widget, - GdkEventButton *event); -static gint gtk_dial_button_release (GtkWidget *widget, - GdkEventButton *event); -static gint gtk_dial_motion_notify (GtkWidget *widget, - GdkEventMotion *event); -static gint gtk_dial_timer (GtkDial *dial); +static void gtk_dial_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static gint gtk_dial_expose (GtkWidget *widget, + GdkEventExpose *event); +static gint gtk_dial_button_press (GtkWidget *widget, + GdkEventButton *event); +static gint gtk_dial_button_release (GtkWidget *widget, + GdkEventButton *event); +static gint gtk_dial_motion_notify (GtkWidget *widget, + GdkEventMotion *event); +static gint gtk_dial_timer (GtkDial *dial); static void gtk_dial_update_mouse (GtkDial *dial, gint x, gint y); static void gtk_dial_update (GtkDial *dial); -static void gtk_dial_adjustment_changed (GtkAdjustment *adjustment, - gpointer data); -static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, - gpointer data); +static void gtk_dial_adjustment_changed (GtkAdjustment *adjustment, + gpointer data); +static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, + gpointer data); /* Local data */ @@ -140,12 +141,13 @@ gtk_dial_destroy (GtkObject *object) { GtkDial *dial; + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_DIAL (object)); dial = GTK_DIAL (object); if (dial->adjustment) - g_object_unref (G_OBJECT (dial->adjustment)); + g_object_unref (GTK_OBJECT (dial->adjustment)); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -154,6 +156,7 @@ gtk_dial_destroy (GtkObject *object) GtkAdjustment* gtk_dial_get_adjustment (GtkDial *dial) { + g_return_val_if_fail (dial != NULL, NULL); g_return_val_if_fail (GTK_IS_DIAL (dial), NULL); return dial->adjustment; @@ -163,6 +166,7 @@ void gtk_dial_set_update_policy (GtkDial *dial, GtkUpdateType policy) { + g_return_if_fail (dial != NULL); g_return_if_fail (GTK_IS_DIAL (dial)); dial->policy = policy; @@ -172,23 +176,24 @@ void gtk_dial_set_adjustment (GtkDial *dial, GtkAdjustment *adjustment) { + g_return_if_fail (dial != NULL); g_return_if_fail (GTK_IS_DIAL (dial)); if (dial->adjustment) { - g_signal_handlers_disconnect_by_func (G_OBJECT (dial->adjustment), NULL, (gpointer) dial); - g_object_unref (G_OBJECT (dial->adjustment)); + g_signal_handlers_disconnect_by_func (GTK_OBJECT (dial->adjustment), NULL, (gpointer) dial); + g_object_unref (GTK_OBJECT (dial->adjustment)); } dial->adjustment = adjustment; - g_object_ref (G_OBJECT (dial->adjustment)); + g_object_ref (GTK_OBJECT (dial->adjustment)); - g_signal_connect (G_OBJECT (adjustment), "changed", - G_CALLBACK (gtk_dial_adjustment_changed), - dial); - g_signal_connect (G_OBJECT (adjustment), "value_changed", - G_CALLBACK (gtk_dial_adjustment_value_changed), - dial); + g_signal_connect (GTK_OBJECT (adjustment), "changed", + GTK_SIGNAL_FUNC (gtk_dial_adjustment_changed), + (gpointer) dial); + g_signal_connect (GTK_OBJECT (adjustment), "value_changed", + GTK_SIGNAL_FUNC (gtk_dial_adjustment_value_changed), + (gpointer) dial); dial->old_value = adjustment->value; dial->old_lower = adjustment->lower; @@ -204,6 +209,7 @@ gtk_dial_realize (GtkWidget *widget) GdkWindowAttr attributes; gint attributes_mask; + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_DIAL (widget)); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); @@ -246,6 +252,7 @@ gtk_dial_size_allocate (GtkWidget *widget, { GtkDial *dial; + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_DIAL (widget)); g_return_if_fail (allocation != NULL); @@ -278,6 +285,7 @@ gtk_dial_expose (GtkWidget *widget, gint tick_length; gint i, inc; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -352,7 +360,7 @@ gtk_dial_expose (GtkWidget *widget, for (i = 0; i <= inc; i++) { - theta = ((gdouble)i*M_PI / (18*inc/24.) - M_PI/6.); + theta = ((gfloat)i*M_PI / (18*inc/24.) - M_PI/6.); if ((theta - last) < (increment)) continue; @@ -412,6 +420,7 @@ gtk_dial_button_press (GtkWidget *widget, double d_parallel; double d_perpendicular; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -451,6 +460,7 @@ gtk_dial_button_release (GtkWidget *widget, { GtkDial *dial; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -467,7 +477,7 @@ gtk_dial_button_release (GtkWidget *widget, if ((dial->policy != GTK_UPDATE_CONTINUOUS) && (dial->old_value != dial->adjustment->value)) - gtk_adjustment_value_changed (dial->adjustment); + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); } return FALSE; @@ -481,6 +491,7 @@ gtk_dial_motion_notify (GtkWidget *widget, GdkModifierType mods; gint x, y, mask; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -520,10 +531,11 @@ gtk_dial_motion_notify (GtkWidget *widget, static gint gtk_dial_timer (GtkDial *dial) { + g_return_val_if_fail (dial != NULL, FALSE); g_return_val_if_fail (GTK_IS_DIAL (dial), FALSE); if (dial->policy == GTK_UPDATE_DELAYED) - gtk_adjustment_value_changed (dial->adjustment); + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); return FALSE; } @@ -532,8 +544,9 @@ static void gtk_dial_update_mouse (GtkDial *dial, gint x, gint y) { gint xc, yc; - gdouble old_value; + gfloat old_value; + g_return_if_fail (dial != NULL); g_return_if_fail (GTK_IS_DIAL (dial)); xc = GTK_WIDGET(dial)->allocation.width / 2; @@ -558,7 +571,7 @@ gtk_dial_update_mouse (GtkDial *dial, gint x, gint y) { if (dial->policy == GTK_UPDATE_CONTINUOUS) { - gtk_adjustment_value_changed (dial->adjustment); + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); } else { @@ -580,8 +593,9 @@ gtk_dial_update_mouse (GtkDial *dial, gint x, gint y) static void gtk_dial_update (GtkDial *dial) { - gdouble new_value; + gfloat new_value; + g_return_if_fail (dial != NULL); g_return_if_fail (GTK_IS_DIAL (dial)); new_value = dial->adjustment->value; @@ -594,7 +608,8 @@ gtk_dial_update (GtkDial *dial) if (new_value != dial->adjustment->value) { - gtk_adjustment_set_value (dial->adjustment, new_value); + dial->adjustment->value = new_value; + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); } dial->angle = 7.*M_PI/6. - (new_value - dial->adjustment->lower) * 4.*M_PI/3. / @@ -605,12 +620,12 @@ gtk_dial_update (GtkDial *dial) static void gtk_dial_adjustment_changed (GtkAdjustment *adjustment, - gpointer data) + gpointer data) { GtkDial *dial; g_return_if_fail (adjustment != NULL); - g_return_if_fail (GTK_IS_DIAL (data)); + g_return_if_fail (data != NULL); dial = GTK_DIAL (data); @@ -633,7 +648,7 @@ gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, GtkDial *dial; g_return_if_fail (adjustment != NULL); - g_return_if_fail (GTK_IS_DIAL (data)); + g_return_if_fail (data != NULL); dial = GTK_DIAL (data); diff --git a/examples/list/list.c b/examples/list/list.c index 0f0c22a445..3180a4f0df 100644 --- a/examples/list/list.c +++ b/examples/list/list.c @@ -1,7 +1,4 @@ -/* Include the GTK header files - * Include stdio.h, we need that for the printf() function - */ #include #include diff --git a/examples/packbox/packbox.c b/examples/packbox/packbox.c index 71476e422b..fe411625d2 100644 --- a/examples/packbox/packbox.c +++ b/examples/packbox/packbox.c @@ -14,11 +14,11 @@ gint delete_event( GtkWidget *widget, /* Make a new hbox filled with button-labels. Arguments for the * variables we're interested are passed in to this function. * We do not show the box, but do show everything inside. */ -GtkWidget *make_box( gint homogeneous, - gint spacing, - gint expand, - gint fill, - gint padding ) +GtkWidget *make_box( gboolean homogeneous, + gint spacing, + gboolean expand, + gboolean fill, + guint padding ) { GtkWidget *box; GtkWidget *button; @@ -285,7 +285,7 @@ int main( int argc, gtk_main (); /* Control returns here when gtk_main_quit() is called, but not when - * gtk_exit is used. */ + * exit() is used. */ return 0; } diff --git a/examples/pixmap/pixmap.c b/examples/pixmap/pixmap.c index 09a0a4539d..7707a64ce3 100644 --- a/examples/pixmap/pixmap.c +++ b/examples/pixmap/pixmap.c @@ -57,8 +57,8 @@ int main( int argc, the application */ gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (close_application), NULL); + g_signal_connect (G_OBJECT (window), "delete_event", + G_CALLBACK (close_application), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); gtk_widget_show (window); diff --git a/examples/radiobuttons/radiobuttons.c b/examples/radiobuttons/radiobuttons.c index 21dc6ca438..6d1c27096b 100644 --- a/examples/radiobuttons/radiobuttons.c +++ b/examples/radiobuttons/radiobuttons.c @@ -20,7 +20,7 @@ int main( int argc, GtkWidget *separator; GSList *group; - gtk_init (&argc,&argv); + gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -50,9 +50,8 @@ int main( int argc, gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); - button = gtk_radio_button_new_with_label( - gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)), - "button3"); + button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), + "button3"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); diff --git a/examples/spinbutton/spinbutton.c b/examples/spinbutton/spinbutton.c index 18bd66611b..6247419ac5 100644 --- a/examples/spinbutton/spinbutton.c +++ b/examples/spinbutton/spinbutton.c @@ -217,3 +217,4 @@ int main( int argc, return 0; } + diff --git a/examples/text/text.c b/examples/text/text.c index 74a507e930..fe2a0385f4 100644 --- a/examples/text/text.c +++ b/examples/text/text.c @@ -1,6 +1,4 @@ -/* text.c */ - #define GTK_ENABLE_BROKEN #include #include