Remove sealed members from GtkMenuShell

This commit is contained in:
Matthias Clasen 2010-12-23 18:21:53 -05:00
parent c5b020e628
commit 2ed81aa57c
11 changed files with 757 additions and 741 deletions

View File

@ -400,6 +400,7 @@ gtk_private_h_sources = \
gtkintl.h \
gtkkeyhash.h \
gtkmenuprivate.h \
gtkmenushellprivate.h \
gtkmnemonichash.h \
gtkmodifierstyle.h \
gtkmountoperationprivate.h \

View File

@ -31,6 +31,7 @@
#include "gtkliststore.h"
#include "gtkmain.h"
#include "gtkmenuprivate.h"
#include "gtkmenushellprivate.h"
#include "gtkscrolledwindow.h"
#include "gtkseparatormenuitem.h"
#include "gtktearoffmenuitem.h"
@ -1874,7 +1875,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
menu_ypos -= child_allocation.height / 2;
}
children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->priv->children;
while (children)
{
child = children->data;
@ -1924,15 +1925,15 @@ gtk_combo_box_menu_position (GtkMenu *menu,
GtkComboBoxPrivate *priv = combo_box->priv;
GtkWidget *menu_item;
if (priv->wrap_width > 0 || priv->cell_view == NULL)
if (priv->wrap_width > 0 || priv->cell_view == NULL)
gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
else
{
/* FIXME handle nested menus better */
menu_item = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
if (menu_item)
gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget),
menu_item);
gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget),
menu_item);
gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
}
@ -3189,13 +3190,13 @@ gtk_combo_box_menu_fill (GtkComboBox *combo_box)
GtkWidget *tearoff = gtk_tearoff_menu_item_new ();
gtk_widget_show (tearoff);
if (priv->wrap_width)
gtk_menu_attach (GTK_MENU (menu), tearoff, 0, priv->wrap_width, 0, 1);
gtk_menu_attach (GTK_MENU (menu), tearoff, 0, priv->wrap_width, 0, 1);
else
gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
}
gtk_combo_box_menu_fill_level (combo_box, menu, NULL);
}
@ -3342,11 +3343,11 @@ menu_occupied (GtkMenu *menu,
{
GList *i;
for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next)
for (i = GTK_MENU_SHELL (menu)->priv->children; i; i = i->next)
{
guint l, r, b, t;
gtk_container_child_get (GTK_CONTAINER (menu),
gtk_container_child_get (GTK_CONTAINER (menu),
i->data,
"left-attach", &l,
"right-attach", &r,
@ -3375,12 +3376,12 @@ gtk_combo_box_relayout_item (GtkComboBox *combo_box,
if (!GTK_IS_MENU_SHELL (menu))
return;
if (priv->col_column == -1 &&
priv->row_column == -1 &&
last)
{
gtk_container_child_get (GTK_CONTAINER (menu),
gtk_container_child_get (GTK_CONTAINER (menu),
last,
"right-attach", &current_col,
"top-attach", &current_row,

View File

@ -42,6 +42,7 @@
#include "gtkseparatormenuitem.h"
#include "gtktextutil.h"
#include "gtkmenuitem.h"
#include "gtkmenushellprivate.h"
#include "gtknotebook.h"
#include "gtkstock.h"
#include "gtkbindings.h"

View File

@ -35,6 +35,7 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkmenuprivate.h"
#include "gtkmenushellprivate.h"
#include "gtktearoffmenuitem.h"
#include "gtkwindow.h"
#include "gtkhbox.h"
@ -328,7 +329,7 @@ menu_ensure_layout (GtkMenu *menu)
GList *l;
gchar *row_occupied;
gint current_row;
gint max_right_attach;
gint max_right_attach;
gint max_bottom_attach;
/* Find extents of gridded portion
@ -336,7 +337,7 @@ menu_ensure_layout (GtkMenu *menu)
max_right_attach = 1;
max_bottom_attach = 0;
for (l = menu_shell->children; l; l = l->next)
for (l = menu_shell->priv->children; l; l = l->next)
{
GtkWidget *child = l->data;
AttachInfo *ai = get_attach_info (child);
@ -351,7 +352,7 @@ menu_ensure_layout (GtkMenu *menu)
/* Find empty rows */
row_occupied = g_malloc0 (max_bottom_attach);
for (l = menu_shell->children; l; l = l->next)
for (l = menu_shell->priv->children; l; l = l->next)
{
GtkWidget *child = l->data;
AttachInfo *ai = get_attach_info (child);
@ -368,7 +369,7 @@ menu_ensure_layout (GtkMenu *menu)
/* Lay non-grid-items out in those rows
*/
current_row = 0;
for (l = menu_shell->children; l; l = l->next)
for (l = menu_shell->priv->children; l; l = l->next)
{
GtkWidget *child = l->data;
AttachInfo *ai = get_attach_info (child);
@ -876,7 +877,7 @@ gtk_menu_get_property (GObject *object,
switch (prop_id)
{
case PROP_ACTIVE:
g_value_set_int (value, g_list_index (GTK_MENU_SHELL (menu)->children, gtk_menu_get_active (menu)));
g_value_set_int (value, g_list_index (GTK_MENU_SHELL (menu)->priv->children, gtk_menu_get_active (menu)));
break;
case PROP_ACCEL_GROUP:
g_value_set_object (value, gtk_menu_get_accel_group (menu));
@ -1432,7 +1433,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
keyboard = gdk_device_get_associated_device (device);
}
menu_shell->parent_menu_shell = parent_menu_shell;
menu_shell->priv->parent_menu_shell = parent_menu_shell;
priv->seen_item_enter = FALSE;
@ -1458,7 +1459,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
if (viewable)
xgrab_shell = parent;
parent = GTK_MENU_SHELL (parent)->parent_menu_shell;
parent = GTK_MENU_SHELL (parent)->priv->parent_menu_shell;
}
/* We want to receive events generated when we map the menu;
@ -1489,7 +1490,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
if (popup_grab_on_window (gtk_widget_get_window (xgrab_shell), keyboard, pointer, activate_time))
{
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE;
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
}
}
else
@ -1501,24 +1502,24 @@ gtk_menu_popup_for_device (GtkMenu *menu,
if (popup_grab_on_window (transfer_window, keyboard, pointer, activate_time))
{
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE;
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
}
}
if (!GTK_MENU_SHELL (xgrab_shell)->have_xgrab)
if (!GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab)
{
/* We failed to make our pointer/keyboard grab.
* Rather than leaving the user with a stuck up window,
* we just abort here. Presumably the user will try again.
*/
menu_shell->parent_menu_shell = NULL;
menu_shell->priv->parent_menu_shell = NULL;
menu_grab_transfer_window_destroy (menu);
return;
}
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (menu), pointer);
menu_shell->active = TRUE;
menu_shell->button = button;
menu_shell->priv->active = TRUE;
menu_shell->priv->button = button;
/* If we are popping up the menu from something other than, a button
* press then, as a heuristic, we ignore enter events for the menu
@ -1530,12 +1531,12 @@ gtk_menu_popup_for_device (GtkMenu *menu,
{
if ((current_event->type != GDK_BUTTON_PRESS) &&
(current_event->type != GDK_ENTER_NOTIFY))
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
gdk_event_free (current_event);
}
else
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
if (priv->torn_off)
{
@ -1563,7 +1564,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
priv->position_func = func;
priv->position_func_data = data;
priv->position_func_data_destroy = destroy;
menu_shell->activate_time = activate_time;
menu_shell->priv->activate_time = activate_time;
/* 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
@ -1600,7 +1601,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
gtk_menu_scroll_to (menu, priv->scroll_offset);
/* if no item is selected, select the first one */
if (!menu_shell->active_menu_item)
if (!menu_shell->priv->active_menu_item)
{
gboolean touchscreen_mode;
@ -1627,7 +1628,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
keyboard_mode = _gtk_menu_shell_get_keyboard_mode (GTK_MENU_SHELL (parent_menu_shell));
_gtk_menu_shell_set_keyboard_mode (menu_shell, keyboard_mode);
}
else if (menu_shell->button == 0) /* a keynav-activated context menu */
else if (menu_shell->priv->button == 0) /* a keynav-activated context menu */
_gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
_gtk_menu_shell_update_mnemonics (menu_shell);
@ -1697,20 +1698,20 @@ gtk_menu_popdown (GtkMenu *menu)
menu_shell = GTK_MENU_SHELL (menu);
priv = menu->priv;
menu_shell->parent_menu_shell = NULL;
menu_shell->active = FALSE;
menu_shell->ignore_enter = FALSE;
menu_shell->priv->parent_menu_shell = NULL;
menu_shell->priv->active = FALSE;
menu_shell->priv->ignore_enter = FALSE;
priv->have_position = FALSE;
gtk_menu_stop_scrolling (menu);
gtk_menu_stop_navigating_submenu (menu);
if (menu_shell->active_menu_item)
if (menu_shell->priv->active_menu_item)
{
if (priv->old_active_menu_item)
g_object_unref (priv->old_active_menu_item);
priv->old_active_menu_item = menu_shell->active_menu_item;
priv->old_active_menu_item = menu_shell->priv->active_menu_item;
g_object_ref (priv->old_active_menu_item);
}
@ -1740,7 +1741,7 @@ gtk_menu_popdown (GtkMenu *menu)
/* We popped up the menu from the tearoff, so we need to
* release the grab - we aren't actually hiding the menu.
*/
if (menu_shell->have_xgrab && pointer)
if (menu_shell->priv->have_xgrab && pointer)
{
GdkDevice *keyboard;
@ -1763,7 +1764,7 @@ gtk_menu_popdown (GtkMenu *menu)
else
gtk_widget_hide (GTK_WIDGET (menu));
menu_shell->have_xgrab = FALSE;
menu_shell->priv->have_xgrab = FALSE;
if (pointer)
gtk_device_grab_remove (GTK_WIDGET (menu), pointer);
@ -1785,7 +1786,7 @@ gtk_menu_get_active (GtkMenu *menu)
if (!priv->old_active_menu_item)
{
child = NULL;
children = GTK_MENU_SHELL (menu)->children;
children = GTK_MENU_SHELL (menu)->priv->children;
while (children)
{
@ -1815,7 +1816,7 @@ gtk_menu_set_active (GtkMenu *menu,
g_return_if_fail (GTK_IS_MENU (menu));
tmp_list = g_list_nth (GTK_MENU_SHELL (menu)->children, index);
tmp_list = g_list_nth (GTK_MENU_SHELL (menu)->priv->children, index);
if (tmp_list)
{
child = tmp_list->data;
@ -2266,10 +2267,10 @@ gtk_menu_reorder_child (GtkMenu *menu,
menu_shell = GTK_MENU_SHELL (menu);
if (g_list_find (menu_shell->children, child))
if (g_list_find (menu_shell->priv->children, child))
{
menu_shell->children = g_list_remove (menu_shell->children, child);
menu_shell->children = g_list_insert (menu_shell->children, child, position);
menu_shell->priv->children = g_list_remove (menu_shell->priv->children, child);
menu_shell->priv->children = g_list_insert (menu_shell->priv->children, child, position);
menu_queue_resize (menu);
}
@ -2434,7 +2435,7 @@ gtk_menu_realize (GtkWidget *widget)
&attributes, attributes_mask);
gdk_window_set_user_data (priv->bin_window, menu);
children = GTK_MENU_SHELL (menu)->children;
children = GTK_MENU_SHELL (menu)->priv->children;
while (children)
{
child = children->data;
@ -2447,9 +2448,9 @@ gtk_menu_realize (GtkWidget *widget)
gtk_style_context_set_background (context, priv->view_window);
gtk_style_context_set_background (context, window);
if (GTK_MENU_SHELL (widget)->active_menu_item)
if (GTK_MENU_SHELL (widget)->priv->active_menu_item)
gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
GTK_MENU_SHELL (widget)->active_menu_item);
GTK_MENU_SHELL (widget)->priv->active_menu_item);
gdk_window_show (priv->bin_window);
gdk_window_show (priv->view_window);
@ -2564,7 +2565,7 @@ calculate_line_heights (GtkMenu *menu,
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
avail_width -= (border_width + horizontal_padding + gtk_widget_get_style (widget)->xthickness) * 2;
for (children = menu_shell->children; children; children = children->next)
for (children = menu_shell->priv->children; children; children = children->next)
{
gint part;
gint toggle_size;
@ -2658,7 +2659,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
height = allocation->height - (2 * (border_width + vertical_padding)) -
border.top - border.bottom;
if (menu_shell->active)
if (menu_shell->priv->active)
gtk_menu_scroll_to (menu, priv->scroll_offset);
if (!priv->tearoff_active)
@ -2683,11 +2684,11 @@ gtk_menu_size_allocate (GtkWidget *widget,
gdk_window_move_resize (priv->view_window, x, y, width, height);
}
if (menu_shell->children)
if (menu_shell->priv->children)
{
gint base_width = width / gtk_menu_get_n_columns (menu);
children = menu_shell->children;
children = menu_shell->priv->children;
while (children)
{
child = children->data;
@ -3011,7 +3012,7 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
max_toggle_size = 0;
max_accel_width = 0;
children = menu_shell->children;
children = menu_shell->priv->children;
while (children)
{
gint part;
@ -3238,8 +3239,8 @@ pointer_in_menu_window (GtkWidget *widget,
menu_shell = GTK_MENU_SHELL (widget);
if (GTK_IS_MENU (menu_shell->parent_menu_shell))
return pointer_in_menu_window (menu_shell->parent_menu_shell,
if (GTK_IS_MENU (menu_shell->priv->parent_menu_shell))
return pointer_in_menu_window (menu_shell->priv->parent_menu_shell,
x_root, y_root);
}
@ -3303,8 +3304,8 @@ gtk_menu_button_release (GtkWidget *widget,
* next button_press/button_release in GtkMenuShell.
* See bug #449371.
*/
if (GTK_MENU_SHELL (widget)->active)
GTK_MENU_SHELL (widget)->button = 0;
if (GTK_MENU_SHELL (widget)->priv->active)
GTK_MENU_SHELL (widget)->priv->button = 0;
return TRUE;
}
@ -3434,12 +3435,12 @@ gtk_menu_key_press (GtkWidget *widget,
/* Modify the accelerators */
if (can_change_accels &&
menu_shell->active_menu_item &&
gtk_bin_get_child (GTK_BIN (menu_shell->active_menu_item)) && /* no separators */
GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL && /* no submenus */
menu_shell->priv->active_menu_item &&
gtk_bin_get_child (GTK_BIN (menu_shell->priv->active_menu_item)) && /* no separators */
GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->submenu == NULL && /* no submenus */
(delete || gtk_accelerator_valid (accel_key, accel_mods)))
{
GtkWidget *menu_item = menu_shell->active_menu_item;
GtkWidget *menu_item = menu_shell->priv->active_menu_item;
gboolean locked, replace_accels = TRUE;
const gchar *path;
@ -3566,9 +3567,9 @@ gtk_menu_motion_notify (GtkWidget *widget,
menu = GTK_MENU (menu_shell);
if (definitely_within_item (menu_item, event->x, event->y))
menu_shell->activate_time = 0;
menu_shell->priv->activate_time = 0;
need_enter = (gtk_menu_has_navigation_triangle (menu) || menu_shell->ignore_enter);
need_enter = (gtk_menu_has_navigation_triangle (menu) || menu_shell->priv->ignore_enter);
/* Check to see if we are within an active submenu's navigation region
*/
@ -3592,7 +3593,7 @@ gtk_menu_motion_notify (GtkWidget *widget,
/* The menu is now sensitive to enter events on its items, but
* was previously sensitive. So we fake an enter event.
*/
menu_shell->ignore_enter = FALSE;
menu_shell->priv->ignore_enter = FALSE;
if (event->x >= 0 && event->x < gdk_window_get_width (event->window) &&
event->y >= 0 && event->y < gdk_window_get_height (event->window))
@ -3721,7 +3722,7 @@ gtk_menu_do_timeout_scroll (GtkMenu *menu,
* this would cause the uncovered menu item to be activated on button
* release. Therefore we need to ignore button release here
*/
GTK_MENU_SHELL (menu)->ignore_enter = TRUE;
GTK_MENU_SHELL (menu)->priv->ignore_enter = TRUE;
priv->ignore_button_release = TRUE;
}
}
@ -4162,7 +4163,7 @@ gtk_menu_enter_notify (GtkWidget *widget,
{
GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget);
if (!menu_shell->ignore_enter)
if (!menu_shell->priv->ignore_enter)
gtk_menu_handle_scrolling (GTK_MENU (widget),
event->x_root, event->y_root, TRUE, TRUE);
}
@ -4182,7 +4183,7 @@ gtk_menu_enter_notify (GtkWidget *widget,
* on this menu. This means a release should always
* mean activate.
*/
menu_shell->activate_time = 0;
menu_shell->priv->activate_time = 0;
}
else if ((event->detail != GDK_NOTIFY_NONLINEAR &&
event->detail != GDK_NOTIFY_NONLINEAR_VIRTUAL))
@ -4195,7 +4196,7 @@ gtk_menu_enter_notify (GtkWidget *widget,
* far enough away from the enter point. (see
* gtk_menu_motion_notify())
*/
menu_shell->activate_time = 0;
menu_shell->priv->activate_time = 0;
}
}
@ -4248,16 +4249,16 @@ gtk_menu_leave_notify (GtkWidget *widget,
/* Here we check to see if we're leaving an active menu item
* with a submenu, in which case we enter submenu navigation mode.
*/
if (menu_shell->active_menu_item != NULL
if (menu_shell->priv->active_menu_item != NULL
&& menu_item->submenu != NULL
&& menu_item->submenu_placement == GTK_LEFT_RIGHT)
{
if (GTK_MENU_SHELL (menu_item->submenu)->active)
if (GTK_MENU_SHELL (menu_item->submenu)->priv->active)
{
gtk_menu_set_submenu_navigation_region (menu, menu_item, event);
return TRUE;
}
else if (menu_item == GTK_MENU_ITEM (menu_shell->active_menu_item))
else if (menu_item == GTK_MENU_ITEM (menu_shell->priv->active_menu_item))
{
/* We are leaving an active menu item with nonactive submenu.
* Deselect it so we don't surprise the user with by popping
@ -4467,9 +4468,9 @@ gtk_menu_deactivate (GtkMenuShell *menu_shell)
g_return_if_fail (GTK_IS_MENU (menu_shell));
parent = menu_shell->parent_menu_shell;
parent = menu_shell->priv->parent_menu_shell;
menu_shell->activate_time = 0;
menu_shell->priv->activate_time = 0;
gtk_menu_popdown (GTK_MENU (menu_shell));
if (parent)
@ -4675,7 +4676,7 @@ gtk_menu_position (GtkMenu *menu,
/* FIXME: should this be done in the various position_funcs ? */
x = CLAMP (x, monitor.x, MAX (monitor.x, monitor.x + monitor.width - requisition.width));
if (GTK_MENU_SHELL (menu)->active)
if (GTK_MENU_SHELL (menu)->priv->active)
{
priv->have_position = TRUE;
priv->position_x = x;
@ -4700,10 +4701,10 @@ gtk_menu_position (GtkMenu *menu,
scroll_offset += arrow_border.top;
}
gtk_window_move (GTK_WINDOW (GTK_MENU_SHELL (menu)->active ? priv->toplevel : priv->tearoff_window),
gtk_window_move (GTK_WINDOW (GTK_MENU_SHELL (menu)->priv->active ? priv->toplevel : priv->tearoff_window),
x, y);
if (!GTK_MENU_SHELL (menu)->active)
if (!GTK_MENU_SHELL (menu)->priv->active)
{
gtk_window_resize (GTK_WINDOW (priv->tearoff_window),
requisition.width, requisition.height);
@ -5012,7 +5013,7 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
/* Ignore the enter event we might get if the pointer
* is on the menu
*/
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
gtk_menu_scroll_to (menu, child_offset);
}
else
@ -5041,7 +5042,7 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
/* Ignore the enter event we might get if the pointer
* is on the menu
*/
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
gtk_menu_scroll_to (menu, y);
}
}
@ -5204,7 +5205,7 @@ gtk_menu_attach (GtkMenu *menu,
ai->top_attach = top_attach;
ai->bottom_attach = bottom_attach;
menu_shell->children = g_list_append (menu_shell->children, child);
menu_shell->priv->children = g_list_append (menu_shell->priv->children, child);
gtk_widget_set_parent (child, GTK_WIDGET (menu));
@ -5245,7 +5246,7 @@ find_child_containing (GtkMenuShell *menu_shell,
/* find a child which includes the area given by
* left, right, top, bottom.
*/
for (list = menu_shell->children; list; list = list->next)
for (list = menu_shell->priv->children; list; list = list->next)
{
gint l, r, t, b;
@ -5285,9 +5286,9 @@ gtk_menu_move_current (GtkMenuShell *menu_shell,
}
/* use special table menu key bindings */
if (menu_shell->active_menu_item && gtk_menu_get_n_columns (menu) > 1)
if (menu_shell->priv->active_menu_item && gtk_menu_get_n_columns (menu) > 1)
{
get_effective_child_attach (menu_shell->active_menu_item, &l, &r, &t, &b);
get_effective_child_attach (menu_shell->priv->active_menu_item, &l, &r, &t, &b);
if (direction == GTK_MENU_DIR_NEXT)
{
@ -5341,11 +5342,11 @@ gtk_menu_move_current (GtkMenuShell *menu_shell,
if (!match)
{
GtkWidget *parent = menu_shell->parent_menu_shell;
GtkWidget *parent = menu_shell->priv->parent_menu_shell;
if (!parent
|| g_list_length (GTK_MENU_SHELL (parent)->children) <= 1)
match = menu_shell->active_menu_item;
|| g_list_length (GTK_MENU_SHELL (parent)->priv->children) <= 1)
match = menu_shell->priv->active_menu_item;
}
}
else if (direction == GTK_MENU_DIR_CHILD)
@ -5356,12 +5357,12 @@ gtk_menu_move_current (GtkMenuShell *menu_shell,
if (!match)
{
GtkWidget *parent = menu_shell->parent_menu_shell;
GtkWidget *parent = menu_shell->priv->parent_menu_shell;
if (! GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu &&
if (! GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->submenu &&
(!parent ||
g_list_length (GTK_MENU_SHELL (parent)->children) <= 1))
match = menu_shell->active_menu_item;
g_list_length (GTK_MENU_SHELL (parent)->priv->children) <= 1))
match = menu_shell->priv->active_menu_item;
}
}
@ -5420,7 +5421,7 @@ child_at (GtkMenu *menu,
lower = priv->scroll_offset;
upper = priv->scroll_offset + menu_height;
for (children = menu_shell->children; children; children = children->next)
for (children = menu_shell->priv->children; children; children = children->next)
{
if (gtk_widget_get_visible (children->data))
{
@ -5497,16 +5498,16 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
else
step = page_size;
if (menu_shell->active_menu_item)
if (menu_shell->priv->active_menu_item)
{
gint child_height;
compute_child_offset (menu, menu_shell->active_menu_item,
compute_child_offset (menu, menu_shell->priv->active_menu_item,
&child_offset, &child_height, NULL);
child_offset += child_height / 2;
}
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
old_upper_arrow_visible = priv->upper_arrow_visible && !priv->tearoff_active;
old_offset = priv->scroll_offset;
@ -5515,12 +5516,11 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
gtk_menu_scroll_to (menu, new_offset);
if (menu_shell->active_menu_item)
if (menu_shell->priv->active_menu_item)
{
GtkWidget *new_child;
gboolean new_upper_arrow_visible = priv->upper_arrow_visible && !priv->tearoff_active;
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
if (priv->scroll_offset != old_offset)
@ -5536,13 +5536,13 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
break;
case GTK_SCROLL_START:
/* Ignore the enter event we might get if the pointer is on the menu */
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
gtk_menu_scroll_to (menu, 0);
gtk_menu_shell_select_first (menu_shell, TRUE);
break;
case GTK_SCROLL_END:
/* Ignore the enter event we might get if the pointer is on the menu */
menu_shell->ignore_enter = TRUE;
menu_shell->priv->ignore_enter = TRUE;
gtk_menu_scroll_to (menu, end_position - page_size);
_gtk_menu_shell_select_last (menu_shell, TRUE);
break;
@ -5647,7 +5647,7 @@ gtk_menu_grab_notify (GtkWidget *widget,
group = gtk_window_get_group (GTK_WINDOW (toplevel));
grab = gtk_window_group_get_current_device_grab (group, pointer);
if (GTK_MENU_SHELL (widget)->active && !GTK_IS_MENU_SHELL (grab))
if (GTK_MENU_SHELL (widget)->priv->active && !GTK_IS_MENU_SHELL (grab))
gtk_menu_shell_cancel (GTK_MENU_SHELL (widget));
}

View File

@ -34,6 +34,7 @@
#include "gtkmarshalers.h"
#include "gtkmenuitem.h"
#include "gtkmenuprivate.h"
#include "gtkmenushellprivate.h"
#include "gtksettings.h"
#include "gtksizerequest.h"
#include "gtkwindow.h"
@ -301,7 +302,7 @@ gtk_menu_bar_size_request (GtkWidget *widget,
priv = menu_bar->priv;
nchildren = 0;
children = menu_shell->children;
children = menu_shell->priv->children;
while (children)
{
@ -425,7 +426,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
if (menu_shell->children)
if (menu_shell->priv->children)
{
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
child_allocation.x = (border_width +
@ -454,15 +455,15 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
priv->pack_direction == GTK_PACK_DIRECTION_RTL)
{
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
offset = child_allocation.x; /* Window edge to menubar start */
ltr_x = child_allocation.x;
children = menu_shell->children;
while (children)
{
gint toggle_size;
offset = child_allocation.x; /* Window edge to menubar start */
ltr_x = child_allocation.x;
children = menu_shell->priv->children;
while (children)
{
gint toggle_size;
child = children->data;
children = children->next;
@ -504,15 +505,15 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
else
{
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
offset = child_allocation.y; /* Window edge to menubar start */
ltr_y = child_allocation.y;
children = menu_shell->children;
while (children)
{
gint toggle_size;
offset = child_allocation.y; /* Window edge to menubar start */
ltr_y = child_allocation.y;
children = menu_shell->priv->children;
while (children)
{
gint toggle_size;
child = children->data;
children = children->next;
@ -766,8 +767,8 @@ _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
if (current && current->next)
{
GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
if (new_menushell->children)
to_activate = new_menushell->children->data;
if (new_menushell->priv->children)
to_activate = new_menushell->priv->children->data;
}
}
@ -912,7 +913,7 @@ gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
gtk_widget_queue_resize (GTK_WIDGET (menubar));
for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
gtk_widget_queue_resize (GTK_WIDGET (l->data));
g_object_notify (G_OBJECT (menubar), "pack-direction");
@ -965,7 +966,7 @@ gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
gtk_widget_queue_resize (GTK_WIDGET (menubar));
for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
gtk_widget_queue_resize (GTK_WIDGET (l->data));
g_object_notify (G_OBJECT (menubar), "child-pack-direction");

View File

@ -31,6 +31,7 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkmenuprivate.h"
#include "gtkmenushellprivate.h"
#include "gtkmenubar.h"
#include "gtkmenuprivate.h"
#include "gtkseparatormenuitem.h"
@ -1656,7 +1657,7 @@ gtk_menu_item_mnemonic_activate (GtkWidget *widget,
if (group_cycling &&
parent &&
GTK_IS_MENU_SHELL (parent) &&
GTK_MENU_SHELL (parent)->active)
GTK_MENU_SHELL (parent)->priv->active)
{
gtk_menu_shell_select_item (GTK_MENU_SHELL (parent),
widget);
@ -1816,7 +1817,7 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
widget,
menu_position_func,
menu_item,
GTK_MENU_SHELL (parent)->button,
GTK_MENU_SHELL (parent)->priv->button,
0);
}
@ -1836,12 +1837,12 @@ gtk_menu_item_popup_timeout (gpointer data)
parent = gtk_widget_get_parent (GTK_WIDGET (menu_item));
if ((GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->active) ||
if ((GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->priv->active) ||
(GTK_IS_MENU (parent) && GTK_MENU (parent)->priv->torn_off))
{
gtk_menu_item_real_popup_submenu (GTK_WIDGET (menu_item), TRUE);
if (menu_item->timer_from_keypress && menu_item->submenu)
GTK_MENU_SHELL (menu_item->submenu)->ignore_enter = TRUE;
GTK_MENU_SHELL (menu_item->submenu)->priv->ignore_enter = TRUE;
}
menu_item->timer = 0;

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
@ -37,59 +37,48 @@
G_BEGIN_DECLS
#define GTK_TYPE_MENU_SHELL (gtk_menu_shell_get_type ())
#define GTK_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_SHELL, GtkMenuShell))
#define GTK_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_SHELL, GtkMenuShellClass))
#define GTK_IS_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_SHELL))
#define GTK_IS_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_SHELL))
#define GTK_TYPE_MENU_SHELL (gtk_menu_shell_get_type ())
#define GTK_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_SHELL, GtkMenuShell))
#define GTK_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_SHELL, GtkMenuShellClass))
#define GTK_IS_MENU_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_SHELL))
#define GTK_IS_MENU_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_SHELL))
#define GTK_MENU_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU_SHELL, GtkMenuShellClass))
typedef struct _GtkMenuShell GtkMenuShell;
typedef struct _GtkMenuShellClass GtkMenuShellClass;
typedef struct _GtkMenuShell GtkMenuShell;
typedef struct _GtkMenuShellClass GtkMenuShellClass;
typedef struct _GtkMenuShellPrivate GtkMenuShellPrivate;
struct _GtkMenuShell
{
GtkContainer container;
GList *GSEAL (children);
GtkWidget *GSEAL (active_menu_item);
GtkWidget *GSEAL (parent_menu_shell);
guint GSEAL (button);
guint32 GSEAL (activate_time);
guint GSEAL (active) : 1;
guint GSEAL (have_grab) : 1;
guint GSEAL (have_xgrab) : 1;
guint GSEAL (ignore_leave) : 1; /* unused */
guint GSEAL (menu_flag) : 1; /* unused */
guint GSEAL (ignore_enter) : 1;
guint GSEAL (keyboard_mode) : 1;
/*< private >*/
GtkMenuShellPrivate *priv;
};
struct _GtkMenuShellClass
{
GtkContainerClass parent_class;
guint submenu_placement : 1;
void (*deactivate) (GtkMenuShell *menu_shell);
void (*selection_done) (GtkMenuShell *menu_shell);
void (*move_current) (GtkMenuShell *menu_shell,
GtkMenuDirectionType direction);
void (*activate_current) (GtkMenuShell *menu_shell,
gboolean force_hide);
void (*cancel) (GtkMenuShell *menu_shell);
void (*select_item) (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
void (*insert) (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
gint (*get_popup_delay) (GtkMenuShell *menu_shell);
gboolean (*move_selected) (GtkMenuShell *menu_shell,
gint distance);
guint submenu_placement : 1;
void (*deactivate) (GtkMenuShell *menu_shell);
void (*selection_done) (GtkMenuShell *menu_shell);
void (*move_current) (GtkMenuShell *menu_shell,
GtkMenuDirectionType direction);
void (*activate_current) (GtkMenuShell *menu_shell,
gboolean force_hide);
void (*cancel) (GtkMenuShell *menu_shell);
void (*select_item) (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
void (*insert) (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
gint (*get_popup_delay) (GtkMenuShell *menu_shell);
gboolean (*move_selected) (GtkMenuShell *menu_shell,
gint distance);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
@ -99,50 +88,29 @@ struct _GtkMenuShellClass
};
GType gtk_menu_shell_get_type (void) G_GNUC_CONST;
void gtk_menu_shell_append (GtkMenuShell *menu_shell,
GtkWidget *child);
void gtk_menu_shell_prepend (GtkMenuShell *menu_shell,
GtkWidget *child);
void gtk_menu_shell_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell);
void gtk_menu_shell_select_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
void gtk_menu_shell_deselect (GtkMenuShell *menu_shell);
void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item,
gboolean force_deactivate);
void gtk_menu_shell_select_first (GtkMenuShell *menu_shell,
gboolean search_sensitive);
void _gtk_menu_shell_select_last (GtkMenuShell *menu_shell,
gboolean search_sensitive);
void _gtk_menu_shell_activate (GtkMenuShell *menu_shell);
gint _gtk_menu_shell_get_popup_delay (GtkMenuShell *menu_shell);
void _gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
GdkDevice *device);
GdkDevice * _gtk_menu_shell_get_grab_device (GtkMenuShell *menu_shell);
void gtk_menu_shell_cancel (GtkMenuShell *menu_shell);
void _gtk_menu_shell_add_mnemonic (GtkMenuShell *menu_shell,
guint keyval,
GtkWidget *target);
void _gtk_menu_shell_remove_mnemonic (GtkMenuShell *menu_shell,
guint keyval,
GtkWidget *target);
GType gtk_menu_shell_get_type (void) G_GNUC_CONST;
void gtk_menu_shell_append (GtkMenuShell *menu_shell,
GtkWidget *child);
void gtk_menu_shell_prepend (GtkMenuShell *menu_shell,
GtkWidget *child);
void gtk_menu_shell_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell);
void gtk_menu_shell_select_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
void gtk_menu_shell_deselect (GtkMenuShell *menu_shell);
void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item,
gboolean force_deactivate);
void gtk_menu_shell_select_first (GtkMenuShell *menu_shell,
gboolean search_sensitive);
void gtk_menu_shell_cancel (GtkMenuShell *menu_shell);
gboolean gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell);
void gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell,
gboolean take_focus);
void _gtk_menu_shell_update_mnemonics (GtkMenuShell *menu_shell);
void _gtk_menu_shell_set_keyboard_mode (GtkMenuShell *menu_shell,
gboolean keyboard_mode);
gboolean _gtk_menu_shell_get_keyboard_mode (GtkMenuShell *menu_shell);
G_END_DECLS
#endif /* __GTK_MENU_SHELL_H__ */

82
gtk/gtkmenushellprivate.h Normal file
View File

@ -0,0 +1,82 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_MENU_SHELL_PRIVATE_H__
#define __GTK_MENU_SHELL_PRIVATE_H__
#include <gtk/gtkmenushell.h>
#include <gtk/gtkmnemonichash.h>
#include <gtk/gtkkeyhash.h>
G_BEGIN_DECLS
struct _GtkMenuShellPrivate
{
GList *children;
GtkWidget *active_menu_item;
GtkWidget *parent_menu_shell;
guint button;
guint32 activate_time;
guint active : 1;
guint have_grab : 1;
guint have_xgrab : 1;
guint ignore_enter : 1;
guint keyboard_mode : 1;
guint take_focus : 1;
guint activated_submenu : 1;
guint in_unselectable_item : 1; /* This flag is a crutch to keep
* mnemonics in the same menu if
* the user moves the mouse over
* an unselectable menuitem.
*/
GtkMnemonicHash *mnemonic_hash;
GtkKeyHash *key_hash;
GdkDevice *grab_pointer;
};
void _gtk_menu_shell_select_last (GtkMenuShell *menu_shell,
gboolean search_sensitive);
void _gtk_menu_shell_activate (GtkMenuShell *menu_shell);
gint _gtk_menu_shell_get_popup_delay (GtkMenuShell *menu_shell);
void _gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
GdkDevice *device);
GdkDevice *_gtk_menu_shell_get_grab_device (GtkMenuShell *menu_shell);
void _gtk_menu_shell_add_mnemonic (GtkMenuShell *menu_shell,
guint keyval,
GtkWidget *target);
void _gtk_menu_shell_remove_mnemonic (GtkMenuShell *menu_shell,
guint keyval,
GtkWidget *target);
void _gtk_menu_shell_update_mnemonics (GtkMenuShell *menu_shell);
void _gtk_menu_shell_set_keyboard_mode (GtkMenuShell *menu_shell,
gboolean keyboard_mode);
gboolean _gtk_menu_shell_get_keyboard_mode (GtkMenuShell *menu_shell);
G_END_DECLS
#endif /* __GTK_MENU_SHELL_PRIVATE_H__ */

View File

@ -38,6 +38,7 @@
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkmenu.h"
#include "gtkmenushellprivate.h"
#include "gtkmenubar.h"
#include "gtkmenutoolbutton.h"
#include "gtkseparatormenuitem.h"
@ -1955,9 +1956,9 @@ get_action_by_name (GtkUIManager *merge,
}
static gboolean
find_menu_position (GNode *node,
GtkWidget **menushell_p,
gint *pos_p)
find_menu_position (GNode *node,
GtkWidget **menushell_p,
gint *pos_p)
{
GtkWidget *menushell;
gint pos = 0;
@ -1998,7 +1999,7 @@ find_menu_position (GNode *node,
case NODE_TYPE_MENU_PLACEHOLDER:
menushell = gtk_widget_get_parent (NODE_INFO (parent)->proxy);
g_return_val_if_fail (GTK_IS_MENU_SHELL (menushell), FALSE);
pos = g_list_index (GTK_MENU_SHELL (menushell)->children,
pos = g_list_index (GTK_MENU_SHELL (menushell)->priv->children,
NODE_INFO (parent)->proxy) + 1;
break;
default:
@ -2025,7 +2026,7 @@ find_menu_position (GNode *node,
if (!GTK_IS_MENU_SHELL (menushell))
return FALSE;
pos = g_list_index (GTK_MENU_SHELL (menushell)->children, prev_child) + 1;
pos = g_list_index (GTK_MENU_SHELL (menushell)->priv->children, prev_child) + 1;
}
if (menushell_p)

View File

@ -5173,7 +5173,6 @@ gtk_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
GtkAllocation child_allocation;
GtkWidget *child;
guint border_width;