aboutsummaryrefslogtreecommitdiff
path: root/src/colloquium.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-03-31 19:18:58 +0200
committerThomas White <taw@bitwiz.me.uk>2018-03-31 19:19:42 +0200
commitd21213ef38b2027e3ac668d6906d0ff439b1885a (patch)
tree5b14fa8a8ed422ce585e4bb8901c2ef0c110daad /src/colloquium.c
parent2e5cf1278d8976a1d714c5fe2b0b58fd9175d975 (diff)
Use GResource for app menu and menu bar
Diffstat (limited to 'src/colloquium.c')
-rw-r--r--src/colloquium.c204
1 files changed, 5 insertions, 199 deletions
diff --git a/src/colloquium.c b/src/colloquium.c
index 3e49535..63cacc8 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -327,216 +327,22 @@ static void colloquium_startup(GApplication *papp)
g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries,
G_N_ELEMENTS(app_entries), app);
- builder = gtk_builder_new();
- gtk_builder_add_from_string(builder,
- "<interface>"
-
- " <menu id='app-menu'>"
- " <section>"
- " <item>"
- " <attribute name='label'>_New</attribute>"
- " <attribute name='action'>app.new</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;n</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>_Open...</attribute>"
- " <attribute name='action'>app.open</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;o</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Preferences</attribute>"
- " <attribute name='action'>app.prefs</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>_About</attribute>"
- " <attribute name='action'>app.about</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>_Quit</attribute>"
- " <attribute name='action'>app.quit</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;q</attribute>"
- " </item>"
- " </section>"
- " </menu>"
-
- " <menu id='menubar'>"
- " <submenu>"
- " <attribute name='label' translatable='yes'>File</attribute>"
-
- " <section>"
- " <item>"
- " <attribute name='label'>_New</attribute>"
- " <attribute name='action'>app.new</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;n</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>_Open...</attribute>"
- " <attribute name='action'>app.open</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;o</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>_Save</attribute>"
- " <attribute name='action'>win.save</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;s</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Save As...</attribute>"
- " <attribute name='action'>win.saveas</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>Print...</attribute>"
- " <attribute name='action'>win.print</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Export slides as PDF...</attribute>"
- " <attribute name='action'>win.exportpdf</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>Load stylesheet...</attribute>"
- " <attribute name='action'>win.loadstyle</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Save stylesheet...</attribute>"
- " <attribute name='action'>win.savestyle</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>_Quit</attribute>"
- " <attribute name='action'>app.quit</attribute>"
- " <attribute name='accel'>&lt;Primary&gt;q</attribute>"
- " </item>"
- " </section>"
- " </submenu>"
-
- " <submenu>"
- " <attribute name='label' translatable='yes'>Edit</attribute>"
- " <section>"
- " <item>"
- " <attribute name='label'>Undo</attribute>"
- " <attribute name='action'>win.undo</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Redo</attribute>"
- " <attribute name='action'>win.redo</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>Cut</attribute>"
- " <attribute name='action'>win.cut</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Copy</attribute>"
- " <attribute name='action'>win.copy</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Paste</attribute>"
- " <attribute name='action'>win.paste</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>Delete frame</attribute>"
- " <attribute name='action'>win.deleteframe</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Copy Frame</attribute>"
- " <attribute name='action'>win.copyframe</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Delete slide</attribute>"
- " <attribute name='action'>win.deleteslide</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>Edit stylesheet...</attribute>"
- " <attribute name='action'>win.stylesheet</attribute>"
- " </item>"
- " </section>"
- " <section>"
- " <item>"
- " <attribute name='label'>Preferences</attribute>"
- " <attribute name='action'>app.prefs</attribute>"
- " </item>"
- " </section>"
- " </submenu>"
-
- " <submenu>"
- " <attribute name='label' translatable='yes'>Insert</attribute>"
- " <section>"
- " <item>"
- " <attribute name='label'>Slide</attribute>"
- " <attribute name='action'>win.slide</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Slide title</attribute>"
- " <attribute name='action'>win.slidetitle</attribute>"
- " </item>"
- " </section>"
- " </submenu>"
-
- " <submenu>"
- " <attribute name='label' translatable='yes'>Tools</attribute>"
- " <section>"
- " <item>"
- " <attribute name='label'>Start slideshow</attribute>"
- " <attribute name='action'>win.startslideshow</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Start slideshow here</attribute>"
- " <attribute name='action'>win.startslideshowhere</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Start slideshow without slides</attribute>"
- " <attribute name='action'>win.startslideshownoslides</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Presentation clock</attribute>"
- " <attribute name='action'>win.clock</attribute>"
- " </item>"
- " <item>"
- " <attribute name='label'>Test card</attribute>"
- " <attribute name='action'>win.testcard</attribute>"
- " </item>"
- " </section>"
- " </submenu>"
-
- " <submenu>"
- " <attribute name='label' translatable='yes'>Help</attribute>"
- " <section>"
- " <item>"
- " <attribute name='label'>About</attribute>"
- " <attribute name='action'>app.about</attribute>"
- " </item>"
- " </section>"
- " </submenu>"
- " </menu>"
-
- "</interface>", -1, NULL);
-
+ builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/menu-bar.ui");
gtk_application_set_menubar(GTK_APPLICATION(app),
G_MENU_MODEL(gtk_builder_get_object(builder, "menubar")));
+ g_object_unref(builder);
if ( gtk_application_prefers_app_menu(GTK_APPLICATION(app)) ) {
/* Set the application menu only if it will be shown by the
* desktop environment. All the entries are already in the
* normal menus, so don't let GTK create a fallback menu in the
* menu bar. */
- GMenuModel *mmodel = G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu"));
printf("Using app menu\n");
+ builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/app-menu.ui");
+ GMenuModel *mmodel = G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu"));
gtk_application_set_app_menu(GTK_APPLICATION(app), mmodel);
+ g_object_unref(builder);
}
- g_object_unref(builder);
configdir = g_get_user_config_dir();
app->mydir = malloc(strlen(configdir)+14);