gtk2/gtk/gtkjoinedmenuprivate.h
Christian Hergert d63d9b2319 joinedmenu: add helper to join menus instead of nesting
In many cases, we have an "extra-menu" property that is used to allow
applications to join menus into the native menu for the widget. Previously,
this was done by nesting that menu in a section.

Doing so increases the complexity of the rules for GtkMenuTracker as you
may want different handling from inside of the section vs toplevel
sections.

If instead we synthetically glue the menus together, we have a much more
natural joining of menus as the application developer would expect for
their menu.

This also ports GtkLabel, GtkText, GtkPasswordEntry, and GtkTextView to
use the joined menu helper.

The joined menu helper comes originally from GNOME Builder and has had
extensive use there.

Fixes #4094
2021-07-08 14:16:06 -07:00

42 lines
1.6 KiB
C

/*
* Copyright © 2020 Red Hat, Inc.
*
* 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.1 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#pragma once
#include <gio/gio.h>
G_BEGIN_DECLS
#define GTK_TYPE_JOINED_MENU (gtk_joined_menu_get_type())
G_DECLARE_FINAL_TYPE (GtkJoinedMenu, gtk_joined_menu, GTK, JOINED_MENU, GMenuModel)
GtkJoinedMenu *gtk_joined_menu_new (void);
guint gtk_joined_menu_get_n_joined (GtkJoinedMenu *self);
void gtk_joined_menu_append_menu (GtkJoinedMenu *self,
GMenuModel *model);
void gtk_joined_menu_prepend_menu (GtkJoinedMenu *self,
GMenuModel *model);
void gtk_joined_menu_remove_menu (GtkJoinedMenu *self,
GMenuModel *model);
void gtk_joined_menu_remove_index (GtkJoinedMenu *self,
guint index);
G_END_DECLS