*/
#define GTK_MENU_INTERNALS
-
#include <config.h>
#include <string.h> /* memset */
#include "gdk/gdkkeysyms.h"
#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
CHILD_PROP_BOTTOM_ATTACH
};
-static void gtk_menu_class_init (GtkMenuClass *klass);
-static void gtk_menu_init (GtkMenu *menu);
static void gtk_menu_set_property (GObject *object,
guint prop_id,
const GValue *value,
static void _gtk_menu_refresh_accel_paths (GtkMenu *menu,
gboolean group_changed);
-static GtkMenuShellClass *parent_class = NULL;
static const gchar attach_data_key[] = "gtk-menu-attach-data";
static guint menu_signals[LAST_SIGNAL] = { 0 };
return G_TYPE_INSTANCE_GET_PRIVATE (menu, GTK_TYPE_MENU, GtkMenuPrivate);
}
-GType
-gtk_menu_get_type (void)
-{
- static GType menu_type = 0;
-
- if (!menu_type)
- {
- static const GTypeInfo menu_info =
- {
- sizeof (GtkMenuClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtk_menu_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkMenu),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_menu_init,
- };
-
- menu_type = g_type_register_static (GTK_TYPE_MENU_SHELL, I_("GtkMenu"),
- &menu_info, 0);
- }
-
- return menu_type;
-}
+G_DEFINE_TYPE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL)
static void
menu_queue_resize (GtkMenu *menu)
GtkMenuShellClass *menu_shell_class = GTK_MENU_SHELL_CLASS (class);
GtkBindingSet *binding_set;
- parent_class = g_type_class_peek_parent (class);
-
gobject_class->finalize = gtk_menu_finalize;
gobject_class->set_property = gtk_menu_set_property;
gobject_class->get_property = gtk_menu_get_property;
menu = GTK_MENU (object);
- gtk_menu_stop_scrolling (menu);
+ gtk_menu_remove_scroll_timeout (menu);
data = g_object_get_data (G_OBJECT (object), attach_data_key);
if (data)
priv->title = NULL;
}
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (gtk_menu_parent_class)->destroy (object);
}
static void
g_free (menu->accel_path);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtk_menu_parent_class)->finalize (object);
}
static void
menu->old_active_menu_item = NULL;
}
- GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
+ GTK_CONTAINER_CLASS (gtk_menu_parent_class)->remove (container, widget);
g_object_set_data (G_OBJECT (widget), I_(ATTACH_INFO_KEY), NULL);
menu_queue_resize (menu);
if (GTK_WIDGET_REALIZED (menu_shell))
gtk_widget_set_parent_window (child, menu->bin_window);
- GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
+ GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->insert (menu_shell, child, position);
menu_queue_resize (menu);
}
GtkMenuShell *menu_shell;
gboolean grab_keyboard;
GtkMenuPrivate *priv;
+ GtkWidget *parent_toplevel;
g_return_if_fail (GTK_IS_MENU (menu));
gtk_menu_reparent (menu, menu->toplevel, FALSE);
}
-
+
+ parent_toplevel = NULL;
if (parent_menu_shell)
+ parent_toplevel = gtk_widget_get_toplevel (parent_menu_shell);
+ else if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
{
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (parent_menu_shell);
- if (GTK_IS_WINDOW (toplevel))
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
- GTK_WINDOW (menu->toplevel));
+ GtkWidget *attach_widget = gtk_menu_get_attach_widget (menu);
+ if (attach_widget)
+ parent_toplevel = gtk_widget_get_toplevel (attach_widget);
}
+
+ /* Set transient for to get the right window group and parent relationship */
+ if (parent_toplevel && GTK_IS_WINDOW (parent_toplevel))
+ gtk_window_set_transient_for (GTK_WINDOW (menu->toplevel),
+ GTK_WINDOW (parent_toplevel));
menu->parent_menu_item = parent_menu_item;
menu->position_func = func;
menu_shell = GTK_MENU_SHELL (menu);
private = gtk_menu_get_private (menu);
-
+
menu_shell->parent_menu_shell = NULL;
menu_shell->active = FALSE;
menu_shell->ignore_enter = FALSE;
/* The X Grab, if present, will automatically be removed when we hide
* the window */
gtk_widget_hide (menu->toplevel);
- gtk_window_group_add_window (gtk_window_get_group (NULL), GTK_WINDOW (menu->toplevel));
+ gtk_window_set_transient_for (GTK_WINDOW (menu->toplevel), NULL);
if (menu->torn_off)
{
"app-paintable", TRUE,
NULL);
-
gtk_window_set_type_hint (GTK_WINDOW (menu->tearoff_window),
GDK_WINDOW_TYPE_HINT_MENU);
gtk_window_set_mnemonic_modifier (GTK_WINDOW (menu->tearoff_window), 0);
* @title: a string containing the title for the menu.
*
* Sets the title string for the menu. The title is displayed when the menu
- * is shown as a tearoff menu.
+ * is shown as a tearoff menu. If @title is %NULL, the menu will see if it is
+ * attached to a parent menu item, and if so it will try to use the same text as
+ * that menu item's label.
**/
-void
+void
gtk_menu_set_title (GtkMenu *menu,
const gchar *title)
{
GtkMenuPrivate *priv;
+ char *old_title;
g_return_if_fail (GTK_IS_MENU (menu));
priv = gtk_menu_get_private (menu);
- if (strcmp (title ? title : "", priv->title ? priv->title : "") != 0)
- {
- g_free (priv->title);
- priv->title = g_strdup (title);
+ old_title = priv->title;
+ priv->title = g_strdup (title);
+ g_free (old_title);
- gtk_menu_update_title (menu);
- g_object_notify (G_OBJECT (menu), "tearoff-title");
- }
+ gtk_menu_update_title (menu);
+ g_object_notify (G_OBJECT (menu), "tearoff-title");
}
/**
GList *children;
guint vertical_padding;
guint horizontal_padding;
+ guint scroll_arrow_height;
g_return_if_fail (GTK_IS_MENU (widget));
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
attributes.x = border_width + widget->style->xthickness + horizontal_padding;
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);
gdk_window_destroy (menu->bin_window);
menu->bin_window = NULL;
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+ (* GTK_WIDGET_CLASS (gtk_menu_parent_class)->unrealize) (widget);
}
static void
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);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness + horizontal_padding;
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))
{
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);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
- NULL);
+ "scroll-arrow-vlength", &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;
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,
border_x,
border_y,
width - 2 * border_x,
- MENU_SCROLL_ARROW_HEIGHT);
+ scroll_arrow_height);
gtk_paint_arrow (widget->style,
widget->window,
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,
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);
}
{
gtk_menu_paint (widget, event);
- (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
+ (* GTK_WIDGET_CLASS (gtk_menu_parent_class)->expose_event) (widget, event);
}
return FALSE;
_gtk_menu_refresh_accel_paths (menu, FALSE);
- GTK_WIDGET_CLASS (parent_class)->show (widget);
+ GTK_WIDGET_CLASS (gtk_menu_parent_class)->show (widget);
}
static gboolean
if (gtk_menu_button_scroll (widget, event))
return TRUE;
- return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
+ return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_press_event (widget, event);
}
static gboolean
if (gtk_menu_button_scroll (widget, event))
return TRUE;
- return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
+ return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_release_event (widget, event);
}
static const gchar *
gtk_menu_stop_navigating_submenu (menu);
- if (GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event))
+ if (GTK_WIDGET_CLASS (gtk_menu_parent_class)->key_press_event (widget, event))
return TRUE;
display = gtk_widget_get_display (widget);
"gtk-can-change-accels", &can_change_accels,
NULL);
- if (accel)
+ if (accel && *accel)
{
guint keyval = 0;
GdkModifierType mods = 0;
* (basically, those items are accelerator-locked).
*/
/* g_print("item has no path or is locked, menu prefix: %s\n", menu->accel_path); */
- gdk_display_beep (display);
+ gtk_widget_error_bell (widget);
}
else
{
* locked already
*/
/* g_print("failed to change\n"); */
- gdk_display_beep (display);
+ gtk_widget_error_bell (widget);
}
}
}
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-vlength", &scroll_arrow_height,
+ NULL);
+
double_arrows = get_double_arrows (menu);
/* If we scroll upward and the non-visible top part
* 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: */
/* 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))
GtkSettings *settings;
gboolean touchscreen_mode;
- GDK_THREADS_ENTER ();
-
menu = GTK_MENU (data);
settings = gtk_widget_get_settings (GTK_WIDGET (menu));
gtk_menu_do_timeout_scroll (menu, touchscreen_mode);
- GDK_THREADS_LEAVE ();
-
return TRUE;
}
guint timeout;
gboolean touchscreen_mode;
- GDK_THREADS_ENTER ();
-
menu = GTK_MENU (data);
settings = gtk_widget_get_settings (GTK_WIDGET (menu));
gtk_menu_remove_scroll_timeout (menu);
- menu->timeout_id = g_timeout_add (timeout, gtk_menu_scroll_timeout, menu);
-
- GDK_THREADS_LEAVE ();
+ menu->timeout_id = gdk_threads_add_timeout (timeout, gtk_menu_scroll_timeout, menu);
return FALSE;
}
gtk_menu_do_timeout_scroll (menu, touchscreen_mode);
- menu->timeout_id = g_timeout_add (timeout, gtk_menu_scroll_timeout_initial,
+ menu->timeout_id = gdk_threads_add_timeout (timeout, gtk_menu_scroll_timeout_initial,
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);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
border = GTK_CONTAINER (menu)->border_width +
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 &&
-MENU_SCROLL_STEP2 : -MENU_SCROLL_STEP1;
menu->timeout_id =
- g_timeout_add (scroll_fast ?
+ gdk_threads_add_timeout (scroll_fast ?
MENU_SCROLL_TIMEOUT2 : MENU_SCROLL_TIMEOUT1,
gtk_menu_scroll_timeout, 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 &&
MENU_SCROLL_STEP2 : MENU_SCROLL_STEP1;
menu->timeout_id =
- g_timeout_add (scroll_fast ?
+ gdk_threads_add_timeout (scroll_fast ?
MENU_SCROLL_TIMEOUT2 : MENU_SCROLL_TIMEOUT1,
gtk_menu_scroll_timeout, menu);
}
event->x_root, event->y_root))
return TRUE;
- return GTK_WIDGET_CLASS (parent_class)->enter_notify_event (widget, event);
+ return GTK_WIDGET_CLASS (gtk_menu_parent_class)->enter_notify_event (widget, event);
}
static gboolean
}
}
- return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event);
+ return GTK_WIDGET_CLASS (gtk_menu_parent_class)->leave_notify_event (widget, event);
}
static void
{
gdk_region_destroy (menu->navigation_region);
menu->navigation_region = NULL;
- }
-
+ }
if (menu->navigation_timeout)
{
g_source_remove (menu->navigation_timeout);
GtkMenu *menu = user_data;
GdkWindow *child_window;
- GDK_THREADS_ENTER ();
-
gtk_menu_stop_navigating_submenu (menu);
if (GTK_WIDGET_REALIZED (menu))
send_event->crossing.time = GDK_CURRENT_TIME; /* Bogus */
send_event->crossing.send_event = TRUE;
- GTK_WIDGET_CLASS (parent_class)->enter_notify_event (GTK_WIDGET (menu), (GdkEventCrossing *)send_event);
+ GTK_WIDGET_CLASS (gtk_menu_parent_class)->enter_notify_event (GTK_WIDGET (menu), (GdkEventCrossing *)send_event);
gdk_event_free (send_event);
}
}
- GDK_THREADS_LEAVE ();
-
return FALSE;
}
"gtk-menu-popdown-delay", &popdown_delay,
NULL);
- menu->navigation_timeout = g_timeout_add (popdown_delay,
+ menu->navigation_timeout = gdk_threads_add_timeout (popdown_delay,
gtk_menu_stop_navigating_submenu_cb, menu);
#ifdef DRAW_STAY_UP_TRIANGLE
GdkScreen *screen;
GdkScreen *pointer_screen;
GdkRectangle monitor;
-
+ gint scroll_arrow_height;
+
g_return_if_fail (GTK_IS_MENU (menu));
widget = GTK_WIDGET (menu);
gdk_display_get_pointer (gdk_screen_get_display (screen),
&pointer_screen, &x, &y, NULL);
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &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,
private->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
private->initially_pushed_in = FALSE;
+
+ /* Set the type hint here to allow custom position functions to set a different hint */
+ if (!GTK_WIDGET_VISIBLE (menu->toplevel))
+ gtk_window_set_type_hint (GTK_WINDOW (menu->toplevel), GDK_WINDOW_TYPE_HINT_POPUP_MENU);
if (menu->position_func)
{
}
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);
gboolean touchscreen_mode;
gtk_menu_remove_scroll_timeout (menu);
-
+
g_object_get (G_OBJECT (settings),
- "gtk-touchscreen-mode", &touchscreen_mode,
- NULL);
-
+ "gtk-touchscreen-mode", &touchscreen_mode,
+ NULL);
+
if (!touchscreen_mode)
{
menu->upper_arrow_prelight = FALSE;
guint vertical_padding;
guint horizontal_padding;
gboolean double_arrows;
-
+ gint scroll_arrow_height;
+
widget = GTK_WIDGET (menu);
if (menu->tearoff_active &&
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
+ "scroll-arrow-vlength", &scroll_arrow_height,
NULL);
double_arrows = get_double_arrows (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;
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)
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)
}
if (menu->upper_arrow_visible)
- y += MENU_SCROLL_ARROW_HEIGHT;
+ y += scroll_arrow_height;
}
/* Scroll the menu: */
{
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-vlength", &scroll_arrow_height,
NULL);
double_arrows = get_double_arrows (menu);
{
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
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);
+ GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->select_item (menu_shell, menu_item);
}
}
}
- GTK_MENU_SHELL_CLASS (parent_class)->move_current (menu_shell, direction);
+ GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->move_current (menu_shell, direction);
}
static gint
{
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-vlength", &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;
}
{
gint height;
GtkWidget *widget = GTK_WIDGET (menu);
+ gint scroll_arrow_height;
+ gtk_widget_style_get (GTK_WIDGET (menu),
+ "scroll-arrow-vlength", &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;
}
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-vlength", &scroll_arrow_height,
+ NULL);
switch (type)
{
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)