diff options
71 files changed, 0 insertions, 5922 deletions
diff --git a/examples/arrow/Makefile b/examples/arrow/Makefile deleted file mode 100644 index 08afc28ca6..0000000000 --- a/examples/arrow/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -arrow: arrow.c - $(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 deleted file mode 100644 index 149af8098b..0000000000 --- a/examples/arrow/arrow.c +++ /dev/null @@ -1,72 +0,0 @@ - -#include <gtk/gtk.h> - -/* Create an Arrow widget with the specified parameters - * and pack it into a button */ -static GtkWidget *create_arrow_button( GtkArrowType arrow_type, - GtkShadowType shadow_type ) -{ - GtkWidget *button; - GtkWidget *arrow; - - button = gtk_button_new (); - arrow = gtk_arrow_new (arrow_type, shadow_type); - - gtk_container_add (GTK_CONTAINER (button), arrow); - - gtk_widget_show (button); - gtk_widget_show (arrow); - - return button; -} - -int main( int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window; - GtkWidget *button; - GtkWidget *box; - - /* Initialize the toolkit */ - gtk_init (&argc, &argv); - - /* Create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_window_set_title (GTK_WINDOW (window), "Arrow Buttons"); - - /* It's a good idea to do this for all windows. */ - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create a box to hold the arrows/buttons */ - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (box), 2); - gtk_container_add (GTK_CONTAINER (window), box); - - /* Pack and show all our widgets */ - gtk_widget_show (box); - - button = create_arrow_button (GTK_ARROW_UP, GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3); - - button = create_arrow_button (GTK_ARROW_DOWN, GTK_SHADOW_OUT); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3); - - button = create_arrow_button (GTK_ARROW_LEFT, GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3); - - button = create_arrow_button (GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_OUT); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3); - - gtk_widget_show (window); - - /* Rest in gtk_main and wait for the fun to begin! */ - gtk_main (); - - return 0; -} diff --git a/examples/aspectframe/Makefile b/examples/aspectframe/Makefile deleted file mode 100644 index 10fc747fb3..0000000000 --- a/examples/aspectframe/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -aspectframe: aspectframe.c - $(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 deleted file mode 100644 index f32da1b9d2..0000000000 --- a/examples/aspectframe/aspectframe.c +++ /dev/null @@ -1,42 +0,0 @@ - -#include <gtk/gtk.h> - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *aspect_frame; - GtkWidget *drawing_area; - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Aspect Frame"); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create an aspect_frame and add it to our toplevel window */ - - aspect_frame = gtk_aspect_frame_new ("2x1", /* label */ - 0.5, /* center x */ - 0.5, /* center y */ - 2, /* xsize/ysize = 2 */ - FALSE /* ignore child's aspect */); - - gtk_container_add (GTK_CONTAINER (window), aspect_frame); - gtk_widget_show (aspect_frame); - - /* Now add a child widget to the aspect frame */ - - drawing_area = gtk_drawing_area_new (); - - /* 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_size_request (drawing_area, 200, 200); - gtk_container_add (GTK_CONTAINER (aspect_frame), drawing_area); - gtk_widget_show (drawing_area); - - gtk_widget_show (window); - gtk_main (); - return 0; -} diff --git a/examples/base/Makefile b/examples/base/Makefile deleted file mode 100644 index dbb54890e7..0000000000 --- a/examples/base/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -base: base.c - $(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 deleted file mode 100644 index 4dc29da623..0000000000 --- a/examples/base/base.c +++ /dev/null @@ -1,17 +0,0 @@ - -#include <gtk/gtk.h> - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/buttonbox/Makefile b/examples/buttonbox/Makefile deleted file mode 100644 index 0863978842..0000000000 --- a/examples/buttonbox/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -buttonbox: buttonbox.c - $(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 deleted file mode 100644 index 8643974d72..0000000000 --- a/examples/buttonbox/buttonbox.c +++ /dev/null @@ -1,119 +0,0 @@ - -#include <gtk/gtk.h> - -/* Create a Button Box with the specified parameters */ -static GtkWidget *create_bbox( gint horizontal, - char *title, - gint spacing, - gint child_w, - gint child_h, - gint layout ) -{ - GtkWidget *frame; - GtkWidget *bbox; - GtkWidget *button; - - frame = gtk_frame_new (title); - - if (horizontal) - bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - else - bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL); - - gtk_container_set_border_width (GTK_CONTAINER (bbox), 5); - gtk_container_add (GTK_CONTAINER (frame), bbox); - - /* Set the appearance of the Button Box */ - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout); - gtk_box_set_spacing (GTK_BOX (bbox), spacing); - - button = gtk_button_new_from_stock (GTK_STOCK_OK); - gtk_container_add (GTK_CONTAINER (bbox), button); - - button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); - gtk_container_add (GTK_CONTAINER (bbox), button); - - button = gtk_button_new_from_stock (GTK_STOCK_HELP); - gtk_container_add (GTK_CONTAINER (bbox), button); - - return frame; -} - -int main( int argc, - char *argv[] ) -{ - static GtkWidget* window = NULL; - GtkWidget *main_vbox; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *frame_horz; - GtkWidget *frame_vert; - - /* Initialize GTK */ - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Button Boxes"); - - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), main_vbox); - - frame_horz = gtk_frame_new ("Horizontal Button Boxes"); - gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 10); - gtk_container_add (GTK_CONTAINER (frame_horz), vbox); - - gtk_box_pack_start (GTK_BOX (vbox), - create_bbox (TRUE, "Spread (spacing 40)", 40, 85, 20, GTK_BUTTONBOX_SPREAD), - TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), - create_bbox (TRUE, "Edge (spacing 30)", 30, 85, 20, GTK_BUTTONBOX_EDGE), - TRUE, TRUE, 5); - - gtk_box_pack_start (GTK_BOX (vbox), - create_bbox (TRUE, "Start (spacing 20)", 20, 85, 20, GTK_BUTTONBOX_START), - TRUE, TRUE, 5); - - gtk_box_pack_start (GTK_BOX (vbox), - create_bbox (TRUE, "End (spacing 10)", 10, 85, 20, GTK_BUTTONBOX_END), - TRUE, TRUE, 5); - - frame_vert = gtk_frame_new ("Vertical Button Boxes"); - gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 10); - gtk_container_add (GTK_CONTAINER (frame_vert), hbox); - - gtk_box_pack_start (GTK_BOX (hbox), - create_bbox (FALSE, "Spread (spacing 5)", 5, 85, 20, GTK_BUTTONBOX_SPREAD), - TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (hbox), - create_bbox (FALSE, "Edge (spacing 30)", 30, 85, 20, GTK_BUTTONBOX_EDGE), - TRUE, TRUE, 5); - - gtk_box_pack_start (GTK_BOX (hbox), - create_bbox (FALSE, "Start (spacing 20)", 20, 85, 20, GTK_BUTTONBOX_START), - TRUE, TRUE, 5); - - gtk_box_pack_start (GTK_BOX (hbox), - create_bbox (FALSE, "End (spacing 20)", 20, 85, 20, GTK_BUTTONBOX_END), - TRUE, TRUE, 5); - - gtk_widget_show_all (window); - - /* Enter the event loop */ - gtk_main (); - - return 0; -} diff --git a/examples/buttons/Makefile b/examples/buttons/Makefile deleted file mode 100644 index 7f9a324db2..0000000000 --- a/examples/buttons/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall -Wunused \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -buttons: buttons.c - $(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 deleted file mode 100644 index df68fcb42f..0000000000 --- a/examples/buttons/buttons.c +++ /dev/null @@ -1,92 +0,0 @@ - -#include <stdlib.h> -#include <gtk/gtk.h> - -/* Create a new hbox with an image and a label packed into it - * and return the box. */ - -static GtkWidget *xpm_label_box( gchar *xpm_filename, - gchar *label_text ) -{ - GtkWidget *box; - GtkWidget *label; - GtkWidget *image; - - /* Create box for image and label */ - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (box), 2); - - /* Now on to the image stuff */ - image = gtk_image_new_from_file (xpm_filename); - - /* Create a label for the button */ - label = gtk_label_new (label_text); - - /* Pack the image and label into the box */ - gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3); - gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3); - - gtk_widget_show (image); - gtk_widget_show (label); - - return box; -} - -/* Our usual callback function */ -static void callback( GtkWidget *widget, - gpointer data ) -{ - g_print ("Hello again - %s was pressed\n", (char *) data); -} - -int main( int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window; - GtkWidget *button; - GtkWidget *box; - - gtk_init (&argc, &argv); - - /* Create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!"); - - /* It's a good idea to do this for all windows. */ - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - g_signal_connect (G_OBJECT (window), "delete-event", - G_CALLBACK (gtk_main_quit), NULL); - - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create a new button */ - button = gtk_button_new (); - - /* Connect the "clicked" signal of the button to our callback */ - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (callback), (gpointer) "cool button"); - - /* This calls our box creating function */ - box = xpm_label_box ("info.xpm", "cool button"); - - /* Pack and show all our widgets */ - gtk_widget_show (box); - - gtk_container_add (GTK_CONTAINER (button), box); - - gtk_widget_show (button); - - gtk_container_add (GTK_CONTAINER (window), button); - - gtk_widget_show (window); - - /* Rest in gtk_main and wait for the fun to begin! */ - gtk_main (); - - return 0; -} diff --git a/examples/buttons/info.xpm b/examples/buttons/info.xpm deleted file mode 100644 index 9b0d2efdb2..0000000000 --- a/examples/buttons/info.xpm +++ /dev/null @@ -1,92 +0,0 @@ -/* XPM */ -static char *openfile[] = { -/* width height num_colors chars_per_pixel */ -" 20 19 66 2", -/* colors */ -".. c None", -".# c #000000", -".a c #dfdfdf", -".b c #7f7f7f", -".c c #006f6f", -".d c #00efef", -".e c #009f9f", -".f c #004040", -".g c #00bfbf", -".h c #ff0000", -".i c #ffffff", -".j c #7f0000", -".k c #007070", -".l c #00ffff", -".m c #00a0a0", -".n c #004f4f", -".o c #00cfcf", -".p c #8f8f8f", -".q c #6f6f6f", -".r c #a0a0a0", -".s c #7f7f00", -".t c #007f7f", -".u c #5f5f5f", -".v c #707070", -".w c #00f0f0", -".x c #009090", -".y c #ffff00", -".z c #0000ff", -".A c #00afaf", -".B c #00d0d0", -".C c #00dfdf", -".D c #005f5f", -".E c #00b0b0", -".F c #001010", -".G c #00c0c0", -".H c #000f0f", -".I c #00007f", -".J c #005050", -".K c #002f2f", -".L c #dfcfcf", -".M c #dfd0d0", -".N c #006060", -".O c #00e0e0", -".P c #00ff00", -".Q c #002020", -".R c #dfc0c0", -".S c #008080", -".T c #001f1f", -".U c #003f3f", -".V c #007f00", -".W c #00000f", -".X c #000010", -".Y c #00001f", -".Z c #000020", -".0 c #00002f", -".1 c #000030", -".2 c #00003f", -".3 c #000040", -".4 c #00004f", -".5 c #000050", -".6 c #00005f", -".7 c #000060", -".8 c #00006f", -".9 c #000070", -"#. c #7f7f80", -"## c #9f9f9f", -/* pixels */ -"........................................", -"........................................", -"........................................", -".......................#.#.#............", -".....................#.......#...#......", -"...............................#.#......", -".......#.#.#.................#.#.#......", -".....#.y.i.y.#.#.#.#.#.#.#..............", -".....#.i.y.i.y.i.y.i.y.i.#..............", -".....#.y.i.y.i.y.i.y.i.y.#..............", -".....#.i.y.i.y.#.#.#.#.#.#.#.#.#.#.#....", -".....#.y.i.y.#.s.s.s.s.s.s.s.s.s.#......", -".....#.i.y.#.s.s.s.s.s.s.s.s.s.#........", -".....#.y.#.s.s.s.s.s.s.s.s.s.#..........", -".....#.#.s.s.s.s.s.s.s.s.s.#............", -".....#.#.#.#.#.#.#.#.#.#.#..............", -"........................................", -"........................................", -"........................................" -}; diff --git a/examples/calendar/Makefile b/examples/calendar/Makefile deleted file mode 100644 index 476f98c2d7..0000000000 --- a/examples/calendar/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED - -calendar: calendar.c - $(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 deleted file mode 100644 index 4e65660d17..0000000000 --- a/examples/calendar/calendar.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund - * Copyright (C) 2000 Tony Gale - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <stdio.h> -#include <string.h> -#include <gtk/gtk.h> - -#define DEF_PAD 10 -#define DEF_PAD_SMALL 5 - -#define TM_YEAR_BASE 1900 - -typedef struct _CalendarData { - GtkWidget *flag_checkboxes[5]; - gboolean settings[5]; - GtkWidget *font_dialog; - GtkWidget *window; - GtkWidget *prev2_sig; - GtkWidget *prev_sig; - GtkWidget *last_sig; - GtkWidget *month; -} CalendarData; - -enum { - calendar_show_header, - calendar_show_days, - calendar_month_change, - calendar_show_week, - calendar_monday_first -}; - -/* - * GtkCalendar - */ - -static void calendar_date_to_string( CalendarData *data, - char *buffer, - gint buff_len ) -{ - GDate date; - guint year, month, day; - - gtk_calendar_get_date (GTK_CALENDAR (data->window), - &year, &month, &day); - g_date_set_dmy (&date, day, month + 1, year); - g_date_strftime (buffer, buff_len - 1, "%x", &date); - -} - -static void calendar_set_signal_strings( char *sig_str, - CalendarData *data ) -{ - const gchar *prev_sig; - - prev_sig = gtk_label_get_text (GTK_LABEL (data->prev_sig)); - gtk_label_set_text (GTK_LABEL (data->prev2_sig), prev_sig); - - 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); -} - -static void calendar_month_changed( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "month_changed: "; - - calendar_date_to_string (data, buffer + 15, 256 - 15); - calendar_set_signal_strings (buffer, data); -} - -static void calendar_day_selected( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "day_selected: "; - - calendar_date_to_string (data, buffer + 14, 256 - 14); - calendar_set_signal_strings (buffer, data); -} - -static void calendar_day_selected_double_click ( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "day_selected_double_click: "; - guint day; - - calendar_date_to_string (data, buffer + 27, 256 - 27); - calendar_set_signal_strings (buffer, data); - - gtk_calendar_get_date (GTK_CALENDAR (data->window), - NULL, NULL, &day); - - if (GTK_CALENDAR (data->window)->marked_date[day-1] == 0) { - gtk_calendar_mark_day (GTK_CALENDAR (data->window), day); - } else { - gtk_calendar_unmark_day (GTK_CALENDAR (data->window), day); - } -} - -static void calendar_prev_month( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "prev_month: "; - - calendar_date_to_string (data, buffer + 12, 256 - 12); - calendar_set_signal_strings (buffer, data); -} - -static void calendar_next_month( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "next_month: "; - - calendar_date_to_string (data, buffer + 12, 256 - 12); - calendar_set_signal_strings (buffer, data); -} - -static void calendar_prev_year( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "prev_year: "; - - calendar_date_to_string (data, buffer + 11, 256 - 11); - calendar_set_signal_strings (buffer, data); -} - -static void calendar_next_year( GtkWidget *widget, - CalendarData *data ) -{ - char buffer[256] = "next_year: "; - - calendar_date_to_string (data, buffer + 11, 256 - 11); - calendar_set_signal_strings (buffer, data); -} - - -static void calendar_set_flags( CalendarData *calendar ) -{ - gint i; - gint options = 0; - for (i = 0;i < 5; i++) - if (calendar->settings[i]) - { - options = options + (1 << i); - } - if (calendar->window) - gtk_calendar_set_display_options (GTK_CALENDAR (calendar->window), options); -} - -static void calendar_toggle_flag( GtkWidget *toggle, - CalendarData *calendar) -{ - gint i; - gint j; - j = 0; - for (i = 0; i < 5; i++) - if (calendar->flag_checkboxes[i] == toggle) - j = i; - - calendar->settings[j] = !calendar->settings[j]; - calendar_set_flags (calendar); - -} - -static void calendar_font_selection_ok( GtkWidget *button, - CalendarData *calendar ) -{ - GtkRcStyle *style; - char *font_name; - - if (calendar->window) - { - font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (calendar->font_dialog)); - if (font_name) - { - style = gtk_rc_style_new (); - pango_font_description_free (style->font_desc); - style->font_desc = pango_font_description_from_string (font_name); - gtk_widget_modify_style (calendar->window, style); - g_free (font_name); - } - } - - gtk_widget_destroy (calendar->font_dialog); -} - -static void calendar_select_font( GtkWidget *button, - CalendarData *calendar ) -{ - GtkWidget *window; - - if (!calendar->font_dialog) { - window = gtk_font_selection_dialog_new ("Font Selection Dialog"); - g_return_if_fail (GTK_IS_FONT_SELECTION_DIALOG (window)); - calendar->font_dialog = window; - - gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_widget_destroyed), - &calendar->font_dialog); - - g_signal_connect (GTK_FONT_SELECTION_DIALOG (window)->ok_button, - "clicked", G_CALLBACK (calendar_font_selection_ok), - calendar); - g_signal_connect_swapped (GTK_FONT_SELECTION_DIALOG (window)->cancel_button, - "clicked", G_CALLBACK (gtk_widget_destroy), - calendar->font_dialog); - } - window = calendar->font_dialog; - if (!gtk_widget_get_visible (window)) - gtk_widget_show (window); - else - gtk_widget_destroy (window); - -} - -static void create_calendar( void ) -{ - GtkWidget *window; - GtkWidget *vbox, *vbox2, *vbox3; - GtkWidget *hbox; - GtkWidget *hbbox; - GtkWidget *calendar; - GtkWidget *toggle; - GtkWidget *button; - GtkWidget *frame; - GtkWidget *separator; - GtkWidget *label; - GtkWidget *bbox; - static CalendarData calendar_data; - gint i; - - struct { - char *label; - } flags[] = - { - { "Show Heading" }, - { "Show Day Names" }, - { "No Month Change" }, - { "Show Week Numbers" }, - { "Week Start Monday" } - }; - - - calendar_data.window = NULL; - calendar_data.font_dialog = NULL; - - for (i = 0; i < 5; i++) { - calendar_data.settings[i] = 0; - } - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example"); - gtk_container_set_border_width (GTK_CONTAINER (window), 5); - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - g_signal_connect (window, "delete-event", - G_CALLBACK (gtk_false), - NULL); - gtk_window_set_resizable (GTK_WINDOW (window), FALSE); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, DEF_PAD); - gtk_container_add (GTK_CONTAINER (window), vbox); - - /* - * The top part of the window, Calendar, flags and fontsel. - */ - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, DEF_PAD); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, DEF_PAD); - hbbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - 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_box_set_spacing (GTK_BOX (hbbox), 5); - - /* Calendar widget */ - frame = gtk_frame_new ("Calendar"); - gtk_box_pack_start(GTK_BOX (hbbox), frame, FALSE, TRUE, DEF_PAD); - calendar=gtk_calendar_new (); - calendar_data.window = calendar; - calendar_set_flags (&calendar_data); - gtk_calendar_mark_day (GTK_CALENDAR (calendar), 19); - gtk_container_add (GTK_CONTAINER (frame), calendar); - g_signal_connect (calendar, "month-changed", - G_CALLBACK (calendar_month_changed), - &calendar_data); - g_signal_connect (calendar, "day-selected", - G_CALLBACK (calendar_day_selected), - &calendar_data); - g_signal_connect (calendar, "day-selected-double-click", - G_CALLBACK (calendar_day_selected_double_click), - &calendar_data); - g_signal_connect (calendar, "prev-month", - G_CALLBACK (calendar_prev_month), - &calendar_data); - g_signal_connect (calendar, "next-month", - G_CALLBACK (calendar_next_month), - &calendar_data); - g_signal_connect (calendar, "prev-year", - G_CALLBACK (calendar_prev_year), - &calendar_data); - g_signal_connect (calendar, "next-year", - G_CALLBACK (calendar_next_year), - &calendar_data); - - - separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL); - gtk_box_pack_start (GTK_BOX (hbox), separator, FALSE, TRUE, 0); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, DEF_PAD); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, DEF_PAD); - - /* Build the Right frame with the flags in */ - - frame = gtk_frame_new ("Flags"); - gtk_box_pack_start (GTK_BOX (vbox2), frame, TRUE, TRUE, DEF_PAD); - vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, TRUE, DEF_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox3); - - for (i = 0; i < 5; i++) - { - toggle = gtk_check_button_new_with_label (flags[i].label); - g_signal_connect (toggle, - "toggled", - G_CALLBACK (calendar_toggle_flag), - &calendar_data); - gtk_box_pack_start (GTK_BOX (vbox3), toggle, TRUE, TRUE, 0); - calendar_data.flag_checkboxes[i] = toggle; - } - /* Build the right font-button */ - button = gtk_button_new_with_label ("Font..."); - g_signal_connect (button, - "clicked", - G_CALLBACK (calendar_select_font), - &calendar_data); - gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); - - /* - * Build the Signal-event part. - */ - - frame = gtk_frame_new ("Signal events"); - gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, DEF_PAD); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, TRUE, DEF_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (frame), vbox2); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 3); - gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0); - label = gtk_label_new ("Signal:"); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); - calendar_data.last_sig = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), calendar_data.last_sig, FALSE, TRUE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 3); - gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0); - label = gtk_label_new ("Previous signal:"); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); - calendar_data.prev_sig = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev_sig, FALSE, TRUE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 3); - gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, TRUE, 0); - label = gtk_label_new ("Second previous signal:"); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); - calendar_data.prev2_sig = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev2_sig, FALSE, TRUE, 0); - - bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); - - button = gtk_button_new_with_label ("Close"); - g_signal_connect (button, "clicked", - G_CALLBACK (gtk_main_quit), - NULL); - gtk_container_add (GTK_CONTAINER (bbox), button); - gtk_widget_set_can_default (button, TRUE); - gtk_widget_grab_default (button); - - gtk_widget_show_all (window); -} - - -int main (int argc, - char *argv[]) -{ - gtk_init (&argc, &argv); - - create_calendar (); - - gtk_main (); - - return 0; -} diff --git a/examples/colorsel/Makefile b/examples/colorsel/Makefile deleted file mode 100644 index 20d871d1cd..0000000000 --- a/examples/colorsel/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -colorsel: colorsel.c - $(CC) colorsel.c -o colorsel `pkg-config gtk+-2.0 --cflags --libs` - -clean: - rm -f *.o colorsel diff --git a/examples/colorsel/colorsel.c b/examples/colorsel/colorsel.c deleted file mode 100644 index af82bf54fe..0000000000 --- a/examples/colorsel/colorsel.c +++ /dev/null @@ -1,132 +0,0 @@ - -#include <glib.h> -#include <gdk/gdk.h> -#include <gtk/gtk.h> - -GtkWidget *colorseldlg = NULL; -GtkWidget *drawingarea = NULL; -GdkColor color; - -/* Color changed handler */ - -static void color_changed_cb( GtkWidget *widget, - GtkColorSelection *colorsel ) -{ - GdkColor ncolor; - - gtk_color_selection_get_current_color (colorsel, &ncolor); - gtk_widget_modify_bg (drawingarea, GTK_STATE_NORMAL, &ncolor); -} - -/* Drawingarea event handler */ - -static gboolean area_event( GtkWidget *widget, - GdkEvent *event, - gpointer client_data ) -{ - gint handled = FALSE; - gint response; - GtkColorSelection *colorsel; - GtkColorSelectionDialog *selection_dialog; - - /* Check if we've received a button pressed event */ - - if (event->type == GDK_BUTTON_PRESS) - { - handled = TRUE; - - /* Create color selection dialog */ - if (colorseldlg == NULL) - colorseldlg = gtk_color_selection_dialog_new ("Select background color"); - - /* Get the ColorSelection widget */ - selection_dialog = GTK_COLOR_SELECTION_DIALOG (colorseldlg); - colorsel = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_colorsel (selection_dialog)); - - gtk_color_selection_set_previous_color (colorsel, &color); - gtk_color_selection_set_current_color (colorsel, &color); - gtk_color_selection_set_has_palette (colorsel, TRUE); - - /* Connect to the "color-changed" signal, set the client-data - * to the colorsel widget */ - g_signal_connect (colorsel, "color-changed", - G_CALLBACK (color_changed_cb), - colorsel); - - /* Show the dialog */ - response = gtk_dialog_run (GTK_DIALOG (colorseldlg)); - - if (response == GTK_RESPONSE_OK) - gtk_color_selection_get_current_color (colorsel, &color); - else - gtk_widget_modify_bg (drawingarea, GTK_STATE_NORMAL, &color); - - gtk_widget_hide (colorseldlg); - } - - return handled; -} - -/* Close down and exit handler */ - -static gboolean destroy_window( GtkWidget *widget, - GdkEvent *event, - gpointer client_data ) -{ - gtk_main_quit (); - return TRUE; -} - -/* Main */ - -gint main( gint argc, - gchar *argv[] ) -{ - GtkWidget *window; - - /* Initialize the toolkit, remove gtk-related commandline stuff */ - - gtk_init (&argc, &argv); - - /* Create toplevel window, set title and policies */ - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Color selection test"); - gtk_window_set_resizable (GTK_WINDOW (window), TRUE); - - /* Attach to the "delete" and "destroy" events so we can exit */ - - g_signal_connect (window, "delete_event", - G_CALLBACK (destroy_window), (gpointer) window); - - /* Create drawingarea, set size and catch button events */ - - drawingarea = gtk_drawing_area_new (); - - color.red = 0; - color.blue = 65535; - color.green = 0; - gtk_widget_modify_bg (drawingarea, GTK_STATE_NORMAL, &color); - - gtk_widget_set_size_request (GTK_WIDGET (drawingarea), 200, 200); - - gtk_widget_set_events (drawingarea, GDK_BUTTON_PRESS_MASK); - - g_signal_connect (drawingarea, "event", - G_CALLBACK (area_event), (gpointer) drawingarea); - - /* Add drawingarea to window, then show them both */ - - gtk_container_add (GTK_CONTAINER (window), drawingarea); - - gtk_widget_show (drawingarea); - gtk_widget_show (window); - - /* Enter the gtk main loop (this never returns) */ - - gtk_main (); - - /* Satisfy grumpy compilers */ - - return 0; -} diff --git a/examples/entry/Makefile b/examples/entry/Makefile deleted file mode 100644 index 78984e64d7..0000000000 --- a/examples/entry/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -entry: entry.c - $(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 deleted file mode 100644 index f7c577210d..0000000000 --- a/examples/entry/entry.c +++ /dev/null @@ -1,100 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <gtk/gtk.h> - -static void enter_callback( GtkWidget *widget, - GtkWidget *entry ) -{ - const gchar *entry_text; - entry_text = gtk_entry_get_text (GTK_ENTRY (entry)); - printf ("Entry contents: %s\n", entry_text); -} - -static void entry_toggle_editable( GtkWidget *checkbutton, - GtkWidget *entry ) -{ - gtk_editable_set_editable (GTK_EDITABLE (entry), - GTK_TOGGLE_BUTTON (checkbutton)->active); -} - -static void entry_toggle_visibility( GtkWidget *checkbutton, - GtkWidget *entry ) -{ - gtk_entry_set_visibility (GTK_ENTRY (entry), - GTK_TOGGLE_BUTTON (checkbutton)->active); -} - -int main( int argc, - char *argv[] ) -{ - - GtkWidget *window; - GtkWidget *vbox, *hbox; - 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_size_request (GTK_WIDGET (window), 200, 100); - gtk_window_set_title (GTK_WINDOW (window), "GTK Entry"); - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), NULL); - g_signal_connect_swapped (window, "delete-event", - G_CALLBACK (gtk_widget_destroy), - window); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); - - entry = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (entry), 50); - g_signal_connect (entry, "activate", - G_CALLBACK (enter_callback), - (gpointer) entry); - gtk_entry_set_text (GTK_ENTRY (entry), "hello"); - 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); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (vbox), hbox); - gtk_widget_show (hbox); - - check = gtk_check_button_new_with_label ("Editable"); - gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0); - g_signal_connect (check, "toggled", - G_CALLBACK (entry_toggle_editable), (gpointer) 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); - g_signal_connect (check, "toggled", - G_CALLBACK (entry_toggle_visibility), (gpointer) entry); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); - gtk_widget_show (check); - - button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), - window); - gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); - gtk_widget_set_can_default (button, TRUE); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - gtk_widget_show (window); - - gtk_main(); - - return 0; -} diff --git a/examples/eventbox/Makefile b/examples/eventbox/Makefile deleted file mode 100644 index 96b4f5c24b..0000000000 --- a/examples/eventbox/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -eventbox: eventbox.c - $(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 deleted file mode 100644 index f24d81306a..0000000000 --- a/examples/eventbox/eventbox.c +++ /dev/null @@ -1,53 +0,0 @@ - -#include <stdlib.h> -#include <gtk/gtk.h> - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *event_box; - GtkWidget *label; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_window_set_title (GTK_WINDOW (window), "Event Box"); - - g_signal_connect (window, "destroy", - G_CALLBACK (exit), NULL); - - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create an EventBox and add it to our toplevel window */ - - event_box = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (window), event_box); - gtk_widget_show (event_box); - - /* Create a long label */ - - label = gtk_label_new ("Click here to quit, quit, quit, quit, quit"); - gtk_container_add (GTK_CONTAINER (event_box), label); - gtk_widget_show (label); - - /* Clip it short. */ - gtk_widget_set_size_request (label, 110, 20); - - /* And bind an action to it */ - gtk_widget_set_events (event_box, GDK_BUTTON_PRESS_MASK); - g_signal_connect (event_box, "button-press-event", - G_CALLBACK (exit), NULL); - - /* Yet one more thing you need an X window for ... */ - - gtk_widget_realize (event_box); - gdk_window_set_cursor (event_box->window, gdk_cursor_new (GDK_HAND1)); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/fixed/Makefile b/examples/fixed/Makefile deleted file mode 100644 index 941531b20e..0000000000 --- a/examples/fixed/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -fixed: fixed.c - $(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 deleted file mode 100644 index 393040b308..0000000000 --- a/examples/fixed/fixed.c +++ /dev/null @@ -1,72 +0,0 @@ - -#include <gtk/gtk.h> - -/* I'm going to be lazy and use some global variables to - * store the position of the widget within the fixed - * container */ -gint x = 50; -gint y = 50; - -/* This callback function moves the button to a new position - * in the Fixed container. */ -static void move_button( GtkWidget *widget, - GtkWidget *fixed ) -{ - x = (x + 30) % 300; - y = (y + 50) % 300; - gtk_fixed_move (GTK_FIXED (fixed), widget, x, y); -} - -int main( int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window; - GtkWidget *fixed; - GtkWidget *button; - gint i; - - /* Initialise GTK */ - gtk_init (&argc, &argv); - - /* Create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Fixed Container"); - - /* Here we connect the "destroy" event to a signal handler */ - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create a Fixed Container */ - fixed = gtk_fixed_new (); - gtk_container_add (GTK_CONTAINER (window), fixed); - gtk_widget_show (fixed); - - for (i = 1 ; i <= 3 ; i++) { - /* Creates a new button with the label "Press me" */ - button = gtk_button_new_with_label ("Press me"); - - /* When the button receives the "clicked" signal, it will call the - * function move_button() passing it the Fixed Container as its - * argument. */ - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (move_button), (gpointer) fixed); - - /* This packs the button into the fixed containers window. */ - gtk_fixed_put (GTK_FIXED (fixed), button, i*50, i*50); - - /* The final step is to display this newly created widget. */ - gtk_widget_show (button); - } - - /* Display the window */ - gtk_widget_show (window); - - /* Enter the event loop */ - gtk_main (); - - return 0; -} diff --git a/examples/frame/Makefile b/examples/frame/Makefile deleted file mode 100644 index 049b8c40a2..0000000000 --- a/examples/frame/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -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 deleted file mode 100644 index 078fbdd672..0000000000 --- a/examples/frame/frame.c +++ /dev/null @@ -1,48 +0,0 @@ - -#include <gtk/gtk.h> - -int main( int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window; - GtkWidget *frame; - - /* Initialise GTK */ - gtk_init (&argc, &argv); - - /* Create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Frame Example"); - - /* Here we connect the "destroy" event to a signal handler */ - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - gtk_widget_set_size_request (window, 300, 300); - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create a Frame */ - frame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (window), frame); - - /* Set the frame's label */ - gtk_frame_set_label (GTK_FRAME (frame), "GTK Frame Widget"); - - /* Align the label at the right of the frame */ - gtk_frame_set_label_align (GTK_FRAME (frame), 1.0, 0.0); - - /* Set the style of the frame */ - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT); - - gtk_widget_show (frame); - - /* Display the window */ - gtk_widget_show (window); - - /* Enter the event loop */ - gtk_main (); - - return 0; -} diff --git a/examples/gdk/composited-window-example.c b/examples/gdk/composited-window-example.c deleted file mode 100644 index dbb49ec31d..0000000000 --- a/examples/gdk/composited-window-example.c +++ /dev/null @@ -1,137 +0,0 @@ -#include <gtk/gtk.h> - -/* The expose event handler for the event box. - * - * This function simply draws a transparency onto a widget on the area - * for which it receives expose events. This is intended to give the - * event box a "transparent" background. - * - * In order for this to work properly, the widget must have an RGBA - * colourmap. The widget should also be set as app-paintable since it - * doesn't make sense for GTK+ to draw a background if we are drawing it - * (and because GTK+ might actually replace our transparency with its - * default background colour). - */ -static gboolean -transparent_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - cairo_t *cr; - - cr = gdk_cairo_create (widget->window); - cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); - gdk_cairo_region (cr, event->region); - cairo_fill (cr); - cairo_destroy (cr); - - return FALSE; - } - -/* The expose event handler for the window. - * - * This function performs the actual compositing of the event box onto - * the already-existing background of the window at 50% normal opacity. - * - * In this case we do not want app-paintable to be set on the widget - * since we want it to draw its own (red) background. Because of this, - * however, we must ensure that we use g_signal_connect_after so that - * this handler is called after the red has been drawn. If it was - * called before then GTK would just blindly paint over our work. - * - * Note: if the child window has children, then you need a cairo 1.6 - * feature to make this work correctly. - */ -static gboolean -window_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - cairo_region_t *region; - GtkWidget *child; - cairo_t *cr; - - /* get our child (in this case, the event box) */ - child = gtk_bin_get_child (GTK_BIN (widget)); - - /* create a cairo context to draw to the window */ - cr = gdk_cairo_create (widget->window); - - /* the source data is the (composited) event box */ - gdk_cairo_set_source_pixmap (cr, child->window, - child->allocation.x, - child->allocation.y); - - /* draw no more than our expose event intersects our child */ - region = cairo_region_create_rectangle (&child->allocation); - cairo_region_intersect (region, region, event->region); - gdk_cairo_region (cr, region); - cairo_clip (cr); - cairo_region_destroy (region); - - /* composite, with a 50% opacity */ - cairo_set_operator (cr, CAIRO_OPERATOR_OVER); - cairo_paint_with_alpha (cr, 0.5); - - /* we're done */ - cairo_destroy (cr); - - return FALSE; -} - -int -main (int argc, char **argv) -{ - GtkWidget *window, *event, *button; - GdkScreen *screen; - GdkColormap *rgba; - GdkColor red; - - gtk_init (&argc, &argv); - - /* Make the widgets */ - button = gtk_button_new_with_label ("A Button"); - event = gtk_event_box_new (); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - /* Put a red background on the window */ - gdk_color_parse ("red", &red); - gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &red); - - /* Set the colourmap for the event box. - * Must be done before the event box is realised. - */ - screen = gtk_widget_get_screen (event); - rgba = gdk_screen_get_rgba_colormap (screen); - gtk_widget_set_colormap (event, rgba); - - /* Set our event box to have a fully-transparent background - * drawn on it. Currently there is no way to simply tell GTK+ - * that "transparency" is the background colour for a widget. - */ - gtk_widget_set_app_paintable (GTK_WIDGET (event), TRUE); - g_signal_connect (event, "expose-event", - G_CALLBACK (transparent_expose), NULL); - - /* Put them inside one another */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_container_add (GTK_CONTAINER (window), event); - gtk_container_add (GTK_CONTAINER (event), button); - - /* Realise and show everything */ - gtk_widget_show_all (window); - - /* Set the event box GdkWindow to be composited. - * Obviously must be performed after event box is realised. - */ - gdk_window_set_composited (event->window, TRUE); - - /* Set up the compositing handler. - * Note that we do _after_ so that the normal (red) background is drawn - * by gtk before our compositing occurs. - */ - g_signal_connect_after (window, "expose-event", - G_CALLBACK (window_expose_event), NULL); - - gtk_main (); - - return 0; -} diff --git a/examples/gtkdial/Makefile b/examples/gtkdial/Makefile deleted file mode 100644 index 0f83a9df03..0000000000 --- a/examples/gtkdial/Makefile +++ /dev/null @@ -1,20 +0,0 @@ - -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) -c dial_test.c -o dial_test.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags` - -gtkdial.o: gtkdial.c gtkdial.h - $(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 deleted file mode 100644 index a0884afdcf..0000000000 --- a/examples/gtkdial/dial_test.c +++ /dev/null @@ -1,68 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <gtk/gtk.h> -#include "gtkdial.h" - -void value_changed( GtkAdjustment *adjustment, - GtkWidget *label ) -{ - char buffer[16]; - - sprintf(buffer,"%4.2f",gtk_adjustment_get_value (adjustment)); - gtk_label_set_text (GTK_LABEL (label), buffer); -} - -int main( int argc, - char *argv[]) -{ - GtkWidget *window; - GtkAdjustment *adjustment; - GtkWidget *dial; - GtkWidget *frame; - GtkWidget *vbox; - GtkWidget *label; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_window_set_title (GTK_WINDOW (window), "Dial"); - - g_signal_connect (window, "destroy", - G_CALLBACK (exit), NULL); - - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (vbox), frame); - gtk_widget_show (frame); - - 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_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_end (GTK_BOX (vbox), label, 0, 0, 0); - gtk_widget_show (label); - - g_signal_connect (adjustment, "value-changed", - G_CALLBACK (value_changed), - label); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/gtkdial/gtkdial.c b/examples/gtkdial/gtkdial.c deleted file mode 100644 index 8adb035c46..0000000000 --- a/examples/gtkdial/gtkdial.c +++ /dev/null @@ -1,675 +0,0 @@ - -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include <math.h> -#include <stdio.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> - -#include "gtkdial.h" - -#define SCROLL_DELAY_LENGTH 300 -#define DIAL_DEFAULT_SIZE 100 - -/* Forward declarations */ - -static void gtk_dial_class_init (GtkDialClass *klass); -static void gtk_dial_init (GtkDial *dial); -static void gtk_dial_destroy (GtkWidget *widget); -static void gtk_dial_realize (GtkWidget *widget); -static void gtk_dial_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_dial_get_preferred_heigh (GtkWidget *widget, - gint *minimum, - gint *natural); -static void gtk_dial_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean gtk_dial_expose (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_dial_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean gtk_dial_button_release (GtkWidget *widget, - GdkEventButton *event); -static gboolean gtk_dial_motion_notify (GtkWidget *widget, - GdkEventMotion *event); -static gboolean gtk_dial_timer (GtkDial *dial); - -static void gtk_dial_update_mouse (GtkDial *dial, gint x, gint y); -static void gtk_dial_update (GtkDial *dial); -static void gtk_dial_adjustment_changed (GtkAdjustment *adjustment, - gpointer data); -static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, - gpointer data); - -/* Local data */ - -static GtkWidgetClass *parent_class = NULL; - -GType -gtk_dial_get_type () -{ - static GType dial_type = 0; - - if (!dial_type) - { - const GTypeInfo dial_info = - { - sizeof (GtkDialClass), - NULL, - NULL, - (GClassInitFunc) gtk_dial_class_init, - NULL, - NULL, - sizeof (GtkDial), - 0, - (GInstanceInitFunc) gtk_dial_init, - }; - - dial_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkDial", &dial_info, 0); - } - - return dial_type; -} - -static void -gtk_dial_class_init (GtkDialClass *class) -{ - GtkWidgetClass *widget_class; - - widget_class = (GtkWidgetClass*) class; - - parent_class = g_type_class_peek_parent (class); - - widget_class->destroy = gtk_dial_destroy; - widget_class->realize = gtk_dial_realize; - widget_class->expose_event = gtk_dial_expose; - widget_class->get_preferred_width = gtk_dial_get_preferred_width; - widget_class->get_preferred_height = gtk_dial_get_preferred_height; - widget_class->size_allocate = gtk_dial_size_allocate; - widget_class->button_press_event = gtk_dial_button_press; - widget_class->button_release_event = gtk_dial_button_release; - widget_class->motion_notify_event = gtk_dial_motion_notify; -} - -static void -gtk_dial_init (GtkDial *dial) -{ - dial->button = 0; - dial->policy = GTK_UPDATE_CONTINUOUS; - dial->timer = 0; - dial->radius = 0; - dial->pointer_width = 0; - dial->angle = 0.0; - dial->old_value = 0.0; - dial->old_lower = 0.0; - dial->old_upper = 0.0; - dial->adjustment = NULL; -} - -GtkWidget* -gtk_dial_new (GtkAdjustment *adjustment) -{ - GtkDial *dial; - - dial = g_object_new (gtk_dial_get_type (), NULL); - - if (!adjustment) - adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - - gtk_dial_set_adjustment (dial, adjustment); - - return GTK_WIDGET (dial); -} - -static void -gtk_dial_destroy (GtkWidget *widget) -{ - GtkDial *dial; - - g_return_if_fail (object != NULL); - g_return_if_fail (GTK_IS_DIAL (object)); - - dial = GTK_DIAL (widget); - - if (dial->adjustment) - { - g_object_unref (dial->adjustment); - dial->adjustment = NULL; - } - - GTK_WIDGET_CLASS (parent_class)->destroy (widget); -} - -GtkAdjustment* -gtk_dial_get_adjustment (GtkDial *dial) -{ - g_return_val_if_fail (dial != NULL, NULL); - g_return_val_if_fail (GTK_IS_DIAL (dial), NULL); - - return dial->adjustment; -} - -void -gtk_dial_set_update_policy (GtkDial *dial, - GtkUpdateType policy) -{ - g_return_if_fail (dial != NULL); - g_return_if_fail (GTK_IS_DIAL (dial)); - - dial->policy = policy; -} - -void -gtk_dial_set_adjustment (GtkDial *dial, - GtkAdjustment *adjustment) -{ - g_return_if_fail (dial != NULL); - g_return_if_fail (GTK_IS_DIAL (dial)); - - if (dial->adjustment) - { - g_signal_handlers_disconnect_by_func (dial->adjustment, NULL, (gpointer) dial); - g_object_unref (dial->adjustment); - } - - dial->adjustment = adjustment; - g_object_ref (dial->adjustment); - - g_signal_connect (G_OBJECT (adjustment), "changed", - G_CALLBACK (gtk_dial_adjustment_changed), - (gpointer) dial); - g_signal_connect (G_OBJECT (adjustment), "value_changed", - G_CALLBACK (gtk_dial_adjustment_value_changed), - (gpointer) dial); - - dial->old_value = gtk_adjustment_get_value (adjustment); - dial->old_lower = gtk_adjustment_get_lower (adjustment); - dial->old_upper = gtk_adjustment_get_upper (adjustment); - - gtk_dial_update (dial); -} - -static void -gtk_dial_realize (GtkWidget *widget) -{ - GtkDial *dial; - GdkWindowAttr attributes; - gint attributes_mask; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_DIAL (widget)); - - gtk_widget_set_realized (widget, TRUE); - dial = GTK_DIAL (widget); - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = gtk_widget_get_events (widget) | - GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); - - widget->style = gtk_style_attach (widget->style, widget->window); - - gdk_window_set_user_data (widget->window, widget); - - gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE); -} - -static void -gtk_dial_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural); -{ - *minimum = *natural = DIAL_DEFAULT_SIZE; -} - -static void -gtk_dial_get_preferred_heigh (GtkWidget *widget, - gint *minimum, - gint *natural); -{ - *minimum = *natural = DIAL_DEFAULT_SIZE; -} - -static void -gtk_dial_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkDial *dial; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_DIAL (widget)); - g_return_if_fail (allocation != NULL); - - widget->allocation = *allocation; - dial = GTK_DIAL (widget); - - if (gtk_widget_get_realized (widget)) - { - - gdk_window_move_resize (widget->window, - allocation->x, allocation->y, - allocation->width, allocation->height); - - } - dial->radius = MIN (allocation->width, allocation->height) * 0.45; - dial->pointer_width = dial->radius / 5; -} - -static gboolean -gtk_dial_expose( GtkWidget *widget, - GdkEventExpose *event ) -{ - GtkDial *dial; - GdkPoint points[6]; - gdouble s,c; - gdouble theta, last, increment; - GtkStyle *blankstyle; - gint xc, yc; - gint upper, lower; - gint tick_length; - gint i, inc; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (event->count > 0) - return FALSE; - - dial = GTK_DIAL (widget); - -/* gdk_window_clear_area (widget->window, - 0, 0, - widget->allocation.width, - widget->allocation.height); -*/ - xc = widget->allocation.width / 2; - yc = widget->allocation.height / 2; - - upper = gtk_adjustment_get_upper (dial->adjustment); - lower = gtk_adjustment_get_lower (dial->adjustment); - - /* Erase old pointer */ - - s = sin (dial->last_angle); - c = cos (dial->last_angle); - dial->last_angle = dial->angle; - - points[0].x = xc + s*dial->pointer_width/2; - points[0].y = yc + c*dial->pointer_width/2; - points[1].x = xc + c*dial->radius; - points[1].y = yc - s*dial->radius; - points[2].x = xc - s*dial->pointer_width/2; - points[2].y = yc - c*dial->pointer_width/2; - points[3].x = xc - c*dial->radius/10; - points[3].y = yc + s*dial->radius/10; - points[4].x = points[0].x; - points[4].y = points[0].y; - - blankstyle = gtk_style_new (); - blankstyle->bg_gc[GTK_STATE_NORMAL] = - widget->style->bg_gc[GTK_STATE_NORMAL]; - blankstyle->dark_gc[GTK_STATE_NORMAL] = - widget->style->bg_gc[GTK_STATE_NORMAL]; - blankstyle->light_gc[GTK_STATE_NORMAL] = - widget->style->bg_gc[GTK_STATE_NORMAL]; - blankstyle->black_gc = - widget->style->bg_gc[GTK_STATE_NORMAL]; - blankstyle->depth = - gdk_drawable_get_depth( GDK_DRAWABLE (widget->window)); - - gtk_paint_polygon (blankstyle, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - NULL, - widget, - NULL, - points, 5, - FALSE); - - g_object_unref (blankstyle); - - - /* Draw ticks */ - - if ((upper - lower) == 0) - return FALSE; - - increment = (100*M_PI) / (dial->radius*dial->radius); - - inc = (upper - lower); - - while (inc < 100) inc *= 10; - while (inc >= 1000) inc /= 10; - last = -1; - - for (i = 0; i <= inc; i++) - { - theta = ((gfloat)i*M_PI / (18*inc/24.) - M_PI/6.); - - if ((theta - last) < (increment)) - continue; - last = theta; - - s = sin (theta); - c = cos (theta); - - tick_length = (i%(inc/10) == 0) ? dial->pointer_width : dial->pointer_width / 2; - - gdk_draw_line (widget->window, - widget->style->fg_gc[widget->state], - xc + c*(dial->radius - tick_length), - yc - s*(dial->radius - tick_length), - xc + c*dial->radius, - yc - s*dial->radius); - } - - /* Draw pointer */ - - s = sin (dial->angle); - c = cos (dial->angle); - dial->last_angle = dial->angle; - - points[0].x = xc + s*dial->pointer_width/2; - points[0].y = yc + c*dial->pointer_width/2; - points[1].x = xc + c*dial->radius; - points[1].y = yc - s*dial->radius; - points[2].x = xc - s*dial->pointer_width/2; - points[2].y = yc - c*dial->pointer_width/2; - points[3].x = xc - c*dial->radius/10; - points[3].y = yc + s*dial->radius/10; - points[4].x = points[0].x; - points[4].y = points[0].y; - - - gtk_paint_polygon (widget->style, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - NULL, - widget, - NULL, - points, 5, - TRUE); - - return FALSE; -} - -static gboolean -gtk_dial_button_press( GtkWidget *widget, - GdkEventButton *event ) -{ - GtkDial *dial; - gint dx, dy; - double s, c; - double d_parallel; - double d_perpendicular; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - dial = GTK_DIAL (widget); - - /* Determine if button press was within pointer region - we - do this by computing the parallel and perpendicular distance of - the point where the mouse was pressed from the line passing through - the pointer */ - - dx = event->x - widget->allocation.width / 2; - dy = widget->allocation.height / 2 - event->y; - - s = sin (dial->angle); - c = cos (dial->angle); - - d_parallel = s*dy + c*dx; - d_perpendicular = fabs (s*dx - c*dy); - - if (!dial->button && - (d_perpendicular < dial->pointer_width/2) && - (d_parallel > - dial->pointer_width)) - { - gtk_grab_add (widget); - - dial->button = event->button; - - gtk_dial_update_mouse (dial, event->x, event->y); - } - - return FALSE; -} - -static gboolean -gtk_dial_button_release( GtkWidget *widget, - GdkEventButton *event ) -{ - GtkDial *dial; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - dial = GTK_DIAL (widget); - - if (dial->button == event->button) - { - gtk_grab_remove (widget); - - dial->button = 0; - - if (dial->policy == GTK_UPDATE_DELAYED) - g_source_remove (dial->timer); - - if ((dial->policy != GTK_UPDATE_CONTINUOUS) && - (dial->old_value != gtk_adjustment_get_value (dial->adjustment))) - g_signal_emit_by_name (dial->adjustment, "value_changed"); - } - - return FALSE; -} - -static gboolean -gtk_dial_motion_notify( GtkWidget *widget, - GdkEventMotion *event ) -{ - GtkDial *dial; - GdkModifierType mods; - gint x, y, mask; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - dial = GTK_DIAL (widget); - - if (dial->button != 0) - { - x = event->x; - y = event->y; - - if (event->is_hint || (event->window != widget->window)) - gdk_window_get_pointer (widget->window, &x, &y, &mods); - - switch (dial->button) - { - case 1: - mask = GDK_BUTTON1_MASK; - break; - case 2: - mask = GDK_BUTTON2_MASK; - break; - case 3: - mask = GDK_BUTTON3_MASK; - break; - default: - mask = 0; - break; - } - - if (mods & mask) - gtk_dial_update_mouse (dial, x,y); - } - - return FALSE; -} - -static gboolean -gtk_dial_timer( GtkDial *dial ) -{ - g_return_val_if_fail (dial != NULL, FALSE); - g_return_val_if_fail (GTK_IS_DIAL (dial), FALSE); - - if (dial->policy == GTK_UPDATE_DELAYED) - g_signal_emit_by_name (dial->adjustment, "value_changed"); - - return FALSE; -} - -static void -gtk_dial_update_mouse( GtkDial *dial, gint x, gint y ) -{ - gint xc, yc; - gfloat old_value; - - g_return_if_fail (dial != NULL); - g_return_if_fail (GTK_IS_DIAL (dial)); - - xc = GTK_WIDGET(dial)->allocation.width / 2; - yc = GTK_WIDGET(dial)->allocation.height / 2; - - old_value = gtk_adjustment_get_value (dial->adjustment); - dial->angle = atan2(yc-y, x-xc); - - if (dial->angle < -M_PI/2.) - dial->angle += 2*M_PI; - - if (dial->angle < -M_PI/6) - dial->angle = -M_PI/6; - - if (dial->angle > 7.*M_PI/6.) - dial->angle = 7.*M_PI/6.; - - gtk_adjustment_get_value (dial->adjustment) = gtk_adjustment_get_lower (dial->adjustment) + (7.*M_PI/6 - dial->angle) * - (gtk_adjustment_get_upper (dial->adjustment) - gtk_adjustment_get_lower (dial->adjustment)) / (4.*M_PI/3.); - - if (gtk_adjustment_get_value (dial->adjustment) != old_value) - { - if (dial->policy == GTK_UPDATE_CONTINUOUS) - { - g_signal_emit_by_name (dial->adjustment, "value_changed"); - } - else - { - gtk_widget_queue_draw (GTK_WIDGET (dial)); - - if (dial->policy == GTK_UPDATE_DELAYED) - { - if (dial->timer) - g_source_remove (dial->timer); - - dial->timer = gdk_threads_add_timeout (SCROLL_DELAY_LENGTH, - (GSourceFunc) gtk_dial_timer, - (gpointer) dial); - } - } - } -} - -static void -gtk_dial_update (GtkDial *dial) -{ - gfloat new_value; - - g_return_if_fail (dial != NULL); - g_return_if_fail (GTK_IS_DIAL (dial)); - - new_value = gtk_adjustment_get_value (dial->adjustment); - - if (new_value < gtk_adjustment_get_lower (dial->adjustment)) - new_value = gtk_adjustment_get_lower (dial->adjustment); - - if (new_value > gtk_adjustment_get_upper (dial->adjustment)) - new_value = gtk_adjustment_get_upper (dial->adjustment); - - if (new_value != gtk_adjustment_get_value (dial->adjustment)) - { - gtk_adjustment_get_value (dial->adjustment) = new_value; - g_signal_emit_by_name (dial->adjustment, "value_changed"); - } - - dial->angle = 7.*M_PI/6. - (new_value - gtk_adjustment_get_lower (dial->adjustment)) * 4.*M_PI/3. / - (gtk_adjustment_get_upper (dial->adjustment) - gtk_adjustment_get_lower (dial->adjustment)); - - gtk_widget_queue_draw (GTK_WIDGET (dial)); -} - -static void -gtk_dial_adjustment_changed (GtkAdjustment *adjustment, - gpointer data) -{ - GtkDial *dial; - - g_return_if_fail (adjustment != NULL); - g_return_if_fail (data != NULL); - - dial = GTK_DIAL (data); - - if ((dial->old_value != gtk_adjustment_get_value (adjustment)) || - (dial->old_lower != gtk_adjustment_get_lower (adjustment)) || - (dial->old_upper != gtk_adjustment_get_upper (adjustment))) - { - gtk_dial_update (dial); - - dial->old_value = gtk_adjustment_get_value (adjustment); - dial->old_lower = gtk_adjustment_get_lower (adjustment); - dial->old_upper = gtk_adjustment_get_upper (adjustment); - } -} - -static void -gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment, - gpointer data) -{ - GtkDial *dial; - - g_return_if_fail (adjustment != NULL); - g_return_if_fail (data != NULL); - - dial = GTK_DIAL (data); - - if (dial->old_value != gtk_adjustment_get_value (adjustment)) - { - gtk_dial_update (dial); - - dial->old_value = gtk_adjustment_get_value (adjustment); - } -} diff --git a/examples/gtkdial/gtkdial.h b/examples/gtkdial/gtkdial.h deleted file mode 100644 index 0994e79ffa..0000000000 --- a/examples/gtkdial/gtkdial.h +++ /dev/null @@ -1,89 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GTK_DIAL_H__ -#define __GTK_DIAL_H__ - - -#include <gdk/gdk.h> -#include <gtk/gtkadjustment.h> -#include <gtk/gtkwidget.h> - - -G_BEGIN_DECLS - - -#define GTK_DIAL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_dial_get_type (), GtkDial) -#define GTK_DIAL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gtk_dial_get_type (), GtkDialClass) -#define GTK_IS_DIAL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_dial_get_type ()) - - -typedef struct _GtkDial GtkDial; -typedef struct _GtkDialClass GtkDialClass; - -struct _GtkDial -{ - GtkWidget widget; - - /* update policy (GTK_UPDATE_[CONTINUOUS/DELAYED/DISCONTINUOUS]) */ - guint policy : 2; - - /* Button currently pressed or 0 if none */ - guint8 button; - - /* Dimensions of dial components */ - gint radius; - gint pointer_width; - - /* ID of update timer, or 0 if none */ - guint32 timer; - - /* Current angle */ - gfloat angle; - gfloat last_angle; - - /* Old values from adjustment stored so we know when something changes */ - gfloat old_value; - gfloat old_lower; - gfloat old_upper; - - /* The adjustment object that stores the data for this dial */ - GtkAdjustment *adjustment; -}; - -struct _GtkDialClass -{ - GtkWidgetClass parent_class; -}; - - -GtkWidget* gtk_dial_new (GtkAdjustment *adjustment); -GType gtk_dial_get_type (void); -GtkAdjustment* gtk_dial_get_adjustment (GtkDial *dial); -void gtk_dial_set_update_policy (GtkDial *dial, - GtkUpdateType policy); - -void gtk_dial_set_adjustment (GtkDial *dial, - GtkAdjustment *adjustment); - - -G_END_DECLS - - -#endif /* __GTK_DIAL_H__ */ diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile deleted file mode 100644 index 0e3d0559d6..0000000000 --- a/examples/helloworld/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -helloworld: helloworld.c - $(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 deleted file mode 100644 index 8a9b0cb3b2..0000000000 --- a/examples/helloworld/helloworld.c +++ /dev/null @@ -1,99 +0,0 @@ - -#include <gtk/gtk.h> - -/* This is a callback function. The data arguments are ignored - * in this example. More on callbacks below. */ -static void hello( GtkWidget *widget, - gpointer data ) -{ - g_print ("Hello World\n"); -} - -static gboolean delete_event( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - /* If you return FALSE in the "delete_event" signal handler, - * GTK will emit the "destroy" signal. Returning TRUE means - * you don't want the window to be destroyed. - * This is useful for popping up 'are you sure you want to quit?' - * type dialogs. */ - - g_print ("delete event occurred\n"); - - /* Change TRUE to FALSE and the main window will be destroyed with - * a "delete_event". */ - - return TRUE; -} - -/* Another callback */ -static void destroy( GtkWidget *widget, - gpointer data ) -{ - gtk_main_quit (); -} - -int main( int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window; - GtkWidget *button; - - /* This is called in all GTK applications. Arguments are parsed - * from the command line and are returned to the application. */ - gtk_init (&argc, &argv); - - /* create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - /* When the window is given the "delete-event" signal (this is given - * by the window manager, usually by the "close" option, or on the - * 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. */ - g_signal_connect (window, "delete-event", - G_CALLBACK (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. */ - g_signal_connect (window, "destroy", - G_CALLBACK (destroy), NULL); - - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Creates a new button with the label "Hello World". */ - button = gtk_button_new_with_label ("Hello World"); - - /* 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. */ - g_signal_connect (button, "clicked", - G_CALLBACK (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. */ - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), - window); - - /* This packs the button into the window (a gtk container). */ - gtk_container_add (GTK_CONTAINER (window), button); - - /* The final step is to display this newly created widget. */ - gtk_widget_show (button); - - /* and the window */ - gtk_widget_show (window); - - /* All GTK applications must have a gtk_main(). Control ends here - * and waits for an event to occur (like a key press or - * mouse event). */ - gtk_main (); - - return 0; -} diff --git a/examples/helloworld2/Makefile b/examples/helloworld2/Makefile deleted file mode 100644 index d574f2e4bb..0000000000 --- a/examples/helloworld2/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -helloworld2: helloworld2.c - $(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 deleted file mode 100644 index 93fde5bcef..0000000000 --- a/examples/helloworld2/helloworld2.c +++ /dev/null @@ -1,94 +0,0 @@ - -#include <gtk/gtk.h> - -/* Our new improved callback. The data passed to this function - * is printed to stdout. */ -static void callback (GtkWidget *widget, - gpointer data) -{ - g_print ("Hello again - %s was pressed\n", (gchar *) data); -} - -/* another callback */ -static gboolean delete_event (GtkWidget *widget, - GdkEvent *event, - gpointer data) -{ - gtk_main_quit (); - return FALSE; -} - -int main (int argc, - char *argv[]) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window; - GtkWidget *button; - GtkWidget *box1; - - /* This is called in all GTK applications. Arguments are parsed - * from the command line and are returned to the application. */ - gtk_init (&argc, &argv); - - /* Create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - /* This is a new call, which just sets the title of our - * new window to "Hello Buttons!" */ - gtk_window_set_title (GTK_WINDOW (window), "Hello Buttons!"); - - /* Here we just set a handler for delete_event that immediately - * exits GTK. */ - g_signal_connect (window, "delete-event", - G_CALLBACK (delete_event), NULL); - - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* We create a box to pack widgets into. This is described in detail - * in the "packing" section. The box is not really visible, it - * is just used as a tool to arrange widgets. */ - box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - - /* Put the box into the main window. */ - gtk_container_add (GTK_CONTAINER (window), box1); - - /* 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 */ - g_signal_connect (button, "clicked", - G_CALLBACK (callback), "button 1"); - - /* Instead of gtk_container_add, we pack this button into the invisible - * box, which has been packed into the window. */ - gtk_box_pack_start (GTK_BOX (box1), button, TRUE, TRUE, 0); - - /* Always remember this step, this tells GTK that our preparation for - * this button is complete, and it can now be displayed. */ - gtk_widget_show (button); - - /* Do these same steps again to create a second button */ - button = gtk_button_new_with_label ("Button 2"); - - /* Call the same callback function with a different argument, - * passing a pointer to "button 2" instead. */ - g_signal_connect (button, "clicked", - G_CALLBACK (callback), "button 2"); - - gtk_box_pack_start (GTK_BOX (box1), button, TRUE, TRUE, 0); - - /* The order in which we show the buttons is not really important, but I - * recommend showing the window last, so it all pops up at once. */ - gtk_widget_show (button); - - gtk_widget_show (box1); - - gtk_widget_show (window); - - /* Rest in gtk_main and wait for the fun to begin! */ - gtk_main (); - - return 0; -} diff --git a/examples/label/Makefile b/examples/label/Makefile deleted file mode 100644 index f59b4bb1d1..0000000000 --- a/examples/label/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -label: label.c - $(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 deleted file mode 100644 index 48ca40caad..0000000000 --- a/examples/label/label.c +++ /dev/null @@ -1,100 +0,0 @@ - -#include <gtk/gtk.h> - -int main( int argc, - char *argv[] ) -{ - static GtkWidget *window = NULL; - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *frame; - GtkWidget *label; - - /* Initialise GTK */ - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - - gtk_window_set_title (GTK_WINDOW (window), "Label"); - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5); - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 5); - gtk_container_add (GTK_CONTAINER (window), hbox); - gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (window), 5); - - frame = gtk_frame_new ("Normal Label"); - label = gtk_label_new ("This is a Normal label"); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - frame = gtk_frame_new ("Multi-line Label"); - label = gtk_label_new ("This is a Multi-line label.\nSecond line\n" \ - "Third line"); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - frame = gtk_frame_new ("Left Justified Label"); - label = gtk_label_new ("This is a Left-Justified\n" \ - "Multi-line label.\nThird line"); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - frame = gtk_frame_new ("Right Justified Label"); - label = gtk_label_new ("This is a Right-Justified\nMulti-line label.\n" \ - "Fourth line, (j/k)"); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5); - gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); - frame = gtk_frame_new ("Line wrapped label"); - label = gtk_label_new ("This is an example of a line-wrapped label. It " \ - "should not be taking up the entire " /* big space to test spacing */\ - "width allocated to it, but automatically " \ - "wraps the words to fit. " \ - "The time has come, for all good men, to come to " \ - "the aid of their party. " \ - "The sixth sheik's six sheep's sick.\n" \ - " It supports multiple paragraphs correctly, " \ - "and correctly adds "\ - "many extra spaces. "); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - frame = gtk_frame_new ("Filled, wrapped label"); - label = gtk_label_new ("This is an example of a line-wrapped, filled label. " \ - "It should be taking "\ - "up the entire width allocated to it. " \ - "Here is a sentence to prove "\ - "my point. Here is another sentence. "\ - "Here comes the sun, do de do de do.\n"\ - " This is a new paragraph.\n"\ - " This is another newer, longer, better " \ - "paragraph. It is coming to an end, "\ - "unfortunately."); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_FILL); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - frame = gtk_frame_new ("Underlined label"); - label = gtk_label_new ("This label is underlined!\n" - "This one is underlined in quite a funky fashion"); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_label_set_pattern (GTK_LABEL (label), - "_________________________ _ _________ _ ______ __ _______ ___"); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - gtk_widget_show_all (window); - - gtk_main (); - - return 0; -} diff --git a/examples/menu/Makefile b/examples/menu/Makefile deleted file mode 100644 index 0ed6adb5ac..0000000000 --- a/examples/menu/Makefile +++ /dev/null @@ -1,15 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED - -all: menu - -menu: menu.c - $(CC) menu.c -o menu $(CFLAGS) `pkg-config gtk+-3.0 --cflags --libs` - -clean: - rm -f *.o menu diff --git a/examples/menu/menu.c b/examples/menu/menu.c deleted file mode 100644 index f37e4e3e48..0000000000 --- a/examples/menu/menu.c +++ /dev/null @@ -1,134 +0,0 @@ - -#include <stdio.h> -#include <gtk/gtk.h> - -static gboolean button_press (GtkWidget *, GdkEvent *); -static void menuitem_response (gchar *); - -int main( int argc, - char *argv[] ) -{ - - GtkWidget *window; - GtkWidget *menu; - GtkWidget *menu_bar; - GtkWidget *root_menu; - GtkWidget *menu_items; - GtkWidget *vbox; - GtkWidget *button; - char buf[128]; - int i; - - gtk_init (&argc, &argv); - - /* create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); - gtk_window_set_title (GTK_WINDOW (window), "GTK Menu Test"); - g_signal_connect (window, "delete-event", - G_CALLBACK (gtk_main_quit), NULL); - - /* Init the menu-widget, and remember -- never - * gtk_show_widget() the menu widget!! - * This is the menu that holds the menu items, the one that - * will pop up when you click on the "Root Menu" in the app */ - menu = gtk_menu_new (); - - /* Next we make a little loop that makes three menu-entries for "test-menu". - * Notice the call to gtk_menu_shell_append. Here we are adding a list of - * menu items to our menu. Normally, we'd also catch the "clicked" - * signal on each of the menu items and setup a callback for it, - * but it's omitted here to save space. */ - - for (i = 0; i < 3; i++) - { - /* Copy the names to the buf. */ - sprintf (buf, "Test-undermenu - %d", i); - - /* Create a new menu-item with a name... */ - menu_items = gtk_menu_item_new_with_label (buf); - - /* ...and add it to the menu. */ - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); - - /* Do something interesting when the menuitem is selected */ - g_signal_connect_swapped (menu_items, "activate", - G_CALLBACK (menuitem_response), - (gpointer) g_strdup (buf)); - - /* Show the widget */ - gtk_widget_show (menu_items); - } - - /* This is the root menu, and will be the label - * displayed on the menu bar. There won't be a signal handler attached, - * as it only pops up the rest of the menu when pressed. */ - root_menu = gtk_menu_item_new_with_label ("Root Menu"); - - gtk_widget_show (root_menu); - - /* Now we specify that we want our newly created "menu" to be the menu - * for the "root menu" */ - gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu); - - /* A vbox to put a menu and a button in: */ - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); - - /* Create a menu-bar to hold the menus and add it to our main window */ - menu_bar = gtk_menu_bar_new (); - gtk_box_pack_start (GTK_BOX (vbox), menu_bar, FALSE, FALSE, 2); - gtk_widget_show (menu_bar); - - /* Create a button to which to attach menu as a popup */ - button = gtk_button_new_with_label ("press me"); - g_signal_connect_swapped (button, "event", - G_CALLBACK (button_press), - 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_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. */ - gtk_widget_show (window); - - gtk_main (); - - return 0; -} - -/* Respond to a button-press by posting a menu passed in as widget. - * - * Note that the "widget" argument is the menu being posted, NOT - * the button that was pressed. - */ - -static gboolean button_press( GtkWidget *widget, - GdkEvent *event ) -{ - - if (event->type == GDK_BUTTON_PRESS) { - GdkEventButton *bevent = (GdkEventButton *) event; - gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, - bevent->button, bevent->time); - /* Tell calling code that we have handled this event; the buck - * stops here. */ - return TRUE; - } - - /* Tell calling code that we have not handled this event; pass it on. */ - return FALSE; -} - - -/* Print a string when a menu item is selected */ - -static void menuitem_response( gchar *string ) -{ - printf ("%s\n", string); -} diff --git a/examples/notebook/Makefile b/examples/notebook/Makefile deleted file mode 100644 index 7ab745a7da..0000000000 --- a/examples/notebook/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -notebook: notebook.c - $(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 deleted file mode 100644 index 17a22c7943..0000000000 --- a/examples/notebook/notebook.c +++ /dev/null @@ -1,175 +0,0 @@ - -#include <stdio.h> -#include <gtk/gtk.h> - -/* This function rotates the position of the tabs */ -static void rotate_book( GtkButton *button, - GtkNotebook *notebook ) -{ - gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos + 1) % 4); -} - -/* Add/Remove the page tabs and the borders */ -static void tabsborder_book( GtkButton *button, - GtkNotebook *notebook ) -{ - gint tval = FALSE; - gint bval = FALSE; - if (notebook->show_tabs == 0) - tval = TRUE; - if (notebook->show_border == 0) - bval = TRUE; - - gtk_notebook_set_show_tabs (notebook, tval); - gtk_notebook_set_show_border (notebook, bval); -} - -/* Remove a page from the notebook */ -static void remove_book( GtkButton *button, - GtkNotebook *notebook ) -{ - gint page; - - page = gtk_notebook_get_current_page (notebook); - gtk_notebook_remove_page (notebook, page); - /* Need to refresh the widget -- - This forces the widget to redraw itself. */ - gtk_widget_queue_draw (GTK_WIDGET (notebook)); -} - -static gboolean delete( GtkWidget *widget, - GtkWidget *event, - gpointer data ) -{ - gtk_main_quit (); - return FALSE; -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *button; - GtkWidget *table; - GtkWidget *notebook; - GtkWidget *frame; - GtkWidget *label; - GtkWidget *checkbutton; - int i; - char bufferf[32]; - char bufferl[32]; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - g_signal_connect (window, "delete-event", - G_CALLBACK (delete), NULL); - - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - table = gtk_table_new (3, 6, FALSE); - gtk_container_add (GTK_CONTAINER (window), table); - - /* Create a new notebook, place the position of the tabs */ - notebook = gtk_notebook_new (); - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); - gtk_table_attach_defaults (GTK_TABLE (table), notebook, 0, 6, 0, 1); - gtk_widget_show (notebook); - - /* Let's append a bunch of pages to the notebook */ - for (i = 0; i < 5; i++) { - sprintf(bufferf, "Append Frame %d", i + 1); - sprintf(bufferl, "Page %d", i + 1); - - frame = gtk_frame_new (bufferf); - gtk_container_set_border_width (GTK_CONTAINER (frame), 10); - gtk_widget_set_size_request (frame, 100, 75); - gtk_widget_show (frame); - - label = gtk_label_new (bufferf); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_widget_show (label); - - label = gtk_label_new (bufferl); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label); - } - - /* Now let's add a page to a specific spot */ - checkbutton = gtk_check_button_new_with_label ("Check me please!"); - gtk_widget_set_size_request (checkbutton, 100, 75); - gtk_widget_show (checkbutton); - - label = gtk_label_new ("Add page"); - gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), checkbutton, label, 2); - - /* Now finally let's prepend pages to the notebook */ - for (i = 0; i < 5; i++) { - sprintf (bufferf, "Prepend Frame %d", i + 1); - sprintf (bufferl, "PPage %d", i + 1); - - frame = gtk_frame_new (bufferf); - gtk_container_set_border_width (GTK_CONTAINER (frame), 10); - gtk_widget_set_size_request (frame, 100, 75); - gtk_widget_show (frame); - - label = gtk_label_new (bufferf); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_widget_show (label); - - label = gtk_label_new (bufferl); - gtk_notebook_prepend_page (GTK_NOTEBOOK (notebook), frame, label); - } - - /* Set what page to start at (page 4) */ - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 3); - - /* Create a bunch of buttons */ - button = gtk_button_new_with_label ("close"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (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"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_notebook_next_page), - 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"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_notebook_prev_page), - 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"); - g_signal_connect (button, "clicked", - G_CALLBACK (rotate_book), - 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"); - g_signal_connect (button, "clicked", - G_CALLBACK (tabsborder_book), - 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"); - g_signal_connect (button, "clicked", - G_CALLBACK (remove_book), - notebook); - gtk_table_attach_defaults (GTK_TABLE (table), button, 5, 6, 1, 2); - gtk_widget_show (button); - - gtk_widget_show (table); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/packbox/Makefile b/examples/packbox/Makefile deleted file mode 100644 index b837519d75..0000000000 --- a/examples/packbox/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -packbox: packbox.c - $(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 deleted file mode 100644 index d5dd98abbe..0000000000 --- a/examples/packbox/packbox.c +++ /dev/null @@ -1,291 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include "gtk/gtk.h" - -static gboolean delete_event( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit (); - return FALSE; -} - -/* Make a new hbox filled with button-labels. Arguments for the - * variables we're interested are passed in to this function. - * We do not show the box, but do show everything inside. */ -static GtkWidget *make_box( gboolean homogeneous, - gint spacing, - gboolean expand, - gboolean fill, - guint padding ) -{ - GtkWidget *box; - GtkWidget *button; - char padstr[80]; - - /* Create a new hbox with the appropriate homogeneous - * and spacing settings */ - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, homogeneous, spacing); - - /* Create a series of buttons with the appropriate settings */ - button = gtk_button_new_with_label ("gtk_box_pack"); - gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding); - gtk_widget_show (button); - - button = gtk_button_new_with_label ("(box,"); - gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding); - gtk_widget_show (button); - - button = gtk_button_new_with_label ("button,"); - gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding); - gtk_widget_show (button); - - /* Create a button with the label depending on the value of - * expand. */ - if (expand == TRUE) - button = gtk_button_new_with_label ("TRUE,"); - else - button = gtk_button_new_with_label ("FALSE,"); - - gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding); - gtk_widget_show (button); - - /* This is the same as the button creation for "expand" - * above, but uses the shorthand form. */ - button = gtk_button_new_with_label (fill ? "TRUE," : "FALSE,"); - gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding); - gtk_widget_show (button); - - sprintf (padstr, "%d);", padding); - - button = gtk_button_new_with_label (padstr); - gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding); - gtk_widget_show (button); - - return box; -} - -int main( int argc, - char *argv[]) -{ - GtkWidget *window; - GtkWidget *button; - GtkWidget *box1; - GtkWidget *box2; - GtkWidget *separator; - GtkWidget *label; - GtkWidget *quitbox; - int which; - - /* Our init, don't forget this! :) */ - gtk_init (&argc, &argv); - - 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. */ - exit (1); - } - - which = atoi (argv[1]); - - /* Create our window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - /* You should always remember to connect the "delete-event" signal - * to the main window. This is very important for proper intuitive - * behavior */ - g_signal_connect (window, "delete-event", - G_CALLBACK (delete_event), NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* We create a vertical box (vbox) to pack the horizontal boxes into. - * This allows us to stack the horizontal boxes filled with buttons one - * on top of the other in this vbox. */ - box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - - /* which example to show. These correspond to the pictures above. */ - switch (which) { - case 1: - /* create a new label. */ - label = gtk_label_new ("gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);"); - - /* Align the label to the left side. We'll discuss this function and - * others in the section on Widget Attributes. */ - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - - /* Pack the label into the vertical box (vbox box1). Remember that - * widgets added to a vbox will be packed one on top of the other in - * order. */ - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); - - /* Show the label */ - gtk_widget_show (label); - - /* Call our make box function - homogeneous = FALSE, spacing = 0, - * expand = FALSE, fill = FALSE, padding = 0 */ - box2 = make_box (FALSE, 0, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Call our make box function - homogeneous = FALSE, spacing = 0, - * expand = TRUE, fill = FALSE, padding = 0 */ - box2 = make_box (FALSE, 0, TRUE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (FALSE, 0, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Creates a separator, we'll learn more about these later, - * but they are quite simple. */ - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - - /* Pack the separator into the vbox. Remember each of these - * widgets is being packed into a vbox, so they'll be stacked - * vertically. */ - gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); - gtk_widget_show (separator); - - /* Create another new label, and show it. */ - label = gtk_label_new ("gtk_box_new (GTK_ORIENTATION_HORIZONTAL, TRUE, 0);"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (TRUE, 0, TRUE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (TRUE, 0, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Another new separator. */ - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - /* The last 3 arguments to gtk_box_pack_start are: - * expand, fill, padding. */ - gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); - gtk_widget_show (separator); - - break; - - case 2: - - /* Create a new label, remember box1 is a vbox as created - * near the beginning of main() */ - label = gtk_label_new ("gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10);"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (FALSE, 10, TRUE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (FALSE, 10, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - /* The last 3 arguments to gtk_box_pack_start are: - * expand, fill, padding. */ - gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); - gtk_widget_show (separator); - - label = gtk_label_new ("gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (FALSE, 0, TRUE, FALSE, 10); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* Args are: homogeneous, spacing, expand, fill, padding */ - box2 = make_box (FALSE, 0, TRUE, TRUE, 10); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - /* The last 3 arguments to gtk_box_pack_start are: expand, fill, padding. */ - gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 5); - gtk_widget_show (separator); - break; - - case 3: - - /* This demonstrates the ability to use gtk_box_pack_end() to - * right justify widgets. First, we create a new box as before. */ - box2 = make_box (FALSE, 0, FALSE, FALSE, 0); - - /* Create the label that will be put at the end. */ - label = gtk_label_new ("end"); - /* Pack it using gtk_box_pack_end(), so it is put on the right - * side of the hbox created in the make_box() call. */ - gtk_box_pack_end (GTK_BOX (box2), label, FALSE, FALSE, 0); - /* Show the label. */ - gtk_widget_show (label); - - /* Pack box2 into box1 (the vbox remember ? :) */ - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0); - gtk_widget_show (box2); - - /* A separator for the bottom. */ - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - /* This explicitly sets the separator to 400 pixels wide by 5 pixels - * high. This is so the hbox we created will also be 400 pixels wide, - * 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_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); - gtk_widget_show (separator); - } - - /* Create another new hbox.. remember we can use as many as we need! */ - quitbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - - /* Our quit button. */ - button = gtk_button_new_with_label ("Quit"); - - /* Setup the signal to terminate the program when the button is clicked */ - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_main_quit), - window); - /* Pack the button into the quitbox. - * The last 3 arguments to gtk_box_pack_start are: - * expand, fill, padding. */ - gtk_box_pack_start (GTK_BOX (quitbox), button, TRUE, FALSE, 0); - /* pack the quitbox into the vbox (box1) */ - gtk_box_pack_start (GTK_BOX (box1), quitbox, FALSE, FALSE, 0); - - /* Pack the vbox (box1) which now contains all our widgets, into the - * main window. */ - gtk_container_add (GTK_CONTAINER (window), box1); - - /* And show everything left */ - gtk_widget_show (button); - gtk_widget_show (quitbox); - - gtk_widget_show (box1); - /* Showing the window last so everything pops up at once. */ - gtk_widget_show (window); - - /* And of course, our main function. */ - gtk_main (); - - /* Control returns here when gtk_main_quit() is called, but not when - * exit() is used. */ - - return 0; -} diff --git a/examples/paned/Makefile b/examples/paned/Makefile deleted file mode 100644 index d1ad1a9a50..0000000000 --- a/examples/paned/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -paned: paned.c - $(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 deleted file mode 100644 index e72b0830b8..0000000000 --- a/examples/paned/paned.c +++ /dev/null @@ -1,137 +0,0 @@ - -#include <stdio.h> -#include <gtk/gtk.h> - -/* Create the list of "messages" */ -static GtkWidget *create_list( void ) -{ - - GtkWidget *scrolled_window; - GtkWidget *tree_view; - GtkListStore *model; - GtkTreeIter iter; - GtkCellRenderer *cell; - GtkTreeViewColumn *column; - - int i; - - /* Create a new scrolled window, with scrollbars only if needed */ - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - model = gtk_list_store_new (1, G_TYPE_STRING); - tree_view = gtk_tree_view_new (); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), - tree_view); - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); - gtk_widget_show (tree_view); - - /* Add some messages to the window */ - for (i = 0; i < 10; i++) { - gchar *msg = g_strdup_printf ("Message #%d", i); - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), - &iter, - 0, msg, - -1); - g_free (msg); - } - - cell = gtk_cell_renderer_text_new (); - - column = gtk_tree_view_column_new_with_attributes ("Messages", - cell, - "text", 0, - NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), - GTK_TREE_VIEW_COLUMN (column)); - - return scrolled_window; -} - -/* Add some text to our text widget - this is a callback that is invoked -when our window is realized. We could also force our window to be -realized with gtk_widget_realize, but it would have to be part of -a hierarchy first */ - -static void insert_text( GtkTextBuffer *buffer ) -{ - GtkTextIter iter; - - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - - gtk_text_buffer_insert (buffer, &iter, - "From: pathfinder@nasa.gov\n" - "To: mom@nasa.gov\n" - "Subject: Made it!\n" - "\n" - "We just got in this morning. The weather has been\n" - "great - clear but cold, and there are lots of fun sights.\n" - "Sojourner says hi. See you soon.\n" - " -Path\n", -1); -} - -/* Create a scrolled text area that displays a "message" */ -static GtkWidget *create_text( void ) -{ - GtkWidget *scrolled_window; - GtkWidget *view; - GtkTextBuffer *buffer; - - view = gtk_text_view_new (); - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scrolled_window), view); - insert_text (buffer); - - gtk_widget_show_all (scrolled_window); - - return scrolled_window; -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *vpaned; - GtkWidget *list; - GtkWidget *text; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Paned Windows"); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - gtk_widget_set_size_request (GTK_WIDGET (window), 450, 400); - - /* create a vpaned widget and add it to our toplevel window */ - - vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL); - gtk_container_add (GTK_CONTAINER (window), vpaned); - gtk_widget_show (vpaned); - - /* Now create the contents of the two halves of the window */ - - list = create_list (); - gtk_paned_add1 (GTK_PANED (vpaned), list); - gtk_widget_show (list); - - text = create_text (); - gtk_paned_add2 (GTK_PANED (vpaned), text); - gtk_widget_show (text); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/progressbar/Makefile b/examples/progressbar/Makefile deleted file mode 100644 index 42e650c366..0000000000 --- a/examples/progressbar/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -progressbar: progressbar.c - $(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 deleted file mode 100644 index 37342ddec6..0000000000 --- a/examples/progressbar/progressbar.c +++ /dev/null @@ -1,198 +0,0 @@ - -#include <gtk/gtk.h> - -typedef struct _ProgressData { - GtkWidget *window; - GtkWidget *pbar; - int timer; - gboolean activity_mode; -} ProgressData; - -/* Update the value of the progress bar so that we get - * some movement */ -static gboolean progress_timeout( gpointer data ) -{ - ProgressData *pdata = (ProgressData *)data; - gdouble new_val; - - if (pdata->activity_mode) - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (pdata->pbar)); - else - { - /* Calculate the value of the progress bar using the - * value range set in the adjustment object */ - - new_val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (pdata->pbar)) + 0.01; - - if (new_val > 1.0) - new_val = 0.0; - - /* Set the new value */ - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pdata->pbar), new_val); - } - - /* As this is a timeout function, return TRUE so that it - * continues to get called */ - return TRUE; -} - -/* Callback that toggles the text display within the progress bar trough */ -static void toggle_show_text( GtkWidget *widget, - ProgressData *pdata ) -{ - const gchar *text; - - text = gtk_progress_bar_get_text (GTK_PROGRESS_BAR (pdata->pbar)); - if (text && *text) - gtk_progress_bar_set_text (GTK_PROGRESS_BAR (pdata->pbar), ""); - else - gtk_progress_bar_set_text (GTK_PROGRESS_BAR (pdata->pbar), "some text"); -} - -/* Callback that toggles the activity mode of the progress bar */ -static void toggle_activity_mode( GtkWidget *widget, - ProgressData *pdata ) -{ - pdata->activity_mode = !pdata->activity_mode; - if (pdata->activity_mode) - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (pdata->pbar)); - else - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pdata->pbar), 0.0); -} - - -/* Callback that toggles the orientation of the progress bar */ -static void toggle_orientation( GtkWidget *widget, - ProgressData *pdata ) -{ - switch (gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (pdata->pbar))) { - case GTK_PROGRESS_LEFT_TO_RIGHT: - gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (pdata->pbar), - GTK_PROGRESS_RIGHT_TO_LEFT); - break; - case GTK_PROGRESS_RIGHT_TO_LEFT: - gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (pdata->pbar), - GTK_PROGRESS_LEFT_TO_RIGHT); - break; - default:; - /* do nothing */ - } -} - - -/* Clean up allocated memory and remove the timer */ -static void destroy_progress( GtkWidget *widget, - ProgressData *pdata) -{ - g_source_remove (pdata->timer); - pdata->timer = 0; - pdata->window = NULL; - g_free (pdata); - gtk_main_quit (); -} - -int main( int argc, - char *argv[]) -{ - ProgressData *pdata; - GtkWidget *align; - GtkWidget *separator; - GtkWidget *table; - GtkWidget *button; - GtkWidget *check; - GtkWidget *vbox; - - gtk_init (&argc, &argv); - - /* Allocate memory for the data that is passed to the callbacks */ - pdata = g_malloc (sizeof (ProgressData)); - - pdata->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_resizable (GTK_WINDOW (pdata->window), TRUE); - - g_signal_connect (G_OBJECT (pdata->window), "destroy", - G_CALLBACK (destroy_progress), - (gpointer) pdata); - gtk_window_set_title (GTK_WINDOW (pdata->window), "GtkProgressBar"); - gtk_container_set_border_width (GTK_CONTAINER (pdata->window), 0); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 10); - gtk_container_add (GTK_CONTAINER (pdata->window), vbox); - gtk_widget_show (vbox); - - /* Create a centering alignment object */ - align = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 5); - gtk_widget_show (align); - - /* Create the GtkProgressBar */ - pdata->pbar = gtk_progress_bar_new (); - pdata->activity_mode = FALSE; - - gtk_container_add (GTK_CONTAINER (align), pdata->pbar); - gtk_widget_show (pdata->pbar); - - /* Add a timer callback to update the value of the progress bar */ - pdata->timer = gdk_threads_add_timeout (100, progress_timeout, pdata); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0); - gtk_widget_show (separator); - - /* rows, columns, homogeneous */ - table = gtk_table_new (2, 3, FALSE); - gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0); - gtk_widget_show (table); - - /* Add a check button to select displaying of the trough text */ - check = gtk_check_button_new_with_label ("Show text"); - gtk_table_attach (GTK_TABLE (table), check, 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, - 5, 5); - g_signal_connect (G_OBJECT (check), "clicked", - G_CALLBACK (toggle_show_text), - (gpointer) pdata); - gtk_widget_show (check); - - /* Add a check button to toggle activity mode */ - check = gtk_check_button_new_with_label ("Activity mode"); - gtk_table_attach (GTK_TABLE (table), check, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, - 5, 5); - g_signal_connect (G_OBJECT (check), "clicked", - G_CALLBACK (toggle_activity_mode), - (gpointer) pdata); - gtk_widget_show (check); - - /* Add a check button to toggle orientation */ - check = gtk_check_button_new_with_label ("Right to Left"); - gtk_table_attach (GTK_TABLE (table), check, 0, 1, 2, 3, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, - 5, 5); - g_signal_connect (G_OBJECT (check), "clicked", - G_CALLBACK (toggle_orientation), - (gpointer) pdata); - gtk_widget_show (check); - - /* Add a button to exit the program */ - button = gtk_button_new_with_label ("close"); - g_signal_connect_swapped (G_OBJECT (button), "clicked", - G_CALLBACK (gtk_widget_destroy), - G_OBJECT (pdata->window)); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - /* This makes it so the button is the default. */ - gtk_widget_set_can_default (button, TRUE); - - /* This grabs this button to be the default button. Simply hitting - * the "Enter" key will cause this button to activate. */ - gtk_widget_grab_default (button); - gtk_widget_show (button); - - gtk_widget_show (pdata->window); - - gtk_main (); - - return 0; -} diff --git a/examples/radiobuttons/Makefile b/examples/radiobuttons/Makefile deleted file mode 100644 index 43efadeee7..0000000000 --- a/examples/radiobuttons/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -radiobuttons: radiobuttons.c - $(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 deleted file mode 100644 index 2869df9c44..0000000000 --- a/examples/radiobuttons/radiobuttons.c +++ /dev/null @@ -1,80 +0,0 @@ - -#include <glib.h> -#include <gtk/gtk.h> - -static gboolean close_application( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit (); - return FALSE; -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window = NULL; - GtkWidget *box1; - GtkWidget *box2; - GtkWidget *button; - GtkWidget *separator; - GSList *group; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - g_signal_connect (window, "delete-event", - G_CALLBACK (close_application), - NULL); - - gtk_window_set_title (GTK_WINDOW (window), "radio buttons"); - gtk_container_set_border_width (GTK_CONTAINER (window), 0); - - box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), box1); - gtk_widget_show (box1); - - box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - button = gtk_radio_button_new_with_label (NULL, "button1"); - gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); - gtk_widget_show (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_from_widget (GTK_RADIO_BUTTON (button), - "button3"); - gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); - gtk_widget_show (button); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); - gtk_widget_show (separator); - - box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); - gtk_widget_show (box2); - - button = gtk_button_new_with_label ("close"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (close_application), - window); - gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); - gtk_widget_set_can_default (button, TRUE); - gtk_widget_grab_default (button); - gtk_widget_show (button); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/rangewidgets/Makefile b/examples/rangewidgets/Makefile deleted file mode 100644 index f018f81ec9..0000000000 --- a/examples/rangewidgets/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED - -rangewidgets: rangewidgets.c - $(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 deleted file mode 100644 index b59dc85d26..0000000000 --- a/examples/rangewidgets/rangewidgets.c +++ /dev/null @@ -1,293 +0,0 @@ - -#include <gtk/gtk.h> - -GtkWidget *hscale, *vscale; - -static void cb_pos_menu_select( GtkWidget *item, - GtkPositionType pos ) -{ - /* Set the value position on both scale widgets */ - gtk_scale_set_value_pos (GTK_SCALE (hscale), pos); - gtk_scale_set_value_pos (GTK_SCALE (vscale), pos); -} - -static void cb_update_menu_select( GtkWidget *item, - GtkUpdateType policy ) -{ - /* Set the update policy for both scale widgets */ - gtk_range_set_update_policy (GTK_RANGE (hscale), policy); - gtk_range_set_update_policy (GTK_RANGE (vscale), policy); -} - -static void cb_digits_scale( GtkAdjustment *adj ) -{ - /* Set the number of decimal places to which adj->value is rounded */ - gtk_scale_set_digits (GTK_SCALE (hscale), (gint) adj->value); - gtk_scale_set_digits (GTK_SCALE (vscale), (gint) adj->value); -} - -static void cb_page_size( GtkAdjustment *get, - GtkAdjustment *set ) -{ - /* Set the page size and page increment size of the sample - * adjustment to the value specified by the "Page Size" scale */ - set->page_size = get->value; - set->page_increment = get->value; - - /* This sets the adjustment and makes it emit the "changed" signal to - reconfigure all the widgets that are attached to this signal. */ - gtk_adjustment_set_value (set, CLAMP (set->value, - set->lower, - (set->upper - set->page_size))); - g_signal_emit_by_name(G_OBJECT(set), "changed"); -} - -static void cb_draw_value( GtkToggleButton *button ) -{ - /* Turn the value display on the scale widgets off or on depending - * on the state of the checkbutton */ - gtk_scale_set_draw_value (GTK_SCALE (hscale), button->active); - gtk_scale_set_draw_value (GTK_SCALE (vscale), button->active); -} - -/* Convenience functions */ - -static GtkWidget *make_menu_item ( gchar *name, - GCallback callback, - gpointer data ) -{ - GtkWidget *item; - - item = gtk_menu_item_new_with_label (name); - g_signal_connect (item, "activate", - callback, (gpointer) data); - gtk_widget_show (item); - - return item; -} - -static void scale_set_default_values( GtkScale *scale ) -{ - gtk_range_set_update_policy (GTK_RANGE (scale), - GTK_UPDATE_CONTINUOUS); - gtk_scale_set_digits (scale, 1); - gtk_scale_set_value_pos (scale, GTK_POS_TOP); - gtk_scale_set_draw_value (scale, TRUE); -} - -/* makes the sample window */ - -static void create_range_controls( void ) -{ - GtkWidget *window; - GtkWidget *box1, *box2, *box3; - GtkWidget *button; - GtkWidget *scrollbar; - GtkWidget *separator; - GtkWidget *opt, *menu, *item; - GtkWidget *label; - GtkWidget *scale; - GtkAdjustment *adj1, *adj2; - - /* Standard window-creating stuff */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - gtk_window_set_title (GTK_WINDOW (window), "range controls"); - - box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), box1); - gtk_widget_show (box1); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - /* value, lower, upper, step_increment, page_increment, page_size */ - /* Note that the page_size value only makes a difference for - * scrollbar widgets, and the highest value you'll get is actually - * (upper - page_size). */ - adj1 = gtk_adjustment_new (0.0, 0.0, 101.0, 0.1, 1.0, 1.0); - - vscale = gtk_scale_new (GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT (adj1)); - scale_set_default_values (GTK_SCALE (vscale)); - gtk_box_pack_start (GTK_BOX (box2), vscale, TRUE, TRUE, 0); - gtk_widget_show (vscale); - - box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); - gtk_box_pack_start (GTK_BOX (box2), box3, TRUE, TRUE, 0); - gtk_widget_show (box3); - - /* Reuse the same adjustment */ - hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (adj1)); - gtk_widget_set_size_request (GTK_WIDGET (hscale), 200, -1); - scale_set_default_values (GTK_SCALE (hscale)); - gtk_box_pack_start (GTK_BOX (box3), hscale, TRUE, TRUE, 0); - gtk_widget_show (hscale); - - /* Reuse the same adjustment again */ - scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (adj1)); - /* Notice how this causes the scales to always be updated - * continuously when the scrollbar is moved */ - gtk_range_set_update_policy (GTK_RANGE (scrollbar), - GTK_UPDATE_CONTINUOUS); - gtk_box_pack_start (GTK_BOX (box3), scrollbar, TRUE, TRUE, 0); - gtk_widget_show (scrollbar); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - /* 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); - g_signal_connect (button, "toggled", - G_CALLBACK (cb_draw_value), NULL); - gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); - gtk_widget_show (button); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - - /* An option menu to change the position of the value */ - label = gtk_label_new ("Scale Value Position:"); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - opt = gtk_option_menu_new (); - menu = gtk_menu_new (); - - item = make_menu_item ("Top", - G_CALLBACK (cb_pos_menu_select), - GINT_TO_POINTER (GTK_POS_TOP)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = make_menu_item ("Bottom", G_CALLBACK (cb_pos_menu_select), - GINT_TO_POINTER (GTK_POS_BOTTOM)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = make_menu_item ("Left", G_CALLBACK (cb_pos_menu_select), - GINT_TO_POINTER (GTK_POS_LEFT)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = make_menu_item ("Right", G_CALLBACK (cb_pos_menu_select), - GINT_TO_POINTER (GTK_POS_RIGHT)); - 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); - gtk_widget_show (opt); - - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - - /* Yet another option menu, this time for the update policy of the - * scale widgets */ - label = gtk_label_new ("Scale Update Policy:"); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - opt = gtk_option_menu_new (); - menu = gtk_menu_new (); - - item = make_menu_item ("Continuous", - G_CALLBACK (cb_update_menu_select), - GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = make_menu_item ("Discontinuous", - G_CALLBACK (cb_update_menu_select), - GINT_TO_POINTER (GTK_UPDATE_DISCONTINUOUS)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = make_menu_item ("Delayed", - G_CALLBACK (cb_update_menu_select), - GINT_TO_POINTER (GTK_UPDATE_DELAYED)); - 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); - gtk_widget_show (opt); - - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - - /* An HScale widget for adjusting the number of digits on the - * sample scales. */ - label = gtk_label_new ("Scale Digits:"); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - adj2 = gtk_adjustment_new (1.0, 0.0, 5.0, 1.0, 1.0, 0.0); - g_signal_connect (adj2, "value_changed", - G_CALLBACK (cb_digits_scale), NULL); - scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (adj2)); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0); - gtk_widget_show (scale); - - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - - /* And, one last HScale widget for adjusting the page size of the - * scrollbar. */ - label = gtk_label_new ("Scrollbar Page Size:"); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - adj2 = gtk_adjustment_new (1.0, 1.0, 101.0, 1.0, 1.0, 0.0); - g_signal_connect (adj2, "value-changed", - G_CALLBACK (cb_page_size), (gpointer) adj1); - scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (adj2)); - gtk_scale_set_digits (GTK_SCALE (scale), 0); - gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0); - gtk_widget_show (scale); - - gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); - gtk_widget_show (box2); - - separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); - gtk_widget_show (separator); - - box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (box2), 10); - gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); - gtk_widget_show (box2); - - button = gtk_button_new_with_label ("Quit"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_main_quit), - NULL); - gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); - gtk_widget_set_can_default (button, TRUE); - gtk_widget_grab_default (button); - gtk_widget_show (button); - - gtk_widget_show (window); -} - -int main( int argc, - char *argv[] ) -{ - gtk_init (&argc, &argv); - - create_range_controls (); - - gtk_main (); - - return 0; -} - diff --git a/examples/rulers/Makefile b/examples/rulers/Makefile deleted file mode 100644 index 336183ccfc..0000000000 --- a/examples/rulers/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -rulers: rulers.c - $(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 deleted file mode 100644 index 4f689ad844..0000000000 --- a/examples/rulers/rulers.c +++ /dev/null @@ -1,77 +0,0 @@ - -#include <gtk/gtk.h> - -#define EVENT_METHOD(i, x) GTK_WIDGET_GET_CLASS(i)->x - -#define XSIZE 600 -#define YSIZE 400 - -/* This routine gets control when the close button is clicked */ -static gboolean close_application( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit (); - return FALSE; -} - -/* The main routine */ -int main( int argc, - char *argv[] ) { - GtkWidget *window, *table, *area, *hrule, *vrule; - - /* Initialize GTK and create the main window */ - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (window, "delete-event", - G_CALLBACK (close_application), NULL); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - /* Create a table for placing the ruler and the drawing area */ - table = gtk_table_new (3, 2, FALSE); - gtk_container_add (GTK_CONTAINER (window), table); - - area = gtk_drawing_area_new (); - 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 | - GDK_POINTER_MOTION_HINT_MASK); - - /* The horizontal ruler goes on top. As the mouse moves across the - * drawing area, a motion_notify_event is passed to the - * appropriate event handler for the ruler. */ - hrule = gtk_ruler_new (GTK_ORIENTATION_HORIZONTAL); - gtk_ruler_set_metric (GTK_RULER (hrule), GTK_PIXELS); - gtk_ruler_set_range (GTK_RULER (hrule), 7, 13, 0, 20); - g_signal_connect_swapped (area, "motion-notify-event", - G_CALLBACK (EVENT_METHOD (hrule, - motion_notify_event)), - hrule); - gtk_table_attach (GTK_TABLE (table), hrule, 1, 2, 0, 1, - GTK_EXPAND|GTK_SHRINK|GTK_FILL, GTK_FILL, 0, 0); - - /* The vertical ruler goes on the left. As the mouse moves across - * the drawing area, a motion_notify_event is passed to the - * appropriate event handler for the ruler. */ - vrule = gtk_ruler_new (GTK_ORIENTATION_VERTICAL); - gtk_ruler_set_metric (GTK_RULER (vrule), GTK_PIXELS); - gtk_ruler_set_range (GTK_RULER (vrule), 0, YSIZE, 10, YSIZE ); - g_signal_connect_swapped (area, "motion-notify-event", - G_CALLBACK (EVENT_METHOD (vrule, - motion_notify_event)), - vrule); - gtk_table_attach (GTK_TABLE (table), vrule, 0, 1, 1, 2, - GTK_FILL, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0); - - /* Now show everything */ - gtk_widget_show (area); - gtk_widget_show (hrule); - gtk_widget_show (vrule); - gtk_widget_show (table); - gtk_widget_show (window); - gtk_main (); - - return 0; -} diff --git a/examples/scribble-simple/Makefile b/examples/scribble-simple/Makefile deleted file mode 100644 index 53c53aa2a9..0000000000 --- a/examples/scribble-simple/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -scribble-simple: scribble-simple.c - $(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 deleted file mode 100644 index 0689752d85..0000000000 --- a/examples/scribble-simple/scribble-simple.c +++ /dev/null @@ -1,181 +0,0 @@ - -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <stdlib.h> -#include <gtk/gtk.h> - -/* Backing pixmap for drawing area */ -static GdkPixmap *pixmap = NULL; - -/* Create a new backing pixmap of the appropriate size */ -static gboolean configure_event( GtkWidget *widget, - GdkEventConfigure *event ) -{ - if (pixmap) - g_object_unref (pixmap); - - pixmap = gdk_pixmap_new (widget->window, - widget->allocation.width, - widget->allocation.height, - -1); - gdk_draw_rectangle (pixmap, - widget->style->white_gc, - TRUE, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - return TRUE; -} - -/* Redraw the screen from the backing pixmap */ -static gboolean expose_event( GtkWidget *widget, - GdkEventExpose *event ) -{ - gdk_draw_drawable (widget->window, - widget->style->fg_gc[gtk_widget_get_state (widget)], - pixmap, - event->area.x, event->area.y, - event->area.x, event->area.y, - event->area.width, event->area.height); - - return FALSE; -} - -/* Draw a rectangle on the screen */ -static void draw_brush( GtkWidget *widget, - gdouble x, - gdouble y) -{ - GdkRectangle update_rect; - - update_rect.x = x - 5; - update_rect.y = y - 5; - update_rect.width = 10; - update_rect.height = 10; - gdk_draw_rectangle (pixmap, - widget->style->black_gc, - TRUE, - update_rect.x, update_rect.y, - update_rect.width, update_rect.height); - gtk_widget_queue_draw_area (widget, - update_rect.x, update_rect.y, - update_rect.width, update_rect.height); -} - -static gboolean button_press_event( GtkWidget *widget, - GdkEventButton *event ) -{ - if (event->button == 1 && pixmap != NULL) - draw_brush (widget, event->x, event->y); - - return TRUE; -} - -static gboolean motion_notify_event( GtkWidget *widget, - GdkEventMotion *event ) -{ - int x, y; - GdkModifierType state; - - if (event->is_hint) - gdk_window_get_pointer (event->window, &x, &y, &state); - else - { - x = event->x; - y = event->y; - state = event->state; - } - - if (state & GDK_BUTTON1_MASK && pixmap != NULL) - draw_brush (widget, x, y); - - return TRUE; -} - -void quit () -{ - exit (0); -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *drawing_area; - GtkWidget *vbox; - - GtkWidget *button; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_name (window, "Test Input"); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); - - g_signal_connect (window, "destroy", - G_CALLBACK (quit), NULL); - - /* Create the drawing area */ - - drawing_area = gtk_drawing_area_new (); - 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 */ - - g_signal_connect (drawing_area, "expose-event", - G_CALLBACK (expose_event), NULL); - g_signal_connect (drawing_area,"configure-event", - G_CALLBACK (configure_event), NULL); - - /* Event signals */ - - g_signal_connect (drawing_area, "motion-notify-event", - G_CALLBACK (motion_notify_event), NULL); - g_signal_connect (drawing_area, "button-press-event", - G_CALLBACK (button_press_event), NULL); - - gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK - | GDK_LEAVE_NOTIFY_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK); - - /* .. And a quit button */ - button = gtk_button_new_with_label ("Quit"); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), - window); - gtk_widget_show (button); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/scribble-xinput/Makefile b/examples/scribble-xinput/Makefile deleted file mode 100644 index 4907190fdc..0000000000 --- a/examples/scribble-xinput/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED - -scribble-xinput: scribble-xinput.c - $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0` scribble-xinput.c -o scribble-xinput $(LDFLAGS) `pkg-config --libs gtk+-2.0` - -clean: - rm -f *.o scribble-xinput diff --git a/examples/scribble-xinput/scribble-xinput.c b/examples/scribble-xinput/scribble-xinput.c deleted file mode 100644 index 2ca3717ef1..0000000000 --- a/examples/scribble-xinput/scribble-xinput.c +++ /dev/null @@ -1,253 +0,0 @@ - -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <gtk/gtk.h> - -/* Backing pixmap for drawing area */ -static GdkPixmap *pixmap = NULL; - -/* Create a new backing pixmap of the appropriate size */ -static gboolean -configure_event (GtkWidget *widget, GdkEventConfigure *event) -{ - if (pixmap) - g_object_unref (pixmap); - - pixmap = gdk_pixmap_new (widget->window, - widget->allocation.width, - widget->allocation.height, - -1); - gdk_draw_rectangle (pixmap, - widget->style->white_gc, - TRUE, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - return TRUE; -} - -/* Redraw the screen from the backing pixmap */ -static gboolean -expose_event (GtkWidget *widget, GdkEventExpose *event) -{ - gdk_draw_drawable (widget->window, - widget->style->fg_gc[gtk_widget_get_state (widget)], - pixmap, - event->area.x, event->area.y, - event->area.x, event->area.y, - event->area.width, event->area.height); - - return FALSE; -} - -/* Draw a rectangle on the screen, size depending on pressure, - and color on the type of device */ -static void -draw_brush (GtkWidget *widget, GdkInputSource source, - gdouble x, gdouble y, gdouble pressure) -{ - GdkGC *gc; - GdkRectangle update_rect; - - switch (source) - { - case GDK_SOURCE_MOUSE: - gc = widget->style->dark_gc[gtk_widget_get_state (widget)]; - break; - case GDK_SOURCE_PEN: - gc = widget->style->black_gc; - break; - case GDK_SOURCE_ERASER: - gc = widget->style->white_gc; - break; - default: - gc = widget->style->light_gc[gtk_widget_get_state (widget)]; - } - - update_rect.x = x - 10 * pressure; - update_rect.y = y - 10 * pressure; - update_rect.width = 20 * pressure; - update_rect.height = 20 * pressure; - gdk_draw_rectangle (pixmap, gc, TRUE, - update_rect.x, update_rect.y, - update_rect.width, update_rect.height); - gtk_widget_queue_draw_area (widget, - update_rect.x, update_rect.y, - update_rect.width, update_rect.height); -} - -static void -print_button_press (GdkDevice *device) -{ - g_print ("Button press on device '%s'\n", device->name); -} - -static gboolean -button_press_event (GtkWidget *widget, GdkEventButton *event) -{ - print_button_press (event->device); - - 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; -} - -static gboolean -motion_notify_event (GtkWidget *widget, GdkEventMotion *event) -{ - gdouble x, y; - gdouble pressure; - GdkModifierType 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; - gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure); - state = event->state; - } - - if (state & GDK_BUTTON1_MASK && pixmap != NULL) - draw_brush (widget, event->device->source, x, y, pressure); - - return TRUE; -} - -void -input_dialog_destroy (GtkWidget *w, gpointer data) -{ - *((GtkWidget **)data) = NULL; -} - -void -create_input_dialog () -{ - static GtkWidget *inputd = NULL; - - if (!inputd) - { - inputd = gtk_input_dialog_new(); - - g_signal_connect (inputd, "destroy", - G_CALLBACK (input_dialog_destroy), &inputd); - g_signal_connect_swapped (GTK_INPUT_DIALOG (inputd)->close_button, - "clicked", - G_CALLBACK (gtk_widget_hide), - inputd); - gtk_widget_hide (GTK_INPUT_DIALOG (inputd)->save_button); - - gtk_widget_show (inputd); - } - else - { - if (!gtk_widget_get_mapped (inputd)) - gtk_widget_show (inputd); - else - gdk_window_raise (inputd->window); - } -} - -int -main (int argc, char *argv[]) -{ - GtkWidget *window; - GtkWidget *drawing_area; - GtkWidget *vbox; - - GtkWidget *button; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_name (window, "Test Input"); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), NULL); - - /* Create the drawing area */ - - drawing_area = gtk_drawing_area_new (); - 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 */ - - g_signal_connect (drawing_area, "expose-event", - G_CALLBACK (expose_event), NULL); - g_signal_connect (drawing_area,"configure-event", - G_CALLBACK (configure_event), NULL); - - /* Event signals */ - - g_signal_connect (drawing_area, "motion-notify-event", - G_CALLBACK (motion_notify_event), NULL); - g_signal_connect (drawing_area, "button-press-event", - G_CALLBACK (button_press_event), NULL); - - gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK - | GDK_LEAVE_NOTIFY_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK); - - /* The following call enables tracking and processing of extension - events for the drawing area */ - gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_CURSOR); - - /* .. And some buttons */ - button = gtk_button_new_with_label ("Input Dialog"); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - g_signal_connect (button, "clicked", - G_CALLBACK (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); - - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), - window); - gtk_widget_show (button); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/scrolledwin/Makefile b/examples/scrolledwin/Makefile deleted file mode 100644 index 2f07fd50e8..0000000000 --- a/examples/scrolledwin/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -scrolledwin: scrolledwin.c - $(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 deleted file mode 100644 index 7d09e648a8..0000000000 --- a/examples/scrolledwin/scrolledwin.c +++ /dev/null @@ -1,93 +0,0 @@ - -#include <stdio.h> -#include <gtk/gtk.h> - -static void destroy( GtkWidget *widget, - gpointer data ) -{ - gtk_main_quit (); -} - -int main( int argc, - char *argv[] ) -{ - static GtkWidget *window; - GtkWidget *scrolled_window; - GtkWidget *table; - GtkWidget *button; - char buffer[32]; - int i, j; - - gtk_init (&argc, &argv); - - /* Create a new dialog window for the scrolled window to be - * packed into. */ - window = gtk_dialog_new (); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (destroy), NULL); - gtk_window_set_title (GTK_WINDOW (window), "GtkScrolledWindow example"); - gtk_container_set_border_width (GTK_CONTAINER (window), 0); - gtk_widget_set_size_request (window, 300, 300); - - /* create a new scrolled window. */ - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - - gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10); - - /* the policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS. - * GTK_POLICY_AUTOMATIC will automatically decide whether you need - * scrollbars, whereas GTK_POLICY_ALWAYS will always leave the scrollbars - * there. The first one is the horizontal scrollbar, the second, - * the vertical. */ - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - /* The dialog window is created with a vbox packed into it. */ - gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->vbox), scrolled_window, - TRUE, TRUE, 0); - gtk_widget_show (scrolled_window); - - /* create a table of 10 by 10 squares. */ - table = gtk_table_new (10, 10, FALSE); - - /* set the spacing to 10 on x and 10 on y */ - gtk_table_set_row_spacings (GTK_TABLE (table), 10); - gtk_table_set_col_spacings (GTK_TABLE (table), 10); - - /* pack the table into the scrolled window */ - gtk_scrolled_window_add_with_viewport ( - GTK_SCROLLED_WINDOW (scrolled_window), table); - gtk_widget_show (table); - - /* this simply creates a grid of toggle buttons on the table - * to demonstrate the scrolled window. */ - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) { - sprintf (buffer, "button (%d,%d)\n", i, j); - button = gtk_toggle_button_new_with_label (buffer); - gtk_table_attach_defaults (GTK_TABLE (table), button, - i, i+1, j, j+1); - gtk_widget_show (button); - } - - /* Add a "close" button to the bottom of the dialog */ - button = gtk_button_new_with_label ("close"); - g_signal_connect_swapped (G_OBJECT (button), "clicked", - G_CALLBACK (gtk_widget_destroy), - G_OBJECT (window)); - - /* this makes it so the button is the default. */ - - gtk_widget_set_can_default (button, TRUE); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area), button, TRUE, TRUE, 0); - - /* This grabs this button to be the default button. Simply hitting - * the "Enter" key will cause this button to activate. */ - gtk_widget_grab_default (button); - gtk_widget_show (button); - - gtk_widget_show (window); - - gtk_main(); - - return 0; -} diff --git a/examples/selection/Makefile b/examples/selection/Makefile deleted file mode 100644 index eb07c9635a..0000000000 --- a/examples/selection/Makefile +++ /dev/null @@ -1,19 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -all: gettargets setselection - -gettargets: gettargets.c - $(CC) gettargets.c -o gettargets $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs` - -setselection: setselection.c - $(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 deleted file mode 100644 index 9b4aca4d7f..0000000000 --- a/examples/selection/gettargets.c +++ /dev/null @@ -1,97 +0,0 @@ - -#include <stdlib.h> -#include <gtk/gtk.h> - -static void selection_received( GtkWidget *widget, - GtkSelectionData *selection_data, - gpointer data ); - -/* Signal handler invoked when user clicks on the "Get Targets" button */ -static void get_targets( GtkWidget *widget, - gpointer data ) -{ - static GdkAtom targets_atom = GDK_NONE; - GtkWidget *window = (GtkWidget *)data; - - /* Get the atom corresponding to the string "TARGETS" */ - if (targets_atom == GDK_NONE) - targets_atom = gdk_atom_intern ("TARGETS", FALSE); - - /* And request the "TARGETS" target for the primary selection */ - gtk_selection_convert (window, GDK_SELECTION_PRIMARY, targets_atom, - GDK_CURRENT_TIME); -} - -/* Signal handler called when the selections owner returns the data */ -static void selection_received( GtkWidget *widget, - GtkSelectionData *selection_data, - gpointer data ) -{ - GdkAtom *atoms; - GList *item_list; - int i; - - /* **** IMPORTANT **** Check to see if retrieval succeeded */ - if (selection_data->length < 0) - { - g_print ("Selection retrieval failed\n"); - return; - } - /* Make sure we got the data in the expected form */ - if (selection_data->type != GDK_SELECTION_TYPE_ATOM) - { - g_print ("Selection \"TARGETS\" was not returned as atoms!\n"); - return; - } - - /* Print out the atoms we received */ - atoms = (GdkAtom *)selection_data->data; - - item_list = NULL; - for (i = 0; i < selection_data->length / sizeof(GdkAtom); i++) - { - char *name; - name = gdk_atom_name (atoms[i]); - if (name != NULL) - g_print ("%s\n",name); - else - g_print ("(bad atom)\n"); - } - - return; -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *button; - - gtk_init (&argc, &argv); - - /* Create the toplevel window */ - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Event Box"); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - g_signal_connect (window, "destroy", - G_CALLBACK (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); - - g_signal_connect (button, "clicked", - G_CALLBACK (get_targets), (gpointer) window); - g_signal_connect (window, "selection-received", - G_CALLBACK (selection_received), NULL); - - gtk_widget_show (button); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/selection/setselection.c b/examples/selection/setselection.c deleted file mode 100644 index 1e22c4eea1..0000000000 --- a/examples/selection/setselection.c +++ /dev/null @@ -1,111 +0,0 @@ - -#include <stdlib.h> -#include <gtk/gtk.h> -#include <time.h> -#include <string.h> - -GtkWidget *selection_button; -GtkWidget *selection_widget; - -/* Callback when the user toggles the selection */ -static void selection_toggled( GtkWidget *widget, - gint *have_selection ) -{ - if (GTK_TOGGLE_BUTTON (widget)->active) - { - *have_selection = gtk_selection_owner_set (selection_widget, - GDK_SELECTION_PRIMARY, - GDK_CURRENT_TIME); - /* if claiming the selection failed, we return the button to - the out state */ - if (!*have_selection) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); - } - else - { - if (*have_selection) - { - /* Before clearing the selection by setting the owner to NULL, - we check if we are the actual owner */ - if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == widget->window) - gtk_selection_owner_set (NULL, GDK_SELECTION_PRIMARY, - GDK_CURRENT_TIME); - *have_selection = FALSE; - } - } -} - -/* Called when another application claims the selection */ -static gboolean selection_clear( GtkWidget *widget, - GdkEventSelection *event, - gint *have_selection ) -{ - *have_selection = FALSE; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (selection_button), FALSE); - - return TRUE; -} - -/* Supplies the current time as the selection. */ -static void selection_handle( GtkWidget *widget, - GtkSelectionData *selection_data, - guint info, - guint time_stamp, - gpointer data ) -{ - gchar *timestr; - time_t current_time; - - current_time = time (NULL); - timestr = asctime (localtime (¤t_time)); - /* When we return a single string, it should not be null terminated. - That will be done for us */ - - gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, - 8, timestr, strlen (timestr)); -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - - static int have_selection = FALSE; - - gtk_init (&argc, &argv); - - /* Create the toplevel window */ - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "Event Box"); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - g_signal_connect (window, "destroy", - G_CALLBACK (exit), NULL); - - /* Create a toggle button to act as the selection */ - - selection_widget = gtk_invisible_new (); - selection_button = gtk_toggle_button_new_with_label ("Claim Selection"); - gtk_container_add (GTK_CONTAINER (window), selection_button); - gtk_widget_show (selection_button); - - g_signal_connect (selection_button, "toggled", - G_CALLBACK (selection_toggled), &have_selection); - g_signal_connect (selection_widget, "selection-clear-event", - G_CALLBACK (selection_clear), &have_selection); - - gtk_selection_add_target (selection_widget, - GDK_SELECTION_PRIMARY, - GDK_SELECTION_TYPE_STRING, - 1); - g_signal_connect (selection_widget, "selection-get", - G_CALLBACK (selection_handle), &have_selection); - - gtk_widget_show (selection_button); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/spinbutton/Makefile b/examples/spinbutton/Makefile deleted file mode 100644 index be4bcbfbe0..0000000000 --- a/examples/spinbutton/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -spinbutton: spinbutton.c - $(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 deleted file mode 100644 index ccde95d6a0..0000000000 --- a/examples/spinbutton/spinbutton.c +++ /dev/null @@ -1,217 +0,0 @@ - -#include <stdio.h> -#include <gtk/gtk.h> - -static GtkWidget *spinner1; - -static void toggle_snap( GtkWidget *widget, - GtkSpinButton *spin ) -{ - gtk_spin_button_set_snap_to_ticks (spin, GTK_TOGGLE_BUTTON (widget)->active); -} - -static void toggle_numeric( GtkWidget *widget, - GtkSpinButton *spin ) -{ - gtk_spin_button_set_numeric (spin, GTK_TOGGLE_BUTTON (widget)->active); -} - -static void change_digits( GtkWidget *widget, - GtkSpinButton *spin ) -{ - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner1), - gtk_spin_button_get_value_as_int (spin)); -} - -static void get_value( GtkWidget *widget, - gpointer data ) -{ - gchar *buf; - GtkLabel *label; - GtkSpinButton *spin; - - spin = GTK_SPIN_BUTTON (spinner1); - label = GTK_LABEL (g_object_get_data (G_OBJECT (widget), "user_data")); - if (GPOINTER_TO_INT (data) == 1) - buf = g_strdup_printf ("%d", gtk_spin_button_get_value_as_int (spin)); - else - buf = g_strdup_printf ("%0.*f", spin->digits, - gtk_spin_button_get_value (spin)); - gtk_label_set_text (label, buf); - g_free (buf); -} - - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *frame; - GtkWidget *hbox; - GtkWidget *main_vbox; - GtkWidget *vbox; - GtkWidget *vbox2; - GtkWidget *spinner2; - GtkWidget *spinner; - GtkWidget *button; - GtkWidget *label; - GtkWidget *val_label; - GtkAdjustment *adj; - - /* Initialise GTK */ - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - g_signal_connect (window, "destroy", - G_CALLBACK (gtk_main_quit), - NULL); - - gtk_window_set_title (GTK_WINDOW (window), "Spin Button"); - - main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10); - gtk_container_add (GTK_CONTAINER (window), main_vbox); - - frame = gtk_frame_new ("Not accelerated"); - gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - /* Day, month, year spinners */ - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5); - - label = gtk_label_new ("Day :"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0); - - adj = gtk_adjustment_new (1.0, 1.0, 31.0, 1.0, 5.0, 0.0); - spinner = gtk_spin_button_new (adj, 0, 0); - gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE); - gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5); - - label = gtk_label_new ("Month :"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0); - - adj = gtk_adjustment_new (1.0, 1.0, 12.0, 1.0, 5.0, 0.0); - spinner = gtk_spin_button_new (adj, 0, 0); - gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE); - gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5); - - label = gtk_label_new ("Year :"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0); - - adj = gtk_adjustment_new (1998.0, 0.0, 2100.0, 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_size_request (spinner, 55, -1); - gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0); - - frame = gtk_frame_new ("Accelerated"); - gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - gtk_container_add (GTK_CONTAINER (frame), vbox); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5); - - label = gtk_label_new ("Value :"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0); - - adj = gtk_adjustment_new (0.0, -10000.0, 10000.0, 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_size_request (spinner1, 100, -1); - gtk_box_pack_start (GTK_BOX (vbox2), spinner1, FALSE, TRUE, 0); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5); - - label = gtk_label_new ("Digits :"); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0); - - adj = 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); - g_signal_connect (adj, "value-changed", - G_CALLBACK (change_digits), - spinner2); - gtk_box_pack_start (GTK_BOX (vbox2), spinner2, FALSE, TRUE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); - - button = gtk_check_button_new_with_label ("Snap to 0.5-ticks"); - g_signal_connect (button, "clicked", - G_CALLBACK (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"); - g_signal_connect (button, "clicked", - G_CALLBACK (toggle_numeric), - spinner1); - gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - - val_label = gtk_label_new (""); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); - button = gtk_button_new_with_label ("Value as Int"); - g_object_set_data (G_OBJECT (button), "user_data", val_label); - g_signal_connect (button, "clicked", - G_CALLBACK (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"); - g_object_set_data (G_OBJECT (button), "user_data", val_label); - g_signal_connect (button, "clicked", - G_CALLBACK (get_value), - GINT_TO_POINTER (2)); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); - - gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0); - gtk_label_set_text (GTK_LABEL (val_label), "0"); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0); - - button = gtk_button_new_with_label ("Close"); - g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_widget_destroy), - window); - gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); - - gtk_widget_show_all (window); - - /* Enter the event loop */ - gtk_main (); - - return 0; -} - diff --git a/examples/statusbar/Makefile b/examples/statusbar/Makefile deleted file mode 100644 index e2bf326ba5..0000000000 --- a/examples/statusbar/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -statusbar: statusbar.c - $(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 deleted file mode 100644 index bd8d8e2a0b..0000000000 --- a/examples/statusbar/statusbar.c +++ /dev/null @@ -1,74 +0,0 @@ - -#include <stdlib.h> -#include <gtk/gtk.h> -#include <glib.h> - -GtkWidget *status_bar; - -static void push_item( GtkWidget *widget, - gpointer data ) -{ - static int count = 1; - gchar *buff; - - buff = g_strdup_printf ("Item %d", count++); - gtk_statusbar_push (GTK_STATUSBAR (status_bar), GPOINTER_TO_INT (data), buff); - g_free (buff); -} - -static void pop_item( GtkWidget *widget, - gpointer data ) -{ - gtk_statusbar_pop (GTK_STATUSBAR (status_bar), GPOINTER_TO_INT (data)); -} - -int main( int argc, - char *argv[] ) -{ - - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *button; - - gint context_id; - - gtk_init (&argc, &argv); - - /* create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); - gtk_window_set_title (GTK_WINDOW (window), "GTK Statusbar Example"); - g_signal_connect (window, "delete-event", - G_CALLBACK (exit), NULL); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 1); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); - - status_bar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0); - gtk_widget_show (status_bar); - - context_id = gtk_statusbar_get_context_id( - GTK_STATUSBAR (status_bar), "Statusbar example"); - - button = gtk_button_new_with_label ("push item"); - g_signal_connect (button, "clicked", - G_CALLBACK (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"); - g_signal_connect (button, "clicked", - G_CALLBACK (pop_item), GINT_TO_POINTER (context_id)); - gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 2); - 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; -} diff --git a/examples/table/Makefile b/examples/table/Makefile deleted file mode 100644 index 98cbc50b02..0000000000 --- a/examples/table/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -table: table.c - $(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 deleted file mode 100644 index df3a50009e..0000000000 --- a/examples/table/table.c +++ /dev/null @@ -1,97 +0,0 @@ - -#include <gtk/gtk.h> - -/* Our callback. - * The data passed to this function is printed to stdout */ -static void callback( GtkWidget *widget, - gpointer data ) -{ - g_print ("Hello again - %s was pressed\n", (char *) data); -} - -/* This callback quits the program */ -static gboolean delete_event( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit (); - return FALSE; -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *button; - GtkWidget *table; - - gtk_init (&argc, &argv); - - /* Create a new window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - /* Set the window title */ - gtk_window_set_title (GTK_WINDOW (window), "Table"); - - /* Set a handler for delete_event that immediately - * exits GTK. */ - g_signal_connect (window, "delete-event", - G_CALLBACK (delete_event), NULL); - - /* Sets the border width of the window. */ - gtk_container_set_border_width (GTK_CONTAINER (window), 20); - - /* Create a 2x2 table */ - table = gtk_table_new (2, 2, TRUE); - - /* Put the table in the main window */ - gtk_container_add (GTK_CONTAINER (window), table); - - /* Create first button */ - button = gtk_button_new_with_label ("button 1"); - - /* When the button is clicked, we call the "callback" function - * with a pointer to "button 1" as its argument */ - g_signal_connect (button, "clicked", - G_CALLBACK (callback), (gpointer) "button 1"); - - - /* Insert button 1 into the upper left quadrant of the table */ - gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1); - - gtk_widget_show (button); - - /* Create second button */ - - button = gtk_button_new_with_label ("button 2"); - - /* When the button is clicked, we call the "callback" function - * with a pointer to "button 2" as its argument */ - g_signal_connect (button, "clicked", - G_CALLBACK (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); - - gtk_widget_show (button); - - /* Create "Quit" button */ - button = gtk_button_new_with_label ("Quit"); - - /* When the button is clicked, we call the "delete_event" function - * and the program exits */ - g_signal_connect (button, "clicked", - G_CALLBACK (delete_event), NULL); - - /* Insert the quit button into the both - * lower quadrants of the table */ - gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 2, 1, 2); - - gtk_widget_show (button); - - gtk_widget_show (table); - gtk_widget_show (window); - - gtk_main (); - - return 0; -} diff --git a/examples/tictactoe/Makefile b/examples/tictactoe/Makefile deleted file mode 100644 index f9b2cb03e1..0000000000 --- a/examples/tictactoe/Makefile +++ /dev/null @@ -1,20 +0,0 @@ - -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) -c ttt_test.c -o ttt_test.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags` - -tictactoe.o: tictactoe.c tictactoe.h - $(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 deleted file mode 100644 index 3385b1fa0d..0000000000 --- a/examples/tictactoe/tictactoe.c +++ /dev/null @@ -1,158 +0,0 @@ - -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include <gtk/gtksignal.h> -#include <gtk/gtktable.h> -#include <gtk/gtktogglebutton.h> -#include "tictactoe.h" - -enum { - TICTACTOE_SIGNAL, - LAST_SIGNAL -}; - -static void tictactoe_class_init (TictactoeClass *klass); -static void tictactoe_init (Tictactoe *ttt); -static void tictactoe_toggle (GtkWidget *widget, Tictactoe *ttt); - -static guint tictactoe_signals[LAST_SIGNAL] = { 0 }; - -GType -tictactoe_get_type (void) -{ - static GType ttt_type = 0; - - if (!ttt_type) - { - const GTypeInfo ttt_info = - { - sizeof (TictactoeClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) tictactoe_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (Tictactoe), - 0, - (GInstanceInitFunc) tictactoe_init, - }; - - ttt_type = g_type_register_static (GTK_TYPE_TABLE, "Tictactoe", &ttt_info, 0); - } - - return ttt_type; -} - -static void -tictactoe_class_init (TictactoeClass *klass) -{ - - tictactoe_signals[TICTACTOE_SIGNAL] = g_signal_new ("tictactoe", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (TictactoeClass, tictactoe), - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - -} - -static void -tictactoe_init (Tictactoe *ttt) -{ - gint i,j; - - gtk_table_resize (GTK_TABLE (ttt), 3, 3); - gtk_table_set_homogeneous (GTK_TABLE (ttt), TRUE); - - for (i=0;i<3; i++) - for (j=0;j<3; j++) { - ttt->buttons[i][j] = gtk_toggle_button_new (); - gtk_table_attach_defaults (GTK_TABLE (ttt), ttt->buttons[i][j], - i, i+1, j, j+1); - g_signal_connect (G_OBJECT (ttt->buttons[i][j]), "toggled", - G_CALLBACK (tictactoe_toggle), (gpointer) ttt); - gtk_widget_set_size_request (ttt->buttons[i][j], 20, 20); - gtk_widget_show (ttt->buttons[i][j]); - } -} - -GtkWidget* -tictactoe_new () -{ - return GTK_WIDGET (g_object_new (tictactoe_get_type (), NULL)); -} - -void -tictactoe_clear (Tictactoe *ttt) -{ - int i,j; - - for (i = 0; i<3; i++) - for (j = 0; j<3; j++) - { - g_signal_handlers_block_matched (G_OBJECT (ttt->buttons[i][j]), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, ttt); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ttt->buttons[i][j]), - FALSE); - g_signal_handlers_unblock_matched (G_OBJECT (ttt->buttons[i][j]), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, ttt); - } -} - -static void -tictactoe_toggle (GtkWidget *widget, Tictactoe *ttt) -{ - int i,k; - - static int rwins[8][3] = { { 0, 0, 0 }, { 1, 1, 1 }, { 2, 2, 2 }, - { 0, 1, 2 }, { 0, 1, 2 }, { 0, 1, 2 }, - { 0, 1, 2 }, { 0, 1, 2 } }; - static int cwins[8][3] = { { 0, 1, 2 }, { 0, 1, 2 }, { 0, 1, 2 }, - { 0, 0, 0 }, { 1, 1, 1 }, { 2, 2, 2 }, - { 0, 1, 2 }, { 2, 1, 0 } }; - - int success, found; - - for (k = 0; k<8; k++) - { - success = TRUE; - found = FALSE; - - for (i = 0; i<3; i++) - { - success = success && - GTK_TOGGLE_BUTTON (ttt->buttons[rwins[k][i]][cwins[k][i]])->active; - found = found || - ttt->buttons[rwins[k][i]][cwins[k][i]] == widget; - } - - if (success && found) - { - g_signal_emit (G_OBJECT (ttt), - tictactoe_signals[TICTACTOE_SIGNAL], 0); - break; - } - } -} - diff --git a/examples/tictactoe/tictactoe.h b/examples/tictactoe/tictactoe.h deleted file mode 100644 index e48f753dd5..0000000000 --- a/examples/tictactoe/tictactoe.h +++ /dev/null @@ -1,61 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __TICTACTOE_H__ -#define __TICTACTOE_H__ - - -#include <glib.h> -#include <glib-object.h> -#include <gtk/gtktable.h> - - -G_BEGIN_DECLS - -#define TICTACTOE_TYPE (tictactoe_get_type ()) -#define TICTACTOE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TICTACTOE_TYPE, Tictactoe)) -#define TICTACTOE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TICTACTOE_TYPE, TictactoeClass)) -#define IS_TICTACTOE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TICTACTOE_TYPE)) -#define IS_TICTACTOE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TICTACTOE_TYPE)) - - -typedef struct _Tictactoe Tictactoe; -typedef struct _TictactoeClass TictactoeClass; - -struct _Tictactoe -{ - GtkTable table; - - GtkWidget *buttons[3][3]; -}; - -struct _TictactoeClass -{ - GtkTableClass parent_class; - - void (* tictactoe) (Tictactoe *ttt); -}; - -GType tictactoe_get_type (void); -GtkWidget* tictactoe_new (void); -void tictactoe_clear (Tictactoe *ttt); - -G_END_DECLS - -#endif /* __TICTACTOE_H__ */ - diff --git a/examples/tictactoe/ttt_test.c b/examples/tictactoe/ttt_test.c deleted file mode 100644 index 0f8a0f12e5..0000000000 --- a/examples/tictactoe/ttt_test.c +++ /dev/null @@ -1,45 +0,0 @@ - -#include <stdlib.h> -#include <gtk/gtk.h> -#include "tictactoe.h" - -void win( GtkWidget *widget, - gpointer data ) -{ - g_print ("Yay!\n"); - tictactoe_clear (TICTACTOE (widget)); -} - -int main( int argc, - char *argv[] ) -{ - GtkWidget *window; - GtkWidget *ttt; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_window_set_title (GTK_WINDOW (window), "Aspect Frame"); - - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (exit), NULL); - - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - - ttt = tictactoe_new (); - - gtk_container_add (GTK_CONTAINER (window), ttt); - gtk_widget_show (ttt); - - /* And attach to its "tictactoe" signal */ - g_signal_connect (G_OBJECT (ttt), "tictactoe", - G_CALLBACK (win), NULL); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} - diff --git a/examples/wheelbarrow/Makefile b/examples/wheelbarrow/Makefile deleted file mode 100644 index e51c26c565..0000000000 --- a/examples/wheelbarrow/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -CC = gcc - -CFLAGS = -Wall \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED - -wheelbarrow: wheelbarrow.c - $(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 deleted file mode 100644 index 12d8395c0c..0000000000 --- a/examples/wheelbarrow/wheelbarrow.c +++ /dev/null @@ -1,173 +0,0 @@ - -#include <gtk/gtk.h> - -/* XPM */ -static char * WheelbarrowFull_xpm[] = { -"48 48 64 1", -" c None", -". c #DF7DCF3CC71B", -"X c #965875D669A6", -"o c #71C671C671C6", -"O c #A699A289A699", -"+ c #965892489658", -"@ c #8E38410330C2", -"# c #D75C7DF769A6", -"$ c #F7DECF3CC71B", -"% c #96588A288E38", -"& c #A69992489E79", -"* c #8E3886178E38", -"= c #104008200820", -"- c #596510401040", -"; c #C71B30C230C2", -": c #C71B9A699658", -"> c #618561856185", -", c #20811C712081", -"< c #104000000000", -"1 c #861720812081", -"2 c #DF7D4D344103", -"3 c #79E769A671C6", -"4 c #861782078617", -"5 c #41033CF34103", -"6 c #000000000000", -"7 c #49241C711040", -"8 c #492445144924", -"9 c #082008200820", -"0 c #69A618611861", -"q c #B6DA71C65144", -"w c #410330C238E3", -"e c #CF3CBAEAB6DA", -"r c #71C6451430C2", -"t c #EFBEDB6CD75C", -"y c #28A208200820", -"u c #186110401040", -"i c #596528A21861", -"p c #71C661855965", -"a c #A69996589658", -"s c #30C228A230C2", -"d c #BEFBA289AEBA", -"f c #596545145144", -"g c #30C230C230C2", -"h c #8E3882078617", -"j c #208118612081", -"k c #38E30C300820", -"l c #30C2208128A2", -"z c #38E328A238E3", -"x c #514438E34924", -"c c #618555555965", -"v c #30C2208130C2", -"b c #38E328A230C2", -"n c #28A228A228A2", -"m c #41032CB228A2", -"M c #104010401040", -"N c #492438E34103", -"B c #28A2208128A2", -"V c #A699596538E3", -"C c #30C21C711040", -"Z c #30C218611040", -"A c #965865955965", -"S c #618534D32081", -"D c #38E31C711040", -"F c #082000000820", -" ", -" .XoO ", -" +@#$%o& ", -" *=-;#::o+ ", -" >,<12#:34 ", -" 45671#:X3 ", -" +89<02qwo ", -"e* >,67;ro ", -"ty> 459@>+&& ", -"$2u+ ><ipas8* ", -"%$;=* *3:.Xa.dfg> ", -"Oh$;ya *3d.a8j,Xe.d3g8+ ", -" Oh$;ka *3d$a8lz,,xxc:.e3g54 ", -" Oh$;kO *pd$%svbzz,sxxxxfX..&wn> ", -" Oh$@mO *3dthwlsslszjzxxxxxxx3:td8M4 ", -" Oh$@g& *3d$XNlvvvlllm,mNwxxxxxxxfa.:,B* ", -" Oh$@,Od.czlllllzlmmqV@V#V@fxxxxxxxf:%j5& ", -" Oh$1hd5lllslllCCZrV#r#:#2AxxxxxxxxxcdwM* ", -" OXq6c.%8vvvllZZiqqApA:mq:Xxcpcxxxxxfdc9* ", -" 2r<6gde3bllZZrVi7S@SV77A::qApxxxxxxfdcM ", -" :,q-6MN.dfmZZrrSS:#riirDSAX@Af5xxxxxfevo", -" +A26jguXtAZZZC7iDiCCrVVii7Cmmmxxxxxx%3g", -" *#16jszN..3DZZZZrCVSA2rZrV7Dmmwxxxx&en", -" p2yFvzssXe:fCZZCiiD7iiZDiDSSZwwxx8e*>", -" OA1<jzxwwc:$d%NDZZZZCCCZCCZZCmxxfd.B ", -" 3206Bwxxszx%et.eaAp77m77mmmf3&eeeg* ", -" @26MvzxNzvlbwfpdettttttttttt.c,n& ", -" *;16=lsNwwNwgsvslbwwvccc3pcfu<o ", -" p;<69BvwwsszslllbBlllllllu<5+ ", -" OS0y6FBlvvvzvzss,u=Blllj=54 ", -" c1-699Blvlllllu7k96MMMg4 ", -" *10y8n6FjvllllB<166668 ", -" S-kg+>666<M<996-y6n<8* ", -" p71=4 m69996kD8Z-66698&& ", -" &i0ycm6n4 ogk17,0<6666g ", -" N-k-<> >=01-kuu666> ", -" ,6ky& &46-10ul,66, ", -" Ou0<> o66y<ulw<66& ", -" *kk5 >66By7=xu664 ", -" <<M4 466lj<Mxu66o ", -" *>> +66uv,zN666* ", -" 566,xxj669 ", -" 4666FF666> ", -" >966666M ", -" oM6668+ ", -" *4 ", -" ", -" "}; - - -/* When invoked (via signal delete_event), terminates the application */ -gint close_application( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - gtk_main_quit(); - return(FALSE); -} - -int main (int argc, - char *argv[] ) -{ - /* GtkWidget is the storage type for widgets */ - GtkWidget *window, *pixmap, *fixed; - GdkPixmap *gdk_pixmap; - GdkBitmap *mask; - GtkStyle *style; - GdkGC *gc; - - /* Create the main window, and attach delete_event signal to terminate - * the application. Note that the main window will not have a titlebar - * since we're making it a popup. */ - gtk_init (&argc, &argv); - window = gtk_window_new (GTK_WINDOW_POPUP); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (close_application), NULL); - gtk_widget_show (window); - - /* Now for the pixmap and the pixmap widget */ - style = gtk_widget_get_default_style(); - gc = style->black_gc; - gdk_pixmap = gdk_pixmap_create_from_xpm_d (window->window, &mask, - &style->bg[GTK_STATE_NORMAL], - WheelbarrowFull_xpm); - pixmap = gtk_image_new_from_pixmap (gdk_pixmap, mask); - gtk_widget_show (pixmap); - - /* To display the pixmap, we use a fixed widget to place the pixmap */ - fixed = gtk_fixed_new (); - gtk_widget_set_size_request (fixed, 200, 200); - gtk_fixed_put (GTK_FIXED (fixed), pixmap, 0, 0); - gtk_container_add (GTK_CONTAINER (window), fixed); - gtk_widget_show (fixed); - - /* This masks out everything except for the image itself */ - gtk_widget_shape_combine_mask (window, mask, 0, 0); - - /* show the window */ - gtk_widget_show (window); - gtk_main (); - - return 0; -} |