Commit 00943af8 authored by Matthias Clasen's avatar Matthias Clasen

Automatic RTL flipping for some more widgets.

parent ca00536f
2002-11-02 Matthias Clasen <maclas@gmx.de>
* gtk/stock-icons/stock_jump_to_rtl_16.png,
* gtk/stock-icons/stock_jump_to_rtl_24.png: Mirrored variants
of stock_jump_to.
* gtk/stock-icons/Makefile.am:
* gtk/gtkiconfactory.c (get_default_icons): Flip GTK_STOCK_FIRST,
GTK_STOCK_LAST and GTK_STOCK_JUMP_TO for RTL locales. (#96633)
* gtk/gtkaccellabel.c (gtk_accel_label_expose_event):
Flip accel labels for RTL locales. (#96637)
* gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_paint):
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_allocate):
* gtk/gtkmenuitem.c (gtk_menu_item_init):
(gtk_menu_item_size_request):
(gtk_menu_item_size_allocate):
(gtk_menu_item_paint):
(gtk_menu_item_select_timeout):
(gtk_menu_item_position_menu): Flip all kinds of menu items for
RTL locales. (#96637)
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): Support resize
grips for all edges. (#52833)
* gtk/gtkstyle.c (gtk_default_draw_box):
* gtk/gtkoptionmenu.c (gtk_option_menu_size_allocate):
(gtk_option_menu_paint): Flip option menus for RTL
locales. (#96631)
* gtk/gtkmenubar.c (gtk_menu_bar_size_allocate): Flip menubars
for RTL locales. (#96627)
* gtk/gtkprogressbar.c (gtk_progress_bar_act_mode_enter):
(gtk_progress_bar_paint): Flip progress bars for RTL
locales. (#96634)
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Flip toolbars
for RTL locales. (#96626)
2002-11-01 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkim-x11.c:
......
2002-11-02 Matthias Clasen <maclas@gmx.de>
* gtk/stock-icons/stock_jump_to_rtl_16.png,
* gtk/stock-icons/stock_jump_to_rtl_24.png: Mirrored variants
of stock_jump_to.
* gtk/stock-icons/Makefile.am:
* gtk/gtkiconfactory.c (get_default_icons): Flip GTK_STOCK_FIRST,
GTK_STOCK_LAST and GTK_STOCK_JUMP_TO for RTL locales. (#96633)
* gtk/gtkaccellabel.c (gtk_accel_label_expose_event):
Flip accel labels for RTL locales. (#96637)
* gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_paint):
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_allocate):
* gtk/gtkmenuitem.c (gtk_menu_item_init):
(gtk_menu_item_size_request):
(gtk_menu_item_size_allocate):
(gtk_menu_item_paint):
(gtk_menu_item_select_timeout):
(gtk_menu_item_position_menu): Flip all kinds of menu items for
RTL locales. (#96637)
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): Support resize
grips for all edges. (#52833)
* gtk/gtkstyle.c (gtk_default_draw_box):
* gtk/gtkoptionmenu.c (gtk_option_menu_size_allocate):
(gtk_option_menu_paint): Flip option menus for RTL
locales. (#96631)
* gtk/gtkmenubar.c (gtk_menu_bar_size_allocate): Flip menubars
for RTL locales. (#96627)
* gtk/gtkprogressbar.c (gtk_progress_bar_act_mode_enter):
(gtk_progress_bar_paint): Flip progress bars for RTL
locales. (#96634)
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Flip toolbars
for RTL locales. (#96626)
2002-11-01 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkim-x11.c:
......
2002-11-02 Matthias Clasen <maclas@gmx.de>
* gtk/stock-icons/stock_jump_to_rtl_16.png,
* gtk/stock-icons/stock_jump_to_rtl_24.png: Mirrored variants
of stock_jump_to.
* gtk/stock-icons/Makefile.am:
* gtk/gtkiconfactory.c (get_default_icons): Flip GTK_STOCK_FIRST,
GTK_STOCK_LAST and GTK_STOCK_JUMP_TO for RTL locales. (#96633)
* gtk/gtkaccellabel.c (gtk_accel_label_expose_event):
Flip accel labels for RTL locales. (#96637)
* gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_paint):
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_allocate):
* gtk/gtkmenuitem.c (gtk_menu_item_init):
(gtk_menu_item_size_request):
(gtk_menu_item_size_allocate):
(gtk_menu_item_paint):
(gtk_menu_item_select_timeout):
(gtk_menu_item_position_menu): Flip all kinds of menu items for
RTL locales. (#96637)
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): Support resize
grips for all edges. (#52833)
* gtk/gtkstyle.c (gtk_default_draw_box):
* gtk/gtkoptionmenu.c (gtk_option_menu_size_allocate):
(gtk_option_menu_paint): Flip option menus for RTL
locales. (#96631)
* gtk/gtkmenubar.c (gtk_menu_bar_size_allocate): Flip menubars
for RTL locales. (#96627)
* gtk/gtkprogressbar.c (gtk_progress_bar_act_mode_enter):
(gtk_progress_bar_paint): Flip progress bars for RTL
locales. (#96634)
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Flip toolbars
for RTL locales. (#96626)
2002-11-01 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkim-x11.c:
......
2002-11-02 Matthias Clasen <maclas@gmx.de>
* gtk/stock-icons/stock_jump_to_rtl_16.png,
* gtk/stock-icons/stock_jump_to_rtl_24.png: Mirrored variants
of stock_jump_to.
* gtk/stock-icons/Makefile.am:
* gtk/gtkiconfactory.c (get_default_icons): Flip GTK_STOCK_FIRST,
GTK_STOCK_LAST and GTK_STOCK_JUMP_TO for RTL locales. (#96633)
* gtk/gtkaccellabel.c (gtk_accel_label_expose_event):
Flip accel labels for RTL locales. (#96637)
* gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_paint):
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_allocate):
* gtk/gtkmenuitem.c (gtk_menu_item_init):
(gtk_menu_item_size_request):
(gtk_menu_item_size_allocate):
(gtk_menu_item_paint):
(gtk_menu_item_select_timeout):
(gtk_menu_item_position_menu): Flip all kinds of menu items for
RTL locales. (#96637)
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): Support resize
grips for all edges. (#52833)
* gtk/gtkstyle.c (gtk_default_draw_box):
* gtk/gtkoptionmenu.c (gtk_option_menu_size_allocate):
(gtk_option_menu_paint): Flip option menus for RTL
locales. (#96631)
* gtk/gtkmenubar.c (gtk_menu_bar_size_allocate): Flip menubars
for RTL locales. (#96627)
* gtk/gtkprogressbar.c (gtk_progress_bar_act_mode_enter):
(gtk_progress_bar_paint): Flip progress bars for RTL
locales. (#96634)
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Flip toolbars
for RTL locales. (#96626)
2002-11-01 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkim-x11.c:
......
2002-11-02 Matthias Clasen <maclas@gmx.de>
* gtk/stock-icons/stock_jump_to_rtl_16.png,
* gtk/stock-icons/stock_jump_to_rtl_24.png: Mirrored variants
of stock_jump_to.
* gtk/stock-icons/Makefile.am:
* gtk/gtkiconfactory.c (get_default_icons): Flip GTK_STOCK_FIRST,
GTK_STOCK_LAST and GTK_STOCK_JUMP_TO for RTL locales. (#96633)
* gtk/gtkaccellabel.c (gtk_accel_label_expose_event):
Flip accel labels for RTL locales. (#96637)
* gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_paint):
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_allocate):
* gtk/gtkmenuitem.c (gtk_menu_item_init):
(gtk_menu_item_size_request):
(gtk_menu_item_size_allocate):
(gtk_menu_item_paint):
(gtk_menu_item_select_timeout):
(gtk_menu_item_position_menu): Flip all kinds of menu items for
RTL locales. (#96637)
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): Support resize
grips for all edges. (#52833)
* gtk/gtkstyle.c (gtk_default_draw_box):
* gtk/gtkoptionmenu.c (gtk_option_menu_size_allocate):
(gtk_option_menu_paint): Flip option menus for RTL
locales. (#96631)
* gtk/gtkmenubar.c (gtk_menu_bar_size_allocate): Flip menubars
for RTL locales. (#96627)
* gtk/gtkprogressbar.c (gtk_progress_bar_act_mode_enter):
(gtk_progress_bar_paint): Flip progress bars for RTL
locales. (#96634)
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Flip toolbars
for RTL locales. (#96626)
2002-11-01 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkim-x11.c:
......
2002-11-02 Matthias Clasen <maclas@gmx.de>
* gtk/stock-icons/stock_jump_to_rtl_16.png,
* gtk/stock-icons/stock_jump_to_rtl_24.png: Mirrored variants
of stock_jump_to.
* gtk/stock-icons/Makefile.am:
* gtk/gtkiconfactory.c (get_default_icons): Flip GTK_STOCK_FIRST,
GTK_STOCK_LAST and GTK_STOCK_JUMP_TO for RTL locales. (#96633)
* gtk/gtkaccellabel.c (gtk_accel_label_expose_event):
Flip accel labels for RTL locales. (#96637)
* gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_paint):
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
* gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_allocate):
* gtk/gtkmenuitem.c (gtk_menu_item_init):
(gtk_menu_item_size_request):
(gtk_menu_item_size_allocate):
(gtk_menu_item_paint):
(gtk_menu_item_select_timeout):
(gtk_menu_item_position_menu): Flip all kinds of menu items for
RTL locales. (#96637)
* gtk/gtkstyle.c (gtk_default_draw_resize_grip): Support resize
grips for all edges. (#52833)
* gtk/gtkstyle.c (gtk_default_draw_box):
* gtk/gtkoptionmenu.c (gtk_option_menu_size_allocate):
(gtk_option_menu_paint): Flip option menus for RTL
locales. (#96631)
* gtk/gtkmenubar.c (gtk_menu_bar_size_allocate): Flip menubars
for RTL locales. (#96627)
* gtk/gtkprogressbar.c (gtk_progress_bar_act_mode_enter):
(gtk_progress_bar_paint): Flip progress bars for RTL
locales. (#96634)
* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Flip toolbars
for RTL locales. (#96626)
2002-11-01 Matthias Clasen <maclas@gmx.de>
* gdk/x11/gdkim-x11.c:
......
......@@ -204,8 +204,6 @@ gtk_accel_label_init (GtkAccelLabel *accel_label)
accel_label->accel_closure = NULL;
accel_label->accel_group = NULL;
accel_label->accel_string = NULL;
gtk_accel_label_refetch (accel_label);
}
GtkWidget*
......@@ -312,7 +310,10 @@ gtk_accel_label_expose_event (GtkWidget *widget,
{
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (widget);
GtkMisc *misc = GTK_MISC (accel_label);
GtkTextDirection direction;
direction = gtk_widget_get_direction (widget);
if (GTK_WIDGET_DRAWABLE (accel_label))
{
guint ac_width;
......@@ -327,12 +328,19 @@ gtk_accel_label_expose_event (GtkWidget *widget,
gint x;
gint y;
if (direction == GTK_TEXT_DIR_RTL)
widget->allocation.x += ac_width;
widget->allocation.width -= ac_width;
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
if (direction == GTK_TEXT_DIR_RTL)
widget->allocation.x -= ac_width;
widget->allocation.width += ac_width;
x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width;
if (direction == GTK_TEXT_DIR_RTL)
x = widget->allocation.x + misc->xpad;
else
x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width;
label_layout = gtk_label_get_layout (GTK_LABEL (accel_label));
gtk_label_get_layout_offsets (GTK_LABEL (accel_label), NULL, &y);
......
......@@ -591,11 +591,13 @@ get_default_icons (GtkIconFactory *factory)
GTK_ICON_SIZE_MENU,
GTK_STOCK_QUIT);
add_sized_with_fallback (factory,
stock_first_24,
stock_first_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_GOTO_FIRST);
add_sized_with_fallback_and_rtl (factory,
stock_first_24,
stock_last_24,
stock_first_16,
stock_last_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_GOTO_FIRST);
add_sized_with_fallback (factory,
stock_font_24,
......@@ -615,17 +617,21 @@ get_default_icons (GtkIconFactory *factory)
GTK_ICON_SIZE_MENU,
GTK_STOCK_HOME);
add_sized_with_fallback (factory,
stock_jump_to_24,
stock_jump_to_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_JUMP_TO);
add_sized_with_fallback_and_rtl (factory,
stock_jump_to_24,
stock_jump_to_rtl_24,
stock_jump_to_16,
stock_jump_to_rtl_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_JUMP_TO);
add_sized_with_fallback (factory,
stock_last_24,
stock_last_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_GOTO_LAST);
add_sized_with_fallback_and_rtl (factory,
stock_last_24,
stock_first_24,
stock_last_16,
stock_first_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_GOTO_LAST);
add_sized_with_fallback_and_rtl (factory,
stock_left_arrow_24,
......@@ -684,10 +690,10 @@ get_default_icons (GtkIconFactory *factory)
GTK_STOCK_PROPERTIES);
add_sized_with_fallback (factory,
stock_redo_24,
stock_redo_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_REDO);
stock_redo_24,
stock_redo_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_REDO);
add_sized_with_fallback (factory,
stock_remove_24,
......@@ -812,10 +818,10 @@ get_default_icons (GtkIconFactory *factory)
GTK_STOCK_UNDELETE);
add_sized_with_fallback (factory,
stock_undo_24,
stock_undo_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_UNDO);
stock_undo_24,
stock_undo_16,
GTK_ICON_SIZE_MENU,
GTK_STOCK_UNDO);
add_sized_with_fallback (factory,
stock_up_arrow_24,
......
......@@ -235,7 +235,7 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
if (image_menu_item->image)
{
gint width, height, x, y;
gint width, height, x, y, offset;
GtkAllocation child_allocation;
/* Man this is lame hardcoding action, but I can't
......@@ -244,10 +244,15 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
width = image_menu_item->image->requisition.width;
height = image_menu_item->image->requisition.height;
x = (GTK_CONTAINER (image_menu_item)->border_width +
widget->style->xthickness) +
(GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2;
offset = GTK_CONTAINER (image_menu_item)->border_width +
widget->style->xthickness;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
x = offset + (GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2;
else
x = widget->allocation.width -
GTK_MENU_ITEM (image_menu_item)->toggle_size - offset +
(GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2;
y = (widget->allocation.height - height) / 2;
child_allocation.width = width;
......
......@@ -270,13 +270,17 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkRequisition child_requisition;
guint offset;
gint ipadding;
GtkTextDirection direction;
gint ltr_x;
g_return_if_fail (GTK_IS_MENU_BAR (widget));
g_return_if_fail (allocation != NULL);
menu_bar = GTK_MENU_BAR (widget);
menu_shell = GTK_MENU_SHELL (widget);
direction = gtk_widget_get_direction (widget);
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
......@@ -303,6 +307,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
offset = child_allocation.x; /* Window edge to menubar start */
ltr_x = child_allocation.x;
children = menu_shell->children;
while (children)
......@@ -322,18 +327,24 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
&& (GTK_MENU_ITEM(child)->right_justify))
{
child_allocation.x = allocation->width -
child_requisition.width - offset;
ltr_x = allocation->width -
child_requisition.width - offset;
}
if (GTK_WIDGET_VISIBLE (child))
{
if (direction == GTK_TEXT_DIR_LTR)
child_allocation.x = ltr_x;
else
child_allocation.x = allocation->width -
child_requisition.width - ltr_x;
child_allocation.width = child_requisition.width;
gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
toggle_size);
gtk_widget_size_allocate (child, &child_allocation);
child_allocation.x += child_allocation.width + CHILD_SPACING * 2;
ltr_x += child_allocation.width + CHILD_SPACING * 2;
}
}
}
......
......@@ -222,7 +222,10 @@ gtk_menu_item_init (GtkMenuItem *menu_item)
menu_item->toggle_size = 0;
menu_item->accelerator_width = 0;
menu_item->show_submenu_indicator = FALSE;
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
if (gtk_widget_get_direction (GTK_WIDGET (menu_item)) == GTK_TEXT_DIR_RTL)
menu_item->submenu_direction = GTK_DIRECTION_LEFT;
else
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
menu_item->submenu_placement = GTK_TOP_BOTTOM;
menu_item->right_justify = FALSE;
......@@ -486,6 +489,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkMenuItem *menu_item;
GtkBin *bin;
GtkAllocation child_allocation;
GtkTextDirection direction;
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
g_return_if_fail (allocation != NULL);
......@@ -493,6 +497,8 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
menu_item = GTK_MENU_ITEM (widget);
bin = GTK_BIN (widget);
direction = gtk_widget_get_direction (widget);
widget->allocation = *allocation;
if (bin->child)
......@@ -506,15 +512,20 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
widget->style->ythickness);
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
child_allocation.x += GTK_MENU_ITEM (widget)->toggle_size;
if (direction == GTK_TEXT_DIR_LTR)
child_allocation.x += GTK_MENU_ITEM (widget)->toggle_size;
child_allocation.width -= GTK_MENU_ITEM (widget)->toggle_size;
child_allocation.x += widget->allocation.x;
child_allocation.y += widget->allocation.y;
gtk_widget_get_child_requisition (bin->child, &child_requisition);
if (menu_item->submenu && menu_item->show_submenu_indicator)
child_allocation.width -= child_requisition.height;
if (menu_item->submenu && menu_item->show_submenu_indicator)
{
if (direction == GTK_TEXT_DIR_RTL)
child_allocation.x += child_requisition.height;
child_allocation.width -= child_requisition.height;
}
if (child_allocation.width < 1)
child_allocation.width = 1;
......@@ -612,7 +623,7 @@ gtk_menu_item_paint (GtkWidget *widget,
menu_item = GTK_MENU_ITEM (widget);
state_type = widget->state;
x = widget->allocation.x + border_width;
y = widget->allocation.y + border_width;
width = widget->allocation.width - border_width * 2;
......@@ -638,7 +649,11 @@ gtk_menu_item_paint (GtkWidget *widget,
gint arrow_x, arrow_y;
gint arrow_size;
gint arrow_extent;
GtkTextDirection direction;
GtkArrowType arrow_type;
direction = gtk_widget_get_direction (widget);
gtk_widget_get_child_requisition (GTK_BIN (menu_item)->child,
&child_requisition);
......@@ -649,13 +664,21 @@ gtk_menu_item_paint (GtkWidget *widget,
if (state_type == GTK_STATE_PRELIGHT)
shadow_type = GTK_SHADOW_IN;
arrow_x = x + width - 1 - arrow_size + (arrow_size - arrow_extent) / 2;
if (direction == GTK_TEXT_DIR_LTR) {
arrow_x = x + width - 1 - arrow_size + (arrow_size - arrow_extent) / 2;
arrow_type = GTK_ARROW_RIGHT;
}
else {
arrow_x = x + 1 + (arrow_size - arrow_extent) / 2;
arrow_type = GTK_ARROW_LEFT;
}
arrow_y = y + (height - arrow_extent) / 2;
gtk_paint_arrow (widget->style, widget->window,
state_type, shadow_type,
area, widget, "menuitem",
GTK_ARROW_RIGHT, TRUE,
arrow_type, TRUE,
arrow_x, arrow_y,
arrow_extent, arrow_extent);
}
......@@ -719,7 +742,6 @@ gtk_real_menu_item_select (GtkItem *item)
if (menu_item->submenu)
{
gint popup_delay;
GtkWidget *parent;
if (menu_item->timer)
gtk_timeout_remove (menu_item->timer);
......@@ -741,7 +763,7 @@ gtk_real_menu_item_select (GtkItem *item)
menu_item->timer_from_keypress = FALSE;
if (event)
gdk_event_free(event);
gdk_event_free (event);
}
else
gtk_menu_item_popup_submenu (menu_item);
......@@ -869,24 +891,24 @@ gtk_menu_item_select_timeout (gpointer data)
static void
gtk_menu_item_popup_submenu (gpointer data)
{
GtkWidget *widget;
GtkMenuItem *menu_item;
menu_item = GTK_MENU_ITEM (data);
widget = GTK_WIDGET (data);
menu_item = GTK_MENU_ITEM (widget);
if (menu_item->timer)
gtk_timeout_remove (menu_item->timer);
menu_item->timer = 0;
if (GTK_WIDGET_IS_SENSITIVE (menu_item->submenu))
{
gtk_menu_popup (GTK_MENU (menu_item->submenu),
GTK_WIDGET (menu_item)->parent,
GTK_WIDGET (menu_item),
gtk_menu_item_position_menu,
menu_item,
GTK_MENU_SHELL (GTK_WIDGET (menu_item)->parent)->button,
0);
}
gtk_menu_popup (GTK_MENU (menu_item->submenu),
widget->parent,
widget,
gtk_menu_item_position_menu,
menu_item,
GTK_MENU_SHELL (widget->parent)->button,
0);
}
static void
......@@ -904,6 +926,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
gint screen_height;
gint twidth, theight;
gint tx, ty;
GtkTextDirection direction;
g_return_if_fail (menu != NULL);
g_return_if_fail (x != NULL);
......@@ -912,6 +935,8 @@ gtk_menu_item_position_menu (GtkMenu *menu,
menu_item = GTK_MENU_ITEM (user_data);
widget = GTK_WIDGET (user_data);
direction = gtk_widget_get_direction (widget);
twidth = GTK_WIDGET (menu)->requisition.width;
theight = GTK_WIDGET (menu)->requisition.height;
......@@ -931,6 +956,14 @@ gtk_menu_item_position_menu (GtkMenu *menu,
switch (menu_item->submenu_placement)
{
case GTK_TOP_BOTTOM:
if (direction == GTK_TEXT_DIR_LTR)
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
else
{
menu_item->submenu_direction = GTK_DIRECTION_LEFT;
tx += widget->allocation.width - twidth;
}
if ((ty + widget->allocation.height + theight) <= screen_height)
ty += widget->allocation.height;
else if ((ty - theight) >= 0)
......@@ -942,10 +975,15 @@ gtk_menu_item_position_menu (GtkMenu *menu,
break;
case GTK_LEFT_RIGHT:
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
parent_menu_item = GTK_MENU (widget->parent)->parent_menu_item;
if (parent_menu_item)
if (parent_menu_item &&
!GTK_MENU (widget->parent)->torn_off &&
!GTK_MENU_SHELL (menu)->active)
menu_item->submenu_direction = GTK_MENU_ITEM (parent_menu_item)->submenu_direction;
else if (direction == GTK_TEXT_DIR_LTR)
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
else
menu_item->submenu_direction = GTK_DIRECTION_LEFT;
switch (menu_item->submenu_direction)
{
......
......@@ -501,7 +501,7 @@ gtk_option_menu_size_allocate (GtkWidget *widget,
{
gint xthickness = GTK_WIDGET (widget)->style->xthickness;
gint ythickness = GTK_WIDGET (widget)->style->ythickness;
child_allocation.x = widget->allocation.x + border_width + xthickness + props.focus_width + props.focus_pad + CHILD_LEFT_SPACING;
child_allocation.y = widget->allocation.y + border_width + ythickness + props.focus_width + props.focus_pad + CHILD_TOP_SPACING;
child_allocation.width = MAX (1, allocation->width - (border_width + xthickness + props.focus_width + props.focus_pad) * 2 -
......@@ -510,6 +510,9 @@ gtk_option_menu_size_allocate (GtkWidget *widget,
child_allocation.height = MAX (1, allocation->height - (border_width + ythickness + props.focus_width + props.focus_pad) * 2 -
CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING);
if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
child_allocation.x += props.indicator_size.width + props.indicator_spacing.left + props.indicator_spacing.right;
gtk_widget_size_allocate (child, &child_allocation);
}
}
......@@ -521,6 +524,7 @@ gtk_option_menu_paint (GtkWidget *widget,
GdkRectangle button_area;
GtkOptionMenuProps props;
gint border_width;
gint tab_x;
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
g_return_if_fail (area != NULL);
......@@ -549,12 +553,18 @@ gtk_option_menu_paint (GtkWidget *widget,
button_area.x, button_area.y,
button_area.width, button_area.height);
if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
tab_x = button_area.x + props.indicator_spacing.left +
widget->style->xthickness;
else
tab_x = button_area.x + button_area.width -
props.indicator_size.width - props.indicator_spacing.right -
widget->style->xthickness;
gtk_paint_tab (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT,
area, widget, "optionmenutab",
button_area.x + button_area.width -
props.indicator_size.width - props.indicator_spacing.right -
widget->style->xthickness,
tab_x,
button_area.y + (button_area.height - props.indicator_size.height) / 2,
props.indicator_size.width, props.indicator_size.height);
......@@ -569,6 +579,10 @@ gtk_option_menu_paint (GtkWidget *widget,
props.indicator_spacing.right +
props.indicator_size.width;
button_area.height -= 2 * (widget->style->ythickness + props.focus_pad);
if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
button_area.x += props.indicator_spacing.left +
props.indicator_spacing.right +
props.indicator_size.width;
}
else
{
......
......@@ -518,18 +518,28 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress)
GtkProgressBar *pbar;
GtkWidget *widget;
gint size;
GtkProgressBarOrientation orientation;
pbar = GTK_PROGRESS_BAR (progress);
widget = GTK_WIDGET (progress);
orientation = pbar->orientation;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
{
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
orientation = GTK_PROGRESS_RIGHT_TO_LEFT;
else if (pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
}
/* calculate start pos */