mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
GtkApplication: add menu API
We add the app-menu and menubar public APIs to GtkApplication while leaving the implementation in GApplication. The actual implementation will be moved soon.
This commit is contained in:
parent
4e5e47931d
commit
8578fefaa5
@ -7006,6 +7006,12 @@ gtk_application_add_window
|
||||
gtk_application_remove_window
|
||||
gtk_application_get_windows
|
||||
|
||||
<SUBSECTION>
|
||||
gtk_application_get_app_menu
|
||||
gtk_application_set_app_menu
|
||||
gtk_application_get_menubar
|
||||
gtk_application_set_menubar
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GtkApplicationClass
|
||||
GTK_TYPE_APPLICATION
|
||||
|
@ -223,8 +223,8 @@ bloat_pad_startup (GApplication *application)
|
||||
" </submenu>"
|
||||
" </menu>"
|
||||
"</interface>", -1, NULL);
|
||||
g_application_set_app_menu (application, G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
|
||||
g_application_set_menubar (application, G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
|
||||
gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
|
||||
gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
|
@ -415,8 +415,8 @@ plug_man_startup (GApplication *application)
|
||||
" </submenu>"
|
||||
" </menu>"
|
||||
"</interface>", -1, NULL);
|
||||
g_application_set_app_menu (application, G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
|
||||
g_application_set_menubar (application, G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
|
||||
gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
|
||||
gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
|
||||
g_object_set_data_full (G_OBJECT (application), "plugin-menu", gtk_builder_get_object (builder, "plugins"), g_object_unref);
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ gtk_application_menu_changed_quartz (GObject *object,
|
||||
GMenu *combined;
|
||||
|
||||
combined = g_menu_new ();
|
||||
g_menu_append_submenu (combined, "Application", g_application_get_app_menu (G_APPLICATION (object)));
|
||||
g_menu_append_section (combined, NULL, g_application_get_menubar (G_APPLICATION (object)));
|
||||
g_menu_append_submenu (combined, "Application", g_application_get_app_menu (application));
|
||||
g_menu_append_section (combined, NULL, gtk_application_get_menubar (application));
|
||||
|
||||
gtk_quartz_set_main_menu (G_MENU_MODEL (combined), G_ACTION_OBSERVABLE (application->priv->muxer));
|
||||
}
|
||||
@ -748,3 +748,98 @@ gtk_application_remove_accelerator (GtkApplication *application,
|
||||
gtk_accel_map_change_entry (accel_path, 0, 0, FALSE);
|
||||
g_free (accel_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_set_app_menu:
|
||||
* @application: a #GtkApplication
|
||||
* @app_menu: (allow-none): a #GMenuModel, or %NULL
|
||||
*
|
||||
* Sets or unsets the application menu for @application.
|
||||
*
|
||||
* The application menu is a single menu containing items that typically
|
||||
* impact the application as a whole, rather than acting on a specific
|
||||
* window or document. For example, you would expect to see
|
||||
* "Preferences" or "Quit" in an application menu, but not "Save" or
|
||||
* "Print".
|
||||
*
|
||||
* If supported, the application menu will be rendered by the desktop
|
||||
* environment.
|
||||
*
|
||||
* Since: 3.4
|
||||
*/
|
||||
void
|
||||
gtk_application_set_app_menu (GtkApplication *application,
|
||||
GMenuModel *app_menu)
|
||||
{
|
||||
g_object_set (application, "app-menu", app_menu, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_get_app_menu:
|
||||
* @application: a #GtkApplication
|
||||
*
|
||||
* Returns the menu model that has been set with
|
||||
* g_application_set_app_menu().
|
||||
*
|
||||
* Returns: the application menu of @application
|
||||
*
|
||||
* Since: 3.4
|
||||
*/
|
||||
GMenuModel *
|
||||
gtk_application_get_app_menu (GtkApplication *application)
|
||||
{
|
||||
GMenuModel *app_menu;
|
||||
|
||||
g_object_get (application, "app-menu", &app_menu, NULL);
|
||||
g_object_unref (app_menu);
|
||||
|
||||
return app_menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_set_menubar:
|
||||
* @application: a #GtkApplication
|
||||
* @menubar: (allow-none): a #GMenuModel, or %NULL
|
||||
*
|
||||
* Sets or unsets the menubar for windows of @application.
|
||||
*
|
||||
* This is a menubar in the traditional sense.
|
||||
*
|
||||
* Depending on the desktop environment, this may appear at the top of
|
||||
* each window, or at the top of the screen. In some environments, if
|
||||
* both the application menu and the menubar are set, the application
|
||||
* menu will be presented as if it were the first item of the menubar.
|
||||
* Other environments treat the two as completely separate -- for
|
||||
* example, the application menu may be rendered by the desktop shell
|
||||
* while the menubar (if set) remains in each individual window.
|
||||
*
|
||||
* Since: 3.4
|
||||
*/
|
||||
void
|
||||
gtk_application_set_menubar (GtkApplication *application,
|
||||
GMenuModel *menubar)
|
||||
{
|
||||
g_object_set (application, "menubar", menubar, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_get_menubar:
|
||||
* @application: a #GtkApplication
|
||||
*
|
||||
* Returns the menu model that has been set with
|
||||
* g_application_set_menubar().
|
||||
*
|
||||
* Returns: the menubar for windows of @application
|
||||
*
|
||||
* Since: 3.4
|
||||
*/
|
||||
GMenuModel *
|
||||
gtk_application_get_menubar (GtkApplication *application)
|
||||
{
|
||||
GMenuModel *menubar;
|
||||
|
||||
g_object_get (application, "menubar", &menubar, NULL);
|
||||
g_object_unref (menubar);
|
||||
|
||||
return menubar;
|
||||
}
|
||||
|
@ -73,9 +73,16 @@ void gtk_application_add_window (GtkApplication *application,
|
||||
|
||||
void gtk_application_remove_window (GtkApplication *application,
|
||||
GtkWindow *window);
|
||||
|
||||
GList * gtk_application_get_windows (GtkApplication *application);
|
||||
|
||||
GMenuModel * gtk_application_get_app_menu (GtkApplication *application);
|
||||
void gtk_application_set_app_menu (GtkApplication *application,
|
||||
GMenuModel *model);
|
||||
|
||||
GMenuModel * gtk_application_get_menubar (GtkApplication *application);
|
||||
void gtk_application_set_menubar (GtkApplication *application,
|
||||
GMenuModel *model);
|
||||
|
||||
void gtk_application_add_accelerator (GtkApplication *application,
|
||||
const gchar *accelerator,
|
||||
const gchar *action_name,
|
||||
|
@ -251,7 +251,7 @@ gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window
|
||||
{
|
||||
GMenuModel *app_menu;
|
||||
|
||||
app_menu = g_application_get_app_menu (G_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
|
||||
app_menu = gtk_application_get_app_menu (gtk_window_get_application (GTK_WINDOW (window)));
|
||||
|
||||
if (app_menu != NULL)
|
||||
g_menu_append_submenu (window->priv->app_menu_section, _("Application"), app_menu);
|
||||
@ -280,7 +280,7 @@ gtk_application_window_update_shell_shows_menubar (GtkApplicationWindow *window,
|
||||
{
|
||||
GMenuModel *menubar;
|
||||
|
||||
menubar = g_application_get_menubar (G_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
|
||||
menubar = gtk_application_get_menubar (gtk_window_get_application (GTK_WINDOW (window)));
|
||||
|
||||
if (menubar != NULL)
|
||||
g_menu_append_section (window->priv->menubar_section, NULL, menubar);
|
||||
|
Loading…
Reference in New Issue
Block a user