summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-02-18 22:08:41 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-02-18 22:08:41 +0000
commit8fe564e37a83dbbc1de33cc96e0b648621ac4859 (patch)
treecf2e4b77779db271dfcb23a432e5f096130bf80b /gtk
parenta2bf986bd08d59268f8836aede4f2321edce841a (diff)
downloadgtk+-8fe564e37a83dbbc1de33cc96e0b648621ac4859.tar.gz
Add some docs for GTK_NEED_REQUEST GTK_NEED_ALLOCATION.
Mon Feb 18 16:44:00 2002 Owen Taylor <otaylor@redhat.com> * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST GTK_NEED_ALLOCATION. * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu to the right place before showing the menu to avoid spurious enter events. * gtk/gtkmenu.c (gtk_menu_realize): Only scroll if there is an active menu item. * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED ALLOC_NEEDED initially.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkmenu.c38
-rw-r--r--gtk/gtkwidget.c2
2 files changed, 32 insertions, 8 deletions
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 930f183644..422e8d3b1f 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -742,17 +742,38 @@ gtk_menu_popup (GtkMenu *menu,
menu->position_func_data = data;
menu_shell->activate_time = activate_time;
- gtk_menu_position (menu);
-
- /* We need to show the menu _here_ because code expects to be
- * able to tell if the menu is onscreen by looking at the
- * GTK_WIDGET_VISIBLE (menu)
+ /* We need to show the menu here rather in the init function because
+ * code expects to be able to tell if the menu is onscreen by
+ * looking at the GTK_WIDGET_VISIBLE (menu)
*/
gtk_widget_show (GTK_WIDGET (menu));
- gtk_widget_show (menu->toplevel);
+
+ /* Compute the size of the toplevel and realize it so we
+ * can position and scroll correctly.
+ */
+ {
+ GtkRequisition tmp_request;
+ GtkAllocation tmp_allocation = { 0, };
+
+ gtk_widget_size_request (menu->toplevel, &tmp_request);
+
+ tmp_allocation.width = tmp_request.width;
+ tmp_allocation.height = tmp_request.height;
+
+ gtk_widget_size_allocate (menu->toplevel, &tmp_allocation);
+
+ gtk_widget_realize (GTK_WIDGET (menu));
+ }
+
+ gtk_menu_position (menu);
gtk_menu_scroll_to (menu, menu->scroll_offset);
+ /* Once everything is set up correctly, map the toplevel window on
+ the screen.
+ */
+ gtk_widget_show (menu->toplevel);
+
if (xgrab_shell == widget)
popup_grab_on_window (widget->window, activate_time); /* Should always succeed */
@@ -1297,8 +1318,9 @@ gtk_menu_realize (GtkWidget *widget)
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),
- GTK_MENU_SHELL (widget)->active_menu_item);
+ if (GTK_MENU_SHELL (widget)->active_menu_item)
+ gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
+ GTK_MENU_SHELL (widget)->active_menu_item);
gdk_window_show (menu->bin_window);
gdk_window_show (menu->view_window);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 625f12cf27..293cd6f625 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -1283,6 +1283,8 @@ gtk_widget_init (GtkWidget *widget)
GTK_DOUBLE_BUFFERED);
GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
+ GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
+ GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
widget->style = gtk_widget_get_default_style ();
g_object_ref (widget->style);