diff options
-rw-r--r-- | data/app-menu.ui | 32 | ||||
-rw-r--r-- | data/colloquium.gresource.xml | 2 | ||||
-rw-r--r-- | data/menu-bar.ui | 164 | ||||
-rw-r--r-- | src/colloquium.c | 204 |
4 files changed, 203 insertions, 199 deletions
diff --git a/data/app-menu.ui b/data/app-menu.ui new file mode 100644 index 0000000..33165ac --- /dev/null +++ b/data/app-menu.ui @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<interface> + <menu id='app-menu'> + <section> + <item> + <attribute name='label'>_New</attribute> + <attribute name='action'>app.new</attribute> + <attribute name='accel'><Primary>n</attribute> + </item> + <item> + <attribute name='label'>_Open...</attribute> + <attribute name='action'>app.open</attribute> + <attribute name='accel'><Primary>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'><Primary>q</attribute> + </item> + </section> + </menu> +</interface> diff --git a/data/colloquium.gresource.xml b/data/colloquium.gresource.xml index 5af8c0e..99b27ff 100644 --- a/data/colloquium.gresource.xml +++ b/data/colloquium.gresource.xml @@ -2,5 +2,7 @@ <gresources> <gresource prefix="/uk/me/bitwiz/Colloquium"> <file>sky.png</file> + <file>app-menu.ui</file> + <file>menu-bar.ui</file> </gresource> </gresources> diff --git a/data/menu-bar.ui b/data/menu-bar.ui new file mode 100644 index 0000000..d5f164f --- /dev/null +++ b/data/menu-bar.ui @@ -0,0 +1,164 @@ +<?xml version="1.0"?> +<interface> + <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'><Primary>n</attribute> + </item> + <item> + <attribute name='label'>_Open...</attribute> + <attribute name='action'>app.open</attribute> + <attribute name='accel'><Primary>o</attribute> + </item> + </section> + <section> + <item> + <attribute name='label'>_Save</attribute> + <attribute name='action'>win.save</attribute> + <attribute name='accel'><Primary>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'><Primary>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> 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'><Primary>n</attribute>" - " </item>" - " <item>" - " <attribute name='label'>_Open...</attribute>" - " <attribute name='action'>app.open</attribute>" - " <attribute name='accel'><Primary>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'><Primary>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'><Primary>n</attribute>" - " </item>" - " <item>" - " <attribute name='label'>_Open...</attribute>" - " <attribute name='action'>app.open</attribute>" - " <attribute name='accel'><Primary>o</attribute>" - " </item>" - " </section>" - " <section>" - " <item>" - " <attribute name='label'>_Save</attribute>" - " <attribute name='action'>win.save</attribute>" - " <attribute name='accel'><Primary>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'><Primary>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); |