Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.7575
diff -u -p -r1.7575 ChangeLog
--- ChangeLog	6 Mar 2006 04:55:51 -0000	1.7575
+++ ChangeLog	6 Mar 2006 16:19:21 -0000
@@ -1,3 +1,9 @@
+Mon Mar  6 17:09:18 2006  Tim Janik  <timj@imendio.com>
+
+	* gtk/gtkmenu.c: turn MENU_SCROLL_ARROW_HEIGHT into a 
+	GtkMenu::scroll-arrow-height style property to allow themes
+	to adapt arrow sizes to the overall theme.
+
 2006-03-05  Matthias Clasen  <mclasen@redhat.com>
 
 	* gtk/gtkiconview.c (adjust_wrap_width): Apply some
Index: gtk/gtkmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenu.c,v
retrieving revision 1.213
diff -u -p -r1.213 gtkmenu.c
--- gtk/gtkmenu.c	22 Feb 2006 10:10:23 -0000	1.213
+++ gtk/gtkmenu.c	6 Mar 2006 16:19:22 -0000
@@ -58,7 +58,6 @@
 
 #define MENU_SCROLL_STEP1 8
 #define MENU_SCROLL_STEP2 15
-#define MENU_SCROLL_ARROW_HEIGHT 16
 #define MENU_SCROLL_FAST_ZONE 8
 #define MENU_SCROLL_TIMEOUT1 50
 #define MENU_SCROLL_TIMEOUT2 20
@@ -570,6 +569,15 @@ gtk_menu_class_init (GtkMenuClass *class
 							     GTK_PARAM_READABLE));
 
   gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_int ("scroll-arrow-height",
+                                                             P_("Scroll Arrow Height"),
+                                                             P_("Height of the arrows used to indcate scrolling direction for menus"),
+                                                             0,
+                                                             G_MAXINT,
+                                                             16,
+                                                             GTK_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_boolean ("double-arrows",
                                                                  P_("Double Arrows"),
                                                                  P_("When scrolling, always show both arrows."),
@@ -2030,6 +2038,7 @@ gtk_menu_realize (GtkWidget *widget)
   GList *children;
   guint vertical_padding;
   guint horizontal_padding;
+  guint scroll_arrow_height;
 
   g_return_if_fail (GTK_IS_MENU (widget));
 
@@ -2060,6 +2069,7 @@ gtk_menu_realize (GtkWidget *widget)
   gtk_widget_style_get (GTK_WIDGET (menu),
 			"vertical-padding", &vertical_padding,
                         "horizontal-padding", &horizontal_padding,
+                        "scroll-arrow-height", &scroll_arrow_height,
 			NULL);
 
   attributes.x = border_width + widget->style->xthickness + horizontal_padding;
@@ -2069,12 +2079,12 @@ gtk_menu_realize (GtkWidget *widget)
 
   if (menu->upper_arrow_visible)
     {
-      attributes.y += MENU_SCROLL_ARROW_HEIGHT;
-      attributes.height -= MENU_SCROLL_ARROW_HEIGHT;
+      attributes.y += scroll_arrow_height;
+      attributes.height -= scroll_arrow_height;
     }
 
   if (menu->lower_arrow_visible)
-    attributes.height -= MENU_SCROLL_ARROW_HEIGHT;
+    attributes.height -= scroll_arrow_height;
 
   menu->view_window = gdk_window_new (widget->window, &attributes, attributes_mask);
   gdk_window_set_user_data (menu->view_window, menu);
@@ -2295,7 +2305,8 @@ gtk_menu_size_allocate (GtkWidget     *w
   gint width, height;
   guint vertical_padding;
   guint horizontal_padding;
-
+  gint scroll_arrow_height;
+  
   g_return_if_fail (GTK_IS_MENU (widget));
   g_return_if_fail (allocation != NULL);
   
@@ -2309,6 +2320,7 @@ gtk_menu_size_allocate (GtkWidget     *w
   gtk_widget_style_get (GTK_WIDGET (menu),
 			"vertical-padding", &vertical_padding,
                         "horizontal-padding", &horizontal_padding,
+                        "scroll-arrow-height", &scroll_arrow_height,
 			NULL);
 
   x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness + horizontal_padding;
@@ -2325,12 +2337,12 @@ gtk_menu_size_allocate (GtkWidget     *w
 
   if (menu->upper_arrow_visible && !menu->tearoff_active)
     {
-      y += MENU_SCROLL_ARROW_HEIGHT;
-      height -= MENU_SCROLL_ARROW_HEIGHT;
+      y += scroll_arrow_height;
+      height -= scroll_arrow_height;
     }
 
   if (menu->lower_arrow_visible && !menu->tearoff_active)
-    height -= MENU_SCROLL_ARROW_HEIGHT;
+    height -= scroll_arrow_height;
 
   if (GTK_WIDGET_REALIZED (widget))
     {
@@ -2454,7 +2466,8 @@ gtk_menu_paint (GtkWidget      *widget,
   gint border_x, border_y;
   guint vertical_padding;
   guint horizontal_padding;
-
+  gint scroll_arrow_height;
+  
   g_return_if_fail (GTK_IS_MENU (widget));
 
   menu = GTK_MENU (widget);
@@ -2463,7 +2476,8 @@ gtk_menu_paint (GtkWidget      *widget,
   gtk_widget_style_get (GTK_WIDGET (menu),
 			"vertical-padding", &vertical_padding,
                         "horizontal-padding", &horizontal_padding,
-			NULL);
+                        "scroll-arrow-height", &scroll_arrow_height,
+                        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;
@@ -2471,7 +2485,7 @@ gtk_menu_paint (GtkWidget      *widget,
 
   if (event->window == widget->window)
     {
-      gint arrow_space = MENU_SCROLL_ARROW_HEIGHT - 2 * widget->style->ythickness;
+      gint arrow_space = scroll_arrow_height - 2 * widget->style->ythickness;
       gint arrow_size = 0.7 * arrow_space;
 
       gtk_paint_box (widget->style,
@@ -2491,7 +2505,7 @@ gtk_menu_paint (GtkWidget      *widget,
 			 border_x,
 			 border_y,
 			 width - 2 * border_x,
-			 MENU_SCROLL_ARROW_HEIGHT);
+			 scroll_arrow_height);
 
 	  gtk_paint_arrow (widget->style,
 			   widget->window,
@@ -2513,9 +2527,9 @@ gtk_menu_paint (GtkWidget      *widget,
 			 GTK_SHADOW_OUT,
 			 NULL, widget, "menu",
 			 border_x,
-			 height - border_y - MENU_SCROLL_ARROW_HEIGHT,
+			 height - border_y - scroll_arrow_height,
 			 width - 2*border_x,
-			 MENU_SCROLL_ARROW_HEIGHT);
+			 scroll_arrow_height);
 
 	  gtk_paint_arrow (widget->style,
 			   widget->window,
@@ -2525,7 +2539,7 @@ gtk_menu_paint (GtkWidget      *widget,
 			   GTK_ARROW_DOWN,
 			   TRUE,
 			   (width - arrow_size) / 2,
-			   height - border_y - MENU_SCROLL_ARROW_HEIGHT +
+			   height - border_y - scroll_arrow_height +
 			      widget->style->ythickness + (arrow_space - arrow_size)/2,
 			   arrow_size, arrow_size);
 	}
@@ -2962,10 +2976,15 @@ gtk_menu_scroll_by (GtkMenu *menu, 
   gint offset;
   gint view_width, view_height;
   gboolean double_arrows;
-
+  gint scroll_arrow_height;
+  
   widget = GTK_WIDGET (menu);
   offset = menu->scroll_offset + step;
 
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "scroll-arrow-height", &scroll_arrow_height,
+                        NULL);
+
   double_arrows = get_double_arrows (menu);
 
   /* If we scroll upward and the non-visible top part
@@ -2974,7 +2993,7 @@ gtk_menu_scroll_by (GtkMenu *menu, 
    * screen space than just scrolling to the top.
    */
   if (!double_arrows)
-    if ((step < 0) && (offset < MENU_SCROLL_ARROW_HEIGHT))
+    if ((step < 0) && (offset < scroll_arrow_height))
       offset = 0;
 
   /* Don't scroll over the top if we weren't before: */
@@ -2985,13 +3004,13 @@ gtk_menu_scroll_by (GtkMenu *menu, 
 
   /* Don't scroll past the bottom if we weren't before: */
   if (menu->scroll_offset > 0)
-    view_height -= MENU_SCROLL_ARROW_HEIGHT;
+    view_height -= scroll_arrow_height;
 
   /* When both arrows are always shown, reduce
    * view height even more.
    */
   if (double_arrows)
-    view_height -= MENU_SCROLL_ARROW_HEIGHT;
+    view_height -= scroll_arrow_height;
 
   if ((menu->scroll_offset + view_height <= widget->requisition.height) &&
       (offset + view_height > widget->requisition.height))
@@ -3137,7 +3156,8 @@ gtk_menu_handle_scrolling (GtkMenu *menu
   gint win_x, win_y;
   GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (menu));
   gboolean touchscreen_mode;
-
+  gint scroll_arrow_height;
+  
   priv = gtk_menu_get_private (menu);
 
   menu_shell = GTK_MENU_SHELL (menu);
@@ -3150,6 +3170,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu
 
   gtk_widget_style_get (GTK_WIDGET (menu),
 			"vertical-padding", &vertical_padding,
+                        "scroll-arrow-height", &scroll_arrow_height,
 			NULL);
 
   border = GTK_CONTAINER (menu)->border_width +
@@ -3166,7 +3187,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu
   rect.x = win_x;
   rect.y = win_y;
   rect.width = width;
-  rect.height = MENU_SCROLL_ARROW_HEIGHT + border;
+  rect.height = scroll_arrow_height + border;
 
   in_arrow = FALSE;
   if (menu->upper_arrow_visible && !menu->tearoff_active &&
@@ -3258,9 +3279,9 @@ gtk_menu_handle_scrolling (GtkMenu *menu
   /*  lower arrow handling  */
 
   rect.x = win_x;
-  rect.y = win_y + height - border - MENU_SCROLL_ARROW_HEIGHT;
+  rect.y = win_y + height - border - scroll_arrow_height;
   rect.width = width;
-  rect.height = MENU_SCROLL_ARROW_HEIGHT + border;
+  rect.height = scroll_arrow_height + border;
 
   in_arrow = FALSE;
   if (menu->lower_arrow_visible && !menu->tearoff_active &&
@@ -3730,7 +3751,8 @@ gtk_menu_position (GtkMenu *menu)
   GdkScreen *screen;
   GdkScreen *pointer_screen;
   GdkRectangle monitor;
-
+  gint scroll_arrow_height;
+  
   g_return_if_fail (GTK_IS_MENU (menu));
 
   widget = GTK_WIDGET (menu);
@@ -3739,6 +3761,10 @@ gtk_menu_position (GtkMenu *menu)
   gdk_display_get_pointer (gdk_screen_get_display (screen),
 			   &pointer_screen, &x, &y, NULL);
 
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "scroll-arrow-height", &scroll_arrow_height,
+                        NULL);
+  
   /* We need the requisition to figure out the right place to
    * popup the menu. In fact, we always need to ask here, since
    * if a size_request was queued while we weren't popped up,
@@ -3929,7 +3955,7 @@ gtk_menu_position (GtkMenu *menu)
     }
 
   if (scroll_offset > 0)
-    scroll_offset += MENU_SCROLL_ARROW_HEIGHT;
+    scroll_offset += scroll_arrow_height;
   
   gtk_window_move (GTK_WINDOW (GTK_MENU_SHELL (menu)->active ? menu->toplevel : menu->tearoff_window), 
 		   x, y);
@@ -3984,7 +4010,8 @@ gtk_menu_scroll_to (GtkMenu *menu,
   guint vertical_padding;
   guint horizontal_padding;
   gboolean double_arrows;
-
+  gint scroll_arrow_height;
+  
   widget = GTK_WIDGET (menu);
 
   if (menu->tearoff_active &&
@@ -4004,6 +4031,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
   gtk_widget_style_get (GTK_WIDGET (menu),
                         "vertical-padding", &vertical_padding,
                         "horizontal-padding", &horizontal_padding,
+                        "scroll-arrow-height", &scroll_arrow_height,
                         NULL);
 
   double_arrows = get_double_arrows (menu);
@@ -4030,8 +4058,8 @@ gtk_menu_scroll_to (GtkMenu *menu,
           if (!menu->upper_arrow_visible || !menu->lower_arrow_visible)
             gtk_widget_queue_draw (GTK_WIDGET (menu));
 
-          view_height -= 2 * MENU_SCROLL_ARROW_HEIGHT;
-          y += MENU_SCROLL_ARROW_HEIGHT;
+          view_height -= 2 * scroll_arrow_height;
+          y += scroll_arrow_height;
 
           menu->upper_arrow_visible = menu->lower_arrow_visible = TRUE;
 
@@ -4092,7 +4120,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
       menu->upper_arrow_visible = offset > 0;
       
       if (menu->upper_arrow_visible)
-	view_height -= MENU_SCROLL_ARROW_HEIGHT;
+	view_height -= scroll_arrow_height;
       
       if ((last_visible != menu->upper_arrow_visible) &&
           !menu->upper_arrow_visible)
@@ -4111,7 +4139,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
       menu->lower_arrow_visible = offset < menu_height - view_height;
       
       if (menu->lower_arrow_visible)
-	view_height -= MENU_SCROLL_ARROW_HEIGHT;
+	view_height -= scroll_arrow_height;
       
       if ((last_visible != menu->lower_arrow_visible) &&
 	   !menu->lower_arrow_visible)
@@ -4127,7 +4155,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
 	}
       
       if (menu->upper_arrow_visible)
-	y += MENU_SCROLL_ARROW_HEIGHT;
+	y += scroll_arrow_height;
     }
 
   /* Scroll the menu: */
@@ -4205,12 +4233,14 @@ gtk_menu_scroll_item_visible (GtkMenuShe
     {
       guint vertical_padding;
       gboolean double_arrows;
-
+      gint scroll_arrow_height;
+      
       y = menu->scroll_offset;
       gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
 
       gtk_widget_style_get (GTK_WIDGET (menu),
 			    "vertical-padding", &vertical_padding,
+                            "scroll-arrow-height", &scroll_arrow_height,
                             NULL);
 
       double_arrows = get_double_arrows (menu);
@@ -4228,21 +4258,21 @@ gtk_menu_scroll_item_visible (GtkMenuShe
 	{
 	  arrow_height = 0;
 	  if (menu->upper_arrow_visible && !menu->tearoff_active)
-	    arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+	    arrow_height += scroll_arrow_height;
 	  if (menu->lower_arrow_visible && !menu->tearoff_active)
-	    arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+	    arrow_height += scroll_arrow_height;
 	  
 	  if (child_offset + child_height > y + height - arrow_height)
 	    {
 	      arrow_height = 0;
 	      if ((!last_child && !menu->tearoff_active) || double_arrows)
-		arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+		arrow_height += scroll_arrow_height;
 
 	      y = child_offset + child_height - height + arrow_height;
 	      if (((y > 0) && !menu->tearoff_active) || double_arrows)
 		{
 		  /* Need upper arrow */
-		  arrow_height += MENU_SCROLL_ARROW_HEIGHT;
+		  arrow_height += scroll_arrow_height;
 		  y = child_offset + child_height - height + arrow_height;
 		}
 	      /* Ignore the enter event we might get if the pointer is on the menu
@@ -4594,15 +4624,20 @@ get_visible_size (GtkMenu *menu)
 {
   GtkWidget *widget = GTK_WIDGET (menu);
   GtkContainer *container = GTK_CONTAINER (menu);
+  gint scroll_arrow_height;
   
   gint menu_height = (widget->allocation.height
 		      - 2 * (container->border_width
 			     + widget->style->ythickness));
   
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "scroll-arrow-height", &scroll_arrow_height,
+                        NULL);
+
   if (menu->upper_arrow_visible && !menu->tearoff_active)
-    menu_height -= MENU_SCROLL_ARROW_HEIGHT;
+    menu_height -= scroll_arrow_height;
   if (menu->lower_arrow_visible && !menu->tearoff_active)
-    menu_height -= MENU_SCROLL_ARROW_HEIGHT;
+    menu_height -= scroll_arrow_height;
 
   return menu_height;
 }
@@ -4656,15 +4691,20 @@ get_menu_height (GtkMenu *menu)
 {
   gint height;
   GtkWidget *widget = GTK_WIDGET (menu);
+  gint scroll_arrow_height;
 
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "scroll-arrow-height", &scroll_arrow_height,
+                        NULL);
+  
   height = widget->requisition.height;
   height -= (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2;
 
   if (menu->upper_arrow_visible && !menu->tearoff_active)
-    height -= MENU_SCROLL_ARROW_HEIGHT;
+    height -= scroll_arrow_height;
 
   if (menu->lower_arrow_visible && !menu->tearoff_active)
-    height -= MENU_SCROLL_ARROW_HEIGHT;
+    height -= scroll_arrow_height;
 
   return height;
 }
@@ -4676,6 +4716,11 @@ gtk_menu_real_move_scroll (GtkMenu      
   gint page_size = get_visible_size (menu);
   gint end_position = get_menu_height (menu);
   GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
+  gint scroll_arrow_height;
+
+  gtk_widget_style_get (GTK_WIDGET (menu),
+                        "scroll-arrow-height", &scroll_arrow_height,
+                        NULL);
   
   switch (type)
     {
@@ -4719,7 +4764,7 @@ gtk_menu_real_move_scroll (GtkMenu      
 	    if (menu->scroll_offset != old_offset)
 	      step = menu->scroll_offset - old_offset;
 
-	    step -= (new_upper_arrow_visible - old_upper_arrow_visible) * MENU_SCROLL_ARROW_HEIGHT;
+	    step -= (new_upper_arrow_visible - old_upper_arrow_visible) * scroll_arrow_height;
 
 	    new_child = child_at (menu, child_offset + step);
 	    if (new_child)
