From cb1db05be72c493c580dd3dbc8fc655ae6bf7002 Mon Sep 17 00:00:00 2001 From: Sven Herzberg Date: Tue, 25 Mar 2008 08:02:17 +0000 Subject: [PATCH] 2008-03-25 Sven Herzberg Fixes: MB:#924: Hildon widgets doesn't support RTL mode Patch from: Mohammad Anwari * src/hildon-banner.c: let the HildonBanners pop up on the left side instead of the right in RTL mode * src/hildon-bread-crumb-trail.c: mirror the appearance of the breadcrumb button list in RTL mode * src/hildon-caption.c: mirror the appearance of the caption widget in RTL mode * src/hildon-date-editor.c: mirror appearance of the date editor in RTL mode * src/hildon-time-editor.c: mirror appearance of the time editor in RTL mode * src/hildon-window.c: fix the position of the popup in RTL mode --- ChangeLog | 17 +++++++++++++++++ src/hildon-banner.c | 6 +++++- src/hildon-bread-crumb-trail.c | 34 ++++++++++++++++++++++++++++++---- src/hildon-caption.c | 40 +++++++++++++++++++++++++++++----------- src/hildon-date-editor.c | 13 ++++++++++++- src/hildon-time-editor.c | 23 +++++++++++++++++++---- src/hildon-window.c | 14 ++++++++++++-- 7 files changed, 124 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c7c13e..1593197 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2008-03-25 Sven Herzberg + Fixes: MB:#924: Hildon widgets doesn't support RTL mode + Patch from: Mohammad Anwari + + * src/hildon-banner.c: let the HildonBanners pop up on the left side + instead of the right in RTL mode + * src/hildon-bread-crumb-trail.c: mirror the appearance of the + breadcrumb button list in RTL mode + * src/hildon-caption.c: mirror the appearance of the caption widget in + RTL mode + * src/hildon-date-editor.c: mirror appearance of the date editor in + RTL mode + * src/hildon-time-editor.c: mirror appearance of the time editor in + RTL mode + * src/hildon-window.c: fix the position of the popup in RTL mode + +2008-03-25 Sven Herzberg + Amendment to the fix of NB#22072. Fix compilation. * src/hildon-banner.c: (hildon_banner_timeout): fix compilation diff --git a/src/hildon-banner.c b/src/hildon-banner.c index 6db6dc5..fc2ef5d 100644 --- a/src/hildon-banner.c +++ b/src/hildon-banner.c @@ -633,7 +633,11 @@ hildon_banner_check_position (GtkWidget *widget) return; } - x = gdk_screen_width() - HILDON_BANNER_WINDOW_X - req.width; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + x = HILDON_BANNER_WINDOW_X; + else + x = gdk_screen_width() - HILDON_BANNER_WINDOW_X - req.width; + y = check_fullscreen_state (get_current_app_window ()) ? HILDON_BANNER_WINDOW_FULLSCREEN_Y : HILDON_BANNER_WINDOW_Y; diff --git a/src/hildon-bread-crumb-trail.c b/src/hildon-bread-crumb-trail.c index 68c154e..cf95c52 100644 --- a/src/hildon-bread-crumb-trail.c +++ b/src/hildon-bread-crumb-trail.c @@ -265,6 +265,10 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget, GList *p, *first_show, *first_hide; gint back_button_size; HildonBreadCrumbTrailPrivate *priv = HILDON_BREAD_CRUMB_TRAIL (widget)->priv; + gboolean rtl; + + /* Get the rtl status */ + rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); widget->allocation = *allocation; @@ -272,14 +276,24 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget, allocation_width = allocation->width - 2 * border_width; /* Allocate the back button */ - child_allocation.x = allocation->x + border_width; + if (rtl) + child_allocation.x = allocation->width - border_width; + else + child_allocation.x = allocation->x + border_width; + child_allocation.y = allocation->y + border_width; gtk_widget_get_child_requisition (priv->back_button, &child_requisition); /* We want the back button to be a square */ back_button_size = MAX (child_requisition.width, child_requisition.height); child_allocation.width = child_allocation.height = back_button_size; + + if (rtl) + child_allocation.x -= back_button_size; + gtk_widget_size_allocate (priv->back_button, &child_allocation); - child_allocation.x += back_button_size; + + if (!rtl) + child_allocation.x += back_button_size; /* If there are no buttons there's nothing else to do */ if (priv->item_list == NULL) @@ -323,8 +337,14 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget, { first_hide = p->next; gtk_widget_set_child_visible (child, TRUE); + + if (rtl) + child_allocation.x -= child_allocation.width; + gtk_widget_size_allocate (child, &child_allocation); - child_allocation.x += child_allocation.width; + + if (!rtl) + child_allocation.x += child_allocation.width; } else { @@ -360,8 +380,14 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget, child_allocation.width = natural_width; gtk_widget_set_child_visible (child, TRUE); + + if (rtl) + child_allocation.x -= child_allocation.width; + gtk_widget_size_allocate (child, &child_allocation); - child_allocation.x += child_allocation.width; + + if (!rtl) + child_allocation.x += child_allocation.width; } for (p = first_hide; p; p = p->next) diff --git a/src/hildon-caption.c b/src/hildon-caption.c index f59abd3..7bcef07 100644 --- a/src/hildon-caption.c +++ b/src/hildon-caption.c @@ -720,14 +720,18 @@ hildon_caption_size_allocate (GtkWidget *widget, { GtkAllocation child_alloc; GtkAllocation caption_alloc; - GtkRequisition req; + GtkRequisition req, child_req; GtkWidget *child = NULL; HildonCaptionPrivate *priv = NULL; + gboolean rtl; g_assert (HILDON_IS_CAPTION (widget)); priv = HILDON_CAPTION_GET_PRIVATE (widget); g_assert (priv); + /* Get the rtl status */ + rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); + /* Position the caption to its allocated location */ if (GTK_WIDGET_REALIZED (widget)) gdk_window_move_resize (widget->window, @@ -737,6 +741,8 @@ hildon_caption_size_allocate (GtkWidget *widget, MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0)); child = GTK_BIN (widget)->child; + if (child) + gtk_widget_get_child_requisition (child, &child_req); widget->allocation = *allocation; gtk_widget_get_child_requisition (priv->caption_area, &req); @@ -746,23 +752,32 @@ hildon_caption_size_allocate (GtkWidget *widget, child_alloc.x = caption_alloc.x = caption_alloc.y = child_alloc.y = 0; /* Center the captioned widget */ - if (child_alloc.width > req.width + HILDON_CAPTION_SPACING) + if (rtl) { - child_alloc.x += req.width + HILDON_CAPTION_SPACING * 2; - caption_alloc.width = req.width; + if (caption_alloc.width > child_req.width + HILDON_CAPTION_SPACING) + { + caption_alloc.x = caption_alloc.width - req.width; + child_alloc.width = child_req.width; + } + caption_alloc.width -= child_req.width + HILDON_CAPTION_SPACING * 2; } + else + { + if (child_alloc.width > req.width + HILDON_CAPTION_SPACING) + { + child_alloc.x += req.width + HILDON_CAPTION_SPACING * 2; + caption_alloc.width = req.width; + } + /* Leave at least the space of the HILDON_CAPTION_SPACING in the left */ + caption_alloc.x = HILDON_CAPTION_SPACING; - /* Leave at least the space of the HILDON_CAPTION_SPACING in the left */ - caption_alloc.x = HILDON_CAPTION_SPACING; - - /* Leave room for the other drawable parts of the caption control */ - child_alloc.width -= req.width + HILDON_CAPTION_SPACING * 2; + /* Leave room for the other drawable parts of the caption control */ + child_alloc.width -= req.width + HILDON_CAPTION_SPACING * 2; + } /* Give the child at least its minimum requisition, unless it is expandable */ if (! priv->expand && child && GTK_WIDGET_VISIBLE(child)) { - GtkRequisition child_req; - gtk_widget_get_child_requisition (child, &child_req); child_alloc.width = MIN (child_alloc.width, child_req.width); child_alloc.height = MIN (child_alloc.height, child_req.height); /* Center the child */ @@ -778,6 +793,9 @@ hildon_caption_size_allocate (GtkWidget *widget, caption_alloc.width = MAX (caption_alloc.width, 0); } + if (rtl) + child_alloc.x = caption_alloc.x - child_req.width - HILDON_CAPTION_SPACING * 2; + child_alloc.height = MAX (child_alloc.height, 0); caption_alloc.height = MAX (caption_alloc.height, 0); diff --git a/src/hildon-date-editor.c b/src/hildon-date-editor.c index f74596f..4fa5d7d 100644 --- a/src/hildon-date-editor.c +++ b/src/hildon-date-editor.c @@ -1277,6 +1277,7 @@ hildon_date_editor_size_allocate (GtkWidget *widget, GtkRequisition req; GtkRequisition max_req; GList *iter; + gboolean rtl; g_assert (GTK_IS_WIDGET (widget)); g_assert (allocation != NULL); @@ -1284,6 +1285,7 @@ hildon_date_editor_size_allocate (GtkWidget *widget, ed = HILDON_DATE_EDITOR (widget); priv = HILDON_DATE_EDITOR_GET_PRIVATE (ed); + rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); widget->allocation = *allocation; gtk_widget_get_child_requisition (widget, &max_req); @@ -1302,7 +1304,6 @@ hildon_date_editor_size_allocate (GtkWidget *widget, f_alloc.width = req.width; f_alloc.height = max_req.height; - gtk_widget_size_allocate (priv->frame, &f_alloc); } /* allocate icon */ @@ -1313,9 +1314,19 @@ hildon_date_editor_size_allocate (GtkWidget *widget, img_alloc.x += f_alloc.width + HILDON_MARGIN_DEFAULT; img_alloc.width = req.width; img_alloc.height = max_req.height; + + if (rtl) + { + img_alloc.x = f_alloc.x; + f_alloc.x += img_alloc.width + HILDON_MARGIN_DEFAULT; + } gtk_widget_size_allocate (priv->d_button_image, &img_alloc); } + if (GTK_WIDGET_VISIBLE (priv->frame)) { + gtk_widget_size_allocate (priv->frame, &f_alloc); + } + /* FIXME: We really should not alloc delimeters by hand (since they are not our own children, but we need to force to appear higher. This ugly hack is needed to compensate the forced diff --git a/src/hildon-time-editor.c b/src/hildon-time-editor.c index 947fad9..6396869 100644 --- a/src/hildon-time-editor.c +++ b/src/hildon-time-editor.c @@ -1734,9 +1734,11 @@ hildon_time_editor_size_allocate (GtkWidget *widget, HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE (widget); GtkAllocation alloc; GtkRequisition req, max_req; + gboolean rtl; g_assert (priv); + rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); widget->allocation = *allocation; gtk_widget_get_child_requisition (widget, &max_req); @@ -1746,19 +1748,32 @@ hildon_time_editor_size_allocate (GtkWidget *widget, alloc.y = allocation->y + MAX (allocation->height - max_req.height, 0) / 2; /* allocate frame */ - gtk_widget_get_child_requisition (priv->frame, &req); + if (rtl) + gtk_widget_get_child_requisition (priv->iconbutton, &req); + else + gtk_widget_get_child_requisition (priv->frame, &req); alloc.width = req.width; alloc.height = max_req.height; - gtk_widget_size_allocate (priv->frame, &alloc); + if (rtl) + gtk_widget_size_allocate (priv->iconbutton, &alloc); + else + gtk_widget_size_allocate (priv->frame, &alloc); /* allocate icon */ if (GTK_WIDGET_VISIBLE (priv->iconbutton)) { - gtk_widget_get_child_requisition (priv->iconbutton, &req); + if (rtl) + gtk_widget_get_child_requisition (priv->frame, &req); + else + gtk_widget_get_child_requisition (priv->iconbutton, &req); alloc.x += alloc.width + HILDON_MARGIN_DEFAULT; alloc.width = req.width; - gtk_widget_size_allocate (priv->iconbutton, &alloc); + + if (rtl) + gtk_widget_size_allocate (priv->frame, &alloc); + else + gtk_widget_size_allocate (priv->iconbutton, &alloc); } /* FIXME: ugly way to move labels up. They just don't seem move up diff --git a/src/hildon-window.c b/src/hildon-window.c index a9904c5..21dead3 100644 --- a/src/hildon-window.c +++ b/src/hildon-window.c @@ -1272,7 +1272,13 @@ hildon_window_menu_popup_func (GtkMenu *menu, gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x, "vertical-offset", y, NULL); - *x += window_x; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + { + *x = GTK_WIDGET (widget)->allocation.width + window_x - GTK_WIDGET (menu)->allocation.width - *x; + } + else + *x += window_x; + *y += window_y; } @@ -1287,7 +1293,11 @@ hildon_window_menu_popup_func_full (GtkMenu *menu, gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x, "vertical-offset", y, NULL); - *x = MAX (0, *x); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + *x = GTK_WIDGET (widget)->allocation.width - GTK_WIDGET (menu)->allocation.width - *x; + else + *x = MAX (0, *x); + *y = MAX (0, *y); } -- 1.7.9.5