aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-paned/e-vpaned.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-25 12:45:10 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-25 12:45:10 +0800
commite90eea58a2109961faa8632ac5e5783d9970366b (patch)
tree2d7ea9bb7967eb5ccd622520c67f9d12235ef870 /widgets/e-paned/e-vpaned.c
parent23d300e9fa624e56f55ab3446b01cbf8908d6ceb (diff)
downloadgsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.tar
gsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.tar.gz
gsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.tar.bz2
gsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.tar.lz
gsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.tar.xz
gsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.tar.zst
gsoc2013-evolution-e90eea58a2109961faa8632ac5e5783d9970366b.zip
Made the handlebar disappear if either side is empty, hidden, or requests
2000-05-25 Christopher James Lahey <clahey@helixcode.com> * widgets/e-paned/e-hpaned.c, widgets/e-paned/e-paned.c, widgets/e-paned/e-paned.h, widgets/e-paned/e-vpaned.c: Made the handlebar disappear if either side is empty, hidden, or requests 0 size. svn path=/trunk/; revision=3198
Diffstat (limited to 'widgets/e-paned/e-vpaned.c')
-rw-r--r--widgets/e-paned/e-vpaned.c118
1 files changed, 75 insertions, 43 deletions
diff --git a/widgets/e-paned/e-vpaned.c b/widgets/e-paned/e-vpaned.c
index 9a71b9acd9..9eb9407a23 100644
--- a/widgets/e-paned/e-vpaned.c
+++ b/widgets/e-paned/e-vpaned.c
@@ -49,6 +49,7 @@ static gboolean e_vpaned_button_release (GtkWidget *widget,
GdkEventButton *event);
static gboolean e_vpaned_motion (GtkWidget *widget,
GdkEventMotion *event);
+static gboolean e_vpaned_handle_shown (EPaned *paned);
GtkType
e_vpaned_get_type (void)
@@ -76,11 +77,13 @@ e_vpaned_get_type (void)
}
static void
-e_vpaned_class_init (EVPanedClass *class)
+e_vpaned_class_init (EVPanedClass *klass)
{
GtkWidgetClass *widget_class;
+ EPanedClass *paned_class;
- widget_class = (GtkWidgetClass *) class;
+ widget_class = (GtkWidgetClass *) klass;
+ paned_class = E_PANED_CLASS (klass);
widget_class->size_request = e_vpaned_size_request;
widget_class->size_allocate = e_vpaned_size_allocate;
@@ -88,6 +91,8 @@ e_vpaned_class_init (EVPanedClass *class)
widget_class->button_press_event = e_vpaned_button_press;
widget_class->button_release_event = e_vpaned_button_release;
widget_class->motion_notify_event = e_vpaned_motion;
+
+ paned_class->handle_shown = e_vpaned_handle_shown;
}
static void
@@ -115,7 +120,7 @@ e_vpaned_new (void)
static void
e_vpaned_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+ GtkRequisition *requisition)
{
EPaned *paned;
GtkRequisition child_requisition;
@@ -144,13 +149,15 @@ e_vpaned_size_request (GtkWidget *widget,
requisition->height += child_requisition.height;
}
- requisition->height += GTK_CONTAINER (paned)->border_width * 2 + paned->handle_size;
+ requisition->height += GTK_CONTAINER (paned)->border_width * 2;
requisition->width += GTK_CONTAINER (paned)->border_width * 2;
+ if (e_paned_handle_shown(paned))
+ requisition->height += paned->handle_size;
}
static void
e_vpaned_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
EPaned *paned;
GtkRequisition child1_requisition;
@@ -158,6 +165,7 @@ e_vpaned_size_allocate (GtkWidget *widget,
GtkAllocation child1_allocation;
GtkAllocation child2_allocation;
gint border_width;
+ gboolean handle_shown;
g_return_if_fail (widget != NULL);
g_return_if_fail (E_IS_VPANED (widget));
@@ -167,42 +175,52 @@ e_vpaned_size_allocate (GtkWidget *widget,
paned = E_PANED (widget);
border_width = GTK_CONTAINER (widget)->border_width;
- if (paned->child1)
+ if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
else
child1_requisition.height = 0;
- if (paned->child2)
+ if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
gtk_widget_get_child_requisition (paned->child2, &child2_requisition);
else
child2_requisition.height = 0;
e_paned_compute_position (paned,
MAX (1, (gint) widget->allocation.height
- - (gint) paned->handle_size
- 2 * border_width),
child1_requisition.height,
child2_requisition.height);
/* Move the handle before the children so we don't get extra expose events */
- paned->handle_xpos = border_width;
- paned->handle_ypos = paned->child1_size + border_width;
- paned->handle_width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
- paned->handle_height = paned->handle_size;
+ gdk_window_move_resize (widget->window,
+ allocation->x, allocation->y,
+ allocation->width,
+ allocation->height);
+
+ handle_shown = e_paned_handle_shown(paned);
+ if (handle_shown)
+ {
+ paned->handle_xpos = border_width;
+ paned->handle_ypos = paned->child1_size + border_width;
+ paned->handle_width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
+ paned->handle_height = paned->handle_size;
- if (GTK_WIDGET_REALIZED(widget))
+ if (GTK_WIDGET_REALIZED(widget))
+ {
+ gdk_window_move_resize (paned->handle,
+ paned->handle_xpos,
+ paned->handle_ypos,
+ paned->handle_width,
+ paned->handle_size);
+ if (paned->handle)
+ gdk_window_show(paned->handle);
+ }
+ }
+ else
{
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width,
- allocation->height);
-
- gdk_window_move_resize (paned->handle,
- paned->handle_xpos,
- paned->handle_ypos,
- paned->handle_width,
- paned->handle_size);
+ if (paned->handle && GTK_WIDGET_REALIZED (widget))
+ gdk_window_hide(paned->handle);
}
child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
@@ -210,7 +228,10 @@ e_vpaned_size_allocate (GtkWidget *widget,
child1_allocation.x = child2_allocation.x = border_width;
child1_allocation.y = border_width;
- child2_allocation.y = child1_allocation.y + child1_allocation.height + paned->handle_height;
+ if (handle_shown)
+ child2_allocation.y = child1_allocation.y + child1_allocation.height + paned->handle_height;
+ else
+ child2_allocation.y = child1_allocation.y + child1_allocation.height;
child2_allocation.height = MAX(1, (gint) allocation->height - child2_allocation.y - border_width);
/* Now allocate the childen, making sure, when resizing not to
@@ -252,26 +273,29 @@ e_vpaned_draw (GtkWidget *widget,
area->x, area->y, area->width,
area->height);
- handle_area.x = paned->handle_xpos;
- handle_area.y = paned->handle_ypos;
- handle_area.width = paned->handle_width;
- handle_area.height = paned->handle_size;
-
- if (gdk_rectangle_intersect (&handle_area, area, &child_area))
+ if (e_paned_handle_shown(paned))
{
- child_area.x -= paned->handle_xpos;
- child_area.y -= paned->handle_ypos;
-
- gtk_paint_handle (widget->style,
- paned->handle,
- GTK_STATE_NORMAL,
- GTK_SHADOW_NONE,
- &child_area,
- widget,
- "paned",
- 0, 0, -1, -1,
- GTK_ORIENTATION_HORIZONTAL);
-
+ handle_area.x = paned->handle_xpos;
+ handle_area.y = paned->handle_ypos;
+ handle_area.width = paned->handle_width;
+ handle_area.height = paned->handle_size;
+
+ if (gdk_rectangle_intersect (&handle_area, area, &child_area))
+ {
+ child_area.x -= paned->handle_xpos;
+ child_area.y -= paned->handle_ypos;
+
+ gtk_paint_handle (widget->style,
+ paned->handle,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_NONE,
+ &child_area,
+ widget,
+ "paned",
+ 0, 0, -1, -1,
+ GTK_ORIENTATION_HORIZONTAL);
+
+ }
}
/* Redraw the children
*/
@@ -401,3 +425,11 @@ e_vpaned_motion (GtkWidget *widget,
return TRUE;
}
+
+static gboolean
+e_vpaned_handle_shown (EPaned *paned)
+{
+ return ((paned->child1 && paned->child2) &&
+ (GTK_WIDGET_VISIBLE (paned->child1) && GTK_WIDGET_VISIBLE (paned->child2)) &&
+ (GTK_WIDGET(paned->child1)->requisition.height > 0 && GTK_WIDGET(paned->child2)->requisition.height > 0));
+}