summaryrefslogtreecommitdiff
path: root/gtk/gtkhandlebox.c
diff options
context:
space:
mode:
authorTim Janik <timj@gimp.org>1998-03-14 08:15:23 +0000
committerTim Janik <timj@src.gnome.org>1998-03-14 08:15:23 +0000
commitc86bf9bae2e939c84254dc2b7308f56948f18df4 (patch)
tree77e1a9f272e79b1abdd967df8142314a03bf1a01 /gtk/gtkhandlebox.c
parentb8e7ea1f11a03ab9c6efd70e1729863eae46e5f5 (diff)
downloadgtk+-c86bf9bae2e939c84254dc2b7308f56948f18df4.tar.gz
refuse to allocate with a greater height than requested.
Sat Mar 14 08:29:56 1998 Tim Janik <timj@gimp.org> * gtk/gtkhandlebox.c (gtk_handle_box_size_allocate): refuse to allocate with a greater height than requested. (gtk_handle_box_remove): clean up if the child is detached. * gtk/gtktoolbar.c (gtk_toolbar_size_allocate): don't take invisible children into account.
Diffstat (limited to 'gtk/gtkhandlebox.c')
-rw-r--r--gtk/gtkhandlebox.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index 1acbe7686f..4db5ab0de2 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -29,7 +29,7 @@
#define DRAG_HANDLE_SIZE 10
#define BORDER_SIZE 5
#define GHOST_HEIGHT 3
-#define SNAP_TOLERANCE 10
+#define SNAP_TOLERANCE 16
enum
{
@@ -52,7 +52,9 @@ static void gtk_handle_box_unrealize (GtkWidget *widget);
static void gtk_handle_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_handle_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
+ GtkAllocation *real_allocation);
+static void gtk_handle_box_remove (GtkContainer *container,
+ GtkWidget *widget);
static void gtk_handle_box_draw_ghost (GtkWidget *widget);
static void gtk_handle_box_paint (GtkWidget *widget,
GdkEventExpose *event,
@@ -114,11 +116,13 @@ gtk_handle_box_marshal_child_attached (GtkObject *object,
static void
gtk_handle_box_class_init (GtkHandleBoxClass *class)
{
- GtkWidgetClass *widget_class;
GtkObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
+ container_class = (GtkContainerClass *) class;
parent_class = gtk_type_class (gtk_bin_get_type ());
@@ -154,6 +158,8 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
widget_class->button_release_event = gtk_handle_box_button_changed;
widget_class->motion_notify_event = gtk_handle_box_motion;
+ container_class->remove = gtk_handle_box_remove;
+
class->child_attached = NULL;
class->child_detached = NULL;
}
@@ -349,21 +355,33 @@ gtk_handle_box_size_request (GtkWidget *widget,
static void
gtk_handle_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *real_allocation)
{
GtkBin *bin;
- GtkAllocation child_allocation;
+ GtkAllocation *allocation;
GtkHandleBox *hb;
gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HANDLE_BOX (widget));
- g_return_if_fail (allocation != NULL);
+ g_return_if_fail (real_allocation != NULL);
- widget->allocation = *allocation;
bin = GTK_BIN (widget);
hb = GTK_HANDLE_BOX (widget);
+ allocation = &widget->allocation;
+
+ allocation->x = real_allocation->x;
+ if (real_allocation->height > widget->requisition.height)
+ allocation->y = real_allocation->y + (real_allocation->height - widget->requisition.height) / 2;
+ else
+ allocation->y = real_allocation->y;
+ allocation->height = MIN (real_allocation->height, widget->requisition.height);
+ allocation->width = real_allocation->width;
+ /* this will refuse to allocate width greater than neccessary:
+ * allocation->width = MIN (real_allocation->width, widget->requisition.width);
+ */
+
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_REALIZED (widget))
@@ -399,6 +417,8 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
+ GtkAllocation child_allocation;
+
child_allocation.x = DRAG_HANDLE_SIZE;
child_allocation.y = 0;
@@ -418,6 +438,34 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
}
static void
+gtk_handle_box_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ GtkHandleBox *hb;
+
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (GTK_IS_HANDLE_BOX (container));
+ g_return_if_fail (widget != NULL);
+
+ hb = GTK_HANDLE_BOX (container);
+
+ if (widget == GTK_BIN (container)->child &&
+ GTK_WIDGET_REALIZED (hb) &&
+ hb->is_onroot)
+ {
+ hb->is_onroot = FALSE;
+
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+
+ gdk_window_reparent (widget->window, hb->steady_window, 0, 0);
+
+ gtk_widget_hide (hb->float_window);
+ }
+
+ GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
+}
+
+static void
gtk_handle_box_draw_ghost (GtkWidget *widget)
{
gtk_draw_hline (widget->style,