[maemo-commits] [maemo-commits] r11586 - in projects/haf/trunk/gtk+: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu May 10 18:30:18 EEST 2007
Author: tko
Date: 2007-05-10 18:30:16 +0300 (Thu, 10 May 2007)
New Revision: 11586

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtkmenu.c
Log:
Move the scroll arrows to the bottom

Having both scroll arrows on the same side of the menu leaves more space
for the menu content, and with physically small screen and large menu
items/scroll arrows the difference can be fairly noticeable.

This adds a new "opposite-arrows" style property which controls whether the
scroll arrows are on opposite sides (top and bottom) or both on the same
side (bottom)

I am not entirely happy with the property name as one could conceivably
want to place both scroll arrows on the left side as well, to save even
more vertical space (right edge would be awkward if there are submenus, top
edge when used with fingers your hand would obscure the content.)

	* gtk/gtkmenu.c (gtk_menu_class_init): Add "opposite-arrows" style
	property (default=FALSE) to toggle scroll arrow location
	(get_arrows_border, get_arrows_visible_area,
	get_arrows_sensitive_area): Calculate the arrow positions when they're
	both at the bottom
	(get_double_arrows): !opposite-arrows implies double-arrows


Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2007-05-10 15:21:45 UTC (rev 11585)
+++ projects/haf/trunk/gtk+/ChangeLog	2007-05-10 15:30:16 UTC (rev 11586)
@@ -1,4 +1,14 @@
 2007-05-10  Tommi Komulainen  <tommi.komulainen at nokia.com>
+
+	* gtk/gtkmenu.c (gtk_menu_class_init): Add "opposite-arrows" style
+	property (default=FALSE) to toggle scroll arrow location
+	(get_arrows_border, get_arrows_visible_area,
+	get_arrows_sensitive_area): Calculate the arrow positions when they're
+	both at the bottom
+	(get_double_arrows): !opposite-arrows implies double-arrows
+	(#436533, NB#51958)
+
+2007-05-10  Tommi Komulainen  <tommi.komulainen at nokia.com>
     
 	* gtk/gtkmenu.c (get_arrows_sensitive_area): New function
 	(gtk_menu_handle_scrolling): Refactor arrow sensitive area calculations

Modified: projects/haf/trunk/gtk+/gtk/gtkmenu.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkmenu.c	2007-05-10 15:21:45 UTC (rev 11585)
+++ projects/haf/trunk/gtk+/gtk/gtkmenu.c	2007-05-10 15:30:16 UTC (rev 11586)
@@ -564,6 +564,14 @@
                                                                  TRUE,
                                                                  GTK_PARAM_READABLE));
 
+#ifdef MAEMO_CHANGES
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_boolean ("opposite-arrows",
+                                                                 P_("Opposite Arrows"),
+                                                                 P_("Place the scroll arrows on opposite sides of the menu."),
+                                                                 FALSE,
+                                                                 GTK_PARAM_READABLE));
+#endif
 
  gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_LEFT_ATTACH,
@@ -2120,13 +2128,29 @@
 get_arrows_border (GtkMenu *menu, GtkBorder *border)
 {
   guint scroll_arrow_height;
+#ifndef MAEMO_CHANGES
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "scroll-arrow-vlength", &scroll_arrow_height,
+                        NULL);
+#else
+  gboolean opposite_arrows;
 
   gtk_widget_style_get (GTK_WIDGET (menu),
                         "scroll-arrow-vlength", &scroll_arrow_height,
+                        "opposite-arrows", &opposite_arrows,
                         NULL);
 
-  border->top = menu->upper_arrow_visible ? scroll_arrow_height : 0;
-  border->bottom = menu->lower_arrow_visible ? scroll_arrow_height : 0;
+  if (!opposite_arrows)
+    {
+      border->top = 0;
+      border->bottom = (menu->upper_arrow_visible || menu->lower_arrow_visible) ? scroll_arrow_height : 0;
+    }
+  else
+#endif
+    {
+      border->top = menu->upper_arrow_visible ? scroll_arrow_height : 0;
+      border->bottom = menu->lower_arrow_visible ? scroll_arrow_height : 0;
+    }
 
   border->left = border->right = 0;
 }
@@ -2565,27 +2589,50 @@
   guint vertical_padding;
   guint horizontal_padding;
   gint scroll_arrow_height;
+#ifdef MAEMO_CHANGES
+  gboolean opposite_arrows;
+#endif
   
   gtk_widget_style_get (widget,
                         "vertical-padding", &vertical_padding,
                         "horizontal-padding", &horizontal_padding,
                         "scroll-arrow-vlength", &scroll_arrow_height,
+#ifdef MAEMO_CHANGES
+                        "opposite-arrows", &opposite_arrows,
+#endif
                         NULL);
 
   border->x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness + horizontal_padding;
   border->y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness + vertical_padding;
   gdk_drawable_get_size (widget->window, &border->width, &border->height);
 
-  upper->x = border->x;
-  upper->y = border->y;
-  upper->width = border->width - 2 * border->x;
-  upper->height = scroll_arrow_height;
+#ifdef MAEMO_CHANGES
+  if (!opposite_arrows)
+    {
+      upper->x = border->x;
+      upper->y = border->height - border->y - scroll_arrow_height;
+      upper->width = (border->width - 2 * border->x) / 2;
+      upper->height = scroll_arrow_height;
 
-  lower->x = border->x;
-  lower->y = border->height - border->y - scroll_arrow_height;
-  lower->width = border->width - 2 * border->x;
-  lower->height = scroll_arrow_height;
+      lower->x = border->x + upper->width;
+      lower->y = border->height - border->y - scroll_arrow_height;
+      lower->width = (border->width - 2 * border->x) / 2;
+      lower->height = scroll_arrow_height;
+    }
+  else
+#endif
+    {
+      upper->x = border->x;
+      upper->y = border->y;
+      upper->width = border->width - 2 * border->x;
+      upper->height = scroll_arrow_height;
 
+      lower->x = border->x;
+      lower->y = border->height - border->y - scroll_arrow_height;
+      lower->width = border->width - 2 * border->x;
+      lower->height = scroll_arrow_height;
+    }
+
   *arrow_space = scroll_arrow_height - 2 * widget->style->ythickness;
 }
 
@@ -3203,11 +3250,22 @@
 {
   GtkMenuPrivate *priv = gtk_menu_get_private (menu);
   gboolean        double_arrows;
+#ifdef MAEMO_CHANGES
+  gboolean        opposite_arrows;
 
   gtk_widget_style_get (GTK_WIDGET (menu),
                         "double-arrows", &double_arrows,
+                        "opposite-arrows", &opposite_arrows,
                         NULL);
 
+  if (!opposite_arrows)
+    return TRUE;
+#else
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "double-arrows", &double_arrows,
+                        NULL);
+#endif
+
   return double_arrows || (priv->initially_pushed_in &&
                            menu->scroll_offset != 0);
 }
@@ -3387,12 +3445,14 @@
   guint vertical_padding;
   gint win_x, win_y;
   gint scroll_arrow_height;
+  gboolean opposite_arrows;
 
   gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
 
   gtk_widget_style_get (GTK_WIDGET (menu),
                         "vertical-padding", &vertical_padding,
                         "scroll-arrow-vlength", &scroll_arrow_height,
+                        "opposite-arrows", &opposite_arrows,
                         NULL);
 
   border = GTK_CONTAINER (menu)->border_width +
@@ -3400,20 +3460,41 @@
 
   gdk_window_get_position (GTK_WIDGET (menu)->window, &win_x, &win_y);
 
-  if (upper)
+  if (opposite_arrows)
     {
-      upper->x = win_x;
-      upper->y = win_y;
-      upper->width = width;
-      upper->height = scroll_arrow_height + border;
+      if (upper)
+        {
+          upper->x = win_x;
+          upper->y = win_y;
+          upper->width = width;
+          upper->height = scroll_arrow_height + border;
+        }
+
+      if (lower)
+        {
+          lower->x = win_x;
+          lower->y = win_y + height - border - scroll_arrow_height;
+          lower->width = width;
+          lower->height = scroll_arrow_height + border;
+        }
     }
+  else /* arrows on same side */
+    {
+      if (upper)
+        {
+          upper->x = win_x;
+          upper->y = win_y + height - border - scroll_arrow_height;
+          upper->width = width / 2;
+          upper->height = scroll_arrow_height + border;
+        }
 
-  if (lower)
-    {
-      lower->x = win_x;
-      lower->y = win_y + height - border - scroll_arrow_height;
-      lower->width = width;
-      lower->height = scroll_arrow_height + border;
+      if (lower)
+        {
+          lower->x = win_x + width / 2;
+          lower->y = win_y + height - border - scroll_arrow_height;
+          lower->width = width / 2;
+          lower->height = scroll_arrow_height + border;
+        }
     }
 }
 


More information about the maemo-commits mailing list