Automatic RTL flipping for some more widgets.

This commit is contained in:
Matthias Clasen 2002-11-02 00:18:14 +00:00
parent ca00536f34
commit 00943af834
20 changed files with 743 additions and 102 deletions

View File

@ -1,3 +1,45 @@
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:

View File

@ -1,3 +1,45 @@
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:

View File

@ -1,3 +1,45 @@
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:

View File

@ -1,3 +1,45 @@
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:

View File

@ -1,3 +1,45 @@
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:

View File

@ -1,3 +1,45 @@
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:

View File

@ -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);

View File

@ -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,

View File

@ -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;
offset = GTK_CONTAINER (image_menu_item)->border_width +
widget->style->xthickness;
x = (GTK_CONTAINER (image_menu_item)->border_width +
widget->style->xthickness) +
(GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2;
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;

View File

@ -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;
}
}
}

View File

@ -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)
{

View File

@ -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
{

View File

@ -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 */
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
{
size = MAX (2, widget->allocation.width / pbar->activity_blocks);
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
{
pbar->activity_pos = widget->style->xthickness;
pbar->activity_dir = 0;
@ -546,7 +556,7 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress)
{
size = MAX (2, widget->allocation.height / pbar->activity_blocks);
if (pbar->orientation == GTK_PROGRESS_TOP_TO_BOTTOM)
if (orientation == GTK_PROGRESS_TOP_TO_BOTTOM)
{
pbar->activity_pos = widget->style->ythickness;
pbar->activity_dir = 0;
@ -574,14 +584,24 @@ gtk_progress_bar_paint (GtkProgress *progress)
gint y;
gdouble percentage;
gint size;
GtkProgressBarOrientation orientation;
g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
pbar = GTK_PROGRESS_BAR (progress);
widget = GTK_WIDGET (progress);
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
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;
}
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
space = widget->allocation.width -
2 * widget->style->xthickness;
else
@ -602,8 +622,8 @@ gtk_progress_bar_paint (GtkProgress *progress)
if (progress->activity_mode)
{
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
{
size = MAX (2, widget->allocation.width / pbar->activity_blocks);
@ -637,7 +657,7 @@ gtk_progress_bar_paint (GtkProgress *progress)
if (amount > 0)
{
switch (pbar->orientation)
switch (orientation)
{
case GTK_PROGRESS_LEFT_TO_RIGHT:

View File

@ -306,6 +306,7 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
gint offset;
g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (check_menu_item));
@ -315,8 +316,12 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
width = 8;
height = 8;
x = widget->allocation.x + (GTK_CONTAINER (check_menu_item)->border_width +
widget->style->xthickness + 2);
offset = GTK_CONTAINER (check_menu_item)->border_width +
widget->style->xthickness + 2;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
x = widget->allocation.x + offset;
else
x = widget->allocation.x + widget->allocation.width - width - offset;
y = widget->allocation.y + (widget->allocation.height - height) / 2;
if (check_menu_item->active ||

View File

@ -3321,16 +3321,22 @@ gtk_default_draw_box (GtkStyle *style,
{
GtkRequisition indicator_size;
GtkBorder indicator_spacing;
gint vline_x;
option_menu_get_props (widget, &indicator_size, &indicator_spacing);
sanitize_size (window, &width, &height);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
vline_x = x + indicator_size.width + indicator_spacing.left + indicator_spacing.right;
else
vline_x = x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness;
gtk_paint_vline (style, window, state_type, area, widget,
detail,
y + style->ythickness + 1,
y + height - style->ythickness - 3,
x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness);
vline_x);
}
}
@ -5010,19 +5016,88 @@ gtk_default_draw_resize_grip (GtkStyle *style,
gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
}
/* make it square, aligning to bottom right */
if (width < height)
switch (edge)
{
y += (height - width);
height = width;
case GDK_WINDOW_EDGE_NORTH_WEST:
/* make it square */
if (width < height)
{
height = width;
}
else if (height < width)
{
width = height;
}
break;
case GDK_WINDOW_EDGE_NORTH:
if (width < height)
{
height = width;
}
break;
case GDK_WINDOW_EDGE_NORTH_EAST:
/* make it square, aligning to top right */
if (width < height)
{
height = width;
}
else if (height < width)
{
x += (width - height);
width = height;
}
break;
case GDK_WINDOW_EDGE_WEST:
if (height < width)
{
width = height;
}
break;
case GDK_WINDOW_EDGE_EAST:
/* aligning to right */
if (height < width)
{
x += (width - height);
width = height;
}
break;
case GDK_WINDOW_EDGE_SOUTH_WEST:
/* make it square, aligning to bottom left */
if (width < height)
{
y += (height - width);
height = width;
}
else if (height < width)
{
width = height;
}
break;
case GDK_WINDOW_EDGE_SOUTH:
/* align to bottom */
if (width < height)
{
y += (height - width);
height = width;
}
break;
case GDK_WINDOW_EDGE_SOUTH_EAST:
/* make it square, aligning to bottom right */
if (width < height)
{
y += (height - width);
height = width;
}
else if (height < width)
{
x += (width - height);
width = height;
}
break;
default:
g_assert_not_reached ();
}
else if (height < width)
{
x += (width - height);
width = height;
}
/* Clear background */
gtk_style_apply_default_background (style, window, FALSE,
state_type, area,
@ -5030,6 +5105,161 @@ gtk_default_draw_resize_grip (GtkStyle *style,
switch (edge)
{
case GDK_WINDOW_EDGE_WEST:
case GDK_WINDOW_EDGE_EAST:
{
gint xi;
xi = x;
while (xi < x + width)
{
gdk_draw_line (window,
style->light_gc[state_type],
xi, y,
xi, y + height);
xi++;
gdk_draw_line (window,
style->dark_gc[state_type],
xi, y,
xi, y + height);
xi += 2;
}
}
break;
case GDK_WINDOW_EDGE_NORTH:
case GDK_WINDOW_EDGE_SOUTH:
{
gint yi;
yi = y;
while (yi < y + height)
{
gdk_draw_line (window,
style->light_gc[state_type],
x, yi,
x + width, yi);
yi++;
gdk_draw_line (window,
style->dark_gc[state_type],
x, yi,
x + width, yi);
yi+= 2;
}
}
break;
case GDK_WINDOW_EDGE_NORTH_WEST:
{
gint xi, yi;
xi = x + width;
yi = y + height;
while (xi > x + 3)
{
gdk_draw_line (window,
style->dark_gc[state_type],
xi, y,
x, yi);
--xi;
--yi;
gdk_draw_line (window,
style->dark_gc[state_type],
xi, y,
x, yi);
--xi;
--yi;
gdk_draw_line (window,
style->light_gc[state_type],
xi, y,
x, yi);
xi -= 3;
yi -= 3;
}
}
break;
case GDK_WINDOW_EDGE_NORTH_EAST:
{
gint xi, yi;
xi = x;
yi = y + height;
while (xi < (x + width - 3))
{
gdk_draw_line (window,
style->light_gc[state_type],
xi, y,
x + width, yi);
++xi;
--yi;
gdk_draw_line (window,
style->dark_gc[state_type],
xi, y,
x + width, yi);
++xi;
--yi;
gdk_draw_line (window,
style->dark_gc[state_type],
xi, y,
x + width, yi);
xi += 3;
yi -= 3;
}
}
break;
case GDK_WINDOW_EDGE_SOUTH_WEST:
{
gint xi, yi;
xi = x + width;
yi = y;
while (xi > x + 3)
{
gdk_draw_line (window,
style->dark_gc[state_type],
x, yi,
xi, y + height);
--xi;
++yi;
gdk_draw_line (window,
style->dark_gc[state_type],
x, yi,
xi, y + height);
--xi;
++yi;
gdk_draw_line (window,
style->light_gc[state_type],
x, yi,
xi, y + height);
xi -= 3;
yi += 3;
}
}
break;
case GDK_WINDOW_EDGE_SOUTH_EAST:
{
gint xi, yi;

View File

@ -132,12 +132,16 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget,
gint width, height;
gint x, y;
gint right_max;
GtkArrowType arrow_type;
GtkTextDirection direction;
if (GTK_WIDGET_DRAWABLE (widget))
{
menu_item = GTK_MENU_ITEM (widget);
tearoff_item = GTK_TEAROFF_MENU_ITEM (widget);
direction = gtk_widget_get_direction (widget);
x = widget->allocation.x + GTK_CONTAINER (menu_item)->border_width;
y = widget->allocation.y + GTK_CONTAINER (menu_item)->border_width;
width = widget->allocation.width - x * 2;
@ -172,29 +176,54 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget,
if (menu_item->toggle_size > ARROW_SIZE)
{
arrow_x = x + (menu_item->toggle_size - ARROW_SIZE)/2;
if (direction == GTK_TEXT_DIR_LTR) {
arrow_x = x + (menu_item->toggle_size - ARROW_SIZE)/2;
arrow_type = GTK_ARROW_LEFT;
}
else {
arrow_x = x + width - menu_item->toggle_size + (menu_item->toggle_size - ARROW_SIZE)/2;
arrow_type = GTK_ARROW_RIGHT;
}
x += menu_item->toggle_size + BORDER_SPACING;
}
else
{
arrow_x = ARROW_SIZE / 2;
if (direction == GTK_TEXT_DIR_LTR) {
arrow_x = ARROW_SIZE / 2;
arrow_type = GTK_ARROW_LEFT;
}
else {
arrow_x = x + width - 2 * ARROW_SIZE + ARROW_SIZE / 2;
arrow_type = GTK_ARROW_RIGHT;
}
x += 2 * ARROW_SIZE;
}
gtk_paint_arrow (widget->style, widget->window,
widget->state, shadow_type,
NULL, widget, "tearoffmenuitem",
GTK_ARROW_LEFT, FALSE,
arrow_type, FALSE,
arrow_x, y + height / 2 - 5,
ARROW_SIZE, ARROW_SIZE);
}
while (x < right_max)
{
gint x1, x2;
if (direction == GTK_TEXT_DIR_LTR) {
x1 = x;
x2 = MIN (x + TEAR_LENGTH, right_max);
}
else {
x1 = right_max - x;
x2 = MAX (right_max - x - TEAR_LENGTH, 0);
}
gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
NULL, widget, "tearoffmenuitem",
x, MIN (x + TEAR_LENGTH, right_max),
y + (height - widget->style->ythickness) / 2);
x1, x2, y + (height - widget->style->ythickness) / 2);
x += 2 * TEAR_LENGTH;
}
}

View File

@ -712,6 +712,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
gint x_border_width, y_border_width;
gint space_size;
gint ipadding;
GtkTextDirection direction;
gint ltr_x;
g_return_if_fail (GTK_IS_TOOLBAR (widget));
g_return_if_fail (allocation != NULL);
@ -719,6 +721,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
toolbar = GTK_TOOLBAR (widget);
widget->allocation = *allocation;
direction = gtk_widget_get_direction (widget);
x_border_width = GTK_CONTAINER (toolbar)->border_width;
y_border_width = GTK_CONTAINER (toolbar)->border_width;
@ -728,7 +732,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
y_border_width += ipadding;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.x = allocation->x + x_border_width;
ltr_x = allocation->x + x_border_width;
else
alloc.y = allocation->y + y_border_width;
@ -746,9 +750,12 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
child_space->alloc_x = alloc.x;
if (direction == GTK_TEXT_DIR_LTR)
child_space->alloc_x = ltr_x;
else
child_space->alloc_x = allocation->width - ltr_x - space_size;
child_space->alloc_y = allocation->y + (allocation->height - toolbar->button_maxh) / 2;
alloc.x += space_size;
ltr_x += space_size;
}
else
{
@ -768,15 +775,21 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
alloc.width = toolbar->button_maxw;
alloc.height = toolbar->button_maxh;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.y = allocation->y + (allocation->height - toolbar->button_maxh) / 2;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (direction == GTK_TEXT_DIR_LTR)
alloc.x = ltr_x;
else
alloc.x = allocation->width - ltr_x - alloc.width;
alloc.y = allocation->y + (allocation->height - toolbar->button_maxh) / 2;
}
else
alloc.x = allocation->x + (allocation->width - toolbar->button_maxw) / 2;
gtk_widget_size_allocate (child->widget, &alloc);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.x += toolbar->button_maxw;
ltr_x += toolbar->button_maxw;
else
alloc.y += toolbar->button_maxh;
@ -791,15 +804,21 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
alloc.width = child_requisition.width;
alloc.height = child_requisition.height;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.y = allocation->y + (allocation->height - child_requisition.height) / 2;
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (direction == GTK_TEXT_DIR_LTR)
alloc.x = ltr_x;
else
alloc.x = allocation->width - ltr_x - alloc.width;
alloc.y = allocation->y + (allocation->height - child_requisition.height) / 2;
}
else
alloc.x = allocation->x + (allocation->width - child_requisition.width) / 2;
gtk_widget_size_allocate (child->widget, &alloc);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
alloc.x += child_requisition.width;
ltr_x += child_requisition.width;
else
alloc.y += child_requisition.height;

View File

@ -51,6 +51,8 @@ IMAGES = @STRIP_BEGIN@ \
stock_index_24.png \
stock_jump_to_16.png \
stock_jump_to_24.png \
stock_jump_to_rtl_16.png \
stock_jump_to_rtl_24.png \
stock_last_16.png \
stock_last_24.png \
stock_left_arrow_16.png \
@ -177,6 +179,8 @@ VARIABLES3 = @STRIP_BEGIN@ \
stock_index_24 $(srcdir)/stock_index_24.png \
stock_jump_to_16 $(srcdir)/stock_jump_to_16.png \
stock_jump_to_24 $(srcdir)/stock_jump_to_24.png \
stock_jump_to_rtl_16 $(srcdir)/stock_jump_to_rtl_16.png \
stock_jump_to_rtl_24 $(srcdir)/stock_jump_to_rtl_24.png \
stock_last_16 $(srcdir)/stock_last_16.png \
stock_last_24 $(srcdir)/stock_last_24.png \
stock_left_arrow_16 $(srcdir)/stock_left_arrow_16.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB