* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtkmarshalers.h"
#include "gtkorientable.h"
#include "gtkwindow.h"
-
+#include "gtktypebuiltins.h"
+#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtkintl.h"
-
+#include "a11y/gtkpanedaccessible.h"
/**
* SECTION:gtkpaned
- * @Short_description: Base class for widgets with two adjustable panes
+ * @Short_description: A widget with two adjustable panes
* @Title: GtkPaned
*
- * #GtkPaned is the base class for widgets with two panes, arranged either
- * horizontally (#GtkHPaned) or vertically (#GtkVPaned). Child widgets are
+ * #GtkPaned has two panes, arranged either
+ * horizontally or vertically. The division between
+ * the two panes is adjustable by the user by dragging
+ * a handle.
+ *
+ * Child widgets are
* added to the panes of the widget with gtk_paned_pack1() and
* gtk_paned_pack2(). The division between the two children is set by default
* from the size requests of the children, but it can be adjusted by the
* </example>
*/
+enum {
+ CHILD1,
+ CHILD2
+};
+
struct _GtkPanedPrivate
{
- GtkOrientation orientation;
GtkPaned *first_paned;
GtkWidget *child1;
GtkWidget *child2;
+ GdkWindow *child1_window;
+ GdkWindow *child2_window;
GtkWidget *last_child1_focus;
GtkWidget *last_child2_focus;
GtkWidget *saved_focus;
+ GtkOrientation orientation;
GdkCursorType cursor_type;
GdkDevice *grab_device;
gint min_position;
gint original_position;
+ guint32 grab_time;
+
guint handle_prelit : 1;
guint in_drag : 1;
guint in_recursion : 1;
guint child2_resize : 1;
guint child2_shrink : 1;
guint position_set : 1;
-
- guint32 grab_time;
};
enum {
static void gtk_paned_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
+static void gtk_paned_get_preferred_width_for_height
+ (GtkWidget *widget,
+ gint height,
+ gint *minimum,
+ gint *natural);
+static void gtk_paned_get_preferred_height_for_width
+ (GtkWidget *widget,
+ gint width,
+ gint *minimum,
+ gint *natural);
static void gtk_paned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
widget_class->get_preferred_width = gtk_paned_get_preferred_width;
widget_class->get_preferred_height = gtk_paned_get_preferred_height;
+ widget_class->get_preferred_width_for_height = gtk_paned_get_preferred_width_for_height;
+ widget_class->get_preferred_height_for_width = gtk_paned_get_preferred_height_for_width;
widget_class->size_allocate = gtk_paned_size_allocate;
widget_class->realize = gtk_paned_realize;
widget_class->unrealize = gtk_paned_unrealize;
add_move_binding (binding_set, GDK_KEY_KP_End, 0, GTK_SCROLL_END);
g_type_class_add_private (object_class, sizeof (GtkPanedPrivate));
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_PANED_ACCESSIBLE);
}
static GType
priv->child1 = NULL;
priv->child2 = NULL;
priv->handle = NULL;
- priv->cursor_type = GDK_CROSS;
priv->handle_pos.width = 5;
priv->handle_pos.height = 5;
{
case PROP_ORIENTATION:
priv->orientation = g_value_get_enum (value);
+ _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
priv->cursor_type = GDK_SB_H_DOUBLE_ARROW;
G_OBJECT_CLASS (gtk_paned_parent_class)->finalize (object);
}
+static void
+get_preferred_size_for_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint size,
+ gint *minimum,
+ gint *natural)
+{
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (size < 0)
+ gtk_widget_get_preferred_width (widget, minimum, natural);
+ else
+ gtk_widget_get_preferred_width_for_height (widget, size, minimum, natural);
+ else
+ if (size < 0)
+ gtk_widget_get_preferred_height (widget, minimum, natural);
+ else
+ gtk_widget_get_preferred_height_for_width (widget, size, minimum, natural);
+}
+
static void
gtk_paned_get_preferred_size (GtkWidget *widget,
GtkOrientation orientation,
+ gint size,
gint *minimum,
gint *natural)
{
if (priv->child1 && gtk_widget_get_visible (priv->child1))
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_preferred_width (priv->child1, &child_min, &child_nat);
+ get_preferred_size_for_size (priv->child1, orientation, size, &child_min, &child_nat);
+ if (priv->child1_shrink && priv->orientation == orientation)
+ *minimum = 0;
else
- gtk_widget_get_preferred_height (priv->child1, &child_min, &child_nat);
-
- *minimum = child_min;
+ *minimum = child_min;
*natural = child_nat;
}
if (priv->child2 && gtk_widget_get_visible (priv->child2))
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_preferred_width (priv->child2, &child_min, &child_nat);
- else
- gtk_widget_get_preferred_height (priv->child2, &child_min, &child_nat);
+ get_preferred_size_for_size (priv->child2, orientation, size, &child_min, &child_nat);
if (priv->orientation == orientation)
{
- *minimum += child_min;
+ if (!priv->child2_shrink)
+ *minimum += child_min;
*natural += child_nat;
}
else
gint *minimum,
gint *natural)
{
- gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
+ gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, -1, minimum, natural);
}
static void
gint *minimum,
gint *natural)
{
- gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural);
+ gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, -1, minimum, natural);
+}
+
+static void
+gtk_paned_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum,
+ gint *natural)
+{
+ gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, height, minimum, natural);
+}
+
+static void
+gtk_paned_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum,
+ gint *natural)
+{
+ gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, width, minimum, natural);
}
static void
child_pos->x = 2 * x + width - child_pos->x - child_pos->width;
}
+static void
+gtk_paned_set_child_visible (GtkPaned *paned,
+ guint id,
+ gboolean visible)
+{
+ GtkPanedPrivate *priv = paned->priv;
+ GtkWidget *child;
+
+ child = id == CHILD1 ? priv->child1 : priv->child2;
+
+ if (child == NULL)
+ return;
+
+ gtk_widget_set_child_visible (child, visible);
+
+ if (gtk_widget_get_mapped (GTK_WIDGET (paned)))
+ {
+ GdkWindow *window = id == CHILD1 ? priv->child1_window : priv->child2_window;
+
+ if (visible != gdk_window_is_visible (window))
+ {
+ if (visible)
+ gdk_window_show (window);
+ else
+ gdk_window_hide (window);
+ }
+ }
+}
+
+static void
+gtk_paned_child_allocate (GtkWidget *child,
+ GdkWindow *child_window, /* can be NULL */
+ const GtkAllocation *window_allocation,
+ GtkAllocation *child_allocation)
+{
+ if (child_window)
+ gdk_window_move_resize (child_window,
+ window_allocation->x, window_allocation->y,
+ window_allocation->width, window_allocation->height);
+
+ gtk_widget_size_allocate (child, child_allocation);
+}
+
static void
gtk_paned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
- GtkAllocation widget_allocation;
gtk_widget_set_allocation (widget, allocation);
if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
priv->child2 && gtk_widget_get_visible (priv->child2))
{
- GtkRequisition child1_requisition;
- GtkRequisition child2_requisition;
- GtkAllocation child1_allocation;
- GtkAllocation child2_allocation;
+ GtkAllocation child1_allocation, window1_allocation;
+ GtkAllocation child2_allocation, window2_allocation;
GtkAllocation priv_child1_allocation;
GdkRectangle old_handle_pos;
gint handle_size;
gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
- gtk_widget_get_preferred_size (priv->child1, &child1_requisition, NULL);
- gtk_widget_get_preferred_size (priv->child2, &child2_requisition, NULL);
-
old_handle_pos = priv->handle_pos;
- gtk_widget_get_allocation (widget, &widget_allocation);
-
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
+ gint child1_width, child2_width;
+
+ gtk_widget_get_preferred_width_for_height (priv->child1,
+ allocation->height,
+ &child1_width, NULL);
+ gtk_widget_get_preferred_width_for_height (priv->child2,
+ allocation->height,
+ &child2_width, NULL);
+
gtk_paned_calc_position (paned,
- MAX (1, widget_allocation.width - handle_size),
- child1_requisition.width,
- child2_requisition.width);
+ MAX (1, allocation->width - handle_size),
+ child1_width,
+ child2_width);
- priv->handle_pos.x = widget_allocation.x + priv->child1_size;
- priv->handle_pos.y = widget_allocation.y;
+ priv->handle_pos.x = allocation->x + priv->child1_size;
+ priv->handle_pos.y = allocation->y;
priv->handle_pos.width = handle_size;
- priv->handle_pos.height = widget_allocation.height;
+ priv->handle_pos.height = allocation->height;
- child1_allocation.height = child2_allocation.height = allocation->height;
- child1_allocation.width = MAX (1, priv->child1_size);
- child1_allocation.x = widget_allocation.x;
- child1_allocation.y = child2_allocation.y = widget_allocation.y;
+ window1_allocation.height = window2_allocation.height = allocation->height;
+ window1_allocation.width = MAX (1, priv->child1_size);
+ window1_allocation.x = allocation->x;
+ window1_allocation.y = window2_allocation.y = allocation->y;
- child2_allocation.x = child1_allocation.x + priv->child1_size + priv->handle_pos.width;
- child2_allocation.width = MAX (1, widget_allocation.x + widget_allocation.width - child2_allocation.x);
+ window2_allocation.x = window1_allocation.x + priv->child1_size + priv->handle_pos.width;
+ window2_allocation.width = MAX (1, allocation->x + allocation->width - window2_allocation.x);
if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
{
- flip_child (widget, &(child2_allocation));
- flip_child (widget, &(child1_allocation));
+ flip_child (widget, &(window2_allocation));
+ flip_child (widget, &(window1_allocation));
flip_child (widget, &(priv->handle_pos));
}
+
+ child1_allocation.x = child1_allocation.y = 0;
+ child1_allocation.width = window1_allocation.width;
+ child1_allocation.height = window1_allocation.height;
+ if (child1_width > child1_allocation.width)
+ {
+ if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_LTR)
+ child1_allocation.x -= child1_width - child1_allocation.width;
+ child1_allocation.width = child1_width;
+ }
+
+ child2_allocation.x = child2_allocation.y = 0;
+ child2_allocation.width = window2_allocation.width;
+ child2_allocation.height = window2_allocation.height;
+ if (child2_width > child2_allocation.width)
+ {
+ if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
+ child2_allocation.x -= child2_width - child2_allocation.width;
+ child2_allocation.width = child2_width;
+ }
}
else
{
+ gint child1_height, child2_height;
+
+ gtk_widget_get_preferred_height_for_width (priv->child1,
+ allocation->width,
+ &child1_height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->child2,
+ allocation->width,
+ &child2_height, NULL);
+
gtk_paned_calc_position (paned,
- MAX (1, widget_allocation.height - handle_size),
- child1_requisition.height,
- child2_requisition.height);
+ MAX (1, allocation->height - handle_size),
+ child1_height,
+ child2_height);
- priv->handle_pos.x = widget_allocation.x;
- priv->handle_pos.y = widget_allocation.y + priv->child1_size;
- priv->handle_pos.width = widget_allocation.width;
+ priv->handle_pos.x = allocation->x;
+ priv->handle_pos.y = allocation->y + priv->child1_size;
+ priv->handle_pos.width = allocation->width;
priv->handle_pos.height = handle_size;
- child1_allocation.width = child2_allocation.width = allocation->width;
- child1_allocation.height = MAX (1, priv->child1_size);
- child1_allocation.x = child2_allocation.x = widget_allocation.x;
- child1_allocation.y = widget_allocation.y;
+ window1_allocation.width = window2_allocation.width = allocation->width;
+ window1_allocation.height = MAX (1, priv->child1_size);
+ window1_allocation.x = window2_allocation.x = allocation->x;
+ window1_allocation.y = allocation->y;
- child2_allocation.y = child1_allocation.y + priv->child1_size + priv->handle_pos.height;
- child2_allocation.height = MAX (1, widget_allocation.y + widget_allocation.height - child2_allocation.y);
+ window2_allocation.y = window1_allocation.y + priv->child1_size + priv->handle_pos.height;
+ window2_allocation.height = MAX (1, allocation->y + allocation->height - window2_allocation.y);
+
+ child1_allocation.x = child1_allocation.y = 0;
+ child1_allocation.width = window1_allocation.width;
+ child1_allocation.height = window1_allocation.height;
+ if (child1_height > child1_allocation.height)
+ {
+ child1_allocation.y -= child1_height - child1_allocation.height;
+ child1_allocation.height = child1_height;
+ }
+
+ child2_allocation.x = child2_allocation.y = 0;
+ child2_allocation.width = window2_allocation.width;
+ child2_allocation.height = window2_allocation.height;
+ if (child2_height > child2_allocation.height)
+ child2_allocation.height = child2_height;
}
if (gtk_widget_get_mapped (widget) &&
(priv->orientation == GTK_ORIENTATION_VERTICAL &&
priv_child1_allocation.height < child1_allocation.height)))
{
- gtk_widget_size_allocate (priv->child2, &child2_allocation);
- gtk_widget_size_allocate (priv->child1, &child1_allocation);
+ gtk_paned_child_allocate (priv->child2,
+ priv->child2_window,
+ &window2_allocation,
+ &child2_allocation);
+ gtk_paned_child_allocate (priv->child1,
+ priv->child1_window,
+ &window1_allocation,
+ &child1_allocation);
}
else
{
- gtk_widget_size_allocate (priv->child1, &child1_allocation);
- gtk_widget_size_allocate (priv->child2, &child2_allocation);
+ gtk_paned_child_allocate (priv->child1,
+ priv->child1_window,
+ &window1_allocation,
+ &child1_allocation);
+ gtk_paned_child_allocate (priv->child2,
+ priv->child2_window,
+ &window2_allocation,
+ &child2_allocation);
}
}
else
{
- GtkAllocation child_allocation;
+ GtkAllocation window_allocation, child_allocation;
if (gtk_widget_get_realized (widget))
gdk_window_hide (priv->handle);
- if (priv->child1)
- gtk_widget_set_child_visible (priv->child1, TRUE);
- if (priv->child2)
- gtk_widget_set_child_visible (priv->child2, TRUE);
-
- gtk_widget_get_allocation (widget, &widget_allocation);
-
- child_allocation.x = widget_allocation.x;
- child_allocation.y = widget_allocation.y;
+ window_allocation.x = allocation->x;
+ window_allocation.y = allocation->y;
+ window_allocation.width = allocation->width;
+ window_allocation.height = allocation->height;
+ child_allocation.x = child_allocation.y = 0;
child_allocation.width = allocation->width;
child_allocation.height = allocation->height;
if (priv->child1 && gtk_widget_get_visible (priv->child1))
- gtk_widget_size_allocate (priv->child1, &child_allocation);
+ {
+ gtk_paned_set_child_visible (paned, 0, TRUE);
+ if (priv->child2)
+ gtk_paned_set_child_visible (paned, 1, FALSE);
+
+ gtk_paned_child_allocate (priv->child1,
+ priv->child1_window,
+ &window_allocation,
+ &child_allocation);
+ }
else if (priv->child2 && gtk_widget_get_visible (priv->child2))
- gtk_widget_size_allocate (priv->child2, &child_allocation);
+ {
+ gtk_paned_set_child_visible (paned, 1, TRUE);
+ if (priv->child1)
+ gtk_paned_set_child_visible (paned, 0, FALSE);
+
+ gtk_paned_child_allocate (priv->child2,
+ priv->child2_window,
+ &window_allocation,
+ &child_allocation);
+ }
+ else
+ {
+ if (priv->child1)
+ gtk_paned_set_child_visible (paned, 0, FALSE);
+ if (priv->child2)
+ gtk_paned_set_child_visible (paned, 1, FALSE);
+ }
}
}
+static GdkWindow *
+gtk_paned_create_child_window (GtkPaned *paned,
+ GtkWidget *child) /* may be NULL */
+{
+ GtkWidget *widget = GTK_WIDGET (paned);
+ GtkPanedPrivate *priv = paned->priv;
+ GdkWindow *window;
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
+ if (child)
+ {
+ GtkAllocation allocation;
+ int handle_size;
+
+ gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
+ child == priv->child2 && priv->child1 &&
+ gtk_widget_get_visible (priv->child1))
+ attributes.x = priv->handle_pos.x + handle_size;
+ else
+ attributes.x = allocation.x;
+ if (priv->orientation == GTK_ORIENTATION_VERTICAL &&
+ child == priv->child2 && priv->child1 &&
+ gtk_widget_get_visible (priv->child1))
+ attributes.y = priv->handle_pos.y + handle_size;
+ else
+ attributes.y = allocation.y;
+
+ gtk_widget_get_allocation (child, &allocation);
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+ }
+ else
+ {
+ attributes.width = 1;
+ attributes.height = 1;
+ attributes_mask = 0;
+ }
+
+ window = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (window, paned);
+ gtk_style_context_set_background (gtk_widget_get_style_context (widget), window);
+
+ if (child)
+ gtk_widget_set_parent_window (child, window);
+
+ return window;
+}
+
static void
gtk_paned_realize (GtkWidget *widget)
{
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK);
+ GDK_POINTER_MOTION_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
if (gtk_widget_is_sensitive (widget))
{
if (attributes_mask & GDK_WA_CURSOR)
g_object_unref (attributes.cursor);
- if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
- priv->child2 && gtk_widget_get_visible (priv->child2))
- gdk_window_show (priv->handle);
+ priv->child1_window = gtk_paned_create_child_window (paned, priv->child1);
+ priv->child2_window = gtk_paned_create_child_window (paned, priv->child2);
}
static void
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
+ if (priv->child2)
+ gtk_widget_set_parent_window (priv->child2, NULL);
+ gdk_window_set_user_data (priv->child2_window, NULL);
+ gdk_window_destroy (priv->child2_window);
+ priv->child2_window = NULL;
+
+ if (priv->child1)
+ gtk_widget_set_parent_window (priv->child1, NULL);
+ gdk_window_set_user_data (priv->child1_window, NULL);
+ gdk_window_destroy (priv->child1_window);
+ priv->child1_window = NULL;
+
if (priv->handle)
{
gdk_window_set_user_data (priv->handle, NULL);
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
- gdk_window_show (priv->handle);
+ if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
+ priv->child2 && gtk_widget_get_visible (priv->child2))
+ gdk_window_show (priv->handle);
+
+ if (priv->child1 && gtk_widget_get_visible (priv->child1) && gtk_widget_get_child_visible (priv->child1))
+ gdk_window_show (priv->child1_window);
+ if (priv->child2 && gtk_widget_get_visible (priv->child2) && gtk_widget_get_child_visible (priv->child2))
+ gdk_window_show (priv->child2_window);
GTK_WIDGET_CLASS (gtk_paned_parent_class)->map (widget);
}
GtkPanedPrivate *priv = paned->priv;
gdk_window_hide (priv->handle);
+
+ if (gdk_window_is_visible (priv->child1_window))
+ gdk_window_hide (priv->child1_window);
+ if (gdk_window_is_visible (priv->child2_window))
+ gdk_window_hide (priv->child2_window);
GTK_WIDGET_CLASS (gtk_paned_parent_class)->unmap (widget);
}
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
- if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) &&
+ if (gtk_cairo_should_draw_window (cr, priv->child1_window))
+ {
+ cairo_save (cr);
+ gtk_cairo_transform_to_window (cr, widget, priv->child1_window);
+ gtk_render_background (gtk_widget_get_style_context (widget),
+ cr,
+ 0, 0,
+ gdk_window_get_width (priv->child1_window),
+ gdk_window_get_height (priv->child1_window));
+ cairo_restore (cr);
+ }
+
+ if (gtk_cairo_should_draw_window (cr, priv->child2_window))
+ {
+ cairo_save (cr);
+ gtk_cairo_transform_to_window (cr, widget, priv->child2_window);
+ gtk_render_background (gtk_widget_get_style_context (widget),
+ cr,
+ 0, 0,
+ gdk_window_get_width (priv->child2_window),
+ gdk_window_get_height (priv->child2_window));
+ cairo_restore (cr);
+ }
+
+ if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)) &&
priv->child1 && gtk_widget_get_visible (priv->child1) &&
priv->child2 && gtk_widget_get_visible (priv->child2))
{
gtk_style_context_save (context);
gtk_style_context_set_state (context, state);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_PANE_SEPARATOR);
gtk_render_handle (context, cr,
priv->handle_pos.x - allocation.x,
priv->handle_pos.y - allocation.y,
}
static void
-update_drag (GtkPaned *paned)
+update_drag (GtkPaned *paned,
+ /* relative to priv->handle */
+ int xpos,
+ int ypos)
{
GtkPanedPrivate *priv = paned->priv;
GtkAllocation allocation;
gint pos;
gint handle_size;
gint size;
+ gint x, y;
+ gdk_window_get_position (priv->handle, &x, &y);
+ gtk_widget_get_allocation (widget, &allocation);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_pointer (widget, &pos, NULL);
+ {
+ pos = xpos + x - allocation.x;
+ }
else
- gtk_widget_get_pointer (widget, NULL, &pos);
+ {
+ pos = ypos + y - allocation.y;
+ }
pos -= priv->drag_pos;
"handle-size", &handle_size,
NULL);
- gtk_widget_get_allocation (widget, &allocation);
size = allocation.width - pos - handle_size;
}
else
GtkPanedPrivate *priv = paned->priv;
if (priv->in_drag)
- update_drag (paned);
+ update_drag (paned, event->x, event->y);
else
{
priv->handle_prelit = TRUE;
GtkPanedPrivate *priv = paned->priv;
if (priv->in_drag)
- update_drag (paned);
+ update_drag (paned, event->x, event->y);
else
{
priv->handle_prelit = FALSE;
GtkPanedPrivate *priv = paned->priv;
if (!priv->in_drag &&
- (event->window == priv->handle) && (event->button == 1))
+ (event->window == priv->handle) && (event->button == GDK_BUTTON_PRIMARY))
{
/* We need a server grab here, not gtk_grab_add(), since
* we don't want to pass events on to the widget's children */
if (gdk_device_grab (event->device,
priv->handle,
GDK_OWNERSHIP_WINDOW, FALSE,
- GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON1_MOTION_MASK
+ GDK_BUTTON1_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_LEAVE_NOTIFY_MASK,
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
- if (priv->in_drag && (event->button == 1))
+ if (priv->in_drag && (event->button == GDK_BUTTON_PRIMARY))
{
stop_drag (paned);
if (priv->in_drag)
{
- update_drag (paned);
+ update_drag (paned, event->x, event->y);
return TRUE;
}
priv->child1_resize = resize;
priv->child1_shrink = shrink;
+ gtk_widget_set_parent_window (child, priv->child1_window);
gtk_widget_set_parent (child, GTK_WIDGET (paned));
}
}
priv->child2_resize = resize;
priv->child2_shrink = shrink;
+ gtk_widget_set_parent_window (child, priv->child2_window);
gtk_widget_set_parent (child, GTK_WIDGET (paned));
}
}
if (priv->child1 == widget)
{
+ if (priv->child1_window && gdk_window_is_visible (priv->child1_window))
+ gdk_window_hide (priv->child1_window);
+
gtk_widget_unparent (widget);
priv->child1 = NULL;
}
else if (priv->child2 == widget)
{
+ if (priv->child2_window && gdk_window_is_visible (priv->child2_window))
+ gdk_window_hide (priv->child2_window);
+
gtk_widget_unparent (widget);
priv->child2 = NULL;
priv->max_position);
if (priv->child1)
- gtk_widget_set_child_visible (priv->child1, priv->child1_size != 0);
+ gtk_paned_set_child_visible (paned, 0, priv->child1_size != 0);
if (priv->child2)
- gtk_widget_set_child_visible (priv->child2, priv->child1_size != allocation);
+ gtk_paned_set_child_visible (paned, 1, priv->child1_size != allocation);
g_object_freeze_notify (G_OBJECT (paned));
if (priv->child1_size != old_position)