Commit f91ae4ed authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen

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.
parent aac21b6f
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.
2003-07-04 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_polygon,
......
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.
2003-07-04 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_polygon,
......
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.
2003-07-04 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_polygon,
......
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.
2003-07-04 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_polygon,
......
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.
2003-07-04 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_polygon,
......
......@@ -201,6 +201,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
NULL,
G_PARAM_WRITABLE));
g_print ("installing background gdk\n");
g_object_class_install_property (object_class,
PROP_BACKGROUND_GDK,
g_param_spec_boxed ("background_gdk",
......
......@@ -34,6 +34,7 @@
#include "gtkmarshalers.h"
#include "gtkwindow.h"
#include "gtkintl.h"
#include "gtktoolbar.h"
#include <gobject/gobjectnotifyqueue.c>
#include <gobject/gvaluecollector.h>
......@@ -978,7 +979,13 @@ gtk_container_remove (GtkContainer *container,
{
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (widget->parent == GTK_WIDGET (container));
/* When using the deprecated API of the toolbar, it is possible
* to legitimately call this function with a widget that is not
* a direct child of the container.
*/
g_return_if_fail (GTK_IS_TOOLBAR (container) ||
widget->parent == GTK_WIDGET (container));
g_signal_emit (container, container_signals[REMOVE], 0, widget);
}
......
......@@ -31,6 +31,7 @@ BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED,BOXED
BOOLEAN:OBJECT,STRING,STRING
BOOLEAN:INT,INT
BOOLEAN:INT,INT,INT
BOOLEAN:VOID
BOOLEAN:BOOLEAN
BOOLEAN:NONE
......
......@@ -168,6 +168,7 @@ static GtkToolbarSpaceStyle get_space_style (GtkToolbar *to
static gint get_internal_padding (GtkToolbar *toolbar);
static void gtk_toolbar_remove_tool_item (GtkToolbar *toolbar,
GtkToolItem *item);
static gboolean gtk_toolbar_popup_menu (GtkWidget *toolbar);
static GtkWidget *gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
GtkToolbarChildType type,
......@@ -297,6 +298,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
widget_class->unrealize = gtk_toolbar_unrealize;
widget_class->map = gtk_toolbar_map;
widget_class->unmap = gtk_toolbar_unmap;
widget_class->popup_menu = gtk_toolbar_popup_menu;
widget_class->drag_leave = gtk_toolbar_drag_leave;
widget_class->drag_motion = gtk_toolbar_drag_motion;
......@@ -332,11 +334,13 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
toolbar_signals[POPUP_CONTEXT_MENU] =
g_signal_new ("popup_context_menu",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkToolbarClass, popup_context_menu),
NULL, NULL,
_gtk_marshal_VOID__INT_INT_INT,
G_TYPE_NONE, 0);
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__INT_INT_INT,
G_TYPE_BOOLEAN, 3,
G_TYPE_INT, G_TYPE_INT,
G_TYPE_INT);
toolbar_signals[MOVE_FOCUS] =
_gtk_binding_signal_new ("move_focus",
G_TYPE_FROM_CLASS (klass),
......@@ -1746,6 +1750,7 @@ gtk_toolbar_remove (GtkContainer *container,
GtkToolItem *item = NULL;
g_return_if_fail (GTK_IS_TOOLBAR (container));
g_return_if_fail (GTK_IS_WIDGET (widget));
toolbar = GTK_TOOLBAR (container);
......@@ -1987,13 +1992,31 @@ gtk_toolbar_button_press (GtkWidget *toolbar,
{
if (event->button == 3)
{
gboolean return_value;
g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
(int)event->x_root, (int)event->y_root, event->button, NULL);
(int)event->x_root, (int)event->y_root, event->button,
&return_value);
return return_value;
}
return FALSE;
}
static gboolean
gtk_toolbar_popup_menu (GtkWidget *toolbar)
{
gboolean return_value;
/* This function is the handler for the "popup menu" keybinding,
* ie., it is called when the user presses Shift F10
*/
g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0,
-1, -1, -1, &return_value);
return return_value;
}
static void
gtk_toolbar_update_button_relief (GtkToolbar *toolbar)
{
......@@ -2104,36 +2127,38 @@ gtk_toolbar_remove_tool_item (GtkToolbar *toolbar,
{
GtkToolbarPrivate *priv;
GList *tmp;
gint nth_child;
g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
g_return_if_fail (GTK_IS_TOOL_ITEM (item));
g_return_if_fail (g_list_find (priv->items, item));
priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
nth_child = 0;
tmp = priv->items;
while (tmp)
for (tmp = priv->items; tmp != NULL; tmp = tmp->next)
{
GList *next = tmp->next;
GtkWidget *child = tmp->data;
if (child == GTK_WIDGET (item))
{
gboolean was_visible;
was_visible = GTK_WIDGET_VISIBLE (item);
gtk_widget_unparent (GTK_WIDGET (item));
if (tmp->data == item)
break;
priv->items = g_list_remove_link (priv->items, tmp);
toolbar->num_children--;
nth_child++;
}
if (was_visible && GTK_WIDGET_VISIBLE (toolbar))
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
priv->items = g_list_remove (priv->items, item);
break;
}
tmp = next;
gtk_widget_unparent (GTK_WIDGET (item));
if (priv->api_mode == OLD_API)
{
GtkToolbarChild *toolbar_child;
toolbar_child = g_list_nth_data (toolbar->children, nth_child);
toolbar->children = g_list_remove (toolbar->children, toolbar_child);
g_free (toolbar_child);
}
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
}
GtkWidget *
......@@ -2772,10 +2797,16 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
static void
gtk_toolbar_finalize (GObject *object)
{
GList *list;
GtkToolbar *toolbar = GTK_TOOLBAR (object);
if (toolbar->tooltips)
g_object_unref (toolbar->tooltips);
for (list = toolbar->children; list != NULL; list = list->next)
g_free (list->data);
g_list_free (toolbar->children);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -57,7 +57,6 @@ G_BEGIN_DECLS
#define GTK_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOOLBAR, GtkToolbarClass))
#define GTK_TOOLBAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOLBAR, GtkToolbarPrivate))
#ifndef GTK_DISABLE_DEPRECATED
typedef enum
{
......@@ -117,14 +116,14 @@ struct _GtkToolbarClass
GtkContainerClass parent_class;
/* signals */
void (* orientation_changed) (GtkToolbar *toolbar,
GtkOrientation orientation);
void (* style_changed) (GtkToolbar *toolbar,
GtkToolbarStyle style);
void (* popup_context_menu) (GtkToolbar *toolbar,
gint x,
gint y,
gint button_number);
void (* orientation_changed) (GtkToolbar *toolbar,
GtkOrientation orientation);
void (* style_changed) (GtkToolbar *toolbar,
GtkToolbarStyle style);
gboolean (* popup_context_menu) (GtkToolbar *toolbar,
gint x,
gint y,
gint button_number);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
......
......@@ -148,9 +148,7 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkToolItemClass, create_menu_proxy),
_gtk_boolean_handled_accumulator, NULL, /* FIXME: use gtk_boolean_handled() when
* we are added to gtk+
*/
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
toolitem_signals[TOOLBAR_RECONFIGURED] =
......@@ -166,9 +164,7 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkToolItemClass, set_tooltip),
_gtk_boolean_handled_accumulator, NULL, /* FIXME: use gtk_boolean_handled() when
* we are added to gtk+
*/
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__OBJECT_STRING_STRING,
G_TYPE_BOOLEAN, 3,
GTK_TYPE_TOOLTIPS,
......
......@@ -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)
......
#! /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
......@@ -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 ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment