API: menu: Remove tearoff support

This commit is contained in:
Benjamin Otte 2016-09-05 03:09:20 +02:00
parent 1a0a423250
commit 4ed9452e90
17 changed files with 33 additions and 1668 deletions

View File

@ -28,7 +28,6 @@ deprecated_h_sources = \
deprecated/gtkstyleproperties.h \
deprecated/gtksymboliccolor.h \
deprecated/gtktable.h \
deprecated/gtktearoffmenuitem.h \
deprecated/gtkthemingengine.h \
deprecated/gtktoggleaction.h \
deprecated/gtkuimanager.h \
@ -76,7 +75,6 @@ deprecated_c_sources = \
deprecated/gtkstyleproperties.c \
deprecated/gtksymboliccolor.c \
deprecated/gtktable.c \
deprecated/gtktearoffmenuitem.c \
deprecated/gtkthemingengine.c \
deprecated/gtktoggleaction.c \
deprecated/gtkuimanager.c \

View File

@ -97,7 +97,6 @@
#include "gtkmarshalers.h"
#include "gtkmenuitem.h"
#include "gtkstock.h"
#include "gtktearoffmenuitem.h"
#include "gtktoolbutton.h"
#include "gtktoolbar.h"
#include "gtkprivate.h"

View File

@ -1,328 +0,0 @@
/* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gtkmenu.h"
#include "gtkmenuitemprivate.h"
#include "gtkrender.h"
#include "gtkstylecontext.h"
#include "gtktearoffmenuitem.h"
#include "gtkintl.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* SECTION:gtktearoffmenuitem
* @Short_description: A menu item used to tear off and reattach its menu
* @Title: GtkTearoffMenuItem
* @See_also: #GtkMenu
*
* A #GtkTearoffMenuItem is a special #GtkMenuItem which is used to
* tear off and reattach its menu.
*
* When its menu is shown normally, the #GtkTearoffMenuItem is drawn as a
* dotted line indicating that the menu can be torn off. Activating it
* causes its menu to be torn off and displayed in its own window
* as a tearoff menu.
*
* When its menu is shown as a tearoff menu, the #GtkTearoffMenuItem is drawn
* as a dotted line which has a left pointing arrow graphic indicating that
* the tearoff menu can be reattached. Activating it will erase the tearoff
* menu window.
*
* > #GtkTearoffMenuItem is deprecated and should not be used in newly
* > written code. Menus are not meant to be torn around.
*/
#define ARROW_SIZE 10
#define TEAR_LENGTH 5
#define BORDER_SPACING 3
struct _GtkTearoffMenuItemPrivate
{
guint torn_off : 1;
};
static void gtk_tearoff_menu_item_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static gboolean gtk_tearoff_menu_item_draw (GtkWidget *widget,
cairo_t *cr);
static void gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item);
static void gtk_tearoff_menu_item_parent_set (GtkWidget *widget,
GtkWidget *previous);
G_DEFINE_TYPE_WITH_PRIVATE (GtkTearoffMenuItem, gtk_tearoff_menu_item, GTK_TYPE_MENU_ITEM)
/**
* gtk_tearoff_menu_item_new:
*
* Creates a new #GtkTearoffMenuItem.
*
* Returns: a new #GtkTearoffMenuItem.
*
* Deprecated: 3.4: #GtkTearoffMenuItem is deprecated and should not be
* used in newly written code.
*/
GtkWidget*
gtk_tearoff_menu_item_new (void)
{
return g_object_new (GTK_TYPE_TEAROFF_MENU_ITEM, NULL);
}
static void
gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass)
{
GtkWidgetClass *widget_class;
GtkMenuItemClass *menu_item_class;
widget_class = (GtkWidgetClass*) klass;
menu_item_class = (GtkMenuItemClass*) klass;
widget_class->draw = gtk_tearoff_menu_item_draw;
widget_class->get_preferred_width = gtk_tearoff_menu_item_get_preferred_width;
widget_class->get_preferred_height = gtk_tearoff_menu_item_get_preferred_height;
widget_class->parent_set = gtk_tearoff_menu_item_parent_set;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TEAR_OFF_MENU_ITEM);
menu_item_class->activate = gtk_tearoff_menu_item_activate;
}
static void
gtk_tearoff_menu_item_init (GtkTearoffMenuItem *self)
{
self->priv = gtk_tearoff_menu_item_get_instance_private (self);
self->priv->torn_off = FALSE;
}
static void
gtk_tearoff_menu_item_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkStyleContext *context;
guint border_width;
GtkBorder padding;
GtkStateFlags state;
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
*minimum = *natural = (border_width + BORDER_SPACING) * 2 + padding.left + padding.right;
}
static void
gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkStyleContext *context;
GtkBorder padding;
GtkStateFlags state;
GtkWidget *parent;
guint border_width;
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
*minimum = *natural = (border_width * 2) + padding.top + padding.bottom;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU (parent) && gtk_menu_get_tearoff_state (GTK_MENU (parent)))
{
*minimum += ARROW_SIZE;
*natural += ARROW_SIZE;
}
else
{
*minimum += padding.top + 4;
*natural += padding.top + 4;
}
}
static gboolean
gtk_tearoff_menu_item_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkMenuItem *menu_item;
GtkStateFlags state;
GtkStyleContext *context;
GtkBorder padding;
gint x, y, width, height;
gint right_max;
guint border_width;
GtkTextDirection direction;
GtkWidget *parent;
gdouble angle;
menu_item = GTK_MENU_ITEM (widget);
context = gtk_widget_get_style_context (widget);
direction = gtk_widget_get_direction (widget);
state = gtk_widget_get_state_flags (widget);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_item));
x = border_width;
y = border_width;
width = gtk_widget_get_allocated_width (widget) - border_width * 2;
height = gtk_widget_get_allocated_height (widget) - border_width * 2;
right_max = x + width;
gtk_style_context_save (context);
gtk_style_context_set_state (context, state);
gtk_style_context_get_padding (context, state, &padding);
if (state & GTK_STATE_FLAG_PRELIGHT)
{
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
}
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU (parent) && gtk_menu_get_tearoff_state (GTK_MENU (parent)))
{
gint arrow_x;
if (menu_item->priv->toggle_size > ARROW_SIZE)
{
if (direction == GTK_TEXT_DIR_LTR)
{
arrow_x = x + (menu_item->priv->toggle_size - ARROW_SIZE)/2;
angle = (3 * G_PI) / 2;
}
else
{
arrow_x = x + width - menu_item->priv->toggle_size + (menu_item->priv->toggle_size - ARROW_SIZE)/2;
angle = G_PI / 2;
}
x += menu_item->priv->toggle_size + BORDER_SPACING;
}
else
{
if (direction == GTK_TEXT_DIR_LTR)
{
arrow_x = ARROW_SIZE / 2;
angle = (3 * G_PI) / 2;
}
else
{
arrow_x = x + width - 2 * ARROW_SIZE + ARROW_SIZE / 2;
angle = G_PI / 2;
}
x += 2 * ARROW_SIZE;
}
gtk_render_arrow (context, cr, angle,
arrow_x, height / 2 - 5,
ARROW_SIZE);
}
while (x < right_max)
{
gint x1, x2;
if (direction == GTK_TEXT_DIR_LTR)
{
x1 = x;
x2 = MIN (x + TEAR_LENGTH, right_max);
}
else
{
x1 = right_max - x;
x2 = MAX (right_max - x - TEAR_LENGTH, 0);
}
gtk_render_line (context, cr,
x1, y + (height - padding.bottom) / 2,
x2, y + (height - padding.bottom) / 2);
x += 2 * TEAR_LENGTH;
}
gtk_style_context_restore (context);
return FALSE;
}
static void
gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item)
{
GtkWidget *parent;
parent = gtk_widget_get_parent (GTK_WIDGET (menu_item));
if (GTK_IS_MENU (parent))
{
GtkMenu *menu = GTK_MENU (parent);
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
gtk_menu_set_tearoff_state (menu, !gtk_menu_get_tearoff_state (menu));
}
}
static void
tearoff_state_changed (GtkMenu *menu,
GParamSpec *pspec,
gpointer data)
{
GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (data);
GtkTearoffMenuItemPrivate *priv = tearoff_menu_item->priv;
priv->torn_off = gtk_menu_get_tearoff_state (menu);
}
static void
gtk_tearoff_menu_item_parent_set (GtkWidget *widget,
GtkWidget *previous)
{
GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (widget);
GtkTearoffMenuItemPrivate *priv = tearoff_menu_item->priv;
GtkMenu *menu;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL;
if (previous)
g_signal_handlers_disconnect_by_func (previous,
tearoff_state_changed,
tearoff_menu_item);
if (menu)
{
priv->torn_off = gtk_menu_get_tearoff_state (menu);
g_signal_connect (menu, "notify::tearoff-state",
G_CALLBACK (tearoff_state_changed),
tearoff_menu_item);
}
}

View File

@ -1,81 +0,0 @@
/* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_TEAROFF_MENU_ITEM_H__
#define __GTK_TEAROFF_MENU_ITEM_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkmenuitem.h>
G_BEGIN_DECLS
#define GTK_TYPE_TEAROFF_MENU_ITEM (gtk_tearoff_menu_item_get_type ())
#define GTK_TEAROFF_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEAROFF_MENU_ITEM, GtkTearoffMenuItem))
#define GTK_TEAROFF_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEAROFF_MENU_ITEM, GtkTearoffMenuItemClass))
#define GTK_IS_TEAROFF_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEAROFF_MENU_ITEM))
#define GTK_IS_TEAROFF_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEAROFF_MENU_ITEM))
#define GTK_TEAROFF_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEAROFF_MENU_ITEM, GtkTearoffMenuItemClass))
typedef struct _GtkTearoffMenuItem GtkTearoffMenuItem;
typedef struct _GtkTearoffMenuItemPrivate GtkTearoffMenuItemPrivate;
typedef struct _GtkTearoffMenuItemClass GtkTearoffMenuItemClass;
struct _GtkTearoffMenuItem
{
GtkMenuItem menu_item;
/*< private >*/
GtkTearoffMenuItemPrivate *priv;
};
/**
* GtkTearoffMenuItemClass:
* @parent_class: The parent class.
*/
struct _GtkTearoffMenuItemClass
{
GtkMenuItemClass parent_class;
/*< private >*/
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GDK_DEPRECATED_IN_3_4
GType gtk_tearoff_menu_item_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_4
GtkWidget* gtk_tearoff_menu_item_new (void);
G_END_DECLS
#endif /* __GTK_TEAROFF_MENU_ITEM_H__ */

View File

@ -48,7 +48,6 @@
#include "gtkprivate.h"
#include "gtkuimanager.h"
#include "gtktearoffmenuitem.h"
/**
* SECTION:gtkuimanager
@ -325,8 +324,6 @@ struct _GtkUIManagerPrivate
guint last_merge_id;
guint update_tag;
gboolean add_tearoffs;
};
#define NODE_INFO(node) ((Node *)node->data)
@ -394,8 +391,6 @@ static void gtk_ui_manager_buildable_custom_tag_end (GtkBuildable *buildab
GObject *child,
const gchar *tagname,
gpointer *data);
static void gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
gboolean add_tearoffs);
@ -413,7 +408,6 @@ enum
enum
{
PROP_0,
PROP_ADD_TEAROFFS,
PROP_UI
};
@ -437,28 +431,6 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass)
klass->get_widget = gtk_ui_manager_real_get_widget;
klass->get_action = gtk_ui_manager_real_get_action;
/**
* GtkUIManager:add-tearoffs:
*
* The "add-tearoffs" property controls whether generated menus
* have tearoff menu items.
*
* Note that this only affects regular menus. Generated popup
* menus never have tearoff menu items.
*
* Since: 2.4
*
* Deprecated: 3.4: Tearoff menus are deprecated and should not
* be used in newly written code.
*/
g_object_class_install_property (gobject_class,
PROP_ADD_TEAROFFS,
g_param_spec_boolean ("add-tearoffs",
P_("Add tearoffs to menus"),
P_("Whether tearoff menu items should be added to menus"),
FALSE,
GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
g_object_class_install_property (gobject_class,
PROP_UI,
g_param_spec_string ("ui",
@ -635,7 +607,6 @@ gtk_ui_manager_init (GtkUIManager *manager)
manager->private_data->action_groups = NULL;
manager->private_data->last_merge_id = 0;
manager->private_data->add_tearoffs = FALSE;
merge_id = gtk_ui_manager_new_merge_id (manager);
node = get_child_node (manager, NULL, NULL, "ui", 2,
@ -749,13 +720,8 @@ gtk_ui_manager_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GtkUIManager *manager = GTK_UI_MANAGER (object);
switch (prop_id)
{
case PROP_ADD_TEAROFFS:
gtk_ui_manager_do_set_add_tearoffs (manager, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -772,9 +738,6 @@ gtk_ui_manager_get_property (GObject *object,
switch (prop_id)
{
case PROP_ADD_TEAROFFS:
g_value_set_boolean (value, manager->private_data->add_tearoffs);
break;
case PROP_UI:
g_value_take_string (value, gtk_ui_manager_get_ui (manager));
break;
@ -838,71 +801,6 @@ gtk_ui_manager_new (void)
return g_object_new (GTK_TYPE_UI_MANAGER, NULL);
}
/**
* gtk_ui_manager_get_add_tearoffs:
* @manager: a #GtkUIManager
*
* Returns whether menus generated by this #GtkUIManager
* will have tearoff menu items.
*
* Returns: whether tearoff menu items are added
*
* Since: 2.4
*
* Deprecated: 3.4: Tearoff menus are deprecated and should not
* be used in newly written code.
**/
gboolean
gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager)
{
g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), FALSE);
return manager->private_data->add_tearoffs;
}
/**
* gtk_ui_manager_set_add_tearoffs:
* @manager: a #GtkUIManager
* @add_tearoffs: whether tearoff menu items are added
*
* Sets the add_tearoffs property, which controls whether menus
* generated by this #GtkUIManager will have tearoff menu items.
*
* Note that this only affects regular menus. Generated popup
* menus never have tearoff menu items.
*
* Since: 2.4
*
* Deprecated: 3.4: Tearoff menus are deprecated and should not
* be used in newly written code.
**/
void
gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
gboolean add_tearoffs)
{
g_return_if_fail (GTK_IS_UI_MANAGER (manager));
gtk_ui_manager_do_set_add_tearoffs (manager, add_tearoffs);
}
static void
gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
gboolean add_tearoffs)
{
add_tearoffs = add_tearoffs != FALSE;
if (add_tearoffs != manager->private_data->add_tearoffs)
{
manager->private_data->add_tearoffs = add_tearoffs;
dirty_all_nodes (manager);
g_object_notify (G_OBJECT (manager), "add-tearoffs");
}
}
static void
cb_proxy_connect_proxy (GtkActionGroup *group,
GtkAction *action,
@ -2289,7 +2187,6 @@ find_menu_position (GNode *node,
if (node->prev == NULL)
{
GNode *parent;
GList *siblings;
parent = node->parent;
switch (NODE_INFO (parent)->type)
@ -2303,18 +2200,6 @@ find_menu_position (GNode *node,
menushell = NODE_INFO (parent)->proxy;
if (GTK_IS_MENU_ITEM (menushell))
menushell = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menushell));
siblings = gtk_container_get_children (GTK_CONTAINER (menushell));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
pos = 1;
else
pos = 0;
G_GNUC_END_IGNORE_DEPRECATIONS
g_list_free (siblings);
break;
case NODE_TYPE_MENU_PLACEHOLDER:
menushell = gtk_widget_get_parent (NODE_INFO (parent)->proxy);
@ -2495,9 +2380,7 @@ update_smart_separators (GtkWidget *proxy)
{
last = NULL;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (GTK_IS_TEAROFF_MENU_ITEM (cur->data) || cur->data == filler)
if (cur->data == filler)
visible = FALSE;
else
{
@ -2505,8 +2388,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
empty = FALSE;
}
G_GNUC_END_IGNORE_DEPRECATIONS
}
cur = cur->next;
@ -2596,35 +2477,7 @@ update_node (GtkUIManager *manager,
* we only have to update the tearoff menu items.
*/
if (info->proxy != NULL && action == info->action)
{
if (info->type == NODE_TYPE_MENU)
{
GtkWidget *menu;
GList *siblings;
if (GTK_IS_MENU (info->proxy))
menu = info->proxy;
else
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
siblings = gtk_container_get_children (GTK_CONTAINER (menu));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
{
if (manager->private_data->add_tearoffs && !in_popup)
gtk_widget_show (GTK_WIDGET (siblings->data));
else
gtk_widget_hide (GTK_WIDGET (siblings->data));
}
G_GNUC_END_IGNORE_DEPRECATIONS
g_list_free (siblings);
}
goto recurse_children;
}
goto recurse_children;
switch (info->type)
{
@ -2650,7 +2503,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
{
GtkWidget *prev_submenu = NULL;
GtkWidget *menu = NULL;
GList *siblings;
/* remove the proxy if it is of the wrong type ... */
if (info->proxy &&
@ -2688,18 +2540,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
if (!menu)
{
GtkWidget *tearoff;
GtkWidget *filler;
menu = gtk_menu_new ();
gtk_widget_set_name (menu, info->name);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
tearoff = gtk_tearoff_menu_item_new ();
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_no_show_all (tearoff, TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
filler = gtk_menu_item_new_with_label (_("Empty"));
g_object_set_data (G_OBJECT (filler),
I_("gtk-empty-menu-item"),
@ -2748,22 +2593,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
menu = info->proxy;
else
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
siblings = gtk_container_get_children (GTK_CONTAINER (menu));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
{
if (manager->private_data->add_tearoffs && !in_popup)
gtk_widget_show (GTK_WIDGET (siblings->data));
else
gtk_widget_hide (GTK_WIDGET (siblings->data));
}
G_GNUC_END_IGNORE_DEPRECATIONS
g_list_free (siblings);
}
break;
case NODE_TYPE_UNDECIDED:

View File

@ -128,11 +128,6 @@ GDK_DEPRECATED_IN_3_10
GType gtk_ui_manager_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_10
GtkUIManager *gtk_ui_manager_new (void);
GDK_DEPRECATED_IN_3_4
void gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
gboolean add_tearoffs);
GDK_DEPRECATED_IN_3_4
gboolean gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager);
GDK_DEPRECATED_IN_3_10
void gtk_ui_manager_insert_action_group (GtkUIManager *manager,

View File

@ -273,7 +273,6 @@
#include <gtk/deprecated/gtkstyleproperties.h>
#include <gtk/deprecated/gtksymboliccolor.h>
#include <gtk/deprecated/gtktable.h>
#include <gtk/deprecated/gtktearoffmenuitem.h>
#include <gtk/deprecated/gtkthemingengine.h>
#include <gtk/deprecated/gtktoggleaction.h>
#include <gtk/deprecated/gtkuimanager.h>

View File

@ -36,7 +36,6 @@
#include "gtkmenuprivate.h"
#include "gtkmenushellprivate.h"
#include "gtkscrolledwindow.h"
#include "deprecated/gtktearoffmenuitem.h"
#include "gtktogglebutton.h"
#include "gtktreeselection.h"
#include "gtkwidgetpath.h"
@ -170,7 +169,6 @@ struct _GtkComboBoxPrivate
guint popup_in_progress : 1;
guint popup_shown : 1;
guint add_tearoffs : 1;
guint has_frame : 1;
guint is_cell_renderer : 1;
guint editing_canceled : 1;
@ -184,8 +182,6 @@ struct _GtkComboBoxPrivate
GDestroyNotify row_separator_destroy;
GdkDevice *grab_pointer;
gchar *tearoff_title;
};
/* While debugging this evil code, I have learned that
@ -250,8 +246,6 @@ enum {
PROP_ROW_SPAN_COLUMN,
PROP_COLUMN_SPAN_COLUMN,
PROP_ACTIVE,
PROP_ADD_TEAROFFS,
PROP_TEAROFF_TITLE,
PROP_HAS_FRAME,
PROP_POPUP_SHOWN,
PROP_BUTTON_SENSITIVITY,
@ -385,7 +379,6 @@ static void gtk_combo_box_list_popup_resize (GtkComboBox *combo_box)
/* menu */
static void gtk_combo_box_menu_setup (GtkComboBox *combo_box);
static void gtk_combo_box_update_title (GtkComboBox *combo_box);
static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box);
@ -996,26 +989,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
-1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkComboBox:add-tearoffs:
*
* The add-tearoffs property controls whether generated menus
* have tearoff menu items.
*
* Note that this only affects menu style combo boxes.
*
* Since: 2.6
*
* Deprecated: 3.10
*/
g_object_class_install_property (object_class,
PROP_ADD_TEAROFFS,
g_param_spec_boolean ("add-tearoffs",
P_("Add tearoffs to menus"),
P_("Whether dropdowns should have a tearoff menu item"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED));
/**
* GtkComboBox:has-frame:
*
@ -1032,25 +1005,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkComboBox:tearoff-title:
*
* A title that may be displayed by the window manager
* when the popup is torn-off.
*
* Since: 2.10
*
* Deprecated: 3.10
*/
g_object_class_install_property (object_class,
PROP_TEAROFF_TITLE,
g_param_spec_string ("tearoff-title",
P_("Tearoff Title"),
P_("A title that may be displayed by the window manager when the popup is torn-off"),
NULL,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED));
/**
* GtkComboBox:popup-shown:
*
@ -1303,7 +1257,6 @@ gtk_combo_box_init (GtkComboBox *combo_box)
priv->row_column = -1;
priv->popup_shown = FALSE;
priv->add_tearoffs = FALSE;
priv->has_frame = TRUE;
priv->is_cell_renderer = FALSE;
priv->editing_canceled = FALSE;
@ -1366,12 +1319,6 @@ gtk_combo_box_set_property (GObject *object,
gtk_combo_box_set_active (combo_box, g_value_get_int (value));
break;
case PROP_ADD_TEAROFFS:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_combo_box_set_add_tearoffs (combo_box, g_value_get_boolean (value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_HAS_FRAME:
if (priv->has_frame != g_value_get_boolean (value))
{
@ -1383,12 +1330,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS;
}
break;
case PROP_TEAROFF_TITLE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_combo_box_set_title (combo_box, g_value_get_string (value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_POPUP_SHOWN:
if (g_value_get_boolean (value))
gtk_combo_box_popup (combo_box);
@ -1483,22 +1424,10 @@ gtk_combo_box_get_property (GObject *object,
g_value_set_int (value, gtk_combo_box_get_active (combo_box));
break;
case PROP_ADD_TEAROFFS:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_value_set_boolean (value, gtk_combo_box_get_add_tearoffs (combo_box));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_HAS_FRAME:
g_value_set_boolean (value, priv->has_frame);
break;
case PROP_TEAROFF_TITLE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_value_set_string (value, gtk_combo_box_get_title (combo_box));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_POPUP_SHOWN:
g_value_set_boolean (value, priv->popup_shown);
break;
@ -2126,9 +2055,6 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
path = gtk_tree_row_reference_get_path (priv->active_row);
active_item = gtk_tree_path_get_indices (path)[0];
gtk_tree_path_free (path);
if (priv->add_tearoffs)
active_item++;
}
/* FIXME handle nested menus better */
@ -2756,7 +2682,6 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box)
_gtk_tree_menu_set_wrap_width (GTK_TREE_MENU (menu), priv->wrap_width);
_gtk_tree_menu_set_row_span_column (GTK_TREE_MENU (menu), priv->row_column);
_gtk_tree_menu_set_column_span_column (GTK_TREE_MENU (menu), priv->col_column);
_gtk_tree_menu_set_tearoff (GTK_TREE_MENU (menu), priv->add_tearoffs);
g_signal_connect (menu, "menu-activate",
G_CALLBACK (gtk_combo_box_menu_activate), combo_box);
@ -2770,7 +2695,7 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box)
G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
gtk_combo_box_set_popup_widget (combo_box, menu);
gtk_combo_box_update_title (combo_box);
gtk_combo_box_check_appearance (combo_box);
}
static void
@ -4338,7 +4263,6 @@ gtk_combo_box_finalize (GObject *object)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (object);
g_free (combo_box->priv->tearoff_title);
g_clear_object (&combo_box->priv->gadget);
G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
@ -4472,130 +4396,6 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
}
}
/**
* gtk_combo_box_get_add_tearoffs:
* @combo_box: a #GtkComboBox
*
* Gets the current value of the :add-tearoffs property.
*
* Returns: the current value of the :add-tearoffs property.
*
* Deprecated: 3.10
*/
gboolean
gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box)
{
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
return combo_box->priv->add_tearoffs;
}
/**
* gtk_combo_box_set_add_tearoffs:
* @combo_box: a #GtkComboBox
* @add_tearoffs: %TRUE to add tearoff menu items
*
* Sets whether the popup menu should have a tearoff
* menu item.
*
* Since: 2.6
*
* Deprecated: 3.10
*/
void
gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
gboolean add_tearoffs)
{
GtkComboBoxPrivate *priv;
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
priv = combo_box->priv;
add_tearoffs = add_tearoffs != FALSE;
if (priv->add_tearoffs != add_tearoffs)
{
priv->add_tearoffs = add_tearoffs;
gtk_combo_box_check_appearance (combo_box);
if (GTK_IS_TREE_MENU (priv->popup_widget))
_gtk_tree_menu_set_tearoff (GTK_TREE_MENU (priv->popup_widget),
priv->add_tearoffs);
g_object_notify (G_OBJECT (combo_box), "add-tearoffs");
}
}
/**
* gtk_combo_box_get_title:
* @combo_box: a #GtkComboBox
*
* Gets the current title of the menu in tearoff mode. See
* gtk_combo_box_set_add_tearoffs().
*
* Returns: the menus title in tearoff mode. This is an internal copy of the
* string which must not be freed.
*
* Since: 2.10
*
* Deprecated: 3.10
*/
const gchar*
gtk_combo_box_get_title (GtkComboBox *combo_box)
{
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
return combo_box->priv->tearoff_title;
}
static void
gtk_combo_box_update_title (GtkComboBox *combo_box)
{
GtkComboBoxPrivate *priv = combo_box->priv;
gtk_combo_box_check_appearance (combo_box);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (priv->popup_widget && GTK_IS_MENU (priv->popup_widget))
gtk_menu_set_title (GTK_MENU (priv->popup_widget), priv->tearoff_title);
G_GNUC_END_IGNORE_DEPRECATIONS
}
/**
* gtk_combo_box_set_title:
* @combo_box: a #GtkComboBox
* @title: a title for the menu in tearoff mode
*
* Sets the menus title in tearoff mode.
*
* Since: 2.10
*
* Deprecated: 3.10
*/
void
gtk_combo_box_set_title (GtkComboBox *combo_box,
const gchar *title)
{
GtkComboBoxPrivate *priv;
g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
priv = combo_box->priv;
if (strcmp (title ? title : "",
priv->tearoff_title ? priv->tearoff_title : "") != 0)
{
g_free (priv->tearoff_title);
priv->tearoff_title = g_strdup (title);
gtk_combo_box_update_title (combo_box);
g_object_notify (G_OBJECT (combo_box), "tearoff-title");
}
}
/**
* gtk_combo_box_set_popup_fixed_width:
* @combo_box: a #GtkComboBox

View File

@ -107,18 +107,6 @@ GDK_AVAILABLE_IN_ALL
void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
gint column_span);
GDK_DEPRECATED_IN_3_10
gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_3_10
void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
gboolean add_tearoffs);
GDK_DEPRECATED_IN_3_10
const gchar * gtk_combo_box_get_title (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_3_10
void gtk_combo_box_set_title (GtkComboBox *combo_box,
const gchar *title);
GDK_DEPRECATED_IN_3_20_FOR(gtk_widget_get_focus_on_click)
gboolean gtk_combo_box_get_focus_on_click (GtkComboBox *combo);
GDK_DEPRECATED_IN_3_20_FOR(gtk_widget_set_focus_on_click)

View File

@ -133,9 +133,6 @@
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "deprecated/gtktearoffmenuitem.h"
#include "a11y/gtkmenuaccessible.h"
#include "gdk/gdk-private.h"
@ -272,15 +269,11 @@ static void gtk_menu_select_item (GtkMenuShell *menu_shell,
static void gtk_menu_real_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
static void gtk_menu_scrollbar_changed (GtkAdjustment *adjustment,
GtkMenu *menu);
static void gtk_menu_handle_scrolling (GtkMenu *menu,
gint event_x,
gint event_y,
gboolean enter,
gboolean motion);
static void gtk_menu_set_tearoff_hints (GtkMenu *menu,
gint width);
static gboolean gtk_menu_focus (GtkWidget *widget,
GtkDirectionType direction);
static gint gtk_menu_get_popup_delay (GtkMenuShell *menu_shell);
@ -302,14 +295,9 @@ static void gtk_menu_deactivate (GtkMenuShell *menu_shell);
static void gtk_menu_show_all (GtkWidget *widget);
static void gtk_menu_position (GtkMenu *menu,
gboolean set_scroll_offset);
static void gtk_menu_reparent (GtkMenu *menu,
GtkWidget *new_parent,
gboolean unrealize);
static void gtk_menu_remove (GtkContainer *menu,
GtkWidget *widget);
static void gtk_menu_update_title (GtkMenu *menu);
static void menu_grab_transfer_window_destroy (GtkMenu *menu);
static GdkWindow *menu_grab_transfer_window_get (GtkMenu *menu);
@ -681,39 +669,6 @@ gtk_menu_class_init (GtkMenuClass *class)
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE));
/**
* GtkMenu:tearoff-title:
*
* A title that may be displayed by the window manager when this
* menu is torn-off.
*
* Deprecated: 3.10
**/
g_object_class_install_property (gobject_class,
PROP_TEAROFF_TITLE,
g_param_spec_string ("tearoff-title",
P_("Tearoff Title"),
P_("A title that may be displayed by the window manager when this menu is torn-off"),
NULL,
GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
/**
* GtkMenu:tearoff-state:
*
* A boolean that indicates whether the menu is torn-off.
*
* Since: 2.6
*
* Deprecated: 3.10
**/
g_object_class_install_property (gobject_class,
PROP_TEAROFF_STATE,
g_param_spec_boolean ("tearoff-state",
P_("Tearoff State"),
P_("A boolean that indicates whether the menu is torn-off"),
FALSE,
GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
/**
* GtkMenu:monitor:
*
@ -1123,16 +1078,6 @@ gtk_menu_set_property (GObject *object,
gtk_menu_attach_to_widget (menu, widget, NULL);
}
break;
case PROP_TEAROFF_STATE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_menu_set_tearoff_state (menu, g_value_get_boolean (value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_TEAROFF_TITLE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_menu_set_title (menu, g_value_get_string (value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_MONITOR:
gtk_menu_set_monitor (menu, g_value_get_int (value));
break;
@ -1195,16 +1140,6 @@ gtk_menu_get_property (GObject *object,
case PROP_ATTACH_WIDGET:
g_value_set_object (value, gtk_menu_get_attach_widget (menu));
break;
case PROP_TEAROFF_STATE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_value_set_boolean (value, gtk_menu_get_tearoff_state (menu));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_TEAROFF_TITLE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_value_set_string (value, gtk_menu_get_title (menu));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_MONITOR:
g_value_set_int (value, gtk_menu_get_monitor (menu));
break;
@ -1436,13 +1371,8 @@ gtk_menu_destroy (GtkWidget *widget)
gtk_widget_destroy (priv->toplevel);
}
if (priv->tearoff_window)
gtk_widget_destroy (priv->tearoff_window);
g_clear_pointer (&priv->heights, g_free);
g_clear_pointer (&priv->title, g_free);
if (priv->position_func_data_destroy)
{
priv->position_func_data_destroy (priv->position_func_data);
@ -1477,12 +1407,6 @@ menu_change_screen (GtkMenu *menu,
return;
}
if (priv->torn_off)
{
gtk_window_set_screen (GTK_WINDOW (priv->tearoff_window), new_screen);
gtk_menu_position (menu, TRUE);
}
gtk_window_set_screen (GTK_WINDOW (priv->toplevel), new_screen);
priv->monitor_num = -1;
}
@ -1570,9 +1494,6 @@ gtk_menu_attach_to_widget (GtkMenu *menu,
_gtk_widget_update_parent_muxer (GTK_WIDGET (menu));
/* Fallback title for menu comes from attach widget */
gtk_menu_update_title (menu);
g_object_notify (G_OBJECT (menu), "attach-widget");
}
@ -1652,9 +1573,6 @@ gtk_menu_detach (GtkMenu *menu)
_gtk_widget_update_parent_muxer (GTK_WIDGET (menu));
/* Fallback title for menu comes from attach widget */
gtk_menu_update_title (menu);
g_object_notify (G_OBJECT (menu), "attach-widget");
g_object_unref (menu);
}
@ -1718,46 +1636,6 @@ gtk_menu_real_insert (GtkMenuShell *menu_shell,
menu_queue_resize (menu);
}
static void
gtk_menu_tearoff_bg_copy (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
gint width, height;
if (priv->torn_off)
{
GdkWindow *window;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr;
priv->tearoff_active = FALSE;
priv->saved_scroll_offset = priv->scroll_offset;
window = gtk_widget_get_window (priv->tearoff_window);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
surface = gdk_window_create_similar_surface (window,
CAIRO_CONTENT_COLOR,
width,
height);
cr = cairo_create (surface);
gdk_cairo_set_source_window (cr, window, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
gtk_widget_set_size_request (priv->tearoff_window, width, height);
pattern = cairo_pattern_create_for_surface (surface);
gdk_window_set_background_pattern (window, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface);
}
}
static gboolean
popup_grab_on_window (GdkWindow *window,
GdkDevice *pointer)
@ -1936,13 +1814,6 @@ gtk_menu_popup_internal (GtkMenu *menu,
else
menu_shell->priv->ignore_enter = TRUE;
if (priv->torn_off)
{
gtk_menu_tearoff_bg_copy (menu);
gtk_menu_reparent (menu, priv->toplevel, FALSE);
}
parent_toplevel = NULL;
if (parent_menu_shell)
parent_toplevel = gtk_widget_get_toplevel (parent_menu_shell);
@ -2475,7 +2346,6 @@ gtk_menu_popdown (GtkMenu *menu)
{
GtkMenuPrivate *priv;
GtkMenuShell *menu_shell;
GdkDevice *pointer;
g_return_if_fail (GTK_IS_MENU (menu));
@ -2510,35 +2380,7 @@ gtk_menu_popdown (GtkMenu *menu)
gtk_window_set_transient_for (GTK_WINDOW (priv->toplevel), NULL);
}
pointer = _gtk_menu_shell_get_grab_device (menu_shell);
if (priv->torn_off)
{
gtk_widget_set_size_request (priv->tearoff_window, -1, -1);
if (gtk_bin_get_child (GTK_BIN (priv->toplevel)))
{
gtk_menu_reparent (menu, priv->tearoff_hbox, TRUE);
}
else
{
/* 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->priv->have_xgrab && pointer)
gdk_seat_ungrab (gdk_device_get_seat (pointer));
}
/* gtk_menu_popdown is called each time a menu item is selected from
* a torn off menu. Only scroll back to the saved position if the
* non-tearoff menu was popped down.
*/
if (!priv->tearoff_active)
gtk_menu_scroll_to (menu, priv->saved_scroll_offset);
priv->tearoff_active = TRUE;
}
else
gtk_widget_hide (GTK_WIDGET (menu));
gtk_widget_hide (GTK_WIDGET (menu));
menu_shell->priv->have_xgrab = FALSE;
@ -2804,299 +2646,10 @@ gtk_menu_reposition (GtkMenu *menu)
{
g_return_if_fail (GTK_IS_MENU (menu));
if (!menu->priv->torn_off && gtk_widget_is_drawable (GTK_WIDGET (menu)))
if (gtk_widget_is_drawable (GTK_WIDGET (menu)))
gtk_menu_position (menu, FALSE);
}
static void
gtk_menu_scrollbar_changed (GtkAdjustment *adjustment,
GtkMenu *menu)
{
double value;
value = gtk_adjustment_get_value (adjustment);
if (menu->priv->scroll_offset != value)
gtk_menu_scroll_to (menu, value);
}
static void
gtk_menu_set_tearoff_hints (GtkMenu *menu,
gint width)
{
GtkMenuPrivate *priv = menu->priv;
GdkGeometry geometry_hints;
if (!priv->tearoff_window)
return;
if (gtk_widget_get_visible (priv->tearoff_scrollbar))
{
GtkRequisition requisition;
gtk_widget_get_preferred_size (priv->tearoff_scrollbar,
&requisition, NULL);
width += requisition.width;
}
geometry_hints.min_width = width;
geometry_hints.max_width = width;
geometry_hints.min_height = 0;
geometry_hints.max_height = priv->requested_height;
gtk_window_set_geometry_hints (GTK_WINDOW (priv->tearoff_window),
NULL,
&geometry_hints,
GDK_HINT_MAX_SIZE|GDK_HINT_MIN_SIZE);
}
static void
gtk_menu_update_title (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
if (priv->tearoff_window)
{
const gchar *title;
GtkWidget *attach_widget;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
title = gtk_menu_get_title (menu);
G_GNUC_END_IGNORE_DEPRECATIONS;
if (!title)
{
attach_widget = gtk_menu_get_attach_widget (menu);
if (GTK_IS_MENU_ITEM (attach_widget))
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (attach_widget));
if (GTK_IS_LABEL (child))
title = gtk_label_get_text (GTK_LABEL (child));
}
}
if (title)
gtk_window_set_title (GTK_WINDOW (priv->tearoff_window), title);
}
}
static GtkWidget*
gtk_menu_get_toplevel (GtkWidget *menu)
{
GtkWidget *attach, *toplevel;
attach = gtk_menu_get_attach_widget (GTK_MENU (menu));
if (GTK_IS_MENU_ITEM (attach))
attach = gtk_widget_get_parent (attach);
if (GTK_IS_MENU (attach))
return gtk_menu_get_toplevel (attach);
else if (GTK_IS_WIDGET (attach))
{
toplevel = gtk_widget_get_toplevel (attach);
if (gtk_widget_is_toplevel (toplevel))
return toplevel;
}
return NULL;
}
static void
tearoff_window_destroyed (GtkWidget *widget,
GtkMenu *menu)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_menu_set_tearoff_state (menu, FALSE);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
/**
* gtk_menu_set_tearoff_state:
* @menu: a #GtkMenu
* @torn_off: If %TRUE, menu is displayed as a tearoff menu.
*
* Changes the tearoff state of the menu. A menu is normally
* displayed as drop down menu which persists as long as the menu is
* active. It can also be displayed as a tearoff menu which persists
* until it is closed or reattached.
*
* Deprecated: 3.10
*/
void
gtk_menu_set_tearoff_state (GtkMenu *menu,
gboolean torn_off)
{
GtkMenuPrivate *priv = menu->priv;
gint height;
g_return_if_fail (GTK_IS_MENU (menu));
if (priv->torn_off != torn_off)
{
priv->torn_off = torn_off;
priv->tearoff_active = torn_off;
if (priv->torn_off)
{
if (gtk_widget_get_visible (GTK_WIDGET (menu)))
gtk_menu_popdown (menu);
if (!priv->tearoff_window)
{
GtkWidget *toplevel;
priv->tearoff_window = g_object_new (GTK_TYPE_WINDOW,
"type", GTK_WINDOW_TOPLEVEL,
"screen", gtk_widget_get_screen (priv->toplevel),
"app-paintable", TRUE,
NULL);
gtk_window_set_type_hint (GTK_WINDOW (priv->tearoff_window),
GDK_WINDOW_TYPE_HINT_MENU);
gtk_window_set_mnemonic_modifier (GTK_WINDOW (priv->tearoff_window), 0);
g_signal_connect (priv->tearoff_window, "destroy",
G_CALLBACK (tearoff_window_destroyed), menu);
g_signal_connect (priv->tearoff_window, "event",
G_CALLBACK (gtk_menu_window_event), menu);
gtk_menu_update_title (menu);
gtk_widget_realize (priv->tearoff_window);
toplevel = gtk_menu_get_toplevel (GTK_WIDGET (menu));
if (toplevel != NULL)
gtk_window_set_transient_for (GTK_WINDOW (priv->tearoff_window),
GTK_WINDOW (toplevel));
priv->tearoff_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (priv->tearoff_window),
priv->tearoff_hbox);
height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET (menu)));
priv->tearoff_adjustment = gtk_adjustment_new (0,
0, priv->requested_height,
MENU_SCROLL_STEP2,
height/2,
height);
g_object_connect (priv->tearoff_adjustment,
"signal::value-changed", gtk_menu_scrollbar_changed, menu,
NULL);
priv->tearoff_scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, priv->tearoff_adjustment);
gtk_box_pack_end (GTK_BOX (priv->tearoff_hbox),
priv->tearoff_scrollbar,
FALSE, FALSE, 0);
if (gtk_adjustment_get_upper (priv->tearoff_adjustment) > height)
gtk_widget_show (priv->tearoff_scrollbar);
gtk_widget_show (priv->tearoff_hbox);
}
gtk_menu_reparent (menu, priv->tearoff_hbox, FALSE);
/* Update menu->requisition */
gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, NULL);
gtk_menu_set_tearoff_hints (menu, gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET (menu))));
gtk_widget_realize (priv->tearoff_window);
gtk_menu_position (menu, TRUE);
gtk_widget_show (GTK_WIDGET (menu));
gtk_widget_show (priv->tearoff_window);
gtk_menu_scroll_to (menu, 0);
}
else
{
gtk_widget_hide (GTK_WIDGET (menu));
gtk_widget_hide (priv->tearoff_window);
if (GTK_IS_CONTAINER (priv->toplevel))
gtk_menu_reparent (menu, priv->toplevel, FALSE);
gtk_widget_destroy (priv->tearoff_window);
priv->tearoff_window = NULL;
priv->tearoff_hbox = NULL;
priv->tearoff_scrollbar = NULL;
priv->tearoff_adjustment = NULL;
}
g_object_notify (G_OBJECT (menu), "tearoff-state");
}
}
/**
* gtk_menu_get_tearoff_state:
* @menu: a #GtkMenu
*
* Returns whether the menu is torn off.
* See gtk_menu_set_tearoff_state().
*
* Returns: %TRUE if the menu is currently torn off.
*
* Deprecated: 3.10
*/
gboolean
gtk_menu_get_tearoff_state (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), FALSE);
return menu->priv->torn_off;
}
/**
* gtk_menu_set_title:
* @menu: a #GtkMenu
* @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. 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 items label.
*
* Deprecated: 3.10
*/
void
gtk_menu_set_title (GtkMenu *menu,
const gchar *title)
{
GtkMenuPrivate *priv = menu->priv;
char *old_title;
g_return_if_fail (GTK_IS_MENU (menu));
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_get_title:
* @menu: a #GtkMenu
*
* Returns the title of the menu. See gtk_menu_set_title().
*
* Returns: the title of the menu, or %NULL if the menu
* has no title set on it. This string is owned by GTK+
* and should not be modified or freed.
*
* Deprecated: 3.10
**/
const gchar *
gtk_menu_get_title (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
return menu->priv->title;
}
/**
* gtk_menu_reorder_child:
* @menu: a #GtkMenu
@ -3471,13 +3024,6 @@ gtk_menu_size_allocate (GtkWidget *widget,
&arrow_allocation, -1,
&clip);
if (!priv->tearoff_active)
{
y += arrow_border.top;
height -= arrow_border.top;
height -= arrow_border.bottom;
}
width = MAX (1, width);
height = MAX (1, height);
@ -3547,36 +3093,6 @@ gtk_menu_size_allocate (GtkWidget *widget,
w = gtk_menu_get_n_columns (menu) * base_width;
gdk_window_resize (priv->bin_window, w, h);
}
if (priv->tearoff_active)
{
if (height >= priv->requested_height)
{
if (gtk_widget_get_visible (priv->tearoff_scrollbar))
{
gtk_widget_hide (priv->tearoff_scrollbar);
gtk_menu_set_tearoff_hints (menu, allocation->width);
gtk_menu_scroll_to (menu, 0);
}
}
else
{
gtk_adjustment_configure (priv->tearoff_adjustment,
gtk_adjustment_get_value (priv->tearoff_adjustment),
0,
priv->requested_height,
gtk_adjustment_get_step_increment (priv->tearoff_adjustment),
gtk_adjustment_get_page_increment (priv->tearoff_adjustment),
allocation->height);
if (!gtk_widget_get_visible (priv->tearoff_scrollbar))
{
gtk_widget_show (priv->tearoff_scrollbar);
gtk_menu_set_tearoff_hints (menu, allocation->width);
}
}
}
}
}
@ -3603,10 +3119,10 @@ gtk_menu_draw (GtkWidget *widget,
gtk_render_frame (context, cr, 0, 0,
width, height);
if (priv->upper_arrow_visible && !priv->tearoff_active)
if (priv->upper_arrow_visible)
gtk_css_gadget_draw (priv->top_arrow_gadget, cr);
if (priv->lower_arrow_visible && !priv->tearoff_active)
if (priv->lower_arrow_visible)
gtk_css_gadget_draw (priv->bottom_arrow_gadget, cr);
}
@ -3742,12 +3258,6 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
*minimum_size = min_width;
*natural_size = nat_width;
/* Don't resize the tearoff if it is not active,
* because it won't redraw (it is only a background pixmap).
*/
if (priv->tearoff_active)
gtk_menu_set_tearoff_hints (menu, min_width);
}
static void
@ -4252,7 +3762,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
get_arrows_sensitive_area (menu, &rect, NULL);
in_arrow = FALSE;
if (priv->upper_arrow_visible && !priv->tearoff_active &&
if (priv->upper_arrow_visible &&
(x >= rect.x) && (x < rect.x + rect.width) &&
(y >= rect.y) && (y < rect.y + rect.height))
{
@ -4263,7 +3773,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
{
gboolean arrow_pressed = FALSE;
if (priv->upper_arrow_visible && !priv->tearoff_active)
if (priv->upper_arrow_visible)
{
scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE);
@ -4326,7 +3836,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
get_arrows_sensitive_area (menu, NULL, &rect);
in_arrow = FALSE;
if (priv->lower_arrow_visible && !priv->tearoff_active &&
if (priv->lower_arrow_visible &&
(x >= rect.x) && (x < rect.x + rect.width) &&
(y >= rect.y) && (y < rect.y + rect.height))
{
@ -4337,7 +3847,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
{
gboolean arrow_pressed = FALSE;
if (priv->lower_arrow_visible && !priv->tearoff_active)
if (priv->lower_arrow_visible)
{
scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE);
@ -5094,14 +4604,7 @@ gtk_menu_position_legacy (GtkMenu *menu,
scroll_offset += arrow_border.top;
}
gtk_window_move (GTK_WINDOW (GTK_MENU_SHELL (menu)->priv->active ? priv->toplevel : priv->tearoff_window),
x, y);
if (!GTK_MENU_SHELL (menu)->priv->active)
{
gtk_window_resize (GTK_WINDOW (priv->tearoff_window),
requisition.width, requisition.height);
}
gtk_window_move (GTK_WINDOW (priv->toplevel), x, y);
if (set_scroll_offset)
priv->scroll_offset = scroll_offset;
@ -5243,18 +4746,14 @@ gtk_menu_scroll_to (GtkMenu *menu,
{
GtkMenuPrivate *priv = menu->priv;
GtkCssNode *top_arrow_node, *bottom_arrow_node;
GtkBorder arrow_border, padding;
GtkBorder padding;
GtkWidget *widget;
gint x, y;
gint view_width, view_height;
gint border_width;
gint menu_height;
widget = GTK_WIDGET (menu);
if (priv->tearoff_active && priv->tearoff_adjustment)
gtk_adjustment_set_value (priv->tearoff_adjustment, offset);
/* Move/resize the viewport according to arrows: */
view_width = gtk_widget_get_allocated_width (widget);
view_height = gtk_widget_get_allocated_height (widget);
@ -5265,92 +4764,10 @@ gtk_menu_scroll_to (GtkMenu *menu,
view_width -= (2 * border_width) + padding.left + padding.right;
view_height -= (2 * border_width) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * border_width) - padding.top - padding.bottom;
x = border_width + padding.left;
y = border_width + padding.top;
if (!priv->tearoff_active)
{
if (view_height < menu_height ||
(offset > 0 && priv->scroll_offset > 0) ||
(offset < 0 && priv->scroll_offset < 0))
{
GtkStateFlags upper_arrow_previous_state = priv->upper_arrow_state;
GtkStateFlags lower_arrow_previous_state = priv->lower_arrow_state;
if (!priv->upper_arrow_visible || !priv->lower_arrow_visible)
gtk_widget_queue_draw (GTK_WIDGET (menu));
priv->upper_arrow_visible = priv->lower_arrow_visible = TRUE;
get_arrows_border (menu, &arrow_border);
y += arrow_border.top;
view_height -= arrow_border.top;
view_height -= arrow_border.bottom;
if (offset <= 0)
priv->upper_arrow_state |= GTK_STATE_FLAG_INSENSITIVE;
else
{
priv->upper_arrow_state &= ~(GTK_STATE_FLAG_INSENSITIVE);
if (priv->upper_arrow_prelight)
priv->upper_arrow_state |= GTK_STATE_FLAG_PRELIGHT;
else
priv->upper_arrow_state &= ~(GTK_STATE_FLAG_PRELIGHT);
}
if (offset >= menu_height - view_height)
priv->lower_arrow_state |= GTK_STATE_FLAG_INSENSITIVE;
else
{
priv->lower_arrow_state &= ~(GTK_STATE_FLAG_INSENSITIVE);
if (priv->lower_arrow_prelight)
priv->lower_arrow_state |= GTK_STATE_FLAG_PRELIGHT;
else
priv->lower_arrow_state &= ~(GTK_STATE_FLAG_PRELIGHT);
}
if ((priv->upper_arrow_state != upper_arrow_previous_state) ||
(priv->lower_arrow_state != lower_arrow_previous_state))
gtk_widget_queue_draw (GTK_WIDGET (menu));
if ((upper_arrow_previous_state & GTK_STATE_FLAG_INSENSITIVE) == 0 &&
(priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) != 0)
{
/* At the upper border, possibly remove timeout */
if (priv->scroll_step < 0)
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
if ((lower_arrow_previous_state & GTK_STATE_FLAG_INSENSITIVE) == 0 &&
(priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) != 0)
{
/* At the lower border, possibly remove timeout */
if (priv->scroll_step > 0)
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
}
else if (priv->upper_arrow_visible || priv->lower_arrow_visible)
{
offset = 0;
priv->upper_arrow_visible = priv->lower_arrow_visible = FALSE;
priv->upper_arrow_prelight = priv->lower_arrow_prelight = FALSE;
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
top_arrow_node = gtk_css_gadget_get_node (priv->top_arrow_gadget);
gtk_css_node_set_visible (top_arrow_node, priv->upper_arrow_visible);
gtk_css_node_set_state (top_arrow_node, priv->upper_arrow_state);
@ -5452,8 +4869,7 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
arrow_height = 0;
get_arrows_border (menu, &arrow_border);
if (!priv->tearoff_active)
arrow_height = arrow_border.top + arrow_border.bottom;
arrow_height = arrow_border.top + arrow_border.bottom;
if (child_offset + child_height > y + height - arrow_height)
{
@ -5483,67 +4899,6 @@ gtk_menu_select_item (GtkMenuShell *menu_shell,
}
/* Reparent the menu, taking care of the refcounting
*
* If unrealize is true we force a unrealize while reparenting the parent.
* This can help eliminate flicker in some cases.
*
* What happens is that when the menu is unrealized and then re-realized,
* the allocations are as follows:
*
* parent - 1x1 at (0,0)
* child1 - 100x20 at (0,0)
* child2 - 100x20 at (0,20)
* child3 - 100x20 at (0,40)
*
* That is, the parent is small but the children are full sized. Then,
* when the queued_resize gets processed, the parent gets resized to
* full size.
*
* But in order to eliminate flicker when scrolling, gdkgeometry-x11.c
* contains the following logic:
*
* - if a move or resize operation on a window would change the clip
* region on the children, then before the window is resized
* the background for children is temporarily set to None, the
* move/resize done, and the background for the children restored.
*
* So, at the point where the parent is resized to final size, the
* background for the children is temporarily None, and thus they
* are not cleared to the background color and the previous background
* (the image of the menu) is left in place.
*/
static void
gtk_menu_reparent (GtkMenu *menu,
GtkWidget *new_parent,
gboolean unrealize)
{
GObject *object = G_OBJECT (menu);
GtkWidget *widget = GTK_WIDGET (menu);
gboolean was_floating = g_object_is_floating (object);
g_object_ref_sink (object);
if (unrealize)
{
g_object_ref (object);
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
g_object_unref (object);
}
else
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_widget_reparent (widget, new_parent);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
if (was_floating)
g_object_force_floating (object);
else
g_object_unref (object);
}
static void
gtk_menu_show_all (GtkWidget *widget)
{
@ -5804,11 +5159,10 @@ gtk_menu_move_current (GtkMenuShell *menu_shell,
static gint
get_visible_size (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (menu);
GtkContainer *container = GTK_CONTAINER (menu);
GtkBorder padding;
GtkBorder padding, arrow_border;
gint menu_height;
gtk_widget_get_allocation (widget, &allocation);
@ -5818,14 +5172,9 @@ get_visible_size (GtkMenu *menu)
(2 * gtk_container_get_border_width (container)) -
padding.top - padding.bottom);
if (!priv->tearoff_active)
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
menu_height -= arrow_border.top;
menu_height -= arrow_border.bottom;
}
get_arrows_border (menu, &arrow_border);
menu_height -= arrow_border.top;
menu_height -= arrow_border.bottom;
return menu_height;
}
@ -5864,14 +5213,8 @@ child_at (GtkMenu *menu,
{
child = children->data;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (child_offset + child_requisition.height > y &&
!GTK_IS_TEAROFF_MENU_ITEM (child))
if (child_offset + child_requisition.height > y)
return child;
G_GNUC_END_IGNORE_DEPRECATIONS
}
child_offset += child_requisition.height;
@ -5886,7 +5229,7 @@ get_menu_height (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
GtkWidget *widget = GTK_WIDGET (menu);
GtkBorder padding;
GtkBorder padding, arrow_border;
gint height;
get_menu_padding (widget, &padding);
@ -5895,14 +5238,9 @@ get_menu_height (GtkMenu *menu)
height -= (gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2) +
padding.top + padding.bottom;
if (!priv->tearoff_active)
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
height -= arrow_border.top;
height -= arrow_border.bottom;
}
get_arrows_border (menu, &arrow_border);
height -= arrow_border.top;
height -= arrow_border.bottom;
return height;
}
@ -5942,7 +5280,7 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
}
menu_shell->priv->ignore_enter = TRUE;
old_upper_arrow_visible = priv->upper_arrow_visible && !priv->tearoff_active;
old_upper_arrow_visible = priv->upper_arrow_visible;
old_offset = priv->scroll_offset;
new_offset = priv->scroll_offset + step;
@ -5953,7 +5291,7 @@ gtk_menu_real_move_scroll (GtkMenu *menu,
if (menu_shell->priv->active_menu_item)
{
GtkWidget *new_child;
gboolean new_upper_arrow_visible = priv->upper_arrow_visible && !priv->tearoff_active;
gboolean new_upper_arrow_visible = priv->upper_arrow_visible;
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);

View File

@ -219,21 +219,6 @@ void gtk_menu_detach (GtkMenu *menu);
GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_menu_get_attach_widget (GtkMenu *menu);
GDK_DEPRECATED_IN_3_10
void gtk_menu_set_tearoff_state (GtkMenu *menu,
gboolean torn_off);
GDK_DEPRECATED_IN_3_10
gboolean gtk_menu_get_tearoff_state (GtkMenu *menu);
/* This sets the window manager title for the window that
* appears when a menu is torn off
*/
GDK_DEPRECATED_IN_3_10
void gtk_menu_set_title (GtkMenu *menu,
const gchar *title);
GDK_DEPRECATED_IN_3_10
const gchar * gtk_menu_get_title (GtkMenu *menu);
GDK_AVAILABLE_IN_ALL
void gtk_menu_reorder_child (GtkMenu *menu,
GtkWidget *child,

View File

@ -46,7 +46,6 @@
#include "gtksettings.h"
#include "gtktypebuiltins.h"
#include "a11y/gtkmenuitemaccessible.h"
#include "deprecated/gtktearoffmenuitem.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
@ -1257,8 +1256,8 @@ activatable_update_label (GtkMenuItem *menu_item, GtkAction *action)
* @menu: (allow-none): a #GtkMenu or %NULL
*
* Determines whether @menu is empty. A menu is considered empty if it
* the only visible children are tearoff menu items or filler menu
* items which were inserted to mark the menu as empty.
* the only visible children are filler menu items which were
* inserted to mark the menu as empty.
*
* This function is used by #GtkAction.
*
@ -1282,18 +1281,11 @@ gtk_menu_is_empty (GtkWidget *menu)
{
if (gtk_widget_get_visible (cur->data))
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!GTK_IS_TEAROFF_MENU_ITEM (cur->data) &&
!g_object_get_data (cur->data, "gtk-empty-menu-item"))
if (!g_object_get_data (cur->data, "gtk-empty-menu-item"))
{
result = FALSE;
break;
}
G_GNUC_END_IGNORE_DEPRECATIONS
}
cur = cur->next;
}
@ -1757,8 +1749,7 @@ gtk_real_menu_item_select (GtkMenuItem *menu_item)
if ((!source_device ||
gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN) &&
priv->submenu &&
(!gtk_widget_get_mapped (priv->submenu) ||
GTK_MENU (priv->submenu)->priv->tearoff_active))
!gtk_widget_get_mapped (priv->submenu))
{
_gtk_menu_item_popup_submenu (GTK_WIDGET (menu_item), TRUE);
}
@ -2088,8 +2079,7 @@ 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)->priv->active) ||
(GTK_IS_MENU (parent) && GTK_MENU (parent)->priv->torn_off))
if (GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->priv->active)
{
gtk_menu_item_real_popup_submenu (GTK_WIDGET (menu_item), info->trigger_event, TRUE);
if (info->trigger_event &&

View File

@ -72,11 +72,6 @@ struct _GtkMenuPrivate
*/
GtkWidget *toplevel;
GtkWidget *tearoff_window;
GtkWidget *tearoff_hbox;
GtkWidget *tearoff_scrollbar;
GtkAdjustment *tearoff_adjustment;
GdkWindow *view_window;
GdkWindow *bin_window;
@ -90,11 +85,6 @@ struct _GtkMenuPrivate
guint scroll_timeout;
guint needs_destruction_ref : 1;
guint torn_off : 1;
/* The tearoff is active when it is torn off and the not-torn-off
* menu is not popped up.
*/
guint tearoff_active : 1;
guint scroll_fast : 1;
guint upper_arrow_visible : 1;
@ -122,8 +112,6 @@ struct _GtkMenuPrivate
gint n_rows;
gint n_columns;
gchar *title;
/* Arrow states */
GtkStateFlags lower_arrow_state;
GtkStateFlags upper_arrow_state;

View File

@ -77,8 +77,6 @@
#include "gtkwidgetprivate.h"
#include "gtklabelprivate.h"
#include "deprecated/gtktearoffmenuitem.h"
#include "a11y/gtkmenushellaccessible.h"
@ -1449,9 +1447,7 @@ gtk_menu_shell_move_selected (GtkMenuShell *menu_shell,
* should be %FALSE if the menu is being
* popped up initially.
*
* Select the first visible or selectable child of the menu shell;
* dont select tearoff items unless the only item is a tearoff
* item.
* Select the first visible or selectable child of the menu shell.
*
* Since: 2.2
*/
@ -1472,14 +1468,6 @@ gtk_menu_shell_select_first (GtkMenuShell *menu_shell,
_gtk_menu_item_is_selectable (child))
{
to_select = child;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!GTK_IS_TEAROFF_MENU_ITEM (child))
break;
G_GNUC_END_IGNORE_DEPRECATIONS
}
tmp_list = tmp_list->next;
@ -1506,13 +1494,6 @@ _gtk_menu_shell_select_last (GtkMenuShell *menu_shell,
_gtk_menu_item_is_selectable (child))
{
to_select = child;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!GTK_IS_TEAROFF_MENU_ITEM (child))
break;
G_GNUC_END_IGNORE_DEPRECATIONS
}
tmp_list = tmp_list->prev;

View File

@ -49,8 +49,6 @@
#define GDK_DEPRECATED
#define GDK_DEPRECATED_FOR(f)
#include "deprecated/gtktearoffmenuitem.h"
/* GObjectClass */
static void gtk_tree_menu_constructed (GObject *object);
static void gtk_tree_menu_dispose (GObject *object);
@ -170,7 +168,6 @@ struct _GtkTreeMenuPrivate
/* Flags */
guint32 menu_with_header : 1;
guint32 tearoff : 1;
/* Row separators */
GtkTreeViewRowSeparatorFunc row_separator_func;
@ -183,7 +180,6 @@ enum {
PROP_MODEL,
PROP_ROOT,
PROP_CELL_AREA,
PROP_TEAROFF,
PROP_WRAP_WIDTH,
PROP_ROW_SPAN_COL,
PROP_COL_SPAN_COL
@ -309,21 +305,6 @@ _gtk_tree_menu_class_init (GtkTreeMenuClass *class)
GTK_TYPE_CELL_AREA,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/*
* GtkTreeMenu:tearoff:
*
* Specifies whether this menu comes with a leading tearoff menu item
*
* Since: 3.0
*/
g_object_class_install_property (object_class,
PROP_TEAROFF,
g_param_spec_boolean ("tearoff",
P_("Tearoff"),
P_("Whether the menu has a tearoff item"),
FALSE,
GTK_PARAM_READWRITE));
/*
* GtkTreeMenu:wrap-width:
*
@ -477,10 +458,6 @@ gtk_tree_menu_set_property (GObject *object,
gtk_tree_menu_set_area (menu, (GtkCellArea *)g_value_get_object (value));
break;
case PROP_TEAROFF:
_gtk_tree_menu_set_tearoff (menu, g_value_get_boolean (value));
break;
case PROP_WRAP_WIDTH:
_gtk_tree_menu_set_wrap_width (menu, g_value_get_int (value));
break;
@ -522,10 +499,6 @@ gtk_tree_menu_get_property (GObject *object,
g_value_set_object (value, priv->area);
break;
case PROP_TEAROFF:
g_value_set_boolean (value, priv->tearoff);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -706,7 +679,7 @@ gtk_tree_menu_get_path_item (GtkTreeMenu *menu,
item = child;
}
}
else if (!GTK_IS_TEAROFF_MENU_ITEM (child))
else
{
GtkWidget *view = gtk_bin_get_child (GTK_BIN (child));
@ -845,7 +818,7 @@ find_empty_submenu (GtkTreeMenu *menu)
/* Separators dont get submenus, if it already has a submenu then let
* the submenu handle inserted rows */
if (!GTK_IS_SEPARATOR_MENU_ITEM (child) && !GTK_IS_TEAROFF_MENU_ITEM (child))
if (!GTK_IS_SEPARATOR_MENU_ITEM (child))
{
GtkWidget *view = gtk_bin_get_child (GTK_BIN (child));
@ -896,12 +869,6 @@ row_inserted_cb (GtkTreeModel *model,
if (priv->menu_with_header)
index += 2;
/* Index after the tearoff item for the root menu if
* there is a tearoff item
*/
if (priv->root == NULL && priv->tearoff)
index += 1;
item = gtk_tree_menu_create_item (menu, iter, FALSE);
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, index);
@ -1386,20 +1353,6 @@ gtk_tree_menu_populate (GtkTreeMenu *menu)
}
else
{
/* Tearoff menu items only go in the root menu */
if (priv->tearoff)
{
menu_item = gtk_tearoff_menu_item_new ();
gtk_widget_show (menu_item);
if (priv->wrap_width > 0)
gtk_menu_attach (GTK_MENU (menu), menu_item, 0, priv->wrap_width, 0, 1);
else
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
prev = menu_item;
}
valid = gtk_tree_model_iter_children (priv->model, &iter, NULL);
}
@ -1664,57 +1617,6 @@ _gtk_tree_menu_get_root (GtkTreeMenu *menu)
return NULL;
}
/*
* _gtk_tree_menu_get_tearoff:
* @menu: a #GtkTreeMenu
*
* Gets whether this menu is build with a leading tearoff menu item.
*
* Returns: %TRUE if the menu has a tearoff item.
*
* Since: 3.0
*/
gboolean
_gtk_tree_menu_get_tearoff (GtkTreeMenu *menu)
{
GtkTreeMenuPrivate *priv;
g_return_val_if_fail (GTK_IS_TREE_MENU (menu), FALSE);
priv = menu->priv;
return priv->tearoff;
}
/*
* _gtk_tree_menu_set_tearoff:
* @menu: a #GtkTreeMenu
* @tearoff: whether the menu should have a leading tearoff menu item.
*
* Sets whether this menu has a leading tearoff menu item.
*
* Since: 3.0
*/
void
_gtk_tree_menu_set_tearoff (GtkTreeMenu *menu,
gboolean tearoff)
{
GtkTreeMenuPrivate *priv;
g_return_if_fail (GTK_IS_TREE_MENU (menu));
priv = menu->priv;
if (priv->tearoff != tearoff)
{
priv->tearoff = tearoff;
rebuild_menu (menu);
g_object_notify (G_OBJECT (menu), "tearoff");
}
}
/*
* _gtk_tree_menu_get_wrap_width:
* @menu: a #GtkTreeMenu

View File

@ -79,9 +79,6 @@ GtkTreeModel *_gtk_tree_menu_get_model (GtkTreeMenu
void _gtk_tree_menu_set_root (GtkTreeMenu *menu,
GtkTreePath *path);
GtkTreePath *_gtk_tree_menu_get_root (GtkTreeMenu *menu);
gboolean _gtk_tree_menu_get_tearoff (GtkTreeMenu *menu);
void _gtk_tree_menu_set_tearoff (GtkTreeMenu *menu,
gboolean tearoff);
gint _gtk_tree_menu_get_wrap_width (GtkTreeMenu *menu);
void _gtk_tree_menu_set_wrap_width (GtkTreeMenu *menu,
gint width);

View File

@ -75,17 +75,6 @@ dump_toplevels (GtkWidget *button,
g_slist_free (toplevels);
}
static void
toggle_tearoffs (GtkWidget *button,
GtkUIManager *merge)
{
gboolean add_tearoffs;
add_tearoffs = gtk_ui_manager_get_add_tearoffs (merge);
gtk_ui_manager_set_add_tearoffs (merge, !add_tearoffs);
}
static gint
delayed_toggle_dynamic (GtkUIManager *merge)
{
@ -677,10 +666,6 @@ main (int argc, char **argv)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
}
button = gtk_check_button_new_with_label ("Tearoffs");
g_signal_connect (button, "clicked", G_CALLBACK (toggle_tearoffs), merge);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_check_button_new_with_label ("Dynamic");
g_signal_connect (button, "clicked", G_CALLBACK (toggle_dynamic), merge);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);