diff options
author | PST 1998 Shawn T. Amundson <amundson@gtk.org> | 1998-03-28 01:01:54 +0000 |
---|---|---|
committer | Shawn Amundson <amundson@src.gnome.org> | 1998-03-28 01:01:54 +0000 |
commit | 7033e33822a607feb3683516f9d83426f7982694 (patch) | |
tree | d055025e6c9586ca0e8989aa40a002295acd9aab /examples | |
parent | b2c30ad95d9e6d06592da25cf1490be3510b7946 (diff) | |
download | gtk+-7033e33822a607feb3683516f9d83426f7982694.tar.gz |
Released GTK+ 0.99.9GTK_0_99_9
Fri Mar 27 16:35:00 PST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 0.99.9
* examples: added a couple more, fixed some Makefiles
Diffstat (limited to 'examples')
-rw-r--r-- | examples/buttons/Makefile | 8 | ||||
-rw-r--r-- | examples/buttons/buttons.c | 106 | ||||
-rw-r--r-- | examples/buttons/info.xpm | 92 | ||||
-rw-r--r-- | examples/gtkdial/Makefile | 2 | ||||
-rw-r--r-- | examples/helloworld/Makefile | 2 | ||||
-rw-r--r-- | examples/helloworld2/Makefile | 2 | ||||
-rw-r--r-- | examples/scribble-simple/Makefile | 2 | ||||
-rw-r--r-- | examples/tictactoe/Makefile | 2 |
8 files changed, 211 insertions, 5 deletions
diff --git a/examples/buttons/Makefile b/examples/buttons/Makefile new file mode 100644 index 0000000000..6485609e1b --- /dev/null +++ b/examples/buttons/Makefile @@ -0,0 +1,8 @@ + +CC = gcc + +buttons: buttons.c + $(CC) `gtk-config --cflags` `gtk-config --libs` buttons.c -o buttons + +clean: + rm -f *.o buttons diff --git a/examples/buttons/buttons.c b/examples/buttons/buttons.c new file mode 100644 index 0000000000..fae4085fca --- /dev/null +++ b/examples/buttons/buttons.c @@ -0,0 +1,106 @@ +/* This file extracted from the GTK tutorial. */ + +/* buttons.c */ + +#include <gtk/gtk.h> + +/* create a new hbox with an image and a label packed into it + * and return the box.. */ + +GtkWidget *xpm_label_box (GtkWidget *parent, gchar *xpm_filename, gchar *label_text) +{ + GtkWidget *box1; + GtkWidget *label; + GtkWidget *pixmapwid; + GdkPixmap *pixmap; + GdkBitmap *mask; + GtkStyle *style; + + /* create box for xpm and label */ + box1 = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (box1), 2); + + /* get style of button.. I assume it's to get the background color. + * if someone knows the real reason, please enlighten me. */ + style = gtk_widget_get_style(parent); + + /* now on to the xpm stuff.. load xpm */ + pixmap = gdk_pixmap_create_from_xpm (parent->window, &mask, + &style->bg[GTK_STATE_NORMAL], + xpm_filename); + pixmapwid = gtk_pixmap_new (pixmap, mask); + + /* create label for button */ + label = gtk_label_new (label_text); + + /* pack the pixmap and label into the box */ + gtk_box_pack_start (GTK_BOX (box1), + pixmapwid, FALSE, FALSE, 3); + + gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 3); + + gtk_widget_show(pixmapwid); + gtk_widget_show(label); + + return (box1); +} + +/* our usual callback function */ +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 *box1; + + 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. */ + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_exit), NULL); + + gtk_signal_connect (GTK_OBJECT (window), "delete_event", + GTK_SIGNAL_FUNC (gtk_exit), NULL); + + + /* sets the border width of the window. */ + gtk_container_border_width (GTK_CONTAINER (window), 10); + gtk_widget_realize(window); + + /* create a new button */ + button = gtk_button_new (); + + /* You should be getting used to seeing most of these functions by now */ + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (callback), (gpointer) "cool button"); + + /* this calls our box creating function */ + box1 = xpm_label_box(window, "info.xpm", "cool button"); + + /* pack and show all our widgets */ + gtk_widget_show(box1); + + gtk_container_add (GTK_CONTAINER (button), box1); + + 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 new file mode 100644 index 0000000000..9b0d2efdb2 --- /dev/null +++ b/examples/buttons/info.xpm @@ -0,0 +1,92 @@ +/* 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/gtkdial/Makefile b/examples/gtkdial/Makefile index 18962eb0b9..ce97b6dc8c 100644 --- a/examples/gtkdial/Makefile +++ b/examples/gtkdial/Makefile @@ -11,4 +11,4 @@ gtkdial.o: gtkdial.c gtkdial.h $(CC) `gtk-config --cflags` -c gtkdial.c -o gtkdial.o clean: - rm *.o dial_test + rm -f *.o dial_test diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile index 1857cf36dc..3edbea65dd 100644 --- a/examples/helloworld/Makefile +++ b/examples/helloworld/Makefile @@ -5,4 +5,4 @@ helloworld: helloworld.c $(CC) `gtk-config --cflags` `gtk-config --libs` helloworld.c -o helloworld clean: - rm helloworld + rm -f helloworld diff --git a/examples/helloworld2/Makefile b/examples/helloworld2/Makefile index ff5eb9d8d7..d51e27b06a 100644 --- a/examples/helloworld2/Makefile +++ b/examples/helloworld2/Makefile @@ -5,4 +5,4 @@ helloworld2: helloworld2.c $(CC) `gtk-config --cflags` `gtk-config --libs` helloworld2.c -o helloworld2 clean: - rm helloworld2 + rm -f helloworld2 diff --git a/examples/scribble-simple/Makefile b/examples/scribble-simple/Makefile index cc752f18d7..9570038777 100644 --- a/examples/scribble-simple/Makefile +++ b/examples/scribble-simple/Makefile @@ -5,4 +5,4 @@ scribble-simple: scribble-simple.c $(CC) `gtk-config --cflags` `gtk-config --libs` scribble-simple.c -o scribble-simple clean: - rm scribble-simple + rm -f scribble-simple diff --git a/examples/tictactoe/Makefile b/examples/tictactoe/Makefile index c8a8a52df3..5096fa5804 100644 --- a/examples/tictactoe/Makefile +++ b/examples/tictactoe/Makefile @@ -11,4 +11,4 @@ tictactoe.o: tictactoe.c tictactoe.h $(CC) `gtk-config --cflags` -c tictactoe.c -o tictactoe.o clean: - rm *.o ttt_test + rm -f *.o ttt_test |