diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-03-03 18:23:21 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-03-03 18:23:21 +0000 |
commit | efefd9f0bab3c57494a55b0418b5d488f0dae64b (patch) | |
tree | f1c5e5b51e8fd46875724a20f92e7fe3882feece /tests/testsocket_child.c | |
parent | 5f2975ade7f2b578eb3360f6ab67d755aa867271 (diff) | |
download | gtk+-efefd9f0bab3c57494a55b0418b5d488f0dae64b.tar.gz |
Add plug-socket tests. (Won't work worth a darn until I commit the rest of
Sat Mar 3 13:21:27 2001 Owen Taylor <otaylor@redhat.com>
* tests/Makefile.am tests/testsocket.c tests/testsocket_child.c:
Add plug-socket tests. (Won't work worth a darn until I commit
the rest of the plug-socket changes, but no reason these
can't go into CVS now.)
Diffstat (limited to 'tests/testsocket_child.c')
-rw-r--r-- | tests/testsocket_child.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/testsocket_child.c b/tests/testsocket_child.c new file mode 100644 index 0000000000..873067bbf0 --- /dev/null +++ b/tests/testsocket_child.c @@ -0,0 +1,95 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <gtk/gtk.h> + +void +remove_buttons (GtkWidget *widget, GtkWidget *other_button) +{ + gtk_widget_destroy (other_button); + gtk_widget_destroy (widget); +} + +void +add_buttons (GtkWidget *widget, GtkWidget *box) +{ + GtkWidget *add_button; + GtkWidget *remove_button; + GtkWidget *toplevel = gtk_widget_get_toplevel (box); + GtkAccelGroup *accel_group = gtk_window_get_default_accel_group (GTK_WINDOW (toplevel)); + + add_button = gtk_button_new_accel ("_Add", accel_group); + gtk_box_pack_start (GTK_BOX (box), add_button, TRUE, TRUE, 0); + gtk_widget_show (add_button); + + gtk_signal_connect (GTK_OBJECT (add_button), "clicked", + GTK_SIGNAL_FUNC (add_buttons), + box); + + remove_button = gtk_button_new_accel ("_Remove", accel_group); + gtk_box_pack_start (GTK_BOX (box), remove_button, TRUE, TRUE, 0); + gtk_widget_show (remove_button); + + gtk_signal_connect (GTK_OBJECT (remove_button), "clicked", + GTK_SIGNAL_FUNC (remove_buttons), + add_button); +} + +int +main (int argc, char *argv[]) +{ + guint32 xid; + + GtkWidget *window; + GtkWidget *hbox; + GtkWidget *entry; + GtkWidget *button; + GtkAccelGroup *accel_group; + gtk_init (&argc, &argv); + + if (argc < 2) + { + fprintf (stderr, "Usage: testsocket_child WINDOW_ID\n"); + exit (1); + } + + xid = strtol (argv[1], NULL, 0); + if (xid == 0) + { + fprintf (stderr, "Invalid window id '%s'\n", argv[1]); + exit (1); + } + + window = gtk_plug_new (xid); + gtk_signal_connect (GTK_OBJECT (window), "destroy", + (GtkSignalFunc) gtk_exit, NULL); + gtk_container_set_border_width (GTK_CONTAINER (window), 0); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), hbox); + gtk_widget_show (hbox); + + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + gtk_widget_show (entry); + + accel_group = gtk_window_get_default_accel_group (GTK_WINDOW (window)); + + button = gtk_button_new_accel ("_Close", accel_group); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (window)); + + add_buttons (NULL, hbox); + + gtk_widget_show (window); + + gtk_main (); + + return 0; +} + + |