Commit fc3f1ef3 authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen
Browse files

implement RTL flipping (#96632)

Fri Sep 19 18:15:31 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtkpaned.c, gtk/gtkhpaned.c: implement RTL flipping
	(#96632)
parent ad709dcf
Fri Sep 19 18:15:31 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkpaned.c, gtk/gtkhpaned.c: implement RTL flipping
(#96632)
Fri Sep 19 13:24:54 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeview.c (gtk_tree_view_get_cursor): Improve
......
Fri Sep 19 18:15:31 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkpaned.c, gtk/gtkhpaned.c: implement RTL flipping
(#96632)
Fri Sep 19 13:24:54 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeview.c (gtk_tree_view_get_cursor): Improve
......
Fri Sep 19 18:15:31 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkpaned.c, gtk/gtkhpaned.c: implement RTL flipping
(#96632)
Fri Sep 19 13:24:54 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeview.c (gtk_tree_view_get_cursor): Improve
......
Fri Sep 19 18:15:31 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkpaned.c, gtk/gtkhpaned.c: implement RTL flipping
(#96632)
Fri Sep 19 13:24:54 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeview.c (gtk_tree_view_get_cursor): Improve
......
Fri Sep 19 18:15:31 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkpaned.c, gtk/gtkhpaned.c: implement RTL flipping
(#96632)
Fri Sep 19 13:24:54 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeview.c (gtk_tree_view_get_cursor): Improve
......
......@@ -137,6 +137,15 @@ gtk_hpaned_size_request (GtkWidget *widget,
}
}
static void
flip_child (GtkWidget *widget, GtkAllocation *child_pos)
{
gint x = widget->allocation.x;
gint width = widget->allocation.width;
child_pos->x = 2 * x + width - child_pos->x - child_pos->width;
}
static void
gtk_hpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
......@@ -171,6 +180,21 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
paned->handle_pos.y = widget->allocation.y + border_width;
paned->handle_pos.width = handle_size;
paned->handle_pos.height = MAX (1, widget->allocation.height - 2 * border_width);
child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
child1_allocation.width = MAX (1, paned->child1_size);
child1_allocation.x = widget->allocation.x + border_width;
child1_allocation.y = child2_allocation.y = widget->allocation.y + border_width;
child2_allocation.x = child1_allocation.x + paned->child1_size + paned->handle_pos.width;
child2_allocation.width = MAX (1, widget->allocation.x + widget->allocation.width - child2_allocation.x - border_width);
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, &(paned->handle_pos));
}
if (GTK_WIDGET_REALIZED (widget))
{
......@@ -183,14 +207,6 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
paned->handle_pos.height);
}
child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
child1_allocation.width = MAX (1, paned->child1_size);
child1_allocation.x = widget->allocation.x + border_width;
child1_allocation.y = child2_allocation.y = widget->allocation.y + border_width;
child2_allocation.x = child1_allocation.x + paned->child1_size + paned->handle_pos.width;
child2_allocation.width = MAX (1, widget->allocation.x + widget->allocation.width - child2_allocation.x - border_width);
/* Now allocate the childen, making sure, when resizing not to
* overlap the windows
*/
......
......@@ -733,6 +733,18 @@ gtk_paned_expose (GtkWidget *widget,
return FALSE;
}
static gboolean
is_rtl (GtkPaned *paned)
{
if (paned->orientation == GTK_ORIENTATION_VERTICAL &&
gtk_widget_get_direction (GTK_WIDGET (paned)) == GTK_TEXT_DIR_RTL)
{
return TRUE;
}
return FALSE;
}
static void
update_drag (GtkPaned *paned)
{
......@@ -745,9 +757,23 @@ update_drag (GtkPaned *paned)
else
gtk_widget_get_pointer (GTK_WIDGET (paned), &pos, NULL);
gtk_widget_style_get (GTK_WIDGET (paned), "handle_size", &handle_size, NULL);
pos -= paned->drag_pos;
if (is_rtl (paned))
{
gtk_widget_style_get (GTK_WIDGET (paned),
"handle_size", &handle_size,
NULL);
size = GTK_WIDGET (paned)->allocation.width - pos - handle_size;
}
else
{
size = pos;
}
size -= GTK_CONTAINER (paned)->border_width;
size = pos - GTK_CONTAINER (paned)->border_width - paned->drag_pos;
size = CLAMP (size, paned->min_position, paned->max_position);
if (size != paned->child1_size)
......@@ -1332,7 +1358,7 @@ gtk_paned_cycle_child_focus (GtkPaned *paned,
{
GList *cycle_chain = NULL;
GList *list;
GtkDirectionType direction = reversed? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
/* ignore f6 if the handle is focused */
......@@ -1429,38 +1455,40 @@ gtk_paned_move_handle (GtkPaned *paned,
{
gint old_position;
gint new_position;
gint increment;
enum {
SINGLE_STEP_SIZE = 1,
PAGE_STEP_SIZE = 75
};
old_position = gtk_paned_get_position (paned);
new_position = old_position = gtk_paned_get_position (paned);
increment = 0;
switch (scroll)
{
case GTK_SCROLL_STEP_LEFT:
case GTK_SCROLL_STEP_UP:
case GTK_SCROLL_STEP_BACKWARD:
new_position = old_position - SINGLE_STEP_SIZE;
increment = - SINGLE_STEP_SIZE;
break;
case GTK_SCROLL_STEP_RIGHT:
case GTK_SCROLL_STEP_DOWN:
case GTK_SCROLL_STEP_FORWARD:
new_position = old_position + SINGLE_STEP_SIZE;
increment = SINGLE_STEP_SIZE;
break;
case GTK_SCROLL_PAGE_LEFT:
case GTK_SCROLL_PAGE_UP:
case GTK_SCROLL_PAGE_BACKWARD:
new_position = old_position - PAGE_STEP_SIZE;
increment = - PAGE_STEP_SIZE;
break;
case GTK_SCROLL_PAGE_RIGHT:
case GTK_SCROLL_PAGE_DOWN:
case GTK_SCROLL_PAGE_FORWARD:
new_position = old_position + PAGE_STEP_SIZE;
increment = PAGE_STEP_SIZE;
break;
case GTK_SCROLL_START:
......@@ -1470,11 +1498,18 @@ gtk_paned_move_handle (GtkPaned *paned,
case GTK_SCROLL_END:
new_position = paned->max_position;
break;
default:
new_position = old_position;
break;
}
if (increment)
{
if (is_rtl (paned))
increment = -increment;
new_position = old_position + increment;
}
new_position = CLAMP (new_position, paned->min_position, paned->max_position);
......
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