diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-16 23:52:30 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-02-16 23:52:30 +0000 |
commit | b3d5f148e6c0e2cb688403655c7800b762e33602 (patch) | |
tree | 1056439dd24e464adbabc5c374182a886c669345 /examples | |
parent | 554838e4f602d59f5be241d1da188934d51d49c3 (diff) | |
download | gdk-pixbuf-b3d5f148e6c0e2cb688403655c7800b762e33602.tar.gz |
More work on #71430.
* examples/*/Makefile (CFLAGS): add deprecation guards.
* docs/tutorial/gtk-tut.sgml, examples/*/*.c: make most examples
deprecation-clean; the major offenders right now are the examples
that make heavy use of completely deprecated or broken widgets:
list, tree, text, pixmap, paned and progressbar. These will have
to be redone from scratch.
* demos/Makefile.am (INCLUDES): add -DGDK_PIXBUF_DISABLE_DEPRECATED.
Diffstat (limited to 'examples')
80 files changed, 675 insertions, 523 deletions
diff --git a/examples/arrow/Makefile b/examples/arrow/Makefile index 34904d491..08afc28ca 100644 --- a/examples/arrow/Makefile +++ b/examples/arrow/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + arrow: arrow.c - $(CC) `pkg-config --cflags gtk+-2.0` arrow.c -o arrow `pkg-config --libs gtk+-2.0` + $(CC) arrow.c -o arrow $(DEPRECTATED) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o arrow diff --git a/examples/arrow/arrow.c b/examples/arrow/arrow.c index 69cb49c43..884bc4752 100644 --- a/examples/arrow/arrow.c +++ b/examples/arrow/arrow.c @@ -1,4 +1,3 @@ -/* example-start arrow arrow.c */ #include <gtk/gtk.h> @@ -71,4 +70,3 @@ int main( int argc, return(0); } -/* example-end */ diff --git a/examples/aspectframe/Makefile b/examples/aspectframe/Makefile index 1e7f3f568..10fc747fb 100644 --- a/examples/aspectframe/Makefile +++ b/examples/aspectframe/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + aspectframe: aspectframe.c - $(CC) `pkg-config --cflags gtk+-2.0` aspectframe.c -o aspectframe `pkg-config --libs gtk+-2.0` + $(CC) aspectframe.c -o aspectframe $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o aspectframe diff --git a/examples/aspectframe/aspectframe.c b/examples/aspectframe/aspectframe.c index c1201fbbe..6f231188f 100644 --- a/examples/aspectframe/aspectframe.c +++ b/examples/aspectframe/aspectframe.c @@ -1,4 +1,3 @@ -/* example-start aspectframe aspectframe.c */ #include <gtk/gtk.h> @@ -12,8 +11,8 @@ int main( int argc, window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Aspect Frame"); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_main_quit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_main_quit), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* Create an aspect_frame and add it to our toplevel window */ @@ -33,7 +32,7 @@ int main( int argc, /* Ask for a 200x200 window, but the AspectFrame will give us a 200x100 * window since we are forcing a 2x1 aspect ratio */ - gtk_widget_set_usize (drawing_area, 200, 200); + gtk_widget_set_size_request (drawing_area, 200, 200); gtk_container_add (GTK_CONTAINER(aspect_frame), drawing_area); gtk_widget_show (drawing_area); @@ -41,4 +40,3 @@ int main( int argc, gtk_main (); return 0; } -/* example-end */ diff --git a/examples/base/Makefile b/examples/base/Makefile index 6865097f5..dbb54890e 100644 --- a/examples/base/Makefile +++ b/examples/base/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + base: base.c - $(CC) `pkg-config --cflags gtk+-2.0` base.c -o base `pkg-config --libs gtk+-2.0` + $(CC) base.c -o base $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o base diff --git a/examples/base/base.c b/examples/base/base.c index d0e9d8daa..94b5360ff 100644 --- a/examples/base/base.c +++ b/examples/base/base.c @@ -1,4 +1,3 @@ -/* example-start base base.c */ #include <gtk/gtk.h> @@ -16,4 +15,3 @@ int main( int argc, return(0); } -/* example-end */ diff --git a/examples/buttonbox/Makefile b/examples/buttonbox/Makefile index d28bd8d9a..086397884 100644 --- a/examples/buttonbox/Makefile +++ b/examples/buttonbox/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + buttonbox: buttonbox.c - $(CC) `pkg-config --cflags gtk+-2.0` buttonbox.c -o buttonbox `pkg-config --libs gtk+-2.0` + $(CC) buttonbox.c -o buttonbox $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o buttonbox diff --git a/examples/buttonbox/buttonbox.c b/examples/buttonbox/buttonbox.c index 18346403a..45e71c94f 100644 --- a/examples/buttonbox/buttonbox.c +++ b/examples/buttonbox/buttonbox.c @@ -1,4 +1,3 @@ -/* example-start buttonbox buttonbox.c */ #include <gtk/gtk.h> @@ -26,8 +25,8 @@ GtkWidget *create_bbox( gint horizontal, /* Set the appearance of the Button Box */ gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), spacing); - gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), child_w, child_h); + gtk_box_set_spacing (GTK_BOX (bbox), spacing); + /*gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), child_w, child_h);*/ button = gtk_button_new_with_label ("OK"); gtk_container_add (GTK_CONTAINER (bbox), button); @@ -57,9 +56,9 @@ int main( int argc, window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Button Boxes"); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC(gtk_main_quit), - NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC(gtk_main_quit), + NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -119,4 +118,3 @@ int main( int argc, return(0); } -/* example-end */ diff --git a/examples/buttons/Makefile b/examples/buttons/Makefile index a8474ae2d..9a9d2af64 100644 --- a/examples/buttons/Makefile +++ b/examples/buttons/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + buttons: buttons.c - $(CC) `pkg-config --cflags gtk+-2.0` buttons.c -o buttons `pkg-config --libs gtk+-2.0` + $(CC) buttons.c -o buttons $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o buttons diff --git a/examples/buttons/buttons.c b/examples/buttons/buttons.c index 82bc5069e..0f7864afa 100644 --- a/examples/buttons/buttons.c +++ b/examples/buttons/buttons.c @@ -1,5 +1,5 @@ -/* example-start buttons buttons.c */ +#include <stdlib.h> #include <gtk/gtk.h> /* Create a new hbox with an image and a label packed into it @@ -28,7 +28,7 @@ GtkWidget *xpm_label_box( GtkWidget *parent, pixmap = gdk_pixmap_create_from_xpm (parent->window, &mask, &style->bg[GTK_STATE_NORMAL], xpm_filename); - pixmapwid = gtk_pixmap_new (pixmap, mask); + pixmapwid = gtk_image_new_from_file (xpm_filename); /* Create a label for the button */ label = gtk_label_new (label_text); @@ -52,7 +52,6 @@ void callback( GtkWidget *widget, g_print ("Hello again - %s was pressed\n", (char *) data); } - int main( int argc, char *argv[] ) { @@ -68,12 +67,14 @@ int main( int argc, gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!"); +#if 1 /* It's a good idea to do this for all windows. */ - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (exit), NULL); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "delete_event", + GTK_SIGNAL_FUNC (exit), NULL); +#endif /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -83,8 +84,8 @@ int main( int argc, button = gtk_button_new (); /* Connect the "clicked" signal of the button to our callback */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (callback), (gpointer) "cool button"); + g_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (callback), (gpointer) "cool button"); /* This calls our box creating function */ box1 = xpm_label_box(window, "info.xpm", "cool button"); @@ -105,4 +106,3 @@ int main( int argc, return(0); } -/* example-end */ diff --git a/examples/calendar/Makefile b/examples/calendar/Makefile index e260fa07d..a27b6a794 100644 --- a/examples/calendar/Makefile +++ b/examples/calendar/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + calendar: calendar.c - $(CC) `pkg-config --cflags gtk+-2.0` calendar.c -o calendar `pkg-config --libs gtk+-2.0` + $(CC) calendar.c -o calendar $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f calendar diff --git a/examples/calendar/calendar.c b/examples/calendar/calendar.c index c3dfc4c17..5e395b915 100644 --- a/examples/calendar/calendar.c +++ b/examples/calendar/calendar.c @@ -1,4 +1,3 @@ -/* example-start calendar calendar.c */ /* * Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund * Copyright (C) 2000 Tony Gale @@ -70,14 +69,14 @@ void calendar_date_to_string( CalendarData *data, void calendar_set_signal_strings( char *sig_str, CalendarData *data) { - gchar *prev_sig; + const gchar *prev_sig; - gtk_label_get (GTK_LABEL (data->prev_sig), &prev_sig); - gtk_label_set (GTK_LABEL (data->prev2_sig), prev_sig); + prev_sig = gtk_label_get_text (GTK_LABEL (data->prev_sig)); + gtk_label_set_text (GTK_LABEL (data->prev2_sig), prev_sig); - gtk_label_get (GTK_LABEL (data->last_sig), &prev_sig); - gtk_label_set (GTK_LABEL (data->prev_sig), prev_sig); - gtk_label_set (GTK_LABEL (data->last_sig), sig_str); + prev_sig = gtk_label_get_text (GTK_LABEL (data->last_sig)); + gtk_label_set_text (GTK_LABEL (data->prev_sig), prev_sig); + gtk_label_set_text (GTK_LABEL (data->last_sig), sig_str); } void calendar_month_changed( GtkWidget *widget, @@ -188,19 +187,17 @@ void calendar_font_selection_ok( GtkWidget *button, CalendarData *calendar ) { GtkStyle *style; - GdkFont *font; + PangoFontDescription *font_desc; calendar->font = gtk_font_selection_dialog_get_font_name( GTK_FONT_SELECTION_DIALOG (calendar->font_dialog)); if (calendar->window) { - font = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(calendar->font_dialog)); - if (font) + font_desc = pango_font_description_from_string (calendar->font); + if (font_desc) { style = gtk_style_copy (gtk_widget_get_style (calendar->window)); - gdk_font_unref (style->font); - style->font = font; - gdk_font_ref (style->font); + style->font_desc = font_desc; gtk_widget_set_style (calendar->window, style); } } @@ -216,19 +213,19 @@ void calendar_select_font( GtkWidget *button, g_return_if_fail(GTK_IS_FONT_SELECTION_DIALOG(window)); calendar->font_dialog = window; - gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); + gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroyed), - &calendar->font_dialog); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &calendar->font_dialog); - gtk_signal_connect (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->ok_button), - "clicked", GTK_SIGNAL_FUNC(calendar_font_selection_ok), - calendar); - gtk_signal_connect_object (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (calendar->font_dialog)); + g_signal_connect (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->ok_button), + "clicked", GTK_SIGNAL_FUNC(calendar_font_selection_ok), + calendar); + g_signal_connect_swapped (GTK_OBJECT (GTK_FONT_SELECTION_DIALOG (window)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (calendar->font_dialog)); } window=calendar->font_dialog; if (!GTK_WIDGET_VISIBLE (window)) @@ -276,15 +273,15 @@ void create_calendar() window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "GtkCalendar Example"); - gtk_container_border_width (GTK_CONTAINER (window), 5); - gtk_signal_connect(GTK_OBJECT(window), "destroy", - GTK_SIGNAL_FUNC(gtk_main_quit), - NULL); - gtk_signal_connect(GTK_OBJECT(window), "delete-event", - GTK_SIGNAL_FUNC(gtk_false), - NULL); + gtk_container_set_border_width (GTK_CONTAINER (window), 5); + g_signal_connect(GTK_OBJECT(window), "destroy", + GTK_SIGNAL_FUNC(gtk_main_quit), + NULL); + g_signal_connect(GTK_OBJECT(window), "delete-event", + GTK_SIGNAL_FUNC(gtk_false), + NULL); - gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE); + gtk_window_set_resizable (GTK_WINDOW (window), FALSE); vbox = gtk_vbox_new(FALSE, DEF_PAD); gtk_container_add (GTK_CONTAINER (window), vbox); @@ -298,7 +295,7 @@ void create_calendar() hbbox = gtk_hbutton_box_new(); gtk_box_pack_start(GTK_BOX(hbox), hbbox, FALSE, FALSE, DEF_PAD); gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_SPREAD); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 5); + gtk_box_set_spacing (GTK_BOX (hbbox), 5); /* Calendar widget */ frame = gtk_frame_new("Calendar"); @@ -308,27 +305,27 @@ void create_calendar() calendar_set_flags(&calendar_data); gtk_calendar_mark_day ( GTK_CALENDAR(calendar), 19); gtk_container_add( GTK_CONTAINER( frame), calendar); - gtk_signal_connect (GTK_OBJECT (calendar), "month_changed", - GTK_SIGNAL_FUNC (calendar_month_changed), - &calendar_data); - gtk_signal_connect (GTK_OBJECT (calendar), "day_selected", - GTK_SIGNAL_FUNC (calendar_day_selected), - &calendar_data); - gtk_signal_connect (GTK_OBJECT (calendar), "day_selected_double_click", - GTK_SIGNAL_FUNC (calendar_day_selected_double_click), - &calendar_data); - gtk_signal_connect (GTK_OBJECT (calendar), "prev_month", - GTK_SIGNAL_FUNC (calendar_prev_month), - &calendar_data); - gtk_signal_connect (GTK_OBJECT (calendar), "next_month", - GTK_SIGNAL_FUNC (calendar_next_month), - &calendar_data); - gtk_signal_connect (GTK_OBJECT (calendar), "prev_year", - GTK_SIGNAL_FUNC (calendar_prev_year), - &calendar_data); - gtk_signal_connect (GTK_OBJECT (calendar), "next_year", - GTK_SIGNAL_FUNC (calendar_next_year), - &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "month_changed", + GTK_SIGNAL_FUNC (calendar_month_changed), + &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "day_selected", + GTK_SIGNAL_FUNC (calendar_day_selected), + &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "day_selected_double_click", + GTK_SIGNAL_FUNC (calendar_day_selected_double_click), + &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "prev_month", + GTK_SIGNAL_FUNC (calendar_prev_month), + &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "next_month", + GTK_SIGNAL_FUNC (calendar_next_month), + &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "prev_year", + GTK_SIGNAL_FUNC (calendar_prev_year), + &calendar_data); + g_signal_connect (GTK_OBJECT (calendar), "next_year", + GTK_SIGNAL_FUNC (calendar_next_year), + &calendar_data); separator = gtk_vseparator_new (); @@ -347,7 +344,7 @@ void create_calendar() for (i = 0; i < 5; i++) { toggle = gtk_check_button_new_with_label(flags[i].label); - gtk_signal_connect (GTK_OBJECT (toggle), + g_signal_connect (GTK_OBJECT (toggle), "toggled", GTK_SIGNAL_FUNC(calendar_toggle_flag), &calendar_data); @@ -356,7 +353,7 @@ void create_calendar() } /* Build the right font-button */ button = gtk_button_new_with_label("Font..."); - gtk_signal_connect (GTK_OBJECT (button), + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(calendar_select_font), &calendar_data); @@ -398,7 +395,7 @@ void create_calendar() gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); button = gtk_button_new_with_label ("Close"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); gtk_container_add (GTK_CONTAINER (bbox), button); @@ -418,6 +415,5 @@ int main(int argc, gtk_main(); - return(0); + return 0; } -/* example-end */ diff --git a/examples/clist/Makefile b/examples/clist/Makefile index cdb294811..1e45050df 100644 --- a/examples/clist/Makefile +++ b/examples/clist/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + clist: clist.c - $(CC) `pkg-config --cflags gtk+-2.0` clist.c -o clist `pkg-config --libs gtk+-2.0` + $(CC) clist.c -o clist `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o clist diff --git a/examples/clist/clist.c b/examples/clist/clist.c index 9bb4d22a0..1a2f25b97 100644 --- a/examples/clist/clist.c +++ b/examples/clist/clist.c @@ -1,4 +1,3 @@ -/* example-start clist clist.c */ #include <gtk/gtk.h> @@ -90,7 +89,7 @@ int main( int argc, gtk_init(&argc, &argv); window=gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize(GTK_WIDGET(window), 300, 150); + gtk_widget_set_size_request (GTK_WIDGET (window), 300, 150); gtk_window_set_title(GTK_WINDOW(window), "GtkCList Example"); gtk_signal_connect(GTK_OBJECT(window), @@ -171,4 +170,3 @@ int main( int argc, return(0); } -/* example-end */ diff --git a/examples/entry/Makefile b/examples/entry/Makefile index ef5b67ef7..78984e64d 100644 --- a/examples/entry/Makefile +++ b/examples/entry/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + entry: entry.c - $(CC) `pkg-config --cflags gtk+-2.0` entry.c -o entry `pkg-config --libs gtk+-2.0` + $(CC) entry.c -o entry $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o entry diff --git a/examples/entry/entry.c b/examples/entry/entry.c index b53a9f9a3..4de30711d 100644 --- a/examples/entry/entry.c +++ b/examples/entry/entry.c @@ -1,11 +1,12 @@ -/* example-start entry entry.c */ +#include <stdio.h> +#include <stdlib.h> #include <gtk/gtk.h> void enter_callback( GtkWidget *widget, GtkWidget *entry ) { - gchar *entry_text; + const gchar *entry_text; entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); printf("Entry contents: %s\n", entry_text); } @@ -13,8 +14,8 @@ void enter_callback( GtkWidget *widget, void entry_toggle_editable( GtkWidget *checkbutton, GtkWidget *entry ) { - gtk_entry_set_editable(GTK_ENTRY(entry), - GTK_TOGGLE_BUTTON(checkbutton)->active); + gtk_editable_set_editable (GTK_EDITABLE (entry), + GTK_TOGGLE_BUTTON (checkbutton)->active); } void entry_toggle_visibility( GtkWidget *checkbutton, @@ -33,28 +34,31 @@ int main( int argc, GtkWidget *entry; GtkWidget *button; GtkWidget *check; + gint tmp_pos; gtk_init (&argc, &argv); /* create a new window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize( GTK_WIDGET (window), 200, 100); + gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); gtk_window_set_title(GTK_WINDOW (window), "GTK Entry"); - gtk_signal_connect(GTK_OBJECT (window), "delete_event", - (GtkSignalFunc) gtk_exit, NULL); + g_signal_connect(GTK_OBJECT (window), "delete_event", + (GtkSignalFunc) exit, NULL); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); - entry = gtk_entry_new_with_max_length (50); - gtk_signal_connect(GTK_OBJECT(entry), "activate", + entry = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (entry), 50); + g_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(enter_callback), entry); gtk_entry_set_text (GTK_ENTRY (entry), "hello"); - gtk_entry_append_text (GTK_ENTRY (entry), " world"); - gtk_entry_select_region (GTK_ENTRY (entry), - 0, GTK_ENTRY(entry)->text_length); + tmp_pos = GTK_ENTRY (entry)->text_length; + gtk_editable_insert_text (GTK_EDITABLE (entry), " world", -1, &tmp_pos); + gtk_editable_select_region (GTK_EDITABLE (entry), + 0, GTK_ENTRY(entry)->text_length); gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0); gtk_widget_show (entry); @@ -64,21 +68,21 @@ int main( int argc, check = gtk_check_button_new_with_label("Editable"); gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT(check), "toggled", + g_signal_connect (GTK_OBJECT(check), "toggled", GTK_SIGNAL_FUNC(entry_toggle_editable), entry); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE); gtk_widget_show (check); check = gtk_check_button_new_with_label("Visible"); gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0); - gtk_signal_connect (GTK_OBJECT(check), "toggled", + g_signal_connect (GTK_OBJECT(check), "toggled", GTK_SIGNAL_FUNC(entry_toggle_visibility), entry); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE); gtk_widget_show (check); button = gtk_button_new_with_label ("Close"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC(gtk_exit), + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC(exit), GTK_OBJECT (window)); gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); @@ -88,6 +92,5 @@ int main( int argc, gtk_widget_show(window); gtk_main(); - return(0); + return 0; } -/* example-end */ diff --git a/examples/eventbox/Makefile b/examples/eventbox/Makefile index 3eb24d5ce..96b4f5c24 100644 --- a/examples/eventbox/Makefile +++ b/examples/eventbox/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + eventbox: eventbox.c - $(CC) `pkg-config --cflags gtk+-2.0` eventbox.c -o eventbox `pkg-config --libs gtk+-2.0` + $(CC) eventbox.c -o eventbox $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o eventbox diff --git a/examples/eventbox/eventbox.c b/examples/eventbox/eventbox.c index ac1e52489..85a886f91 100644 --- a/examples/eventbox/eventbox.c +++ b/examples/eventbox/eventbox.c @@ -1,5 +1,5 @@ -/* example-start eventbox eventbox.c */ +#include <stdlib.h> #include <gtk/gtk.h> int main( int argc, @@ -15,8 +15,8 @@ int main( int argc, gtk_window_set_title (GTK_WINDOW (window), "Event Box"); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (exit), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -33,12 +33,12 @@ int main( int argc, gtk_widget_show (label); /* Clip it short. */ - gtk_widget_set_usize (label, 110, 20); + gtk_widget_set_size_request (label, 110, 20); /* And bind an action to it */ gtk_widget_set_events (event_box, GDK_BUTTON_PRESS_MASK); - gtk_signal_connect (GTK_OBJECT(event_box), "button_press_event", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT(event_box), "button_press_event", + GTK_SIGNAL_FUNC (exit), NULL); /* Yet one more thing you need an X window for ... */ @@ -49,6 +49,5 @@ int main( int argc, gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/filesel/Makefile b/examples/filesel/Makefile index fe1378683..92d5e3d00 100644 --- a/examples/filesel/Makefile +++ b/examples/filesel/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + filesel: filesel.c - $(CC) `pkg-config --cflags gtk+-2.0` filesel.c -o filesel `pkg-config --libs gtk+-2.0` + $(CC) filesel.c -o filesel $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o filesel diff --git a/examples/filesel/filesel.c b/examples/filesel/filesel.c index 1e1fcaad4..87daf1264 100644 --- a/examples/filesel/filesel.c +++ b/examples/filesel/filesel.c @@ -1,4 +1,3 @@ -/* example-start filesel filesel.c */ #include <gtk/gtk.h> @@ -25,16 +24,16 @@ int main( int argc, /* Create a new file selection widget */ filew = gtk_file_selection_new ("File selection"); - gtk_signal_connect (GTK_OBJECT (filew), "destroy", - (GtkSignalFunc) destroy, &filew); + g_signal_connect (GTK_OBJECT (filew), "destroy", + GTK_SIGNAL_FUNC (destroy), &filew); /* Connect the ok_button to file_ok_sel function */ - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), - "clicked", (GtkSignalFunc) file_ok_sel, filew ); + g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filew)->ok_button), + "clicked", GTK_SIGNAL_FUNC (file_ok_sel), filew ); /* Connect the cancel_button to destroy the widget */ - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION + g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button), - "clicked", (GtkSignalFunc) gtk_widget_destroy, + "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (filew)); /* Lets set the filename, as if this were a save dialog, and we are giving @@ -46,4 +45,3 @@ int main( int argc, gtk_main (); return 0; } -/* example-end */ diff --git a/examples/fixed/Makefile b/examples/fixed/Makefile index 4fe88024b..941531b20 100644 --- a/examples/fixed/Makefile +++ b/examples/fixed/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + fixed: fixed.c - $(CC) `pkg-config --cflags gtk+-2.0` fixed.c -o fixed `pkg-config --libs gtk+-2.0` + $(CC) fixed.c -o fixed $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o fixed diff --git a/examples/fixed/fixed.c b/examples/fixed/fixed.c index 645f976cf..83d6990d7 100644 --- a/examples/fixed/fixed.c +++ b/examples/fixed/fixed.c @@ -1,4 +1,3 @@ -/* example-start fixed fixed.c */ #include <gtk/gtk.h> @@ -35,7 +34,7 @@ int main( int argc, gtk_window_set_title(GTK_WINDOW(window), "Fixed Container"); /* Here we connect the "destroy" event to a signal handler */ - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); /* Sets the border width of the window. */ @@ -53,7 +52,7 @@ int main( int argc, /* When the button receives the "clicked" signal, it will call the * function move_button() passing it the Fixed Container as its * argument. */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (move_button), fixed); /* This packs the button into the fixed containers window. */ @@ -69,6 +68,5 @@ int main( int argc, /* Enter the event loop */ gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/frame/Makefile b/examples/frame/Makefile index b8e389ab7..049b8c40a 100644 --- a/examples/frame/Makefile +++ b/examples/frame/Makefile @@ -1,8 +1,14 @@ CC = gcc -frame: frame.c - $(CC) `pkg-config --cflags gtk+-2.0` frame.c -o frame `pkg-config --libs gtk+-2.0` +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + +frame: frame.c + $(CC) frame.c -o frame $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o frame diff --git a/examples/frame/frame.c b/examples/frame/frame.c index e2cb09a39..05afcd476 100644 --- a/examples/frame/frame.c +++ b/examples/frame/frame.c @@ -1,4 +1,3 @@ -/* example-start frame frame.c */ #include <gtk/gtk.h> @@ -8,8 +7,6 @@ int main( int argc, /* GtkWidget is the storage type for widgets */ GtkWidget *window; GtkWidget *frame; - GtkWidget *button; - gint i; /* Initialise GTK */ gtk_init(&argc, &argv); @@ -19,10 +16,10 @@ int main( int argc, gtk_window_set_title(GTK_WINDOW(window), "Frame Example"); /* Here we connect the "destroy" event to a signal handler */ - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); - gtk_widget_set_usize(window, 300, 300); + gtk_widget_set_size_request (window, 300, 300); /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -47,6 +44,5 @@ int main( int argc, /* Enter the event loop */ gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/gtkdial/Makefile b/examples/gtkdial/Makefile index 1c388104e..0f83a9df0 100644 --- a/examples/gtkdial/Makefile +++ b/examples/gtkdial/Makefile @@ -1,14 +1,20 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + dial_test: gtkdial.o dial_test.o $(CC) dial_test.o gtkdial.o -o dial_test `pkg-config --libs gtk+-2.0` dial_test.o: dial_test.c gtkdial.h - $(CC) `pkg-config --cflags gtk+-2.0` -c dial_test.c -o dial_test.o + $(CC) -c dial_test.c -o dial_test.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags` gtkdial.o: gtkdial.c gtkdial.h - $(CC) `pkg-config --cflags gtk+-2.0` -c gtkdial.c -o gtkdial.o + $(CC) -c gtkdial.c -o gtkdial.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags` clean: rm -f *.o dial_test diff --git a/examples/gtkdial/dial_test.c b/examples/gtkdial/dial_test.c index ebcea0c7d..e753cc198 100644 --- a/examples/gtkdial/dial_test.c +++ b/examples/gtkdial/dial_test.c @@ -1,17 +1,19 @@ +#include <stdio.h> +#include <stdlib.h> #include <gtk/gtk.h> #include "gtkdial.h" -void -value_changed (GtkAdjustment *adjustment, GtkWidget *label) +void value_changed( GtkAdjustment *adjustment, + GtkWidget *label ) { char buffer[16]; sprintf(buffer,"%4.2f",adjustment->value); - gtk_label_set (GTK_LABEL (label), buffer); + gtk_label_set_text (GTK_LABEL (label), buffer); } -int -main (int argc, char *argv[]) +int main( int argc, + char *argv[]) { GtkWidget *window; GtkAdjustment *adjustment; @@ -26,10 +28,10 @@ main (int argc, char *argv[]) gtk_window_set_title (GTK_WINDOW (window), "Dial"); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (exit), NULL); - gtk_container_border_width (GTK_CONTAINER (window), 10); + gtk_container_set_border_width (GTK_CONTAINER (window), 10); vbox = gtk_vbox_new (FALSE, 5); gtk_container_add (GTK_CONTAINER (window), vbox); @@ -37,23 +39,23 @@ main (int argc, char *argv[]) frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX(vbox), frame, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (vbox), frame); gtk_widget_show (frame); - adjustment = GTK_ADJUSTMENT(gtk_adjustment_new (0, -1.0, 1.0, 0.01, 0.1, 0)); + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 100, 0.01, 0.1, 0)); dial = gtk_dial_new(adjustment); gtk_dial_set_update_policy (GTK_DIAL(dial), GTK_UPDATE_DELAYED); - /* gtk_widget_set_usize (dial, 100, 100); */ + /* gtk_widget_set_size_request (dial, 100, 100); */ gtk_container_add (GTK_CONTAINER (frame), dial); gtk_widget_show (dial); label = gtk_label_new("0.00"); - gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 0); + gtk_box_pack_end (GTK_BOX(vbox), label, 0, 0, 0); gtk_widget_show (label); - gtk_signal_connect (GTK_OBJECT(adjustment), "value_changed", + g_signal_connect (GTK_OBJECT(adjustment), "value_changed", GTK_SIGNAL_FUNC (value_changed), label); gtk_widget_show (window); diff --git a/examples/gtkdial/gtkdial.c b/examples/gtkdial/gtkdial.c index 51e70d2d6..0bd89fd13 100644 --- a/examples/gtkdial/gtkdial.c +++ b/examples/gtkdial/gtkdial.c @@ -1,4 +1,3 @@ -/* example-start gtkdial gtkdial.c */ /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald @@ -59,25 +58,27 @@ static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, static GtkWidgetClass *parent_class = NULL; -guint +GType gtk_dial_get_type () { - static guint dial_type = 0; + static GType dial_type = 0; if (!dial_type) { - GtkTypeInfo dial_info = + static const GTypeInfo dial_info = { - "GtkDial", - sizeof (GtkDial), sizeof (GtkDialClass), - (GtkClassInitFunc) gtk_dial_class_init, - (GtkObjectInitFunc) gtk_dial_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, + NULL, + NULL, + (GClassInitFunc) gtk_dial_class_init, + NULL, + NULL, + sizeof (GtkDial), + 0, + (GInstanceInitFunc) gtk_dial_init, }; - dial_type = gtk_type_unique (gtk_widget_get_type (), &dial_info); + dial_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkDial", &dial_info, 0); } return dial_type; @@ -125,7 +126,7 @@ gtk_dial_new (GtkAdjustment *adjustment) { GtkDial *dial; - dial = gtk_type_new (gtk_dial_get_type ()); + dial = g_object_new (gtk_dial_get_type (), NULL); if (!adjustment) adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0); @@ -146,7 +147,7 @@ gtk_dial_destroy (GtkObject *object) dial = GTK_DIAL (object); if (dial->adjustment) - gtk_object_unref (GTK_OBJECT (dial->adjustment)); + g_object_unref (GTK_OBJECT (dial->adjustment)); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -180,18 +181,18 @@ gtk_dial_set_adjustment (GtkDial *dial, if (dial->adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (dial->adjustment), (gpointer) dial); - gtk_object_unref (GTK_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; - gtk_object_ref (GTK_OBJECT (dial->adjustment)); + g_object_ref (GTK_OBJECT (dial->adjustment)); - gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - (GtkSignalFunc) gtk_dial_adjustment_changed, + g_signal_connect (GTK_OBJECT (adjustment), "changed", + GTK_SIGNAL_FUNC (gtk_dial_adjustment_changed), (gpointer) dial); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - (GtkSignalFunc) gtk_dial_adjustment_value_changed, + g_signal_connect (GTK_OBJECT (adjustment), "value_changed", + GTK_SIGNAL_FUNC (gtk_dial_adjustment_value_changed), (gpointer) dial); dial->old_value = adjustment->value; @@ -331,20 +332,23 @@ gtk_dial_expose (GtkWidget *widget, blankstyle->black_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - gtk_draw_polygon (blankstyle, + gtk_paint_polygon (blankstyle, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, + widget, + NULL, points, 5, FALSE); - gtk_style_unref(blankstyle); + g_object_unref(blankstyle); /* Draw ticks */ if ((upper - lower) == 0) - return; + return FALSE; increment = (100*M_PI)/(dial->radius*dial->radius); @@ -393,10 +397,13 @@ gtk_dial_expose (GtkWidget *widget, points[4].y = points[0].y; - gtk_draw_polygon (widget->style, + gtk_paint_polygon (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, + widget, + NULL, points, 5, TRUE); @@ -470,7 +477,7 @@ gtk_dial_button_release (GtkWidget *widget, if ((dial->policy != GTK_UPDATE_CONTINUOUS) && (dial->old_value != dial->adjustment->value)) - gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); } return FALSE; @@ -528,7 +535,7 @@ gtk_dial_timer (GtkDial *dial) g_return_val_if_fail (GTK_IS_DIAL (dial), FALSE); if (dial->policy == GTK_UPDATE_DELAYED) - gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); return FALSE; } @@ -564,11 +571,11 @@ gtk_dial_update_mouse (GtkDial *dial, gint x, gint y) { if (dial->policy == GTK_UPDATE_CONTINUOUS) { - gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); + g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); } else { - gtk_widget_draw (GTK_WIDGET(dial), NULL); + gtk_widget_queue_draw (GTK_WIDGET (dial)); if (dial->policy == GTK_UPDATE_DELAYED) { @@ -602,13 +609,13 @@ gtk_dial_update (GtkDial *dial) if (new_value != dial->adjustment->value) { dial->adjustment->value = new_value; - gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed"); + 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. / (dial->adjustment->upper - dial->adjustment->lower); - gtk_widget_draw (GTK_WIDGET(dial), NULL); + gtk_widget_queue_draw (GTK_WIDGET (dial)); } static void @@ -652,4 +659,3 @@ gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, dial->old_value = adjustment->value; } } -/* example-end */ diff --git a/examples/gtkdial/gtkdial.h b/examples/gtkdial/gtkdial.h index 781943548..850d7ea1e 100644 --- a/examples/gtkdial/gtkdial.h +++ b/examples/gtkdial/gtkdial.h @@ -1,4 +1,3 @@ -/* example-start gtkdial gtkdial.h */ /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald @@ -77,7 +76,7 @@ struct _GtkDialClass GtkWidget* gtk_dial_new (GtkAdjustment *adjustment); -guint gtk_dial_get_type (void); +GtkType gtk_dial_get_type (void); GtkAdjustment* gtk_dial_get_adjustment (GtkDial *dial); void gtk_dial_set_update_policy (GtkDial *dial, GtkUpdateType policy); @@ -90,4 +89,3 @@ void gtk_dial_set_adjustment (GtkDial *dial, #endif /* __GTK_DIAL_H__ */ -/* example-end */ diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile index 1a60bc6e4..0e3d0559d 100644 --- a/examples/helloworld/Makefile +++ b/examples/helloworld/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + helloworld: helloworld.c - $(CC) `pkg-config --cflags gtk+-2.0` helloworld.c -o helloworld `pkg-config --libs gtk+-2.0` + $(CC) helloworld.c -o helloworld $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o helloworld diff --git a/examples/helloworld/helloworld.c b/examples/helloworld/helloworld.c index eaa56fb32..64ac0f6bb 100644 --- a/examples/helloworld/helloworld.c +++ b/examples/helloworld/helloworld.c @@ -1,4 +1,3 @@ -/* example-start helloworld helloworld.c */ #include <gtk/gtk.h> @@ -54,13 +53,13 @@ int main( int argc, * titlebar), we ask it to call the delete_event () function * as defined above. The data passed to the callback * function is NULL and is ignored in the callback function. */ - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); /* Here we connect the "destroy" event to a signal handler. * This event occurs when we call gtk_widget_destroy() on the window, * or if we return FALSE in the "delete_event" callback. */ - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (destroy), NULL); /* Sets the border width of the window. */ @@ -72,13 +71,13 @@ int main( int argc, /* When the button receives the "clicked" signal, it will call the * function hello() passing it NULL as its argument. The hello() * function is defined above. */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (hello), NULL); /* This will cause the window to be destroyed by calling * gtk_widget_destroy(window) when "clicked". Again, the destroy * signal could come from here, or the window manager. */ - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); @@ -96,6 +95,5 @@ int main( int argc, * mouse event). */ gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/helloworld2/Makefile b/examples/helloworld2/Makefile index d1433bcb9..d574f2e4b 100644 --- a/examples/helloworld2/Makefile +++ b/examples/helloworld2/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + helloworld2: helloworld2.c - $(CC) `pkg-config --cflags gtk+-2.0` helloworld2.c -o helloworld2 `pkg-config --libs gtk+-2.0` + $(CC) helloworld2.c -o helloworld2 $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o helloworld2 diff --git a/examples/helloworld2/helloworld2.c b/examples/helloworld2/helloworld2.c index ae41fd15f..79bbd039d 100644 --- a/examples/helloworld2/helloworld2.c +++ b/examples/helloworld2/helloworld2.c @@ -1,4 +1,3 @@ -/* example-start helloworld2 helloworld2.c */ #include <gtk/gtk.h> @@ -40,7 +39,7 @@ int main( int argc, /* Here we just set a handler for delete_event that immediately * exits GTK. */ - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); /* Sets the border width of the window. */ @@ -56,10 +55,10 @@ int main( int argc, /* Creates a new button with the label "Button 1". */ button = gtk_button_new_with_label ("Button 1"); - + /* Now when the button is clicked, we call the "callback" function * with a pointer to "button 1" as its argument */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (callback), (gpointer) "button 1"); /* Instead of gtk_container_add, we pack this button into the invisible @@ -75,7 +74,7 @@ int main( int argc, /* Call the same callback function with a different argument, * passing a pointer to "button 2" instead. */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (callback), (gpointer) "button 2"); gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0); @@ -87,10 +86,9 @@ int main( int argc, gtk_widget_show(box1); gtk_widget_show (window); - + /* Rest in gtk_main and wait for the fun to begin! */ gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/label/Makefile b/examples/label/Makefile index 3cf6d9573..f59b4bb1d 100644 --- a/examples/label/Makefile +++ b/examples/label/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + label: label.c - $(CC) `pkg-config --cflags gtk+-2.0` label.c -o label `pkg-config --libs gtk+-2.0` + $(CC) label.c -o label $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o label diff --git a/examples/label/label.c b/examples/label/label.c index 5711a4c98..66420166a 100644 --- a/examples/label/label.c +++ b/examples/label/label.c @@ -1,4 +1,3 @@ -/* example-start label label.c */ #include <gtk/gtk.h> @@ -15,7 +14,7 @@ int main( int argc, gtk_init(&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); @@ -97,6 +96,5 @@ int main( int argc, gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/list/Makefile b/examples/list/Makefile index 33e5765b8..59cc93aa4 100644 --- a/examples/list/Makefile +++ b/examples/list/Makefile @@ -1,8 +1,16 @@ CC = gcc +#CFLAGS = -Wall \ +# -DG_DISABLE_DEPRECATED \ +# -DGDK_DISABLE_DEPRECATED \ +# -DGDK_PIXBUF_DISABLE_DEPRECATED \ +# -DGTK_DISABLE_DEPRECATED + +CFLAGS = + list: list.c - $(CC) `pkg-config --cflags gtk+-2.0` list.c -o list `pkg-config --libs gtk+-2.0` + $(CC) list.c -o list $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o list diff --git a/examples/list/list.c b/examples/list/list.c index 812786bdc..d797ae331 100644 --- a/examples/list/list.c +++ b/examples/list/list.c @@ -1,10 +1,9 @@ -/* example-start list list.c */ /* Include the GTK header files * Include stdio.h, we need that for the printf() function */ -#include <gtk/gtk.h> -#include <stdio.h> +#include <gtk/gtk.h> +#include <stdio.h> /* This is our data identification string to store * data in list items @@ -52,7 +51,7 @@ gint main( int argc, */ window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "GtkList Example"); - gtk_signal_connect(GTK_OBJECT(window), + g_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); @@ -61,13 +60,13 @@ gint main( int argc, /* Inside the window we need a box to arrange the widgets * vertically */ vbox=gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); /* This is the scrolled window to put the List widget inside */ scrolled_window=gtk_scrolled_window_new(NULL, NULL); - gtk_widget_set_usize(scrolled_window, 250, 150); + gtk_widget_set_size_request (scrolled_window, 250, 150); gtk_container_add(GTK_CONTAINER(vbox), scrolled_window); gtk_widget_show(scrolled_window); @@ -87,8 +86,8 @@ gint main( int argc, /* We create a "Prison" to put a list item in ;) */ frame=gtk_frame_new("Prison"); - gtk_widget_set_usize(frame, 200, 50); - gtk_container_set_border_width(GTK_CONTAINER(frame), 5); + gtk_widget_set_size_request (frame, 200, 50); + gtk_container_set_border_width (GTK_CONTAINER (frame), 5); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(vbox), frame); gtk_widget_show(frame); @@ -267,7 +266,7 @@ void sigh_print_selection( GtkWidget *gtklist, gchar *item_data_string; list_item=GTK_OBJECT(dlist->data); - item_data_string=gtk_object_get_data(list_item, + item_data_string=g_object_get_data(G_OBJECT (list_item), list_item_data_key); g_print("%s ", item_data_string); @@ -275,4 +274,3 @@ void sigh_print_selection( GtkWidget *gtklist, } g_print("\n"); } -/* example-end */ diff --git a/examples/menu/Makefile b/examples/menu/Makefile index 8c4489ce4..290ac1792 100644 --- a/examples/menu/Makefile +++ b/examples/menu/Makefile @@ -1,13 +1,19 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + all: menu itemfactory menu: menu.c - $(CC) `pkg-config --cflags gtk+-2.0` menu.c -o menu `pkg-config --libs gtk+-2.0` + $(CC) menu.c -o menu $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` itemfactory: itemfactory.c - $(CC) `pkg-config --cflags gtk+-2.0` itemfactory.c -o itemfactory `pkg-config --libs gtk+-2.0` + $(CC) itemfactory.c -o itemfactory $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o menu itemfactory diff --git a/examples/menu/itemfactory.c b/examples/menu/itemfactory.c index d1239baff..e8932f37c 100644 --- a/examples/menu/itemfactory.c +++ b/examples/menu/itemfactory.c @@ -1,4 +1,3 @@ -/* example-start menu itemfactory.c */ #include <gtk/gtk.h> #include <strings.h> @@ -91,14 +90,14 @@ int main( int argc, gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), "WM destroy"); gtk_window_set_title (GTK_WINDOW(window), "Item Factory"); - gtk_widget_set_usize (GTK_WIDGET(window), 300, 200); + gtk_widget_set_size_request (GTK_WIDGET (window), 300, 200); main_vbox = gtk_vbox_new (FALSE, 1); - gtk_container_border_width (GTK_CONTAINER (main_vbox), 1); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1); gtk_container_add (GTK_CONTAINER (window), main_vbox); gtk_widget_show (main_vbox); @@ -109,6 +108,5 @@ int main( int argc, gtk_widget_show (window); gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/menu/menu.c b/examples/menu/menu.c index e1420e80a..c8479097c 100644 --- a/examples/menu/menu.c +++ b/examples/menu/menu.c @@ -1,5 +1,5 @@ -/* example-start menu menu.c */ +#include <stdio.h> #include <gtk/gtk.h> static gint button_press (GtkWidget *, GdkEvent *); @@ -23,9 +23,9 @@ int main( int argc, /* create a new window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize (GTK_WIDGET (window), 200, 100); + gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); gtk_window_set_title (GTK_WINDOW (window), "GTK Menu Test"); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", (GtkSignalFunc) gtk_main_quit, NULL); /* Init the menu-widget, and remember -- never @@ -49,10 +49,10 @@ int main( int argc, menu_items = gtk_menu_item_new_with_label (buf); /* ...and add it to the menu. */ - gtk_menu_append (GTK_MENU (menu), menu_items); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); /* Do something interesting when the menuitem is selected */ - gtk_signal_connect_object (GTK_OBJECT (menu_items), "activate", + g_signal_connect_swapped (GTK_OBJECT (menu_items), "activate", GTK_SIGNAL_FUNC (menuitem_response), (gpointer) g_strdup (buf)); /* Show the widget */ @@ -82,14 +82,14 @@ int main( int argc, /* Create a button to which to attach menu as a popup */ button = gtk_button_new_with_label ("press me"); - gtk_signal_connect_object (GTK_OBJECT (button), "event", + g_signal_connect_swapped (GTK_OBJECT (button), "event", GTK_SIGNAL_FUNC (button_press), GTK_OBJECT (menu)); gtk_box_pack_end (GTK_BOX (vbox), button, TRUE, TRUE, 2); gtk_widget_show (button); /* And finally we append the menu-item to the menu-bar -- this is the * "root" menu-item I have been raving about =) */ - gtk_menu_bar_append (GTK_MENU_BAR (menu_bar), root_menu); + gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu); /* always display the window as the last step so it all splashes on * the screen at once. */ @@ -97,7 +97,7 @@ int main( int argc, gtk_main (); - return(0); + return 0; } /* Respond to a button-press by posting a menu passed in as widget. @@ -130,4 +130,3 @@ static void menuitem_response( gchar *string ) { printf ("%s\n", string); } -/* example-end */ diff --git a/examples/notebook/Makefile b/examples/notebook/Makefile index fcfda957f..7ab745a7d 100644 --- a/examples/notebook/Makefile +++ b/examples/notebook/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + notebook: notebook.c - $(CC) `pkg-config --cflags gtk+-2.0` notebook.c -o notebook `pkg-config --libs gtk+-2.0` + $(CC) notebook.c -o notebook $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o notebook diff --git a/examples/notebook/notebook.c b/examples/notebook/notebook.c index 79c4bc414..3a5808fcb 100644 --- a/examples/notebook/notebook.c +++ b/examples/notebook/notebook.c @@ -1,5 +1,5 @@ -/* example-start notebook notebook.c */ +#include <stdio.h> #include <gtk/gtk.h> /* This function rotates the position of the tabs */ @@ -34,15 +34,15 @@ void remove_book( GtkButton *button, gtk_notebook_remove_page (notebook, page); /* Need to refresh the widget -- This forces the widget to redraw itself. */ - gtk_widget_draw(GTK_WIDGET(notebook), NULL); + gtk_widget_queue_draw (GTK_WIDGET (notebook)); } gint delete( GtkWidget *widget, GtkWidget *event, gpointer data ) { - gtk_main_quit(); - return(FALSE); + gtk_main_quit (); + return FALSE; } int main( int argc, @@ -63,7 +63,7 @@ int main( int argc, window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -84,7 +84,7 @@ int main( int argc, frame = gtk_frame_new (bufferf); gtk_container_set_border_width (GTK_CONTAINER (frame), 10); - gtk_widget_set_usize (frame, 100, 75); + gtk_widget_set_size_request (frame, 100, 75); gtk_widget_show (frame); label = gtk_label_new (bufferf); @@ -97,7 +97,7 @@ int main( int argc, /* Now let's add a page to a specific spot */ checkbutton = gtk_check_button_new_with_label ("Check me please!"); - gtk_widget_set_usize(checkbutton, 100, 75); + gtk_widget_set_size_request (checkbutton, 100, 75); gtk_widget_show (checkbutton); label = gtk_label_new ("Add page"); @@ -110,7 +110,7 @@ int main( int argc, frame = gtk_frame_new (bufferf); gtk_container_set_border_width (GTK_CONTAINER (frame), 10); - gtk_widget_set_usize (frame, 100, 75); + gtk_widget_set_size_request (frame, 100, 75); gtk_widget_show (frame); label = gtk_label_new (bufferf); @@ -122,46 +122,46 @@ int main( int argc, } /* Set what page to start at (page 4) */ - gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 3); + gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 3); /* Create a bunch of buttons */ button = gtk_button_new_with_label ("close"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (delete), NULL); gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,1,2); gtk_widget_show(button); button = gtk_button_new_with_label ("next page"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) gtk_notebook_next_page, + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (gtk_notebook_next_page), GTK_OBJECT (notebook)); gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,1,2); gtk_widget_show(button); button = gtk_button_new_with_label ("prev page"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) gtk_notebook_prev_page, + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (gtk_notebook_prev_page), GTK_OBJECT (notebook)); gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,1,2); gtk_widget_show(button); button = gtk_button_new_with_label ("tab position"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) rotate_book, + g_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (rotate_book), GTK_OBJECT(notebook)); gtk_table_attach_defaults(GTK_TABLE(table), button, 3,4,1,2); gtk_widget_show(button); button = gtk_button_new_with_label ("tabs/border on/off"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) tabsborder_book, + g_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (tabsborder_book), GTK_OBJECT (notebook)); gtk_table_attach_defaults(GTK_TABLE(table), button, 4,5,1,2); gtk_widget_show(button); button = gtk_button_new_with_label ("remove page"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) remove_book, + g_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (remove_book), GTK_OBJECT(notebook)); gtk_table_attach_defaults(GTK_TABLE(table), button, 5,6,1,2); gtk_widget_show(button); @@ -171,6 +171,5 @@ int main( int argc, gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/packbox/Makefile b/examples/packbox/Makefile index b61a8fc8d..b837519d7 100644 --- a/examples/packbox/Makefile +++ b/examples/packbox/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + packbox: packbox.c - $(CC) `pkg-config --cflags gtk+-2.0` packbox.c -o packbox `pkg-config --libs gtk+-2.0` + $(CC) packbox.c -o packbox $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o packbox diff --git a/examples/packbox/packbox.c b/examples/packbox/packbox.c index 637836d30..ed7fa7219 100644 --- a/examples/packbox/packbox.c +++ b/examples/packbox/packbox.c @@ -1,4 +1,3 @@ -/* example-start packbox packbox.c */ #include <stdio.h> #include <stdlib.h> @@ -9,7 +8,7 @@ gint delete_event( GtkWidget *widget, gpointer data ) { gtk_main_quit(); - return(FALSE); + return FALSE; } /* Make a new hbox filled with button-labels. Arguments for the @@ -85,7 +84,7 @@ int main( int argc, if (argc != 2) { fprintf (stderr, "usage: packbox num, where num is 1, 2, or 3.\n"); /* This just does cleanup in GTK and exits with an exit status of 1. */ - gtk_exit (1); + exit (1); } which = atoi (argv[1]); @@ -96,7 +95,7 @@ int main( int argc, /* You should always remember to connect the delete_event signal * to the main window. This is very important for proper intuitive * behavior */ - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -246,7 +245,7 @@ int main( int argc, * and the "end" label will be separated from the other labels in the * hbox. Otherwise, all the widgets in the hbox would be packed as * close together as possible. */ - gtk_widget_set_usize (separator, 400, 5); + gtk_widget_set_size_request (separator, 400, 5); /* pack the separator into the vbox (box1) created near the start * of main() */ gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); @@ -260,7 +259,7 @@ int main( int argc, button = gtk_button_new_with_label ("Quit"); /* Setup the signal to terminate the program when the button is clicked */ - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_main_quit), GTK_OBJECT (window)); /* Pack the button into the quitbox. @@ -288,6 +287,5 @@ int main( int argc, /* Control returns here when gtk_main_quit() is called, but not when * gtk_exit is used. */ - return(0); + return 0; } -/* example-end */ diff --git a/examples/paned/Makefile b/examples/paned/Makefile index dc894a289..857e53fe2 100644 --- a/examples/paned/Makefile +++ b/examples/paned/Makefile @@ -1,8 +1,16 @@ CC = gcc +#CFLAGS = -Wall \ +# -DG_DISABLE_DEPRECATED \ +# -DGDK_DISABLE_DEPRECATED \ +# -DGDK_PIXBUF_DISABLE_DEPRECATED \ +# -DGTK_DISABLE_DEPRECATED + +CFLAGS = -DGTK_ENABLE_BROKEN + paned: paned.c - $(CC) `pkg-config --cflags gtk+-2.0` paned.c -o paned `pkg-config --libs gtk+-2.0` + $(CC) paned.c -o paned $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o paned diff --git a/examples/paned/paned.c b/examples/paned/paned.c index 7fafb33ad..ce19ea6c8 100644 --- a/examples/paned/paned.c +++ b/examples/paned/paned.c @@ -1,5 +1,5 @@ -/* example-start paned paned.c */ +#include <stdio.h> #include <gtk/gtk.h> /* Create the list of "messages" */ @@ -113,16 +113,12 @@ int main( int argc, gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_widget_set_usize (GTK_WIDGET(window), 450, 400); + gtk_widget_set_size_request (GTK_WIDGET (window), 450, 400); /* create a vpaned widget and add it to our toplevel window */ vpaned = gtk_vpaned_new (); gtk_container_add (GTK_CONTAINER(window), vpaned); - gtk_paned_set_handle_size (GTK_PANED(vpaned), - 10); - gtk_paned_set_gutter_size (GTK_PANED(vpaned), - 15); gtk_widget_show (vpaned); /* Now create the contents of the two halves of the window */ @@ -138,4 +134,3 @@ int main( int argc, gtk_main (); return 0; } -/* example-end */ diff --git a/examples/pixmap/Makefile b/examples/pixmap/Makefile index 7e421f7cb..34c625ed6 100644 --- a/examples/pixmap/Makefile +++ b/examples/pixmap/Makefile @@ -1,8 +1,16 @@ CC = gcc +#CFLAGS = -Wall \ +# -DG_DISABLE_DEPRECATED \ +# -DGDK_DISABLE_DEPRECATED \ +# -DGDK_PIXBUF_DISABLE_DEPRECATED \ +# -DGTK_DISABLE_DEPRECATED + +CFLAGS = + pixmap: pixmap.c - $(CC) `pkg-config --cflags gtk+-2.0` pixmap.c -o pixmap `pkg-config --libs gtk+-2.0` + $(CC) pixmap.c -o pixmap $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o pixmap diff --git a/examples/pixmap/pixmap.c b/examples/pixmap/pixmap.c index 8834c9e2b..71af08e58 100644 --- a/examples/pixmap/pixmap.c +++ b/examples/pixmap/pixmap.c @@ -1,4 +1,3 @@ -/* example-start pixmap pixmap.c */ #include <gtk/gtk.h> @@ -87,4 +86,3 @@ int main( int argc, return 0; } -/* example-end */ diff --git a/examples/progressbar/Makefile b/examples/progressbar/Makefile index 419041619..f13f5ef62 100644 --- a/examples/progressbar/Makefile +++ b/examples/progressbar/Makefile @@ -1,8 +1,16 @@ CC = gcc +#CFLAGS = -Wall \ +# -DG_DISABLE_DEPRECATED \ +# -DGDK_DISABLE_DEPRECATED \ +# -DGDK_PIXBUF_DISABLE_DEPRECATED \ +# -DGTK_DISABLE_DEPRECATED + +CFLAGS = + progressbar: progressbar.c - $(CC) `pkg-config --cflags gtk+-2.0` progressbar.c -o progressbar `pkg-config --libs gtk+-2.0` + $(CC) progressbar.c -o progressbar $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o progressbar diff --git a/examples/progressbar/progressbar.c b/examples/progressbar/progressbar.c index 1a824e286..089df1404 100644 --- a/examples/progressbar/progressbar.c +++ b/examples/progressbar/progressbar.c @@ -1,4 +1,3 @@ -/* example-start progressbar progressbar.c */ #include <gtk/gtk.h> @@ -29,7 +28,7 @@ gint progress_timeout( gpointer data ) /* As this is a timeout function, return TRUE so that it * continues to get called */ - return(TRUE); + return TRUE; } /* Callback that toggles the text display within the progress @@ -97,9 +96,9 @@ int main( int argc, pdata = g_malloc( sizeof(ProgressData) ); pdata->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_policy (GTK_WINDOW (pdata->window), FALSE, FALSE, TRUE); + gtk_window_set_resizable (GTK_WINDOW (pdata->window), TRUE); - gtk_signal_connect (GTK_OBJECT (pdata->window), "destroy", + g_signal_connect (GTK_OBJECT (pdata->window), "destroy", GTK_SIGNAL_FUNC (destroy_progress), pdata); gtk_window_set_title (GTK_WINDOW (pdata->window), "GtkProgressBar"); @@ -150,7 +149,7 @@ int main( int argc, gtk_table_attach (GTK_TABLE (table), check, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5); - gtk_signal_connect (GTK_OBJECT (check), "clicked", + g_signal_connect (GTK_OBJECT (check), "clicked", GTK_SIGNAL_FUNC (toggle_show_text), pdata); gtk_widget_show(check); @@ -160,7 +159,7 @@ int main( int argc, gtk_table_attach (GTK_TABLE (table), check, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5); - gtk_signal_connect (GTK_OBJECT (check), "clicked", + g_signal_connect (GTK_OBJECT (check), "clicked", GTK_SIGNAL_FUNC (toggle_activity_mode), pdata); gtk_widget_show(check); @@ -176,19 +175,19 @@ int main( int argc, gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (set_continuous_mode), pdata); gtk_widget_show (button); /* Add a radio button to select discrete display mode */ button = gtk_radio_button_new_with_label( - gtk_radio_button_group (GTK_RADIO_BUTTON (button)), + gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)), "Discrete"); gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (set_discrete_mode), pdata); gtk_widget_show (button); @@ -199,7 +198,7 @@ int main( int argc, /* Add a button to exit the program */ button = gtk_button_new_with_label ("close"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (pdata->window)); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); @@ -216,6 +215,5 @@ int main( int argc, gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/radiobuttons/Makefile b/examples/radiobuttons/Makefile index c62cfad4c..43efadeee 100644 --- a/examples/radiobuttons/Makefile +++ b/examples/radiobuttons/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + radiobuttons: radiobuttons.c - $(CC) `pkg-config --cflags gtk+-2.0` radiobuttons.c -o radiobuttons `pkg-config --libs gtk+-2.0` + $(CC) radiobuttons.c -o radiobuttons $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o radiobuttons diff --git a/examples/radiobuttons/radiobuttons.c b/examples/radiobuttons/radiobuttons.c index 8fc81872f..15399ba19 100644 --- a/examples/radiobuttons/radiobuttons.c +++ b/examples/radiobuttons/radiobuttons.c @@ -1,14 +1,13 @@ -/* example-start radiobuttons radiobuttons.c */ -#include <gtk/gtk.h> #include <glib.h> +#include <gtk/gtk.h> gint close_application( GtkWidget *widget, GdkEvent *event, gpointer data ) { gtk_main_quit(); - return(FALSE); + return FALSE; } int main( int argc, @@ -25,7 +24,7 @@ int main( int argc, window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(close_application), NULL); @@ -45,14 +44,14 @@ int main( int argc, gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); button = gtk_radio_button_new_with_label(group, "button2"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); 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_group (GTK_RADIO_BUTTON (button)), + gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)), "button3"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); @@ -67,7 +66,7 @@ int main( int argc, gtk_widget_show (box2); button = gtk_button_new_with_label ("close"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(close_application), GTK_OBJECT (window)); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); @@ -78,6 +77,5 @@ int main( int argc, gtk_main(); - return(0); + return 0; } -/* example-end */ diff --git a/examples/rangewidgets/Makefile b/examples/rangewidgets/Makefile index f0e59666b..4ca6e0dd3 100644 --- a/examples/rangewidgets/Makefile +++ b/examples/rangewidgets/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + rangewidgets: rangewidgets.c - $(CC) `pkg-config --cflags gtk+-2.0` rangewidgets.c -o rangewidgets `pkg-config --libs gtk+-2.0` + $(CC) rangewidgets.c -o rangewidgets $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o rangewidgets diff --git a/examples/rangewidgets/rangewidgets.c b/examples/rangewidgets/rangewidgets.c index e293664f0..4c38e8c30 100644 --- a/examples/rangewidgets/rangewidgets.c +++ b/examples/rangewidgets/rangewidgets.c @@ -1,4 +1,3 @@ -/* example-start rangewidgets rangewidgets.c */ #include <gtk/gtk.h> @@ -36,7 +35,7 @@ void cb_page_size( GtkAdjustment *get, set->page_increment = get->value; /* Now emit the "changed" signal to reconfigure all the widgets that * are attached to this adjustment */ - gtk_signal_emit_by_name (GTK_OBJECT (set), "changed"); + g_signal_emit_by_name (GTK_OBJECT (set), "changed"); } void cb_draw_value( GtkToggleButton *button ) @@ -56,11 +55,11 @@ GtkWidget *make_menu_item( gchar *name, GtkWidget *item; item = gtk_menu_item_new_with_label (name); - gtk_signal_connect (GTK_OBJECT (item), "activate", + g_signal_connect (GTK_OBJECT (item), "activate", callback, data); gtk_widget_show (item); - return(item); + return item; } void scale_set_default_values( GtkScale *scale ) @@ -88,7 +87,7 @@ void create_range_controls( void ) /* Standard window-creating stuff */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_window_set_title (GTK_WINDOW (window), "range controls"); @@ -119,7 +118,7 @@ void create_range_controls( void ) /* Reuse the same adjustment */ hscale = gtk_hscale_new (GTK_ADJUSTMENT (adj1)); - gtk_widget_set_usize (GTK_WIDGET (hscale), 200, 30); + gtk_widget_set_size_request (GTK_WIDGET (hscale), 200, 30); scale_set_default_values (GTK_SCALE (hscale)); gtk_box_pack_start (GTK_BOX (box3), hscale, TRUE, TRUE, 0); gtk_widget_show (hscale); @@ -141,7 +140,7 @@ void create_range_controls( void ) /* A checkbutton to control whether the value is displayed or not */ button = gtk_check_button_new_with_label("Display value on scale widgets"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - gtk_signal_connect (GTK_OBJECT (button), "toggled", + g_signal_connect (GTK_OBJECT (button), "toggled", GTK_SIGNAL_FUNC(cb_draw_value), NULL); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); @@ -160,19 +159,19 @@ void create_range_controls( void ) item = make_menu_item ("Top", GTK_SIGNAL_FUNC(cb_pos_menu_select), GINT_TO_POINTER (GTK_POS_TOP)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = make_menu_item ("Bottom", GTK_SIGNAL_FUNC (cb_pos_menu_select), GINT_TO_POINTER (GTK_POS_BOTTOM)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = make_menu_item ("Left", GTK_SIGNAL_FUNC (cb_pos_menu_select), GINT_TO_POINTER (GTK_POS_LEFT)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = make_menu_item ("Right", GTK_SIGNAL_FUNC (cb_pos_menu_select), GINT_TO_POINTER (GTK_POS_RIGHT)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_option_menu_set_menu (GTK_OPTION_MENU (opt), menu); gtk_box_pack_start (GTK_BOX (box2), opt, TRUE, TRUE, 0); @@ -196,17 +195,17 @@ void create_range_controls( void ) item = make_menu_item ("Continuous", GTK_SIGNAL_FUNC (cb_update_menu_select), GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = make_menu_item ("Discontinuous", GTK_SIGNAL_FUNC (cb_update_menu_select), GINT_TO_POINTER (GTK_UPDATE_DISCONTINUOUS)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = make_menu_item ("Delayed", GTK_SIGNAL_FUNC (cb_update_menu_select), GINT_TO_POINTER (GTK_UPDATE_DELAYED)); - gtk_menu_append (GTK_MENU (menu), item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_option_menu_set_menu (GTK_OPTION_MENU (opt), menu); gtk_box_pack_start (GTK_BOX (box2), opt, TRUE, TRUE, 0); @@ -225,7 +224,7 @@ void create_range_controls( void ) gtk_widget_show (label); adj2 = gtk_adjustment_new (1.0, 0.0, 5.0, 1.0, 1.0, 0.0); - gtk_signal_connect (GTK_OBJECT (adj2), "value_changed", + g_signal_connect (GTK_OBJECT (adj2), "value_changed", GTK_SIGNAL_FUNC (cb_digits_scale), NULL); scale = gtk_hscale_new (GTK_ADJUSTMENT (adj2)); gtk_scale_set_digits (GTK_SCALE (scale), 0); @@ -245,7 +244,7 @@ void create_range_controls( void ) gtk_widget_show (label); adj2 = gtk_adjustment_new (1.0, 1.0, 101.0, 1.0, 1.0, 0.0); - gtk_signal_connect (GTK_OBJECT (adj2), "value_changed", + g_signal_connect (GTK_OBJECT (adj2), "value_changed", GTK_SIGNAL_FUNC (cb_page_size), adj1); scale = gtk_hscale_new (GTK_ADJUSTMENT (adj2)); gtk_scale_set_digits (GTK_SCALE (scale), 0); @@ -265,7 +264,7 @@ void create_range_controls( void ) gtk_widget_show (box2); button = gtk_button_new_with_label ("Quit"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); @@ -285,7 +284,6 @@ int main( int argc, gtk_main(); - return(0); + return 0; } -/* example-end */ diff --git a/examples/rulers/Makefile b/examples/rulers/Makefile index d4eb71b40..336183ccf 100644 --- a/examples/rulers/Makefile +++ b/examples/rulers/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + rulers: rulers.c - $(CC) `pkg-config --cflags gtk+-2.0` rulers.c -o rulers `pkg-config --libs gtk+-2.0` + $(CC) rulers.c -o rulers $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o rulers diff --git a/examples/rulers/rulers.c b/examples/rulers/rulers.c index fa933f172..f001e9f82 100644 --- a/examples/rulers/rulers.c +++ b/examples/rulers/rulers.c @@ -1,8 +1,7 @@ -/* example-start rulers rulers.c */ #include <gtk/gtk.h> -#define EVENT_METHOD(i, x) GTK_WIDGET_CLASS(GTK_OBJECT(i)->klass)->x +#define EVENT_METHOD(i, x) GTK_WIDGET_GET_CLASS(i)->x #define XSIZE 600 #define YSIZE 400 @@ -13,7 +12,7 @@ gint close_application( GtkWidget *widget, gpointer data ) { gtk_main_quit(); - return(FALSE); + return FALSE; } /* The main routine */ @@ -25,7 +24,7 @@ int main( int argc, gtk_init( &argc, &argv ); window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( close_application ), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -34,7 +33,7 @@ int main( int argc, gtk_container_add( GTK_CONTAINER(window), table ); area = gtk_drawing_area_new(); - gtk_drawing_area_size( (GtkDrawingArea *)area, XSIZE, YSIZE ); + gtk_widget_set_size_request (GTK_WIDGET (area), XSIZE, YSIZE); gtk_table_attach( GTK_TABLE(table), area, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0 ); gtk_widget_set_events( area, GDK_POINTER_MOTION_MASK | @@ -46,11 +45,10 @@ int main( int argc, hrule = gtk_hruler_new(); gtk_ruler_set_metric( GTK_RULER(hrule), GTK_PIXELS ); gtk_ruler_set_range( GTK_RULER(hrule), 7, 13, 0, 20 ); - gtk_signal_connect_object( GTK_OBJECT(area), "motion_notify_event", + g_signal_connect_swapped( GTK_OBJECT(area), "motion_notify_event", (GtkSignalFunc)EVENT_METHOD(hrule, motion_notify_event), GTK_OBJECT(hrule) ); - /* GTK_WIDGET_CLASS(GTK_OBJECT(hrule)->klass)->motion_notify_event, */ gtk_table_attach( GTK_TABLE(table), hrule, 1, 2, 0, 1, GTK_EXPAND|GTK_SHRINK|GTK_FILL, GTK_FILL, 0, 0 ); @@ -60,10 +58,9 @@ int main( int argc, vrule = gtk_vruler_new(); gtk_ruler_set_metric( GTK_RULER(vrule), GTK_PIXELS ); gtk_ruler_set_range( GTK_RULER(vrule), 0, YSIZE, 10, YSIZE ); - gtk_signal_connect_object( GTK_OBJECT(area), "motion_notify_event", - (GtkSignalFunc) - GTK_WIDGET_CLASS(GTK_OBJECT(vrule)->klass)-> - motion_notify_event, + g_signal_connect_swapped( GTK_OBJECT(area), "motion_notify_event", + (GtkSignalFunc)EVENT_METHOD(vrule, + motion_notify_event), GTK_OBJECT(vrule) ); gtk_table_attach( GTK_TABLE(table), vrule, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0 ); @@ -76,6 +73,5 @@ int main( int argc, gtk_widget_show( window ); gtk_main(); - return(0); + return 0; } -/* example-end */ diff --git a/examples/scribble-simple/Makefile b/examples/scribble-simple/Makefile index 4ded4c992..53c53aa2a 100644 --- a/examples/scribble-simple/Makefile +++ b/examples/scribble-simple/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + scribble-simple: scribble-simple.c - $(CC) `pkg-config --cflags gtk+-2.0` scribble-simple.c -o scribble-simple `pkg-config --libs gtk+-2.0` + $(CC) scribble-simple.c -o scribble-simple $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o scribble-simple diff --git a/examples/scribble-simple/scribble-simple.c b/examples/scribble-simple/scribble-simple.c index 3e6bdf30f..481c67058 100644 --- a/examples/scribble-simple/scribble-simple.c +++ b/examples/scribble-simple/scribble-simple.c @@ -1,4 +1,3 @@ -/* example-start scribble-simple scribble-simple.c */ /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald @@ -29,7 +28,7 @@ static gint configure_event( GtkWidget *widget, GdkEventConfigure *event ) { if (pixmap) - gdk_pixmap_unref(pixmap); + g_object_unref(pixmap); pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, @@ -49,7 +48,7 @@ static gint configure_event( GtkWidget *widget, static gint expose_event( GtkWidget *widget, GdkEventExpose *event ) { - gdk_draw_pixmap(widget->window, + gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pixmap, event->area.x, event->area.y, @@ -75,7 +74,9 @@ static void draw_brush( GtkWidget *widget, TRUE, update_rect.x, update_rect.y, update_rect.width, update_rect.height); - gtk_widget_draw (widget, &update_rect); + gtk_widget_queue_draw_area (widget, + update_rect.x, update_rect.y, + update_rect.width, update_rect.height); } static gint button_press_event( GtkWidget *widget, @@ -110,7 +111,7 @@ static gint motion_notify_event( GtkWidget *widget, void quit () { - gtk_exit (0); + exit (0); } int main( int argc, @@ -131,29 +132,29 @@ int main( int argc, gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (quit), NULL); /* Create the drawing area */ drawing_area = gtk_drawing_area_new (); - gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200); + gtk_widget_set_size_request (GTK_WIDGET (drawing_area), 200, 200); gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0); gtk_widget_show (drawing_area); /* Signals used to handle backing pixmap */ - gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", + g_signal_connect (GTK_OBJECT (drawing_area), "expose_event", (GtkSignalFunc) expose_event, NULL); - gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event", + g_signal_connect (GTK_OBJECT(drawing_area),"configure_event", (GtkSignalFunc) configure_event, NULL); /* Event signals */ - gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", + g_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", (GtkSignalFunc) motion_notify_event, NULL); - gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", + g_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", (GtkSignalFunc) button_press_event, NULL); gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK @@ -166,7 +167,7 @@ int main( int argc, button = gtk_button_new_with_label ("Quit"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); gtk_widget_show (button); @@ -177,4 +178,3 @@ int main( int argc, return 0; } -/* example-end */ diff --git a/examples/scribble-xinput/Makefile b/examples/scribble-xinput/Makefile index 5d38b2a0f..47d24b4c3 100644 --- a/examples/scribble-xinput/Makefile +++ b/examples/scribble-xinput/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + scribble-xinput: scribble-xinput.c - $(CC) `pkg-config --cflags gtk+-2.0` scribble-xinput.c -o scribble-xinput `pkg-config --libs gtk+-2.0` + $(CC) scribble-xinput.c -o scribble-xinput $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o scribble-xinput diff --git a/examples/scribble-xinput/scribble-xinput.c b/examples/scribble-xinput/scribble-xinput.c index 81d4e6423..3519b6249 100644 --- a/examples/scribble-xinput/scribble-xinput.c +++ b/examples/scribble-xinput/scribble-xinput.c @@ -1,4 +1,3 @@ -/* example-start scribble-xinput scribble-xinput.c */ /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald @@ -29,7 +28,7 @@ static gint configure_event (GtkWidget *widget, GdkEventConfigure *event) { if (pixmap) - gdk_pixmap_unref(pixmap); + g_object_unref(pixmap); pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, @@ -49,7 +48,7 @@ configure_event (GtkWidget *widget, GdkEventConfigure *event) static gint expose_event (GtkWidget *widget, GdkEventExpose *event) { - gdk_draw_pixmap(widget->window, + gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pixmap, event->area.x, event->area.y, @@ -90,39 +89,27 @@ draw_brush (GtkWidget *widget, GdkInputSource source, gdk_draw_rectangle (pixmap, gc, TRUE, update_rect.x, update_rect.y, update_rect.width, update_rect.height); - gtk_widget_draw (widget, &update_rect); + gtk_widget_queue_draw_area (widget, + update_rect.x, update_rect.y, + update_rect.width, update_rect.height); } static void -print_button_press (guint32 deviceid) +print_button_press (GdkDevice *device) { - GList *tmp_list; - - /* gdk_input_list_devices returns an internal list, so we shouldn't - free it afterwards */ - tmp_list = gdk_input_list_devices(); - - while (tmp_list) - { - GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data; - - if (info->deviceid == deviceid) - { - g_print("Button press on device '%s'\n", info->name); - return; - } - - tmp_list = tmp_list->next; - } + g_print("Button press on device '%s'\n", device->name); } static gint button_press_event (GtkWidget *widget, GdkEventButton *event) { - print_button_press (event->deviceid); + print_button_press (event->device); - if (event->button == 1 && pixmap != NULL) - draw_brush (widget, event->source, event->x, event->y, event->pressure); + if (event->button == 1 && pixmap != NULL) { + gdouble pressure; + gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure); + draw_brush (widget, event->device->source, event->x, event->y, pressure); + } return TRUE; } @@ -134,20 +121,23 @@ motion_notify_event (GtkWidget *widget, GdkEventMotion *event) gdouble pressure; GdkModifierType state; - if (event->is_hint) - gdk_input_window_get_pointer (event->window, event->deviceid, - &x, &y, &pressure, - NULL, NULL, &state); + if (event->is_hint) + { + gdk_device_get_state (event->device, event->window, NULL, &state); + gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_X, &x); + gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_Y, &y); + gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure); + } else { x = event->x; y = event->y; - pressure = event->pressure; + gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure); state = event->state; } if (state & GDK_BUTTON1_MASK && pixmap != NULL) - draw_brush (widget, event->source, x, y, pressure); + draw_brush (widget, event->device->source, x, y, pressure); return TRUE; } @@ -167,9 +157,9 @@ create_input_dialog () { inputd = gtk_input_dialog_new(); - gtk_signal_connect (GTK_OBJECT(inputd), "destroy", + g_signal_connect (GTK_OBJECT(inputd), "destroy", (GtkSignalFunc)input_dialog_destroy, &inputd); - gtk_signal_connect_object (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), + g_signal_connect_swapped (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button), "clicked", (GtkSignalFunc)gtk_widget_hide, GTK_OBJECT(inputd)); @@ -189,7 +179,7 @@ create_input_dialog () void quit () { - gtk_exit (0); + exit (0); } int @@ -210,29 +200,29 @@ main (int argc, char *argv[]) gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (quit), NULL); /* Create the drawing area */ drawing_area = gtk_drawing_area_new (); - gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200); + gtk_widget_set_size_request (GTK_WIDGET (drawing_area), 200, 200); gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0); gtk_widget_show (drawing_area); /* Signals used to handle backing pixmap */ - gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", + g_signal_connect (GTK_OBJECT (drawing_area), "expose_event", (GtkSignalFunc) expose_event, NULL); - gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event", + g_signal_connect (GTK_OBJECT(drawing_area),"configure_event", (GtkSignalFunc) configure_event, NULL); /* Event signals */ - gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", + g_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", (GtkSignalFunc) motion_notify_event, NULL); - gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", + g_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", (GtkSignalFunc) button_press_event, NULL); gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK @@ -249,14 +239,14 @@ main (int argc, char *argv[]) button = gtk_button_new_with_label ("Input Dialog"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (create_input_dialog), NULL); gtk_widget_show (button); button = gtk_button_new_with_label ("Quit"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); gtk_widget_show (button); @@ -267,4 +257,3 @@ main (int argc, char *argv[]) return 0; } -/* example-end */ diff --git a/examples/scrolledwin/Makefile b/examples/scrolledwin/Makefile index ae74e8283..2f07fd50e 100644 --- a/examples/scrolledwin/Makefile +++ b/examples/scrolledwin/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + scrolledwin: scrolledwin.c - $(CC) `pkg-config --cflags gtk+-2.0` scrolledwin.c -o scrolledwin `pkg-config --libs gtk+-2.0` + $(CC) scrolledwin.c -o scrolledwin $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o scrolledwin diff --git a/examples/scrolledwin/scrolledwin.c b/examples/scrolledwin/scrolledwin.c index 977dcf20f..3c9caef70 100644 --- a/examples/scrolledwin/scrolledwin.c +++ b/examples/scrolledwin/scrolledwin.c @@ -1,5 +1,5 @@ -/* example-start scrolledwin scrolledwin.c */ +#include <stdio.h> #include <gtk/gtk.h> void destroy( GtkWidget *widget, @@ -23,11 +23,11 @@ int main( int argc, /* Create a new dialog window for the scrolled window to be * packed into. */ window = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", (GtkSignalFunc) destroy, NULL); gtk_window_set_title (GTK_WINDOW (window), "GtkScrolledWindow example"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); - gtk_widget_set_usize(window, 300, 300); + gtk_widget_set_size_request (window, 300, 300); /* create a new scrolled window. */ scrolled_window = gtk_scrolled_window_new (NULL, NULL); @@ -71,7 +71,7 @@ int main( int argc, /* Add a "close" button to the bottom of the dialog */ button = gtk_button_new_with_label ("close"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (window)); @@ -89,6 +89,5 @@ int main( int argc, gtk_main(); - return(0); + return 0; } -/* example-end */ diff --git a/examples/selection/Makefile b/examples/selection/Makefile index fad63ff09..eb07c9635 100644 --- a/examples/selection/Makefile +++ b/examples/selection/Makefile @@ -1,13 +1,19 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + all: gettargets setselection gettargets: gettargets.c - $(CC) `pkg-config --cflags gtk+-2.0` gettargets.c -o gettargets `pkg-config --libs gtk+-2.0` + $(CC) gettargets.c -o gettargets $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` setselection: setselection.c - $(CC) `pkg-config --cflags gtk+-2.0` setselection.c -o setselection `pkg-config --libs gtk+-2.0` + $(CC) setselection.c -o setselection $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o gettargets setselection diff --git a/examples/selection/gettargets.c b/examples/selection/gettargets.c index 20292c700..45d6af4ae 100644 --- a/examples/selection/gettargets.c +++ b/examples/selection/gettargets.c @@ -1,5 +1,5 @@ -/* example-start selection gettargets.c */ +#include <stdlib.h> #include <gtk/gtk.h> void selection_received( GtkWidget *widget, @@ -74,17 +74,17 @@ int main( int argc, gtk_window_set_title (GTK_WINDOW (window), "Event Box"); gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (exit), NULL); /* Create a button the user can click to get targets */ button = gtk_button_new_with_label ("Get Targets"); gtk_container_add (GTK_CONTAINER (window), button); - gtk_signal_connect (GTK_OBJECT(button), "clicked", + g_signal_connect (GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC (get_targets), NULL); - gtk_signal_connect (GTK_OBJECT(button), "selection_received", + g_signal_connect (GTK_OBJECT(button), "selection_received", GTK_SIGNAL_FUNC (selection_received), NULL); gtk_widget_show (button); @@ -94,4 +94,3 @@ int main( int argc, return 0; } -/* example-end */ diff --git a/examples/selection/setselection.c b/examples/selection/setselection.c index 690aa49c6..fe93c4489 100644 --- a/examples/selection/setselection.c +++ b/examples/selection/setselection.c @@ -1,5 +1,5 @@ -/* example-start selection setselection.c */ +#include <stdlib.h> #include <gtk/gtk.h> #include <time.h> @@ -77,8 +77,8 @@ int main( int argc, gtk_window_set_title (GTK_WINDOW (window), "Event Box"); gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (exit), NULL); /* Create a toggle button to act as the selection */ @@ -86,16 +86,16 @@ int main( int argc, gtk_container_add (GTK_CONTAINER (window), selection_button); gtk_widget_show (selection_button); - gtk_signal_connect (GTK_OBJECT(selection_button), "toggled", + g_signal_connect (GTK_OBJECT(selection_button), "toggled", GTK_SIGNAL_FUNC (selection_toggled), &have_selection); - gtk_signal_connect (GTK_OBJECT(selection_button), "selection_clear_event", + g_signal_connect (GTK_OBJECT(selection_button), "selection_clear_event", GTK_SIGNAL_FUNC (selection_clear), &have_selection); gtk_selection_add_target (selection_button, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1); - gtk_signal_connect (GTK_OBJECT(selection_button), "selection_get", + g_signal_connect (GTK_OBJECT(selection_button), "selection_get", GTK_SIGNAL_FUNC (selection_handle), &have_selection); gtk_widget_show (selection_button); @@ -105,4 +105,3 @@ int main( int argc, return 0; } -/* example-end */ diff --git a/examples/spinbutton/Makefile b/examples/spinbutton/Makefile index 8963922d4..be4bcbfbe 100644 --- a/examples/spinbutton/Makefile +++ b/examples/spinbutton/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + spinbutton: spinbutton.c - $(CC) `pkg-config --cflags gtk+-2.0` spinbutton.c -o spinbutton `pkg-config --libs gtk+-2.0` + $(CC) spinbutton.c -o spinbutton $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o spinbutton diff --git a/examples/spinbutton/spinbutton.c b/examples/spinbutton/spinbutton.c index 6b26d09a6..7bd1d9188 100644 --- a/examples/spinbutton/spinbutton.c +++ b/examples/spinbutton/spinbutton.c @@ -1,5 +1,5 @@ -/* example-start spinbutton spinbutton.c */ +#include <stdio.h> #include <gtk/gtk.h> static GtkWidget *spinner1; @@ -31,12 +31,12 @@ void get_value( GtkWidget *widget, GtkSpinButton *spin; spin = GTK_SPIN_BUTTON (spinner1); - label = GTK_LABEL (gtk_object_get_user_data (GTK_OBJECT (widget))); + label = GTK_LABEL (g_object_get_data (G_OBJECT (widget), "user_data")); if (GPOINTER_TO_INT (data) == 1) sprintf (buf, "%d", gtk_spin_button_get_value_as_int (spin)); else sprintf (buf, "%0.*f", spin->digits, - gtk_spin_button_get_value_as_float (spin)); + gtk_spin_button_get_value (spin)); gtk_label_set_text (label, buf); } @@ -62,7 +62,7 @@ int main( int argc, window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_signal_connect (GTK_OBJECT (window), "destroy", + g_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); @@ -121,7 +121,7 @@ int main( int argc, 1.0, 100.0, 0.0); spinner = gtk_spin_button_new (adj, 0, 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), FALSE); - gtk_widget_set_usize (spinner, 55, 0); + gtk_widget_set_size_request (spinner, 55, -1); gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0); frame = gtk_frame_new ("Accelerated"); @@ -145,7 +145,7 @@ int main( int argc, 0.5, 100.0, 0.0); spinner1 = gtk_spin_button_new (adj, 1.0, 2); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE); - gtk_widget_set_usize (spinner1, 100, 0); + gtk_widget_set_size_request (spinner1, 100, -1); gtk_box_pack_start (GTK_BOX (vbox2), spinner1, FALSE, TRUE, 0); vbox2 = gtk_vbox_new (FALSE, 0); @@ -158,7 +158,7 @@ int main( int argc, adj = (GtkAdjustment *) gtk_adjustment_new (2, 1, 5, 1, 1, 0); spinner2 = gtk_spin_button_new (adj, 0.0, 0); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner2), TRUE); - gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + g_signal_connect (GTK_OBJECT (adj), "value_changed", GTK_SIGNAL_FUNC (change_digits), (gpointer) spinner2); gtk_box_pack_start (GTK_BOX (vbox2), spinner2, FALSE, TRUE, 0); @@ -167,14 +167,14 @@ int main( int argc, gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); button = gtk_check_button_new_with_label ("Snap to 0.5-ticks"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (toggle_snap), spinner1); gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); button = gtk_check_button_new_with_label ("Numeric only input mode"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (toggle_numeric), spinner1); gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); @@ -185,15 +185,15 @@ int main( int argc, hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); button = gtk_button_new_with_label ("Value as Int"); - gtk_object_set_user_data (GTK_OBJECT (button), val_label); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_object_set_data (G_OBJECT (button), "user_data", val_label); + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (get_value), GINT_TO_POINTER (1)); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); button = gtk_button_new_with_label ("Value as Float"); - gtk_object_set_user_data (GTK_OBJECT (button), val_label); - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_object_set_data (G_OBJECT (button), "user_data", val_label); + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (get_value), GINT_TO_POINTER (2)); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); @@ -205,7 +205,7 @@ int main( int argc, gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0); button = gtk_button_new_with_label ("Close"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + g_signal_connect_swapped (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); @@ -215,6 +215,5 @@ int main( int argc, /* Enter the event loop */ gtk_main (); - return(0); + return 0; } -/* example-end */ diff --git a/examples/statusbar/Makefile b/examples/statusbar/Makefile index 6ca8eaf1a..e2bf326ba 100644 --- a/examples/statusbar/Makefile +++ b/examples/statusbar/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + statusbar: statusbar.c - $(CC) `pkg-config --cflags gtk+-2.0` statusbar.c -o statusbar `pkg-config --libs gtk+-2.0` + $(CC) statusbar.c -o statusbar $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o statusbar diff --git a/examples/statusbar/statusbar.c b/examples/statusbar/statusbar.c index c738bf02c..55e1bda9b 100644 --- a/examples/statusbar/statusbar.c +++ b/examples/statusbar/statusbar.c @@ -1,5 +1,5 @@ -/* example-start statusbar statusbar.c */ +#include <stdlib.h> #include <gtk/gtk.h> #include <glib.h> @@ -38,10 +38,10 @@ int main( int argc, /* create a new window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize( GTK_WIDGET (window), 200, 100); + gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); gtk_window_set_title(GTK_WINDOW (window), "GTK Statusbar Example"); - gtk_signal_connect(GTK_OBJECT (window), "delete_event", - (GtkSignalFunc) gtk_exit, NULL); + g_signal_connect(GTK_OBJECT (window), "delete_event", + GTK_SIGNAL_FUNC (exit), NULL); vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(window), vbox); @@ -55,23 +55,15 @@ int main( int argc, GTK_STATUSBAR(status_bar), "Statusbar example"); button = gtk_button_new_with_label("push item"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", + g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC (push_item), GINT_TO_POINTER(context_id) ); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 2); gtk_widget_show(button); button = gtk_button_new_with_label("pop last item"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", + g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC (pop_item), GINT_TO_POINTER(context_id) ); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 2); - gtk_widget_show(button); + gtk_widget_show(button); /* always display the window as the last step so it all splashes on - * the screen at once. */ - gtk_widget_show(window); - - gtk_main (); - - return 0; -} -/* example-end */ diff --git a/examples/table/Makefile b/examples/table/Makefile index b6221ef63..98cbc50b0 100644 --- a/examples/table/Makefile +++ b/examples/table/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + table: table.c - $(CC) `pkg-config --cflags gtk+-2.0` table.c -o table `pkg-config --libs gtk+-2.0` + $(CC) table.c -o table $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o table diff --git a/examples/table/table.c b/examples/table/table.c index a6b020c14..5311ff4db 100644 --- a/examples/table/table.c +++ b/examples/table/table.c @@ -1,4 +1,3 @@ -/* example-start table table.c */ #include <gtk/gtk.h> @@ -16,7 +15,7 @@ gint delete_event( GtkWidget *widget, gpointer data ) { gtk_main_quit (); - return(FALSE); + return FALSE; } int main( int argc, @@ -36,7 +35,7 @@ int main( int argc, /* Set a handler for delete_event that immediately * exits GTK. */ - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); /* Sets the border width of the window. */ @@ -53,7 +52,7 @@ int main( int argc, /* When the button is clicked, we call the "callback" function * with a pointer to "button 1" as its argument */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (callback), (gpointer) "button 1"); @@ -68,7 +67,7 @@ int main( int argc, /* When the button is clicked, we call the "callback" function * with a pointer to "button 2" as its argument */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (callback), (gpointer) "button 2"); /* Insert button 2 into the upper right quadrant of the table */ gtk_table_attach_defaults (GTK_TABLE(table), button, 1, 2, 0, 1); @@ -80,7 +79,7 @@ int main( int argc, /* When the button is clicked, we call the "delete_event" function * and the program exits */ - gtk_signal_connect (GTK_OBJECT (button), "clicked", + g_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (delete_event), NULL); /* Insert the quit button into the both @@ -96,4 +95,3 @@ int main( int argc, return 0; } -/* example-end */ diff --git a/examples/text/Makefile b/examples/text/Makefile index 627aab313..59e77b6af 100644 --- a/examples/text/Makefile +++ b/examples/text/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + text: text.c - $(CC) `pkg-config --cflags gtk+-2.0` text.c -o text `pkg-config --libs gtk+-2.0` + $(CC) text.c -o text $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o text diff --git a/examples/text/text.c b/examples/text/text.c index d94e06f56..65e94a7d8 100644 --- a/examples/text/text.c +++ b/examples/text/text.c @@ -1,7 +1,7 @@ -/* example-start text text.c */ /* text.c */ +#define GTK_ENABLE_BROKEN #include <stdio.h> #include <gtk/gtk.h> @@ -47,7 +47,7 @@ int main( int argc, gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize (window, 600, 500); + gtk_widget_set_size_request (window, 600, 500); gtk_window_set_policy (GTK_WINDOW(window), TRUE, TRUE, FALSE); gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(close_application), @@ -181,4 +181,3 @@ int main( int argc, return(0); } -/* example-end */ diff --git a/examples/tictactoe/Makefile b/examples/tictactoe/Makefile index 5fe6eb356..f9b2cb03e 100644 --- a/examples/tictactoe/Makefile +++ b/examples/tictactoe/Makefile @@ -1,14 +1,20 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + ttt_test: tictactoe.o ttt_test.o $(CC) ttt_test.o tictactoe.o -o ttt_test `pkg-config --libs gtk+-2.0` ttt_test.o: ttt_test.c tictactoe.h - $(CC) `pkg-config --cflags gtk+-2.0` -c ttt_test.c -o ttt_test.o + $(CC) -c ttt_test.c -o ttt_test.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags` tictactoe.o: tictactoe.c tictactoe.h - $(CC) `pkg-config --cflags gtk+-2.0` -c tictactoe.c -o tictactoe.o + $(CC) -c tictactoe.c -o tictactoe.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags` clean: rm -f *.o ttt_test diff --git a/examples/tictactoe/tictactoe.c b/examples/tictactoe/tictactoe.c index 040d472ea..0625c5179 100644 --- a/examples/tictactoe/tictactoe.c +++ b/examples/tictactoe/tictactoe.c @@ -1,4 +1,3 @@ -/* example-start tictactoe tictactoe.c */ /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald @@ -34,25 +33,27 @@ static void tictactoe_toggle (GtkWidget *widget, Tictactoe *ttt); static gint tictactoe_signals[LAST_SIGNAL] = { 0 }; -guint +GType tictactoe_get_type () { - static guint ttt_type = 0; + static GType ttt_type = 0; if (!ttt_type) { - GtkTypeInfo ttt_info = + static const GTypeInfo ttt_info = { - "Tictactoe", - sizeof (Tictactoe), sizeof (TictactoeClass), - (GtkClassInitFunc) tictactoe_class_init, - (GtkObjectInitFunc) tictactoe_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL + NULL, + NULL, + (GClassInitFunc) tictactoe_class_init, + NULL, + NULL, + sizeof (Tictactoe), + 0, + (GInstanceInitFunc) tictactoe_init, }; - ttt_type = gtk_type_unique (gtk_vbox_get_type (), &ttt_info); + ttt_type = g_type_register_static (GTK_TYPE_VBOX, "Tictactoe", &ttt_info, 0); } return ttt_type; @@ -65,17 +66,16 @@ tictactoe_class_init (TictactoeClass *class) object_class = (GtkObjectClass*) class; - tictactoe_signals[TICTACTOE_SIGNAL] = gtk_signal_new ("tictactoe", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (TictactoeClass, - tictactoe), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); + tictactoe_signals[TICTACTOE_SIGNAL] = g_signal_new ("tictactoe", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, NULL); - gtk_object_class_add_signals (object_class, tictactoe_signals, LAST_SIGNAL); - class->tictactoe = NULL; } @@ -95,9 +95,9 @@ tictactoe_init (Tictactoe *ttt) ttt->buttons[i][j] = gtk_toggle_button_new (); gtk_table_attach_defaults (GTK_TABLE(table), ttt->buttons[i][j], i, i+1, j, j+1); - gtk_signal_connect (GTK_OBJECT (ttt->buttons[i][j]), "toggled", + g_signal_connect (GTK_OBJECT (ttt->buttons[i][j]), "toggled", GTK_SIGNAL_FUNC (tictactoe_toggle), ttt); - gtk_widget_set_usize (ttt->buttons[i][j], 20, 20); + gtk_widget_set_size_request (ttt->buttons[i][j], 20, 20); gtk_widget_show (ttt->buttons[i][j]); } } @@ -105,7 +105,7 @@ tictactoe_init (Tictactoe *ttt) GtkWidget* tictactoe_new () { - return GTK_WIDGET ( gtk_type_new (tictactoe_get_type ())); + return GTK_WIDGET (g_object_new (tictactoe_get_type (), NULL)); } void @@ -116,10 +116,10 @@ tictactoe_clear (Tictactoe *ttt) for (i=0;i<3;i++) for (j=0;j<3;j++) { - gtk_signal_handler_block_by_data (GTK_OBJECT(ttt->buttons[i][j]), ttt); + g_signal_handlers_block_by_func (GTK_OBJECT(ttt->buttons[i][j]), NULL, ttt); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ttt->buttons[i][j]), FALSE); - gtk_signal_handler_unblock_by_data (GTK_OBJECT(ttt->buttons[i][j]), ttt); + g_signal_handlers_unblock_by_func (GTK_OBJECT(ttt->buttons[i][j]), NULL, ttt); } } @@ -152,11 +152,10 @@ tictactoe_toggle (GtkWidget *widget, Tictactoe *ttt) if (success && found) { - gtk_signal_emit (GTK_OBJECT (ttt), - tictactoe_signals[TICTACTOE_SIGNAL]); + g_signal_emit (GTK_OBJECT (ttt), + tictactoe_signals[TICTACTOE_SIGNAL], 0); break; } } } -/* example-end */ diff --git a/examples/tictactoe/tictactoe.h b/examples/tictactoe/tictactoe.h index 6dfa203ad..f36df1913 100644 --- a/examples/tictactoe/tictactoe.h +++ b/examples/tictactoe/tictactoe.h @@ -1,4 +1,3 @@ -/* example-start tictactoe tictactoe.h */ /* GTK - The GIMP Toolkit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald @@ -52,7 +51,7 @@ struct _TictactoeClass void (* tictactoe) (Tictactoe *ttt); }; -guint tictactoe_get_type (void); +GtkType tictactoe_get_type (void); GtkWidget* tictactoe_new (void); void tictactoe_clear (Tictactoe *ttt); @@ -62,4 +61,3 @@ void tictactoe_clear (Tictactoe *ttt); #endif /* __TICTACTOE_H__ */ -/* example-end */ diff --git a/examples/tictactoe/ttt_test.c b/examples/tictactoe/ttt_test.c index 82941e893..6d25f3857 100644 --- a/examples/tictactoe/ttt_test.c +++ b/examples/tictactoe/ttt_test.c @@ -1,5 +1,5 @@ -/* example-start tictactoe ttt_test.c */ +#include <stdlib.h> #include <gtk/gtk.h> #include "tictactoe.h" @@ -22,8 +22,8 @@ int main( int argc, gtk_window_set_title (GTK_WINDOW (window), "Aspect Frame"); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (gtk_exit), NULL); + g_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (exit), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); @@ -32,7 +32,7 @@ int main( int argc, gtk_container_add (GTK_CONTAINER (window), ttt); gtk_widget_show (ttt); - gtk_signal_connect (GTK_OBJECT (ttt), "tictactoe", + g_signal_connect (GTK_OBJECT (ttt), "tictactoe", GTK_SIGNAL_FUNC (win), NULL); gtk_widget_show (window); @@ -42,4 +42,3 @@ int main( int argc, return 0; } -/* example-end */ diff --git a/examples/tree/Makefile b/examples/tree/Makefile index 015f78ece..de510b9b8 100644 --- a/examples/tree/Makefile +++ b/examples/tree/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + tree: tree.c - $(CC) `pkg-config --cflags gtk+-2.0` tree.c -o tree `pkg-config --libs gtk+-2.0` + $(CC) tree.c -o tree $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o tree diff --git a/examples/tree/tree.c b/examples/tree/tree.c index 67b93fe28..acd431e13 100644 --- a/examples/tree/tree.c +++ b/examples/tree/tree.c @@ -1,5 +1,5 @@ -/* example-start tree tree.c */ +#define GTK_ENABLE_BROKEN #include <gtk/gtk.h> /* for all the GtkItem:: and GtkTreeItem:: signals */ @@ -44,7 +44,7 @@ static void cb_selection_changed( GtkWidget *tree ) g_print ("selection_change called for tree %p\n", tree); g_print ("selected objects are:\n"); - i = GTK_TREE_SELECTION(tree); + i = GTK_TREE_SELECTION_OLD(tree); while (i){ gchar *name; GtkLabel *label; @@ -81,7 +81,7 @@ int main( int argc, gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_widget_set_usize (scrolled_win, 150, 200); + gtk_widget_set_size_request (scrolled_win, 150, 200); gtk_container_add (GTK_CONTAINER(window), scrolled_win); gtk_widget_show (scrolled_win); @@ -179,4 +179,3 @@ int main( int argc, gtk_main(); return 0; } -/* example-end */ diff --git a/examples/wheelbarrow/Makefile b/examples/wheelbarrow/Makefile index b004ca918..e51c26c56 100644 --- a/examples/wheelbarrow/Makefile +++ b/examples/wheelbarrow/Makefile @@ -1,8 +1,14 @@ CC = gcc +CFLAGS = -Wall \ + -DG_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED + wheelbarrow: wheelbarrow.c - $(CC) `pkg-config --cflags gtk+-2.0` wheelbarrow.c -o wheelbarrow `pkg-config --libs gtk+-2.0` + $(CC) wheelbarrow.c -o wheelbarrow $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` clean: rm -f *.o wheelbarrow diff --git a/examples/wheelbarrow/wheelbarrow.c b/examples/wheelbarrow/wheelbarrow.c index 5d1df1d15..a0a7cd541 100644 --- a/examples/wheelbarrow/wheelbarrow.c +++ b/examples/wheelbarrow/wheelbarrow.c @@ -1,4 +1,3 @@ -/* example-start wheelbarrow wheelbarrow.c */ #include <gtk/gtk.h> @@ -143,7 +142,7 @@ int main (int argc, * since we're making it a popup. */ gtk_init (&argc, &argv); window = gtk_window_new( GTK_WINDOW_POPUP ); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", + g_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (close_application), NULL); gtk_widget_show (window); @@ -153,12 +152,12 @@ int main (int argc, gdk_pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask, &style->bg[GTK_STATE_NORMAL], WheelbarrowFull_xpm ); - pixmap = gtk_pixmap_new( gdk_pixmap, mask ); + 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_usize( fixed, 200, 200 ); + 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 ); @@ -167,10 +166,9 @@ int main (int argc, gtk_widget_shape_combine_mask( window, mask, 0, 0 ); /* show the window */ - gtk_widget_set_uposition( window, 20, 400 ); + /*gtk_widget_set_uposition( window, 20, 400 );*/ gtk_widget_show( window ); gtk_main (); - return(0); + return 0; } -/* example-end */ |