Fixes: MB:#924: Hildon widgets doesn't support RTL mode
Patch from: Mohammad Anwari <mdamt@maemo.org>
* 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 <sven@imendio.com>
2008-03-25 Sven Herzberg <sven@imendio.com>
+ Fixes: MB:#924: Hildon widgets doesn't support RTL mode
+ Patch from: Mohammad Anwari <mdamt@maemo.org>
+
+ * 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 <sven@imendio.com>
+
Amendment to the fix of NB#22072. Fix compilation.
* src/hildon-banner.c: (hildon_banner_timeout): fix compilation
Amendment to the fix of NB#22072. Fix compilation.
* src/hildon-banner.c: (hildon_banner_timeout): fix compilation
- 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;
y = check_fullscreen_state (get_current_app_window ()) ?
HILDON_BANNER_WINDOW_FULLSCREEN_Y : HILDON_BANNER_WINDOW_Y;
GList *p, *first_show, *first_hide;
gint back_button_size;
HildonBreadCrumbTrailPrivate *priv = HILDON_BREAD_CRUMB_TRAIL (widget)->priv;
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;
widget->allocation = *allocation;
allocation_width = allocation->width - 2 * border_width;
/* Allocate the back button */
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;
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);
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)
/* If there are no buttons there's nothing else to do */
if (priv->item_list == NULL)
{
first_hide = p->next;
gtk_widget_set_child_visible (child, TRUE);
{
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);
gtk_widget_size_allocate (child, &child_allocation);
- child_allocation.x += child_allocation.width;
+
+ if (!rtl)
+ child_allocation.x += child_allocation.width;
child_allocation.width = natural_width;
gtk_widget_set_child_visible (child, TRUE);
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);
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)
}
for (p = first_hide; p; p = p->next)
{
GtkAllocation child_alloc;
GtkAllocation caption_alloc;
{
GtkAllocation child_alloc;
GtkAllocation caption_alloc;
+ GtkRequisition req, child_req;
GtkWidget *child = NULL;
HildonCaptionPrivate *priv = NULL;
GtkWidget *child = NULL;
HildonCaptionPrivate *priv = NULL;
g_assert (HILDON_IS_CAPTION (widget));
priv = HILDON_CAPTION_GET_PRIVATE (widget);
g_assert (priv);
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,
/* Position the caption to its allocated location */
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0));
child = GTK_BIN (widget)->child;
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);
widget->allocation = *allocation;
gtk_widget_get_child_requisition (priv->caption_area, &req);
child_alloc.x = caption_alloc.x = caption_alloc.y = child_alloc.y = 0;
/* Center the captioned 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)
- 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))
{
/* 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 */
child_alloc.width = MIN (child_alloc.width, child_req.width);
child_alloc.height = MIN (child_alloc.height, child_req.height);
/* Center the child */
caption_alloc.width = MAX (caption_alloc.width, 0);
}
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);
child_alloc.height = MAX (child_alloc.height, 0);
caption_alloc.height = MAX (caption_alloc.height, 0);
GtkRequisition req;
GtkRequisition max_req;
GList *iter;
GtkRequisition req;
GtkRequisition max_req;
GList *iter;
g_assert (GTK_IS_WIDGET (widget));
g_assert (allocation != NULL);
g_assert (GTK_IS_WIDGET (widget));
g_assert (allocation != NULL);
ed = HILDON_DATE_EDITOR (widget);
priv = HILDON_DATE_EDITOR_GET_PRIVATE (ed);
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);
widget->allocation = *allocation;
gtk_widget_get_child_requisition (widget, &max_req);
f_alloc.width = req.width;
f_alloc.height = max_req.height;
f_alloc.width = req.width;
f_alloc.height = max_req.height;
- gtk_widget_size_allocate (priv->frame, &f_alloc);
img_alloc.x += f_alloc.width + HILDON_MARGIN_DEFAULT;
img_alloc.width = req.width;
img_alloc.height = max_req.height;
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);
}
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
/* 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
HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE (widget);
GtkAllocation alloc;
GtkRequisition req, max_req;
HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE (widget);
GtkAllocation alloc;
GtkRequisition req, max_req;
+ rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
widget->allocation = *allocation;
gtk_widget_get_child_requisition (widget, &max_req);
widget->allocation = *allocation;
gtk_widget_get_child_requisition (widget, &max_req);
alloc.y = allocation->y + MAX (allocation->height - max_req.height, 0) / 2;
/* allocate frame */
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;
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)) {
/* 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;
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
}
/* FIXME: ugly way to move labels up. They just don't seem move up
gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
"vertical-offset", y, NULL);
gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
"vertical-offset", y, NULL);
+ 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;
+
gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
"vertical-offset", y, NULL);
gtk_widget_style_get (GTK_WIDGET (menu), "horizontal-offset", x,
"vertical-offset", y, NULL);
+ 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);
+