#55310: somewhat more correct patch



Hi,

Appended is a somewhat more correct patch for #55310.

Ok to commit?

regards,


	Kris


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2319
diff -u -r1.2319 ChangeLog
--- ChangeLog	2001/09/21 19:58:33	1.2319
+++ ChangeLog	2001/09/21 21:09:42
@@ -1,3 +1,10 @@
+Fri Sep 21 23:07:43 2001  Kristian Rietveld  <kristian planet nl>
+
+	* gtk/gtkmenu.c (gtk_menu_select_item): move most code
+	to gtk_menu_scroll_item_visible(). Only call
+	gtk_menu_scroll_item_visible() if the menu widget has been
+	realized.
+
 2001-09-21  Hans Breuer  <hans breuer org>

 	* gdk/gdk.def :
Index: gtk/gtkmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenu.c,v
retrieving revision 1.72
diff -u -r1.72 gtkmenu.c
--- gtk/gtkmenu.c	2001/08/25 03:15:26	1.72
+++ gtk/gtkmenu.c	2001/09/21 21:09:45
@@ -97,6 +97,8 @@
 					    gint              offset);
 static void     gtk_menu_stop_scrolling    (GtkMenu          *menu);
 static gboolean gtk_menu_scroll_timeout    (gpointer          data);
+static void     gtk_menu_scroll_item_visible (GtkMenuShell    *menu_shell,
+					      GtkWidget       *menu_item);
 static void     gtk_menu_select_item       (GtkMenuShell     *menu_shell,
 					    GtkWidget        *menu_item);
 static void     gtk_menu_real_insert       (GtkMenuShell     *menu_shell,
@@ -1124,6 +1126,8 @@
   gtk_style_set_background (widget->style, menu->view_window, GTK_STATE_NORMAL);
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);

+  gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget), NULL);
+
   gtk_menu_paint (widget);

   gdk_window_show (menu->bin_window);
@@ -2204,7 +2208,6 @@
 	y += MENU_SCROLL_ARROW_HEIGHT;
     }

-
   gdk_window_move_resize (menu->view_window,
 			  x,
 			  y,
@@ -2215,8 +2218,8 @@
 }

 static void
-gtk_menu_select_item (GtkMenuShell  *menu_shell,
-		      GtkWidget     *menu_item)
+gtk_menu_scroll_item_visible (GtkMenuShell    *menu_shell,
+			      GtkWidget       *menu_item)
 {
   GtkMenu *menu;
   GtkWidget *child;
@@ -2228,8 +2231,6 @@
   gint arrow_height;
   gboolean last_child = 0;

-  g_return_if_fail (GTK_IS_MENU (menu_shell));
-
   menu = GTK_MENU (menu_shell);

   /* We need to check if the selected item fully visible.
@@ -2303,6 +2304,20 @@
 	}

     }
+}
+
+static void
+gtk_menu_select_item (GtkMenuShell  *menu_shell,
+		      GtkWidget     *menu_item)
+{
+  GtkMenu *menu;
+
+  menu = GTK_MENU (menu_shell);
+
+  g_return_if_fail (GTK_IS_MENU (menu_shell));
+
+  if (GTK_WIDGET_REALIZED (GTK_WIDGET (menu)))
+    gtk_menu_scroll_item_visible (menu_shell, menu_item);

   GTK_MENU_SHELL_CLASS (parent_class)->select_item (menu_shell, menu_item);
 }





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]