mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 17:30:10 +00:00
6cff7051b1
Wed Apr 18 14:23:14 2001 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkimage-x11.c (gdk_image_new): Try changing mode on shm segments to 0600. We'll see who complains. * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Call _gdk_windowing_window_destroy() AFTER recursing through children. * tests/Makefile.am (noinst_PROGRAMS): Build testsocket, testsocket_child on X. * tests/testsocket[_child].c: Fix uses of gtk_window_get_default_accel_group(). [ Merge patch from Ramiro Estrugo <ramiro@eazel.com> from gtk-1-2 ] * gdk/gdkimage.c: (gdk_image_get): Deal with the possibility that XGetImage() might return NULL. Allocate the GdkImagePrivate structure only after XGetImage() succeeds in order not to dereference a NULL ximage pointer. This prevents a core dump when XGetImage() fails - which is unlikely, but can happen due to race conditions accessing the geometries of drawables. An x error will still be triggered, but the gdk image wrapper at least wont seg fault.
92 lines
2.1 KiB
C
92 lines
2.1 KiB
C
#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);
|
|
|
|
add_button = gtk_button_new_with_mnemonic ("_Add");
|
|
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_with_mnemonic ("_Remove");
|
|
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;
|
|
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);
|
|
|
|
button = gtk_button_new_with_mnemonic ("_Close");
|
|
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;
|
|
}
|
|
|
|
|