mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
GtkMenuTracker: add 'merge_sections' flag
Add the possibility of a GtkMenuTracker that performs no section merging. Instead, it will report an item in the form of a separator for subsections. It is then possible to get a separate tracker for the subsection contents by using gtk_menu_tracker_new_for_item_link().
This commit is contained in:
parent
f6ee00769a
commit
d930716daf
@ -2071,7 +2071,7 @@ gtk_menu_shell_tracker_insert_func (GtkMenuTrackerItem *item,
|
||||
* lazy...
|
||||
*/
|
||||
submenu->priv->tracker = gtk_menu_tracker_new_for_item_link (item,
|
||||
G_MENU_LINK_SUBMENU,
|
||||
G_MENU_LINK_SUBMENU, TRUE,
|
||||
gtk_menu_shell_tracker_insert_func,
|
||||
gtk_menu_shell_tracker_remove_func,
|
||||
submenu);
|
||||
@ -2186,7 +2186,7 @@ gtk_menu_shell_bind_model (GtkMenuShell *menu_shell,
|
||||
|
||||
if (model)
|
||||
menu_shell->priv->tracker = gtk_menu_tracker_new (GTK_ACTION_OBSERVABLE (muxer),
|
||||
model, with_separators, action_namespace,
|
||||
model, with_separators, FALSE, action_namespace,
|
||||
gtk_menu_shell_tracker_insert_func,
|
||||
gtk_menu_shell_tracker_remove_func,
|
||||
menu_shell);
|
||||
|
@ -60,6 +60,7 @@ typedef struct _GtkMenuTrackerSection GtkMenuTrackerSection;
|
||||
struct _GtkMenuTracker
|
||||
{
|
||||
GtkActionObservable *observable;
|
||||
gboolean merge_sections;
|
||||
GtkMenuTrackerInsertFunc insert_func;
|
||||
GtkMenuTrackerRemoveFunc remove_func;
|
||||
gpointer user_data;
|
||||
@ -308,7 +309,8 @@ gtk_menu_tracker_add_items (GtkMenuTracker *tracker,
|
||||
|
||||
submenu = g_menu_model_get_item_link (model, position + n_items, G_MENU_LINK_SECTION);
|
||||
g_assert (submenu != model);
|
||||
if (submenu != NULL)
|
||||
|
||||
if (submenu != NULL && tracker->merge_sections)
|
||||
{
|
||||
GtkMenuTrackerSection *subsection;
|
||||
gchar *action_namespace = NULL;
|
||||
@ -340,7 +342,7 @@ gtk_menu_tracker_add_items (GtkMenuTracker *tracker,
|
||||
GtkMenuTrackerItem *item;
|
||||
|
||||
item = _gtk_menu_tracker_item_new (tracker->observable, model, position + n_items,
|
||||
section->action_namespace, FALSE);
|
||||
section->action_namespace, submenu != NULL);
|
||||
|
||||
/* In the case that the item may disappear we handle that by
|
||||
* treating the item that we just created as being its own
|
||||
@ -540,6 +542,7 @@ GtkMenuTracker *
|
||||
gtk_menu_tracker_new (GtkActionObservable *observable,
|
||||
GMenuModel *model,
|
||||
gboolean with_separators,
|
||||
gboolean merge_sections,
|
||||
const gchar *action_namespace,
|
||||
GtkMenuTrackerInsertFunc insert_func,
|
||||
GtkMenuTrackerRemoveFunc remove_func,
|
||||
@ -548,6 +551,7 @@ gtk_menu_tracker_new (GtkActionObservable *observable,
|
||||
GtkMenuTracker *tracker;
|
||||
|
||||
tracker = g_slice_new (GtkMenuTracker);
|
||||
tracker->merge_sections = merge_sections;
|
||||
tracker->observable = g_object_ref (observable);
|
||||
tracker->insert_func = insert_func;
|
||||
tracker->remove_func = remove_func;
|
||||
@ -562,6 +566,7 @@ gtk_menu_tracker_new (GtkActionObservable *observable,
|
||||
GtkMenuTracker *
|
||||
gtk_menu_tracker_new_for_item_link (GtkMenuTrackerItem *item,
|
||||
const gchar *link_name,
|
||||
gboolean merge_sections,
|
||||
GtkMenuTrackerInsertFunc insert_func,
|
||||
GtkMenuTrackerRemoveFunc remove_func,
|
||||
gpointer user_data)
|
||||
@ -574,7 +579,7 @@ gtk_menu_tracker_new_for_item_link (GtkMenuTrackerItem *item,
|
||||
namespace = _gtk_menu_tracker_item_get_link_namespace (item);
|
||||
|
||||
tracker = gtk_menu_tracker_new (_gtk_menu_tracker_item_get_observable (item), submenu,
|
||||
TRUE, namespace, insert_func, remove_func, user_data);
|
||||
TRUE, merge_sections, namespace, insert_func, remove_func, user_data);
|
||||
|
||||
g_object_unref (submenu);
|
||||
g_free (namespace);
|
||||
|
@ -35,6 +35,7 @@ typedef void (* GtkMenuTrackerRemoveFunc) (gint
|
||||
GtkMenuTracker * gtk_menu_tracker_new (GtkActionObservable *observer,
|
||||
GMenuModel *model,
|
||||
gboolean with_separators,
|
||||
gboolean merge_sections,
|
||||
const gchar *action_namespace,
|
||||
GtkMenuTrackerInsertFunc insert_func,
|
||||
GtkMenuTrackerRemoveFunc remove_func,
|
||||
@ -42,6 +43,7 @@ GtkMenuTracker * gtk_menu_tracker_new (GtkActi
|
||||
|
||||
GtkMenuTracker * gtk_menu_tracker_new_for_item_link (GtkMenuTrackerItem *item,
|
||||
const gchar *link_name,
|
||||
gboolean merge_sections,
|
||||
GtkMenuTrackerInsertFunc insert_func,
|
||||
GtkMenuTrackerRemoveFunc remove_func,
|
||||
gpointer user_data);
|
||||
|
@ -2084,7 +2084,7 @@ gtk_popover_tracker_insert_func (GtkMenuTrackerItem *item,
|
||||
gtk_widget_set_halign (content, GTK_ALIGN_FILL);
|
||||
gtk_widget_show (content);
|
||||
gtk_container_add (GTK_CONTAINER (child), content);
|
||||
tracker = gtk_menu_tracker_new_for_item_link (item, G_MENU_LINK_SUBMENU,
|
||||
tracker = gtk_menu_tracker_new_for_item_link (item, G_MENU_LINK_SUBMENU, TRUE,
|
||||
gtk_popover_tracker_insert_func,
|
||||
gtk_popover_tracker_remove_func, content);
|
||||
|
||||
@ -2202,6 +2202,7 @@ gtk_popover_bind_model (GtkPopover *popover,
|
||||
priv->tracker = gtk_menu_tracker_new (GTK_ACTION_OBSERVABLE (muxer),
|
||||
model,
|
||||
TRUE,
|
||||
TRUE,
|
||||
action_namespace,
|
||||
gtk_popover_tracker_insert_func,
|
||||
gtk_popover_tracker_remove_func,
|
||||
|
Loading…
Reference in New Issue
Block a user