[maemo-commits] [maemo-commits] r15317 - in projects/haf/trunk/hildon-1: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Mar 25 10:02:27 EET 2008
Author: herzi
Date: 2008-03-25 10:02:17 +0200 (Tue, 25 Mar 2008)
New Revision: 15317

Modified:
   projects/haf/trunk/hildon-1/ChangeLog
   projects/haf/trunk/hildon-1/src/hildon-banner.c
   projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c
   projects/haf/trunk/hildon-1/src/hildon-caption.c
   projects/haf/trunk/hildon-1/src/hildon-date-editor.c
   projects/haf/trunk/hildon-1/src/hildon-time-editor.c
   projects/haf/trunk/hildon-1/src/hildon-window.c
Log:
2008-03-25  Sven Herzberg  <sven at imendio.com>

	Fixes: MB:#924: Hildon widgets doesn't support RTL mode
	Patch from: Mohammad Anwari  <mdamt at 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


Modified: projects/haf/trunk/hildon-1/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-1/ChangeLog	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/ChangeLog	2008-03-25 08:02:17 UTC (rev 15317)
@@ -1,5 +1,22 @@
 2008-03-25  Sven Herzberg  <sven at imendio.com>
 
+	Fixes: MB:#924: Hildon widgets doesn't support RTL mode
+	Patch from: Mohammad Anwari  <mdamt at 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 at imendio.com>
+
 	Amendment to the fix of NB#22072. Fix compilation.
 
 	* src/hildon-banner.c: (hildon_banner_timeout): fix compilation

Modified: projects/haf/trunk/hildon-1/src/hildon-banner.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-banner.c	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/src/hildon-banner.c	2008-03-25 08:02:17 UTC (rev 15317)
@@ -633,7 +633,11 @@
         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;
 

Modified: projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c	2008-03-25 08:02:17 UTC (rev 15317)
@@ -265,22 +265,36 @@
   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;
 
   border_width = (gint) GTK_CONTAINER (widget)->border_width;
   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)
     return;
@@ -323,8 +337,14 @@
             {
               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 @@
 
       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)

Modified: projects/haf/trunk/hildon-1/src/hildon-caption.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-caption.c	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/src/hildon-caption.c	2008-03-25 08:02:17 UTC (rev 15317)
@@ -720,14 +720,18 @@
 {
     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 @@
                 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 @@
     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 @@
         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);
 

Modified: projects/haf/trunk/hildon-1/src/hildon-date-editor.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-date-editor.c	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/src/hildon-date-editor.c	2008-03-25 08:02:17 UTC (rev 15317)
@@ -1277,6 +1277,7 @@
     GtkRequisition req;
     GtkRequisition max_req;
     GList *iter;
+    gboolean rtl;
 
     g_assert (GTK_IS_WIDGET (widget));
     g_assert (allocation != NULL);
@@ -1284,6 +1285,7 @@
     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 @@
 
         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 @@
         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

Modified: projects/haf/trunk/hildon-1/src/hildon-time-editor.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-time-editor.c	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/src/hildon-time-editor.c	2008-03-25 08:02:17 UTC (rev 15317)
@@ -1734,9 +1734,11 @@
     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 @@
     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

Modified: projects/haf/trunk/hildon-1/src/hildon-window.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-window.c	2008-03-25 07:28:23 UTC (rev 15316)
+++ projects/haf/trunk/hildon-1/src/hildon-window.c	2008-03-25 08:02:17 UTC (rev 15317)
@@ -1272,7 +1272,13 @@
     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 @@
     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);
 }
 


More information about the maemo-commits mailing list