[easytag/wip/application-window: 44/72] Add an app menu
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 44/72] Add an app menu
- Date: Wed, 30 Jul 2014 15:43:39 +0000 (UTC)
commit fbd3c7252bcb4f75c15776c71c13b99a3b1595e5
Author: David King <amigadave amigadave com>
Date: Sat Jul 12 22:31:04 2014 +0100
Add an app menu
Install application-wide actions for help, about and quit. Load the app
menu from a resource.
.gitignore | 2 +
Makefile.am | 19 +++++++++-
TODO | 1 -
configure.ac | 4 +-
data/menus.ui | 20 ++++++++++
data/org.gnome.EasyTAG.gresource.xml | 6 +++
po/POTFILES.in | 1 +
src/application.c | 69 +++++++++++++++++++++++++++++++++-
src/bar.c | 9 ----
src/bar.h | 3 -
src/misc.c | 19 ---------
src/misc.h | 2 -
src/ui_manager.h | 7 ---
13 files changed, 118 insertions(+), 44 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b6c5024..f6c5441 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,8 @@ configure
/src/win32/easytag.rc
/src/enums.c
/src/enums.h
+/src/resource.c
+/src/resource.h
/????-report.html
/????-report.xml
/test-suite.log
diff --git a/Makefile.am b/Makefile.am
index 9bdb5a0..75c235d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -83,6 +83,9 @@ easytag_SOURCES = \
src/wavpack_tag.c \
src/win32/win32dep.c
+nodist_easytag_SOURCES = \
+ src/resource.c
+
easytag_headers = \
src/id3lib/id3_bugfix.h \
src/libapetag/apetaglib.h \
@@ -131,11 +134,20 @@ easytag_headers = \
src/wavpack_tag.h \
src/win32/win32dep.h
+nodist_easytag_headers = \
+ src/resource.h
+
easytag_LDADD = \
$(EASYTAG_LIBS) \
$(ID3LIB_LIBS) \
$(easytag_rc)
+noinst_resource_files = \
+ $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(srcdir)/data
$(srcdir)/data/org.gnome.EasyTAG.gresource.xml)
+
+src/resource.c src/resource.h: data/org.gnome.EasyTAG.gresource.xml Makefile $(noinst_resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/data --generate $<
+
if WINDOWS_HOST
ICONDIR = $(srcdir)/data/icons/win32
MANIFESTDIR = $(srcdir)/src/win32
@@ -157,6 +169,7 @@ easytag-$(PACKAGE_VERSION)-setup.exe: easytag-win32-installer.nsi easytag.exe Ma
endif
BUILT_SOURCES = \
+ $(nodist_easytag_SOURCES) \
src/enums.h
enum_data = \
@@ -324,6 +337,8 @@ dist_noinst_DATA = \
$(desktop_in_files) \
$(gsettings_SCHEMAS) \
$(easytag_headers) \
+ data/org.gnome.EasyTAG.gresource.xml \
+ $(noinst_resource_files) \
src/id3lib/patch_id3lib_3.8.3_UTF16_writing_bug.diff \
src/libapetag/COPYING.LGPL \
src/libapetag/README.apetag \
@@ -422,7 +437,9 @@ CLEANFILES = \
$(nodist_man_MANS) \
*.log \
easytag-$(PACKAGE_VERSION)-setup.exe \
- easytag-win32-installer.nsi
+ easytag-win32-installer.nsi \
+ src/resource.c \
+ src/resource.h
DISTCLEANFILES = \
po/.intltool-merge-cache
diff --git a/TODO b/TODO
index 0ae2059..9be4c8a 100644
--- a/TODO
+++ b/TODO
@@ -15,7 +15,6 @@ After GTK+ 3
------------
* Port to GtkApplication
-* Add an application menu with gtk_application_set_app_menu()
* Use GtkAppChooserDialog for selecting applications
Tagging features
diff --git a/configure.ac b/configure.ac
index ffcd1fe..e559e48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,8 @@ AC_PROG_CXXCPP
AC_PROG_SED
PKG_PROG_PKG_CONFIG([0.24])
+AC_SUBST([GLIB_COMPILE_RESOURCES], [`$PKG_CONFIG --variable glib_compile_resources gio-2.0`])
+
AC_MSG_CHECKING([for glib-mkenums script])
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
AS_IF([test "x$GLIB_MKENUMS" = "x"],
@@ -159,7 +161,7 @@ dnl Checks for libraries.
dnl -------------------------------
dnl GTK+ libraries
-GTK_DEPS="gtk+-3.0 >= 3.2.1"
+GTK_DEPS="gtk+-3.0 >= 3.4.0"
GTK_DEPRECATION_FLAGS="-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4"
dnl Patch from Ben Taylor to fix a Solaris bug (for CDDB)
diff --git a/data/menus.ui b/data/menus.ui
new file mode 100644
index 0000000..b393846
--- /dev/null
+++ b/data/menus.ui
@@ -0,0 +1,20 @@
+<interface domain='easytag'>
+ <menu id='app-menu'>
+ <section>
+ <item>
+ <attribute name="accel">F1</attribute>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">app.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ <item>
+ <attribute name="accel"><Primary>q</attribute>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/data/org.gnome.EasyTAG.gresource.xml b/data/org.gnome.EasyTAG.gresource.xml
new file mode 100644
index 0000000..b475283
--- /dev/null
+++ b/data/org.gnome.EasyTAG.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix='/org/gnome/EasyTAG'>
+ <file preprocess='xml-stripblanks'>menus.ui</file>
+ </gresource>
+</gresources>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 58a7009..4c642a1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,5 +1,6 @@
data/easytag.appdata.xml.in
data/easytag.desktop.in
+[type: gettext/glade]data/menus.ui
data/org.gnome.EasyTAG.gschema.xml
nautilus-extension/nautilus-easytag.c
src/about.c
diff --git a/src/application.c b/src/application.c
index 239e526..16bb5ea 100644
--- a/src/application.c
+++ b/src/application.c
@@ -19,7 +19,10 @@
#include "config.h"
#include "application.h"
+
+#include "about.h"
#include "charset.h"
+#include "easytag.h"
#include <glib/gi18n.h>
#include <stdlib.h>
@@ -33,6 +36,49 @@ static const GOptionEntry entries[] =
{ NULL }
};
+static void
+on_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+/* TODO: Link to help.gnome.org, or locally-installed help, on Windows. */
+#ifndef G_OS_WIN32
+ GError *error = NULL;
+
+ gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (MainWindow)),
+ "help:easytag", GDK_CURRENT_TIME, &error);
+
+ if (error)
+ {
+ g_debug ("Error while opening help: %s", error->message);
+ g_error_free (error);
+ }
+#endif
+}
+
+static void
+on_about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ Show_About_Window ();
+}
+
+static void
+on_quit (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ Quit_MainWindow ();
+}
+
+static const GActionEntry actions[] =
+{
+ { "help", on_help },
+ { "about", on_about },
+ { "quit", on_quit }
+};
+
/*
* et_local_command_line:
* @application: the application
@@ -130,9 +176,30 @@ et_local_command_line (GApplication *application, gchar **arguments[],
static void
et_application_startup (GApplication *application)
{
- Charset_Insert_Locales_Init ();
+ GtkBuilder *builder;
+ GError *error = NULL;
+ GMenuModel *appmenu;
+
+ g_action_map_add_action_entries (G_ACTION_MAP (application), actions,
+ G_N_ELEMENTS (actions), application);
G_APPLICATION_CLASS (et_application_parent_class)->startup (application);
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder, "/org/gnome/EasyTAG/menus.ui",
+ &error);
+
+ if (error != NULL)
+ {
+ g_error ("Unable to get app menu from resource: %s", error->message);
+ }
+
+ appmenu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
+ gtk_application_set_app_menu (GTK_APPLICATION (application), appmenu);
+
+ g_object_unref (builder);
+
+ Charset_Insert_Locales_Init ();
}
static void
diff --git a/src/bar.c b/src/bar.c
index 52e2da0..adac839 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -25,7 +25,6 @@
#include "application_window.h"
#include "bar.h"
#include "easytag.h"
-#include "about.h"
#include "preferences_dialog.h"
#include "setting.h"
#include "browser.h"
@@ -331,14 +330,6 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ MENU_VIEW, NULL, _("_View"), NULL, NULL, NULL },
{ MENU_GO, NULL, _("_Go"), NULL, NULL, NULL },
- { MENU_HELP, NULL, _("_Help"), NULL,
NULL, NULL },
-/* TODO: Link to help.gnome.org, or locally-installed help, on Windows. */
-#ifndef G_OS_WIN32
- { AM_OPEN_HELP_CONTENTS, GTK_STOCK_HELP, _("_Contents"), "F1",
- _("Show help"), G_CALLBACK (et_show_help) },
-#endif
- { AM_OPEN_ABOUT_WINDOW, GTK_STOCK_ABOUT, _("_About"), NULL,
_("About"), G_CALLBACK(Show_About_Window) },
-
/*
* Following items are on toolbar but not on menu
diff --git a/src/bar.h b/src/bar.h
index 947fa72..aae4fc9 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -40,7 +40,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
#define MENU_BROWSER "BrowserMenu"
#define MENU_SCANNER "ScannerMenu"
#define MENU_MISC "MiscMenu"
-#define MENU_HELP "HelpMenu"
#define MENU_FILE_SORT_TAG "SortTagMenu"
#define MENU_FILE_SORT_PROP "SortPropMenu"
@@ -99,8 +98,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
#define AM_FILENAME_FROM_TXT "LoadFilenames"
#define AM_WRITE_PLAYLIST "WritePlaylist"
#define AM_RUN_AUDIO_PLAYER "RunAudio"
-#define AM_OPEN_ABOUT_WINDOW "About"
-#define AM_OPEN_HELP_CONTENTS "HelpContents"
#define AM_QUIT "Quit"
#define AM_ARTIST_RUN_AUDIO_PLAYER "ArtistRunAudio"
diff --git a/src/misc.c b/src/misc.c
index decb403..95792cb 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -875,25 +875,6 @@ gchar *Convert_Duration (gulong duration)
}
/*
- * et_show_help:
- */
-void
-et_show_help (void)
-{
- GError *error = NULL;
-
- /* TODO: Add link to application help instead. */
- gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (MainWindow)),
- "help:easytag", GDK_CURRENT_TIME, &error);
-
- if (error)
- {
- g_debug ("Error while opening help: %s", error->message);
- g_error_free (error);
- }
-}
-
-/*
* @filename: (type filename): the path to a file
*
* Gets the size of a file in bytes.
diff --git a/src/misc.h b/src/misc.h
index 34b72c1..bf1200e 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -65,8 +65,6 @@ void Run_Audio_Player_Using_Directory (void);
gchar *Convert_Duration (gulong duration);
-void et_show_help (void);
-
goffset et_get_file_size (const gchar *filename);
gint Combo_Alphabetic_Sort (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data);
diff --git a/src/ui_manager.h b/src/ui_manager.h
index c3d5454..5c08665 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -176,13 +176,6 @@ static const gchar *ui_xml =
" <menuitem action='LastFile' />"
" </menu>"
-" <menu action='HelpMenu'>"
-#ifndef G_OS_WIN32
-" <menuitem action='HelpContents' />"
-#endif /* !G_OS_WIN32 */
-" <menuitem action='About' />"
-" </menu>"
-
" </menubar>"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]