forked from AuroraMiddleware/gtk
gtk-demo: Stop using appmenu apis
The appmenu-related GtkApplication apis are going away.
This commit is contained in:
parent
962c4d6a69
commit
ca1c570c21
@ -328,19 +328,14 @@ static void
|
||||
startup (GApplication *app)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *appmenu;
|
||||
GMenuModel *menubar;
|
||||
|
||||
G_APPLICATION_CLASS (demo_application_parent_class)->startup (app);
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (builder, "/application_demo/menus.ui", NULL);
|
||||
|
||||
appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
|
||||
menubar = (GMenuModel *)gtk_builder_get_object (builder, "menubar");
|
||||
|
||||
gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
|
||||
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
|
||||
gtk_application_set_menubar (GTK_APPLICATION (app),
|
||||
G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
@ -353,6 +348,7 @@ create_window (GApplication *app,
|
||||
|
||||
window = (DemoApplicationWindow *)g_object_new (demo_application_window_get_type (),
|
||||
"application", app,
|
||||
"show-menubar", TRUE,
|
||||
NULL);
|
||||
if (content)
|
||||
gtk_text_buffer_set_text (window->buffer, content, -1);
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="appmenu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">About</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
<attribute name="accel"><Control>q</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
@ -2,7 +2,6 @@
|
||||
<gresources>
|
||||
<gresource prefix="/ui">
|
||||
<file preprocess="xml-stripblanks">main.ui</file>
|
||||
<file preprocess="xml-stripblanks">appmenu.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/application_demo">
|
||||
<file>application.c</file>
|
||||
|
@ -972,23 +972,6 @@ populate_model (GtkTreeModel *model)
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
startup (GApplication *app)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *appmenu;
|
||||
const char *ids[] = { "appmenu", NULL };
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);
|
||||
|
||||
appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
|
||||
|
||||
gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
static void
|
||||
row_activated_cb (GtkWidget *tree_view,
|
||||
GtkTreePath *path,
|
||||
@ -1219,7 +1202,6 @@ main (int argc, char **argv)
|
||||
g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples", NULL);
|
||||
g_application_add_main_option (G_APPLICATION (app), "autoquit", 0, 0, G_OPTION_ARG_NONE, "Quit after a delay", NULL);
|
||||
|
||||
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||
g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
|
||||
g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL);
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="appmenu">
|
||||
<menu id="menubar">
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_Application</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_New</attribute>
|
||||
@ -29,10 +31,9 @@
|
||||
<attribute name="accel"><Control>q</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="menubar">
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name="label" translatable="yes">_Preferences</attribute>
|
||||
<attribute name="label" translatable="yes">_File</attribute>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Prefer Dark Theme</attribute>
|
||||
|
Loading…
Reference in New Issue
Block a user