Commit 086b27dc authored by Tristan Van Berkom's avatar Tristan Van Berkom

o Removed search algorythm for child widgets, removed


	* gladeui/glade-widget.[ch]: 
	  o Removed search algorythm for child widgets, removed glade_widget_event_widget (), 
	    removed popup-menu signal handler, removed call to gtk_window_set_decorated() 
	    on toplevel project widgets, removed widget->setup_events(), removed hide_on_delete()
	  o Added glade_widget_event() to feed events directly to widgets from the design layout.
	  o Call glade_app_hierarchy_changed() upon add/remove/replace operations

	* gladeui/glade-utils.c: Removed glade_utils_deep_fixed_event() and the
	  hacky widget grab that went with it.

	* gladeui/glade-app.[ch]: Added glade_app_hierarchy_changed() and added
	  "hierarchy-changed" signal.
	
	* gladeui/glade-design-layout.c: 
	  o Make sure event window is always on top by trapping GladeApp's "hierarchy-changed"
	    signal
	  o Feed events directly to the proper GladeWidget, if its not handled then pass it
	    on to the underlying widgets (using gtk_widget_event() directly).

	* gladeui/glade-cursor.c: Removed the recursive cursor setting routine.

	* gladeui/glade-fixed.c: Simplified immensely by removing redundant code,
	  now there is only one GladeWidget to deal with, no searching and gropeing
	  for the appropriate widget to operate on.


svn path=/trunk/; revision=1065
parent c15f54b2
2007-01-31 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-widget.[ch]:
o Removed search algorythm for child widgets, removed glade_widget_event_widget (),
removed popup-menu signal handler, removed call to gtk_window_set_decorated()
on toplevel project widgets, removed widget->setup_events(), removed hide_on_delete()
o Added glade_widget_event() to feed events directly to widgets from the design layout.
o Call glade_app_hierarchy_changed() upon add/remove/replace operations
* gladeui/glade-utils.c: Removed glade_utils_deep_fixed_event() and the
hacky widget grab that went with it.
* gladeui/glade-app.[ch]: Added glade_app_hierarchy_changed() and added
"hierarchy-changed" signal.
* gladeui/glade-design-layout.c:
o Make sure event window is always on top by trapping GladeApp's "hierarchy-changed"
signal
o Feed events directly to the proper GladeWidget, if its not handled then pass it
on to the underlying widgets (using gtk_widget_event() directly).
* gladeui/glade-cursor.c: Removed the recursive cursor setting routine.
* gladeui/glade-fixed.c: Simplified immensely by removing redundant code,
now there is only one GladeWidget to deal with, no searching and gropeing
for the appropriate widget to operate on.
2007-01-28 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-command.c: Made 'pasting' an explicit arg of glade_command_add(),
......
......@@ -14,7 +14,6 @@ Pluggable widgets in other languages - (bug 359765) - Juan Pablo
An early start on the 3.2 blocker bugs
=========================================================
Selection reimplementation - (bug 382674, implicitly fixes 347164) Tristan Van Berkom
wrong cursor over widgets - (bug 353002)
Too many accelerators - (bug 380986)
Fix or yank out console - (bug 359661) Vincent Geddes
......@@ -48,4 +47,4 @@ Need better support for resource file
management wrt glade files - (bug 359647)
Deletes unknown widget nodes. - (bug 376628)
Startup errors should be handled - (bug 331797) (Les Harris)
Can't select a GtkCombo box from the workspace - (bug 347164)
......@@ -36,6 +36,7 @@
#include "glade-catalog.h"
#include "glade-fixed.h"
#include "glade-binding.h"
#include "glade-marshallers.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkstock.h>
......@@ -67,7 +68,8 @@ struct _GladeAppPriv {
enum
{
UPDATE_UI_SIGNAL,
HIERARCHY_CHANGED,
UPDATE_UI,
LAST_SIGNAL
};
......@@ -393,7 +395,7 @@ glade_app_class_init (GladeAppClass * klass)
*
* Emitted when a project name changes or a cut/copy/paste/delete occurred.
*/
glade_app_signals[UPDATE_UI_SIGNAL] =
glade_app_signals[UPDATE_UI] =
g_signal_new ("update-ui",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
......@@ -404,6 +406,25 @@ glade_app_class_init (GladeAppClass * klass)
G_TYPE_NONE, 0);
/**
* GladeApp::hierarchy-changed:
* @gladeapp: the #GladeApp which received the signal.
* @arg1: The toplevel #GladeWidget who's hierarchy was modified
*
* Emitted when a #GladeWidget is added or removed from a toplevel
* #GladeWidget's hierarchy.
*/
glade_app_signals[HIERARCHY_CHANGED] =
g_signal_new ("hierarchy-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GladeAppClass,
hierarchy_changed),
NULL, NULL,
glade_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
g_object_class_install_property
(object_class, PROP_ACTIVE_PROJECT,
g_param_spec_object
......@@ -638,8 +659,18 @@ glade_app_update_ui (void)
GladeApp *app = glade_app_get ();
g_signal_emit (G_OBJECT (app),
glade_app_signals[UPDATE_UI_SIGNAL], 0);
glade_app_signals[UPDATE_UI], 0);
}
void
glade_app_hierarchy_changed (GladeWidget *widget)
{
GladeApp *app = glade_app_get();
g_return_if_fail (GLADE_IS_WIDGET (widget));
g_signal_emit (G_OBJECT (app),
glade_app_signals[HIERARCHY_CHANGED], 0, widget);
}
void
......@@ -1395,7 +1426,6 @@ glade_app_redo_button_new (void)
return glade_app_undo_redo_button_new (app, FALSE);
}
GList*
glade_app_get_selection (void)
{
......
......@@ -57,6 +57,7 @@ struct _GladeAppClass
void (* hide_properties) (GladeApp* app);
/* signals */
void (* hierarchy_changed)(GladeApp *app, GladeWidget *toplevel);
void (* update_ui_signal) (GladeApp *app);
};
......@@ -141,6 +142,9 @@ GtkWidget *glade_app_redo_button_new (void);
LIBGLADEUI_API
GList *glade_app_get_selection (void);
LIBGLADEUI_API
void glade_app_hierarchy_changed (GladeWidget *widget);
/* These handle selection on a global scope and take care
* of multiple project logic.
......
......@@ -34,56 +34,6 @@
static GladeCursor *cursor = NULL;
static void
set_cursor_recurse (GtkWidget *widget,
GdkCursor *gdk_cursor)
{
GList *children, *list;
if (!GTK_WIDGET_VISIBLE (widget) ||
!GTK_WIDGET_REALIZED (widget))
return;
gdk_window_set_cursor (widget->window, gdk_cursor);
if (GTK_IS_CONTAINER (widget) &&
(children =
glade_util_container_get_all_children (GTK_CONTAINER (widget))) != NULL)
{
for (list = children; list; list = list->next)
{
set_cursor_recurse (GTK_WIDGET (list->data), gdk_cursor);
}
g_list_free (children);
}
}
static void
set_cursor (GdkCursor *gdk_cursor)
{
GladeProject *project;
GList *list, *projects;
for (projects = glade_app_get_projects ();
projects; projects = projects->next)
{
project = projects->data;
for (list = project->objects;
list; list = list->next)
{
GObject *object = list->data;
if (GTK_IS_WINDOW (object))
{
set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
}
}
}
}
/**
* glade_cursor_set:
* @window: a #GdkWindow
......@@ -101,7 +51,6 @@ glade_cursor_set (GdkWindow *window, GladeCursorType type)
switch (type) {
case GLADE_CURSOR_SELECTOR:
set_cursor (cursor->selector);
gdk_window_set_cursor (window, cursor->selector);
break;
case GLADE_CURSOR_ADD_WIDGET:
......@@ -149,8 +98,6 @@ glade_cursor_set (GdkWindow *window, GladeCursorType type)
}
gdk_window_set_cursor (window, the_cursor);
set_cursor (the_cursor);
}
/**
......
......@@ -25,14 +25,15 @@
#include "config.h"
#include "glade-design-layout.h"
#include "glade.h"
#include "glade-design-layout.h"
#include <gtk/gtk.h>
#define GLADE_DESIGN_LAYOUT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
GLADE_TYPE_DESIGN_LAYOUT, \
GladeDesignLayoutPrivate))
#define GLADE_DESIGN_LAYOUT_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
GLADE_TYPE_DESIGN_LAYOUT, \
GladeDesignLayoutPrivate))
#define OUTLINE_WIDTH 4
#define PADDING 12
......@@ -49,12 +50,13 @@ typedef enum
typedef enum
{
GLADE_REGION_EAST = 1,
GLADE_REGION_INSIDE = 0,
GLADE_REGION_EAST,
GLADE_REGION_SOUTH,
GLADE_REGION_SOUTH_EAST,
GLADE_REGION_WEST_OF_SOUTH_EAST,
GLADE_REGION_NORTH_OF_SOUTH_EAST
GLADE_REGION_NORTH_OF_SOUTH_EAST,
GLADE_REGION_OUTSIDE
} GladePointerRegion;
struct _GladeDesignLayoutPrivate
......@@ -68,10 +70,12 @@ struct _GladeDesignLayoutPrivate
/* state machine */
GladeActivity activity; /* the current activity */
GtkRequisition *current_size_request;
int dx; /* child.width - event.pointer.x */
int dy; /* child.height - event.pointer.y */
int new_width; /* user's new requested width */
int new_height; /* user's new requested height */
gint dx; /* child.width - event.pointer.x */
gint dy; /* child.height - event.pointer.y */
gint new_width; /* user's new requested width */
gint new_height; /* user's new requested height */
gulong hierarchy_changed_id;
};
static GtkBinClass *parent_class = NULL;
......@@ -80,11 +84,11 @@ static GtkBinClass *parent_class = NULL;
G_DEFINE_TYPE(GladeDesignLayout, glade_design_layout, GTK_TYPE_BIN)
static GladePointerRegion
glade_design_layout_get_pointer_region (GladeDesignLayout *layout, int x, int y)
glade_design_layout_get_pointer_region (GladeDesignLayout *layout, gint x, gint y)
{
GladeDesignLayoutPrivate *priv;
GtkAllocation *child_allocation;
GladePointerRegion region = 0;
GladePointerRegion region = GLADE_REGION_INSIDE;
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
......@@ -118,9 +122,14 @@ glade_design_layout_get_pointer_region (GladeDesignLayout *layout, int x, int y)
else if ((x < (child_allocation->x + child_allocation->width + OUTLINE_WIDTH)) &&
(x >= (child_allocation->x + child_allocation->width)))
region = GLADE_REGION_SOUTH_EAST;
region = GLADE_REGION_SOUTH_EAST;
}
if (x < PADDING || y < PADDING ||
x >= (child_allocation->x + child_allocation->width + OUTLINE_WIDTH) ||
y >= (child_allocation->y + child_allocation->height + OUTLINE_WIDTH))
region = GLADE_REGION_OUTSIDE;
return region;
}
......@@ -133,8 +142,8 @@ child_size_request_handler (GtkWidget *widget,
GladeDesignLayout *layout)
{
GladeDesignLayoutPrivate *priv;
int new_width, new_height;
int old_width, old_height;
gint new_width, new_height;
gint old_width, old_height;
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
......@@ -181,7 +190,7 @@ glade_design_layout_leave_notify_event (GtkWidget *widget, GdkEventCrossing *ev)
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
if (priv->activity == GLADE_ACTIVITY_NONE)
gdk_window_set_cursor (widget->window, NULL);
gdk_window_set_cursor (priv->event_window, NULL);
return FALSE;
}
......@@ -205,11 +214,114 @@ glade_design_layout_update_child (GladeDesignLayout *layout,
NULL);
gtk_widget_size_allocate (child, allocation);
gtk_widget_queue_resize (GTK_WIDGET (layout));
}
/* A temp data struct that we use when looking for a widget inside a container
* we need a struct, because the forall can only pass one pointer
*/
typedef struct {
gint x;
gint y;
gboolean any;
GtkWidget *found;
GtkWidget *toplevel;
} GladeFindInContainerData;
static void
glade_design_layout_find_inside_container (GtkWidget *widget, GladeFindInContainerData *data)
{
gint x;
gint y;
gtk_widget_translate_coordinates (data->toplevel, widget, data->x, data->y, &x, &y);
if (GTK_WIDGET_MAPPED(widget) &&
x >= 0 && x < widget->allocation.width && y >= 0 && y < widget->allocation.height)
{
if (glade_widget_get_from_gobject (widget) || data->any)
data->found = widget;
else if (GTK_IS_CONTAINER (widget))
{
/* Recurse and see if any project objects exist
* under this container that is not in the project
* (mostly for dialog buttons).
*/
GladeFindInContainerData search;
search.x = data->x;
search.y = data->y;
search.toplevel = data->toplevel;
search.found = NULL;
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback)
glade_design_layout_find_inside_container, &search);
data->found = search.found;
}
}
}
static GladeWidget *
glade_design_layout_deepest_gwidget_at_position (GtkContainer *toplevel,
GtkContainer *container,
gint top_x, gint top_y)
{
GladeFindInContainerData data;
GladeWidget *ret_widget = NULL;
data.x = top_x;
data.y = top_y;
data.any = FALSE;
data.toplevel = GTK_WIDGET (toplevel);
data.found = NULL;
gtk_container_forall (container, (GtkCallback)
glade_design_layout_find_inside_container, &data);
if (data.found && GTK_IS_CONTAINER (data.found))
ret_widget = glade_design_layout_deepest_gwidget_at_position
(toplevel, GTK_CONTAINER (data.found), top_x, top_y);
else if (data.found)
ret_widget = glade_widget_get_from_gobject (data.found);
else
ret_widget = glade_widget_get_from_gobject (container);
return ret_widget;
}
static GtkWidget *
glade_design_layout_deepest_widget_at_position (GtkContainer *toplevel,
GtkContainer *container,
gint top_x, gint top_y)
{
GladeFindInContainerData data;
GtkWidget *ret_widget = NULL;
data.x = top_x;
data.y = top_y;
data.any = TRUE;
data.toplevel = GTK_WIDGET (toplevel);
data.found = NULL;
gtk_container_forall (container, (GtkCallback)
glade_design_layout_find_inside_container, &data);
if (data.found && GTK_IS_CONTAINER (data.found))
ret_widget = glade_design_layout_deepest_widget_at_position
(toplevel, GTK_CONTAINER (data.found), top_x, top_y);
else if (data.found)
ret_widget = data.found;
else
ret_widget = GTK_WIDGET (container);
return ret_widget;
}
static gboolean
glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
{
......@@ -230,8 +342,8 @@ glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
else
{
x = (int) ((GdkEventMotion *)ev)->x;
y = (int) ((GdkEventMotion *)ev)->y;
x = (gint) ((GdkEventMotion *)ev)->x;
y = (gint) ((GdkEventMotion *)ev)->y;
}
child_glade_widget = glade_widget_get_from_gobject (child);
......@@ -283,18 +395,18 @@ glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
region = glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x, y);
if (region == GLADE_REGION_EAST)
gdk_window_set_cursor (widget->window, priv->cursor_resize_right);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
else if (region == GLADE_REGION_SOUTH)
gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom);
else if (region == GLADE_REGION_SOUTH_EAST ||
region == GLADE_REGION_WEST_OF_SOUTH_EAST ||
region == GLADE_REGION_NORTH_OF_SOUTH_EAST)
gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
else
gdk_window_set_cursor (widget->window, NULL);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
else if (region == GLADE_REGION_OUTSIDE)
gdk_window_set_cursor (priv->event_window, NULL);
}
return FALSE;
}
......@@ -310,8 +422,8 @@ glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
if ((child = GTK_BIN (widget)->child) == NULL)
return FALSE;
x = (int) ((GdkEventButton *) ev)->x;
y = (int) ((GdkEventButton *) ev)->y;
x = (gint) ((GdkEventButton *) ev)->x;
y = (gint) ((GdkEventButton *) ev)->y;
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
region = glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x, y);
......@@ -324,27 +436,27 @@ glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
if (region == GLADE_REGION_EAST)
{
priv->activity = GLADE_ACTIVITY_RESIZE_WIDTH;
gdk_window_set_cursor (widget->window, priv->cursor_resize_right);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
}
if (region == GLADE_REGION_SOUTH)
{
priv->activity = GLADE_ACTIVITY_RESIZE_HEIGHT;
gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom);
}
if (region == GLADE_REGION_SOUTH_EAST)
{
priv->activity = GLADE_ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
}
if (region == GLADE_REGION_WEST_OF_SOUTH_EAST)
{
priv->activity = GLADE_ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
}
if (region == GLADE_REGION_NORTH_OF_SOUTH_EAST)
{
priv->activity = GLADE_ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
}
}
......@@ -363,11 +475,53 @@ glade_design_layout_button_release_event (GtkWidget *widget, GdkEventButton *ev)
priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
priv->activity = GLADE_ACTIVITY_NONE;
gdk_window_set_cursor (widget->window, NULL);
gdk_window_set_cursor (priv->event_window, NULL);
return FALSE;
}
static gboolean
glade_design_layout_event (GtkWidget *widget, GdkEvent *ev)
{
GladeWidget *gwidget;
GtkWidget *child;
gboolean retval;
gint x, y;
gtk_widget_get_pointer (widget, &x, &y);
gwidget = glade_design_layout_deepest_gwidget_at_position
(GTK_CONTAINER (widget), GTK_CONTAINER (widget), x, y);
child = glade_design_layout_deepest_widget_at_position
(GTK_CONTAINER (widget), GTK_CONTAINER (widget), x, y);
/* First try a placeholder */
if (GLADE_IS_PLACEHOLDER (child) && ev->type != GDK_EXPOSE)
{
retval = gtk_widget_event (child, ev);
if (retval)
return retval;
}
/* Then we try a GladeWidget */
if (gwidget)
{
retval = glade_widget_event (gwidget, ev);
if (retval)
return retval;
}
/* Then we send it to a project widget (the actual GtkWidget) */
if (child && child != widget && ev->type != GDK_EXPOSE)
{
return gtk_widget_event (child, ev);
}
return FALSE;
}
static void
glade_design_layout_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
......@@ -432,10 +586,10 @@ glade_design_layout_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
if (priv->event_window)
gdk_window_move_resize (priv->event_window,
allocation->x + border_width,
allocation->y + border_width,
allocation->width - 2 * border_width ,
allocation->height - 2 * border_width);
allocation->x/* + border_width */,
allocation->y/* + border_width */,
allocation->width/* - 2 * border_width */ ,
allocation->height/* - 2 * border_width */);
}
......@@ -507,22 +661,22 @@ glade_design_layout_realize (GtkWidget *widget)
border_width = GTK_CONTAINER (widget)->border_width;
attributes.x = widget->allocation.x + border_width;
attributes.y = widget->allocation.y + border_width;
attributes.width = widget->allocation.width - 2 * border_width;
attributes.height = widget->allocation.height - 2 * border_width;
attributes.x = widget->allocation.x/* + border_width */;
attributes.y = widget->allocation.y/* + border_width */;
attributes.width = widget->allocation.width/* - 2 * border_width */;
attributes.height = widget->allocation.height/* - 2 * border_width */;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_EXPOSURE_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_LEAVE_NOTIFY_MASK;
attributes.event_mask =
gtk_widget_get_events (widget) |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_EXPOSURE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
widget->window = gtk_widget_get_parent_window (widget);
......@@ -532,6 +686,8 @@ glade_design_layout_realize (GtkWidget *widget)
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, widget);
gdk_window_raise (priv->event_window);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
}
......@@ -608,6 +764,9 @@ glade_design_layout_finalize (GObject *object)
GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (object);
g_free (priv->current_size_request);
g_signal_handler_disconnect (glade_app_get (),
priv->hierarchy_changed_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -681,7 +840,16 @@ glade_design_layout_expose_event (GtkWidget *widget, GdkEventExpose *ev)
g_object_unref (gc);
}
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, ev);
return TRUE;
}
static void
glade_design_layout_hierarchy_changed (GladeApp *app,
GladeWidget *toplevel,
GladeDesignLayout *layout)
{
if (layout->priv->event_window)
gdk_window_raise (layout->priv->event_window);
}
static void
......@@ -705,6 +873,9 @@ glade_design_layout_init (GladeDesignLayout *layout)
priv->new_width = -1;
priv->new_height = -1;
priv->hierarchy_changed_id =
g_signal_connect (glade_app_get (), "hierarchy-changed",
G_CALLBACK (glade_design_layout_hierarchy_changed), layout);
}
static void
......@@ -724,7 +895,8 @@ glade_design_layout_class_init (GladeDesignLayoutClass *klass)
container_class->add = glade_design_layout_add;
container_class->remove = glade_design_layout_remove;
widget_class->event = glade_design_layout_event;
widget_class->motion_notify_event = glade_design_layout_motion_notify_event;
widget_class->leave_notify_event = glade_design_layout_leave_notify_event;
widget_class->button_press_event = glade_design_layout_button_press_event;
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-design-view.c
*
......@@ -126,7 +127,6 @@ glade_design_view_init (GladeDesignView *view)
gtk_box_pack_start (GTK_BOX (view), sw, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (view), 0);
}
static void
......
......@@ -489,6 +489,24 @@ glade_fixed_configure_end_impl (GladeFixed *fixed,
return TRUE;
}
static void
glade_fixed_cancel_operation (GladeFixed *fixed,
GladeCursorType new_operation)
{
gboolean handled;
g_signal_emit (G_OBJECT (fixed),
glade_fixed_signals[CONFIGURE_END],
0, fixed->configuring, &handled);
/* Leave the machine state intact untill after
* the user handled signal.
*/
fixed->operation = new_operation;
fixed->configuring = NULL;
}
static gboolean
glade_fixed_handle_child_event (GladeFixed *fixed,
GladeWidget *child,
......@@ -497,8 +515,9 @@ glade_fixed_handle_child_event (GladeFixed *fixed,
{
GladeCursorType operation;
GtkWidget *fixed_widget, *child_widget;
gboolean handled = FALSE, sig_handled;
gint fixed_x, fixed_y, child_x, child_y;
gboolean handled = FALSE, sig_handled;
gboolean button_down;
fixed_widget = GTK_WIDGET (GLADE_WIDGET (fixed)->object);
child_widget = GTK_WIDGET (child->object);
......@@ -527,39 +546,45 @@ glade_fixed_handle_child_event (GladeFixed *fixed,
{
case GDK_ENTER_NOTIFY:
case GDK_MOTION_NOTIFY:
/* Get button state */
if (event->type == GDK_ENTER_NOTIFY)
button_down =
((GdkEventCrossing *)event)->state & GDK_BUTTON1_MASK;
else
button_down =
((GdkEventMotion *)event)->state & GDK_BUTTON1_MASK;
if (fixed->configuring == NULL)
{
glade_cursor_set (((GdkEventAny *)event)->window,
operation);
}
else if (event->type == GDK_MOTION_NOTIFY)
} else if (fixed->configuring && !button_down)
{
/* Cancel drags that no longer have mouse down */
glade_cursor_set (((GdkEventAny *)event)->window,
operation);
glade_fixed_cancel_operation (fixed, operation);
handled = TRUE;
} else if (fixed->configuring &&