diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-25 01:47:44 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-25 01:47:44 +0000 |
commit | 9f1363013fe5e3def58a007b6c109be93d4e5702 (patch) | |
tree | bfd35007c9638a34d6904db1ffd30b38ebc949ec /examples | |
parent | 4d06c9d09f5e8befceb297aa426f293f58248888 (diff) | |
download | gtk+-9f1363013fe5e3def58a007b6c109be93d4e5702.tar.gz |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/base/base.c | 2 | ||||
-rw-r--r-- | examples/buttons/Makefile | 2 | ||||
-rw-r--r-- | examples/buttons/buttons.c | 48 | ||||
-rw-r--r-- | examples/gtkdial/dial_test.c | 1 | ||||
-rw-r--r-- | examples/gtkdial/gtkdial.c | 93 | ||||
-rw-r--r-- | examples/list/list.c | 3 | ||||
-rw-r--r-- | examples/packbox/packbox.c | 12 | ||||
-rw-r--r-- | examples/pixmap/pixmap.c | 4 | ||||
-rw-r--r-- | examples/radiobuttons/radiobuttons.c | 7 | ||||
-rw-r--r-- | examples/spinbutton/spinbutton.c | 1 | ||||
-rw-r--r-- | examples/text/text.c | 2 |
11 files changed, 86 insertions, 89 deletions
diff --git a/examples/base/base.c b/examples/base/base.c index ae8325e95f..4dc29da623 100644 --- a/examples/base/base.c +++ b/examples/base/base.c @@ -9,7 +9,7 @@ int main( int argc, gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_show (window); + gtk_widget_show (window); gtk_main (); diff --git a/examples/buttons/Makefile b/examples/buttons/Makefile index 9a9d2af64f..7f9a324db2 100644 --- a/examples/buttons/Makefile +++ b/examples/buttons/Makefile @@ -1,7 +1,7 @@ CC = gcc -CFLAGS = -Wall \ +CFLAGS = -Wall -Wunused \ -DG_DISABLE_DEPRECATED \ -DGDK_DISABLE_DEPRECATED \ -DGDK_PIXBUF_DISABLE_DEPRECATED \ diff --git a/examples/buttons/buttons.c b/examples/buttons/buttons.c index b89b817ce7..922026346d 100644 --- a/examples/buttons/buttons.c +++ b/examples/buttons/buttons.c @@ -5,44 +5,31 @@ /* 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); - - gtk_box_pack_start (GTK_BOX (box1), label, 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_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 <stdio.h> #include <stdlib.h> #include <gtk/gtk.h> 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 <gtk/gtk.h> #include <stdio.h> 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 <stdio.h> #include <gtk/gtk.h> |