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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu May 10 15:11:57 EEST 2007
Author: tko
Date: 2007-05-10 15:11:55 +0300 (Thu, 10 May 2007)
New Revision: 11574

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtkmenu.c
Log:
Refactor arrow sensitive area calculations

	* gtk/gtkmenu.c (get_arrows_sensitive_area): New function
	(gtk_menu_handle_scrolling): Refactor arrow sensitive area calculations
	to separate function (#436533, NB#51958)


Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2007-05-10 12:11:52 UTC (rev 11573)
+++ projects/haf/trunk/gtk+/ChangeLog	2007-05-10 12:11:55 UTC (rev 11574)
@@ -1,5 +1,11 @@
 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
+	to separate function (#436533, NB#51958)
+
+2007-05-10  Tommi Komulainen  <tommi.komulainen at nokia.com>
+    
 	* gtk/gtkmenu.c (get_arrows_visible_area): New function
 	(gtk_menu_paint): Refactor arrow visible area calculations to a
 	separate function (#436533, NB#51958)

Modified: projects/haf/trunk/gtk+/gtk/gtkmenu.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkmenu.c	2007-05-10 12:11:52 UTC (rev 11573)
+++ projects/haf/trunk/gtk+/gtk/gtkmenu.c	2007-05-10 12:11:55 UTC (rev 11574)
@@ -3378,6 +3378,47 @@
 }
 
 static void
+get_arrows_sensitive_area (GtkMenu *menu,
+                           GdkRectangle *upper,
+                           GdkRectangle *lower)
+{
+  gint width, height;
+  gint border;
+  guint vertical_padding;
+  gint win_x, win_y;
+  gint scroll_arrow_height;
+
+  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,
+                        NULL);
+
+  border = GTK_CONTAINER (menu)->border_width +
+    GTK_WIDGET (menu)->style->ythickness + vertical_padding;
+
+  gdk_window_get_position (GTK_WIDGET (menu)->window, &win_x, &win_y);
+
+  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;
+    }
+}
+
+
+static void
 gtk_menu_handle_scrolling (GtkMenu *menu,
 			   gint     x,
 			   gint     y,
@@ -3386,47 +3427,27 @@
 {
   GtkMenuShell *menu_shell;
   GtkMenuPrivate *priv;
-  gint width, height;
-  gint border;
   GdkRectangle rect;
   gboolean in_arrow;
   gboolean scroll_fast = FALSE;
-  guint vertical_padding;
   gint top_x, top_y;
-  gint win_x, win_y;
   gboolean touchscreen_mode;
-  gint scroll_arrow_height;
 
   priv = gtk_menu_get_private (menu);
 
   menu_shell = GTK_MENU_SHELL (menu);
 
-  gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
-
   g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu)),
                 "gtk-touchscreen-mode", &touchscreen_mode,
                 NULL);
 
-  gtk_widget_style_get (GTK_WIDGET (menu),
-			"vertical-padding", &vertical_padding,
-                        "scroll-arrow-vlength", &scroll_arrow_height,
-			NULL);
-
-  border = GTK_CONTAINER (menu)->border_width +
-    GTK_WIDGET (menu)->style->ythickness + vertical_padding;
-
   gdk_window_get_position (menu->toplevel->window, &top_x, &top_y);
   x -= top_x;
   y -= top_y;
 
-  gdk_window_get_position (GTK_WIDGET (menu)->window, &win_x, &win_y);
-
   /*  upper arrow handling  */
 
-  rect.x = win_x;
-  rect.y = win_y;
-  rect.width = width;
-  rect.height = scroll_arrow_height + border;
+  get_arrows_sensitive_area (menu, &rect, NULL);
 
   in_arrow = FALSE;
   if (menu->upper_arrow_visible && !menu->tearoff_active &&
@@ -3525,10 +3546,7 @@
 
   /*  lower arrow handling  */
 
-  rect.x = win_x;
-  rect.y = win_y + height - border - scroll_arrow_height;
-  rect.width = width;
-  rect.height = scroll_arrow_height + border;
+  get_arrows_sensitive_area (menu, NULL, &rect);
 
   in_arrow = FALSE;
   if (menu->lower_arrow_visible && !menu->tearoff_active &&


More information about the maemo-commits mailing list