GtkMenuTracker: add hidden-when='macos-menubar'
Provide a mechanism for hiding the "Quit", "About" and "Preferences" menu items from the normal places in a traditional menubar layout (in the File and Edit menus) when the menu is being rendered in the Mac OS menubar. These items can already be found in the application menu. With this feature, applications can now define a single menu to use in all 'traditional' scenarios. Use this new attribute in Bloatpad. https://bugzilla.gnome.org/show_bug.cgi?id=741610
This commit is contained in:
committed by
Matthias Clasen
parent
4bc3f02d51
commit
6b26664c41
@ -103,6 +103,7 @@ struct _GtkMenuTrackerItem
|
||||
#define HIDDEN_NEVER 0
|
||||
#define HIDDEN_WHEN_MISSING 1
|
||||
#define HIDDEN_WHEN_DISABLED 2
|
||||
#define HIDDEN_WHEN_ALWAYS 3
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@ -271,6 +272,10 @@ gtk_menu_tracker_item_update_visibility (GtkMenuTrackerItem *self)
|
||||
visible = self->sensitive;
|
||||
break;
|
||||
|
||||
case HIDDEN_WHEN_ALWAYS:
|
||||
visible = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@ -479,6 +484,7 @@ GtkMenuTrackerItem *
|
||||
_gtk_menu_tracker_item_new (GtkActionObservable *observable,
|
||||
GMenuModel *model,
|
||||
gint item_index,
|
||||
gboolean mac_os_mode,
|
||||
const gchar *action_namespace,
|
||||
gboolean is_separator)
|
||||
{
|
||||
@ -501,6 +507,8 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
|
||||
self->hidden_when = HIDDEN_WHEN_DISABLED;
|
||||
else if (g_str_equal (hidden_when, "action-missing"))
|
||||
self->hidden_when = HIDDEN_WHEN_MISSING;
|
||||
else if (mac_os_mode && g_str_equal (hidden_when, "macos-menubar"))
|
||||
self->hidden_when = HIDDEN_WHEN_ALWAYS;
|
||||
|
||||
/* Ignore other values -- this code may be running in context of a
|
||||
* desktop shell or the like and should not spew criticals due to
|
||||
|
||||
Reference in New Issue
Block a user