diff options
author | Soeren Sandmann <sandmann@daimi.au.dk> | 2003-07-04 16:48:40 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2003-07-04 16:48:40 +0000 |
commit | f91ae4ed6f22a9b530d8d253bcdb36bdc10f3395 (patch) | |
tree | 46315455cdb707aa3a2b8c9f9abeeddcf8445aba /tests | |
parent | aac21b6f6a2ac87a5577306a5c777ae980a3c4e5 (diff) | |
download | gtk+-f91ae4ed6f22a9b530d8d253bcdb36bdc10f3395.tar.gz |
new test for removing items
Fri Jul 4 19:06:31 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/stresstest-toolbar.c: new test for removing items
* tests/testtoolbar.c: add a popup menu
* gtk/gtkcontainer.c (gtk_container_remove): add hack to avoid
assert widget->parent == container when the container is a
toolbar.
* gtk/gtktoolbar.c (gtk_toolbar_remove_tool_item): Make much
simpler. Also make correct.
* gtk/gtktoolbar.c (gtk_toolbar_button_press): make
popup_context_menu a boolean handled signal.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rwxr-xr-x | tests/stresstest-toolbar | 117 | ||||
-rw-r--r-- | tests/testtoolbar.c | 58 |
3 files changed, 176 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index fbf6674edf..adff1476f4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,7 @@ noinst_PROGRAMS = \ testtext \ testtextbuffer \ testtoolbar \ + stresstest-toolbar \ testtreeedit \ testtreeview \ testtreefocus \ @@ -94,6 +95,7 @@ testsocket_LDADD = $(LDADDS) testsocket_child_LDADD = $(LDADDS) testtextbuffer_LDADD = $(LDADDS) testtoolbar_LDADD = $(LDADDS) +stresstest_toolbar_LDADD = $(LDADDS) testtreeedit_LDADD = $(LDADDS) testtreeview_LDADD = $(LDADDS) testtreefocus_LDADD = $(LDADDS) diff --git a/tests/stresstest-toolbar b/tests/stresstest-toolbar new file mode 100755 index 0000000000..d76722ae13 --- /dev/null +++ b/tests/stresstest-toolbar @@ -0,0 +1,117 @@ +#! /bin/sh + +# stresstest-toolbar - temporary wrapper script for .libs/stresstest-toolbar +# Generated by ltmain.sh - GNU libtool 1.5 (1.1220 2003/04/05 19:32:58) +# +# The stresstest-toolbar program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/bin/sed -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "${CDPATH+set}" = set; then CDPATH=:; export CDPATH; fi + +relink_command="(cd /home/ssp/vertigo/toolcheck/gtk+/tests; LIBRARY_PATH=\".:/usr/X11R6/lib/\"; export LIBRARY_PATH; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; PATH=\"/usr/local/lib/beta/bin:/home/ssp/vertigo/usr/bin:/home/ssp/vertigo/usr/games:/usr/local/gnu/bin:/usr/java/bin:/home/ssp/usr/bin:/home/ssp/usr/bin/i386-linux:/usr/local/bin:/usr/bin/X11:/usr/bin:/bin:/sbin:/usr/sbin:/usr/ucb:/home/ssp/usr/bin:/usr/ccs/bin:/users/hendren/JOOS/Bin:.\"; export PATH; gcc -g -O2 -g -Wall -o \$progdir/\$file stresstest-toolbar.o ../gdk-pixbuf/.libs/libgdk_pixbuf-2.0.so -L/home/ssp/vertigo/usr/lib ../gdk/.libs/libgdk-x11-2.0.so -L/usr/X11R6/lib -L/usr/local/lib ../gtk/.libs/libgtk-x11-2.0.so /home/ssp/vertigo/toolcheck/gtk+/gdk/.libs/libgdk-x11-2.0.so -lXrandr -lXext -lXinerama /usr/lib/libXft.so /usr/local/lib/libXrender.so /usr/lib/libfontconfig.so /usr/lib/libfreetype.so /usr/lib/libexpat.so -lX11 /usr/local/lib/libfreetype.so -lz -lXcursor /usr/lib/libpangoxft-1.0.so /usr/lib/libpangox-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libgobject-2.0.so /usr/lib/libglib-2.0.so /home/ssp/vertigo/toolcheck/gtk+/gdk-pixbuf/.libs/libgdk_pixbuf-2.0.so /home/ssp/vertigo/usr/lib/libpangoxft-1.0.so /home/ssp/vertigo/usr/lib/libpangox-1.0.so /home/ssp/vertigo/usr/lib/libpango-1.0.so /home/ssp/vertigo/usr/lib/libatk-1.0.so /home/ssp/vertigo/usr/lib/libgobject-2.0.so /home/ssp/vertigo/usr/lib/libgmodule-2.0.so -ldl /home/ssp/vertigo/usr/lib/libglib-2.0.so -lm -Wl,--rpath -Wl,/home/ssp/vertigo/toolcheck/gtk+/gdk-pixbuf/.libs -Wl,--rpath -Wl,/home/ssp/vertigo/toolcheck/gtk+/gdk/.libs -Wl,--rpath -Wl,/home/ssp/vertigo/toolcheck/gtk+/gtk/.libs -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/home/ssp/vertigo/usr/lib -Wl,--rpath -Wl,/home/ssp/vertigo/usr/lib -Wl,--rpath -Wl,/usr/local/lib)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variable: + notinst_deplibs=' ../gdk-pixbuf/libgdk_pixbuf-2.0.la ../gdk/libgdk-x11-2.0.la ../gtk/libgtk-x11-2.0.la /home/ssp/vertigo/toolcheck/gtk+/gdk/libgdk-x11-2.0.la /home/ssp/vertigo/toolcheck/gtk+/gdk-pixbuf/libgdk_pixbuf-2.0.la' +else + # When we are sourced in execute mode, $file and $echo are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + echo="echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : + else + # Restart under the correct shell, and then maybe $echo will work. + exec /bin/sh "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'stresstest-toolbar' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || \ + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + echo "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec $progdir/$program ${1+"$@"} + + $echo "$0: cannot exec $program ${1+"$@"}" + exit 1 + fi + else + # The program doesn't exist. + $echo "$0: error: $progdir/$program does not exist" 1>&2 + $echo "This script is just a wrapper for $program." 1>&2 + echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c index 6d8b92c2af..71e5cf25ce 100644 --- a/tests/testtoolbar.c +++ b/tests/testtoolbar.c @@ -19,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - +#undef GTK_DISABLE_DEPRECATED #include <gtk/gtk.h> #include "prop-editor.h" @@ -378,6 +378,60 @@ rtl_toggled (GtkCheckButton *check) gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR); } +typedef struct +{ + int x; + int y; +} MenuPositionData; + +static void +position_function (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) +{ + /* Do not do this in your own code */ + + MenuPositionData *position_data = user_data; + + if (x) + *x = position_data->x; + + if (y) + *y = position_data->y; + + if (push_in) + *push_in = FALSE; +} + +static gboolean +popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button_number) +{ + MenuPositionData position_data; + + GtkMenu *menu = GTK_MENU (gtk_menu_new ()); + int i; + + for (i = 0; i < 5; i++) + { + GtkWidget *item; + gchar *label = g_strdup_printf ("Item _%d", i); + item = gtk_menu_item_new_with_mnemonic (label); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + } + gtk_widget_show_all (GTK_WIDGET (menu)); + + if (button_number != -1) + { + position_data.x = x; + position_data.y = y; + + gtk_menu_popup (menu, NULL, NULL, position_function, + &position_data, button_number, gtk_get_current_event_time()); + } + else + gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); + + return TRUE; +} + gint main (gint argc, gchar **argv) { @@ -580,6 +634,8 @@ main (gint argc, gchar **argv) gtk_widget_show_all (window); make_prop_editor (G_OBJECT (toolbar)); + + g_signal_connect (toolbar, "popup_context_menu", G_CALLBACK (popup_context_menu), NULL); gtk_main (); |