[easytag/wip/application-window: 12/47] Use GMenuModel for popup menus



commit 88fc9a57a492935aad23e8dd4f61181509a4a9be
Author: David King <amigadave amigadave com>
Date:   Sun Jul 13 21:36:14 2014 +0100

    Use GMenuModel for popup menus

 data/menus.ui            |  378 ++++++++++++++++++++++++++++++++++++++++++++++
 src/application_window.c |  119 ++++++++-------
 src/application_window.h |    4 -
 src/bar.c                |   22 ---
 src/bar.h                |   10 --
 src/browser.c            |   58 +++++---
 src/log.c                |   32 +++-
 src/log.h                |    2 +-
 src/ui_manager.h         |  131 ----------------
 9 files changed, 509 insertions(+), 247 deletions(-)
---
diff --git a/data/menus.ui b/data/menus.ui
index 66b5ea4..c5604ac 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -523,4 +523,382 @@
             </section>
         </submenu>
     </menu>
+    <menu id='directory-menu'>
+        <section>
+            <item>
+                <attribute name="action">win.run-player-directory</attribute>
+                <attribute name="label" translatable="yes">Run Audio Player</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.go-home</attribute>
+                <attribute name="label" translatable="yes">Home Directory</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.go-default</attribute>
+                <attribute name="label" translatable="yes">Default Directory</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.set-default-path</attribute>
+                <attribute name="label" translatable="yes">Set Current Path as Default</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.rename-directory</attribute>
+                <attribute name="label" translatable="yes">Rename Directory</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.reload-directory</attribute>
+                <attribute name="label" translatable="yes">Reload Directory</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.browse-directory</attribute>
+                <attribute name="label" translatable="yes">Browse Directory With…</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.browse-subdir</attribute>
+                <attribute name="label" translatable="yes">Browse Subdirectories</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.browse-show-hidden</attribute>
+                <attribute name="label" translatable="yes">Show Hidden Directories</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.collapse-tree</attribute>
+                <attribute name="label" translatable="yes">Collapse Tree</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.reload-tree</attribute>
+                <attribute name="label" translatable="yes">Reload Tree</attribute>
+            </item>
+        </section>
+    </menu>
+    <menu id='directory-album-menu'>
+        <section>
+            <item>
+                <attribute name="action">win.run-player-album</attribute>
+                <attribute name="label" translatable="yes">Run Audio Player</attribute>
+            </item>
+        </section>
+    </menu>
+    <menu id='directory-artist-menu'>
+        <section>
+            <item>
+                <attribute name="action">win.run-player-artist</attribute>
+                <attribute name="label" translatable="yes">Run Audio Player</attribute>
+            </item>
+        </section>
+    </menu>
+    <menu id='file-menu'>
+        <section>
+            <item>
+                <attribute name="action">win.select-all</attribute>
+                <attribute name="label" translatable="yes">Select All</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.unselect-all</attribute>
+                <attribute name="label" translatable="yes">Unselect All</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.invert-selection</attribute>
+                <attribute name="label" translatable="yes">Invert Selection</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.run-player</attribute>
+                <attribute name="label" translatable="yes">Run Audio Player</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.scanner</attribute>
+                <attribute name="label" translatable="yes">Show Scanner</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="action">win.show-cddb-selection</attribute>
+                <attribute name="label" translatable="yes">CDDB Search Files…</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.find</attribute>
+                <attribute name="label" translatable="yes">Find…</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.delete</attribute>
+                <attribute name="label" translatable="yes">Delete Files</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.reload-directory</attribute>
+                <attribute name="label" translatable="yes">Reload Directory</attribute>
+            </item>
+            <item>
+                <attribute name="action">win.open-with</attribute>
+                <attribute name="label" translatable="yes">Open Files With…</attribute>
+            </item>
+        </section>
+        <section>
+            <submenu>
+                <attribute name="label" translatable="yes">Sort List by Tag</attribute>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by track number</attribute>
+                        <attribute name="target">ascending-track-number</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by track number</attribute>
+                        <attribute name="target">descending-track-number</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by title</attribute>
+                        <attribute name="target">ascending-title</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by title</attribute>
+                        <attribute name="target">descending-title</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by artist</attribute>
+                        <attribute name="target">ascending-artist</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by artist</attribute>
+                        <attribute name="target">descending-artist</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by album artist</attribute>
+                        <attribute name="target">ascending-album-artist</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by album artist</attribute>
+                        <attribute name="target">descending-album-artist</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by album</attribute>
+                        <attribute name="target">ascending-album</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by album</attribute>
+                        <attribute name="target">descending-album</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by year</attribute>
+                        <attribute name="target">ascending-year</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by year</attribute>
+                        <attribute name="target">descending-year</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by genre</attribute>
+                        <attribute name="target">ascending-genre</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by genre</attribute>
+                        <attribute name="target">descending-genre</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by comment</attribute>
+                        <attribute name="target">ascending-comment</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by comment</attribute>
+                        <attribute name="target">descending-comment</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by composer</attribute>
+                        <attribute name="target">ascending-composer</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by composer</attribute>
+                        <attribute name="target">descending-composer</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by original artist</attribute>
+                        <attribute name="target">ascending-orig-artist</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by original artist</attribute>
+                        <attribute name="target">descending-orig-artist</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by copyright</attribute>
+                        <attribute name="target">ascending-copyright</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by copyright</attribute>
+                        <attribute name="target">descending-copyright</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by URL</attribute>
+                        <attribute name="target">ascending-url</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by URL</attribute>
+                        <attribute name="target">descending-url</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by encoder name</attribute>
+                        <attribute name="target">ascending-encoded-by</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by encoder name</attribute>
+                        <attribute name="target">descending-encoded-by</attribute>
+                    </item>
+                </section>
+            </submenu>
+            <submenu>
+                <attribute name="label" translatable="yes">Sort List by Property</attribute>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by filename</attribute>
+                        <attribute name="target">ascending-filename</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by filename</attribute>
+                        <attribute name="target">descending-filename</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by creation date</attribute>
+                        <attribute name="target">ascending-creation-date</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by creation date</attribute>
+                        <attribute name="target">descending-creation-date</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by file type</attribute>
+                        <attribute name="target">ascending-file-type</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by file type</attribute>
+                        <attribute name="target">descending-file-type</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by file size</attribute>
+                        <attribute name="target">ascending-file-size</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by file size</attribute>
+                        <attribute name="target">descending-file-size</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by duration</attribute>
+                        <attribute name="target">ascending-file-duration</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by duration</attribute>
+                        <attribute name="target">descending-file-duration</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by bitrate</attribute>
+                        <attribute name="target">ascending-file-bitrate</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by bitrate</attribute>
+                        <attribute name="target">descending-file-bitrate</attribute>
+                    </item>
+                </section>
+                <section>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Ascending by samplerate</attribute>
+                        <attribute name="target">ascending-file-samplerate</attribute>
+                    </item>
+                    <item>
+                        <attribute name="action">win.sort-mode</attribute>
+                        <attribute name="label" translatable="yes">Descending by samplerate</attribute>
+                        <attribute name="target">descending-file-samplerate</attribute>
+                    </item>
+                </section>
+            </submenu>
+        </section>
+    </menu>
+    <menu id='log-menu'>
+        <section>
+            <item>
+                <attribute name="action">win.clear-log</attribute>
+                <attribute name="label" translatable="yes">Clear Log</attribute>
+            </item>
+        </section>
+    </menu>
 </interface>
diff --git a/src/application_window.c b/src/application_window.c
index 0c96f46..ce8556c 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -2806,6 +2806,67 @@ on_go_last (GSimpleAction *action,
     }
 }
 
+static void
+on_show_cddb_selection (GSimpleAction *action,
+                        GVariant *variant,
+                        gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_application_window_show_cddb_dialog (self);
+    et_cddb_dialog_search_from_selection (ET_CDDB_DIALOG (priv->cddb_dialog));
+}
+
+static void
+on_clear_log (GSimpleAction *action,
+              GVariant *variant,
+              gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_log_area_clear (ET_LOG_AREA (priv->log_area));
+}
+
+static void
+on_run_player_album (GSimpleAction *action,
+                     GVariant *variant,
+                     gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_run_player_for_album_list (ET_BROWSER (priv->browser));
+}
+
+static void
+on_run_player_artist (GSimpleAction *action,
+                      GVariant *variant,
+                      gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_run_player_for_artist_list (ET_BROWSER (priv->browser));
+}
+
+static void
+on_run_player_directory (GSimpleAction *action,
+                         GVariant *variant,
+                         gpointer user_data)
+{
+    Run_Audio_Player_Using_Directory ();
+}
+
 static const GActionEntry actions[] =
 {
     /* File menu. */
@@ -2859,6 +2920,12 @@ static const GActionEntry actions[] =
     { "go-previous", on_go_previous },
     { "go-next", on_go_next },
     { "go-last", on_go_last },
+    /* Popup menus. */
+    { "show-cddb-selection", on_show_cddb_selection },
+    { "clear-log", on_clear_log },
+    { "run-player-album", on_run_player_album },
+    { "run-player-artist", on_run_player_artist },
+    { "run-player-directory", on_run_player_directory }
 };
 
 static void
@@ -3161,19 +3228,6 @@ et_application_window_get_cddb_dialog (EtApplicationWindow *self)
 }
 
 void
-et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action,
-                                                 gpointer user_data)
-{
-    EtApplicationWindowPrivate *priv;
-    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
-    priv = et_application_window_get_instance_private (self);
-
-    et_application_window_show_cddb_dialog (self);
-    et_cddb_dialog_search_from_selection (ET_CDDB_DIALOG (priv->cddb_dialog));
-}
-
-void
 et_application_window_browser_toggle_display_mode (EtApplicationWindow *self)
 {
     EtApplicationWindowPrivate *priv;
@@ -3258,30 +3312,6 @@ et_application_window_browser_clear_artist_model (EtApplicationWindow *self)
 }
 
 void
-et_application_window_run_player_for_album_list (G_GNUC_UNUSED GtkAction *action,
-                                                 gpointer user_data)
-{
-    EtApplicationWindowPrivate *priv;
-    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
-    priv = et_application_window_get_instance_private (self);
-
-    et_browser_run_player_for_album_list (ET_BROWSER (priv->browser));
-}
-
-void
-et_application_window_run_player_for_artist_list (G_GNUC_UNUSED GtkAction *action,
-                                                  gpointer user_data)
-{
-    EtApplicationWindowPrivate *priv;
-    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
-    priv = et_application_window_get_instance_private (self);
-
-    et_browser_run_player_for_artist_list (ET_BROWSER (priv->browser));
-}
-
-void
 et_application_window_select_dir (EtApplicationWindow *self, const gchar *path)
 {
     EtApplicationWindowPrivate *priv;
@@ -3316,21 +3346,6 @@ et_application_window_get_scan_dialog (EtApplicationWindow *self)
 }
 
 /*
- * Action when Scan button is pressed
- */
-void
-et_application_window_scan_selected_files (G_GNUC_UNUSED GtkAction *action,
-                                           gpointer user_data)
-{
-    EtApplicationWindowPrivate *priv;
-    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
-
-    priv = et_application_window_get_instance_private (self);
-
-    et_scan_dialog_scan_selected_files (ET_SCAN_DIALOG (priv->scan_dialog));
-}
-
-/*
  * et_on_action_select_scan_mode:
  * @action: the action on which the signal was emitted
  * @current: the member of the action group which has just been activated
diff --git a/src/application_window.h b/src/application_window.h
index 8cf1929..9fb6d53 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -58,18 +58,14 @@ GtkWidget * et_application_window_get_search_dialog (EtApplicationWindow *self);
 GtkWidget * et_application_window_get_preferences_dialog (EtApplicationWindow *self);
 void et_application_window_show_preferences_dialog_scanner (GtkAction *action, gpointer user_data);
 GtkWidget * et_application_window_get_cddb_dialog (EtApplicationWindow *self);
-void et_application_window_search_cddb_for_selection (GtkAction *action, gpointer user_data);
 void et_application_window_browser_toggle_display_mode (EtApplicationWindow *self);
 void et_application_window_browser_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
 void et_application_window_browser_clear (EtApplicationWindow *self);
 void et_application_window_browser_clear_album_model (EtApplicationWindow *self);
 void et_application_window_browser_clear_artist_model (EtApplicationWindow *self);
-void et_application_window_run_player_for_album_list (GtkAction *action, gpointer user_data);
-void et_application_window_run_player_for_artist_list (GtkAction *action, gpointer user_data);
 void et_application_window_select_dir (EtApplicationWindow *self, const gchar *path);
 const gchar * et_application_window_get_current_path (EtApplicationWindow *self);
 GtkWidget * et_application_window_get_scan_dialog (EtApplicationWindow *self);
-void et_application_window_scan_selected_files (GtkAction *action, gpointer user_data);
 void et_on_action_select_scan_mode (GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
 void et_on_action_select_browser_mode (GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
 void et_application_window_browser_entry_set_text (EtApplicationWindow *self, const gchar *text);
diff --git a/src/bar.c b/src/bar.c
index 3b92255..dedc96e 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -90,28 +90,6 @@ create_main_toolbar (GtkWindow *window)
          */
         { AM_STOP, GTK_STOCK_STOP, _("Stop the current action"), NULL, _("Stop the current action"), 
G_CALLBACK(Action_Main_Stop_Button_Pressed) },
 
-
-        /*
-         * Popup menu's Actions
-         */
-        { POPUP_FILE,                   NULL,              _("_File Operations"),          NULL, NULL,       
                  NULL },
-        { POPUP_SUBMENU_SCANNER,        "document-properties",    _("S_canner"),                  NULL, 
NULL,                         NULL },
-        { POPUP_DIR_RUN_AUDIO,          GTK_STOCK_MEDIA_PLAY,   _("Run Audio Player"),          NULL, _("Run 
audio player"),        G_CALLBACK(Run_Audio_Player_Using_Directory) },
-        { AM_ARTIST_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY,
-          _("Run Audio Player"), NULL, _("Run audio player"),
-          G_CALLBACK (et_application_window_run_player_for_artist_list) },
-        { AM_ALBUM_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY,
-          _("Run Audio Player"), NULL, _("Run audio player"),
-          G_CALLBACK (et_application_window_run_player_for_album_list) },
-        { AM_CDDB_SEARCH_FILE, GTK_STOCK_CDROM, _("CDDB Search Files…"), NULL,
-          _("CDDB search files…"),
-          G_CALLBACK (et_application_window_search_cddb_for_selection) },
-        //{ AM_ARTIST_OPEN_FILE_WITH,     GTK_STOCK_OPEN,    _("Open File(s) with…"),     NULL, _("Open 
File(s) with…"),     G_CALLBACK(Browser_Open_Run_Program_List_Window??? 
Browser_Open_Run_Program_Tree_Window???) },
-        //{ AM_ALBUM_OPEN_FILE_WITH,      GTK_STOCK_OPEN,    _("Open File(s) with…"),     NULL, _("Open 
File(s) with…"),     G_CALLBACK(Browser_Open_Run_Program_List_Window??? 
Browser_Open_Run_Program_Tree_Window???) },
-
-        { AM_LOG_CLEAN, GTK_STOCK_CLEAR, _("Clear log"), NULL, _("Clear log"),
-         G_CALLBACK (et_log_area_clear) }
-
     };
 
     GError *error = NULL;
diff --git a/src/bar.h b/src/bar.h
index 8cdadda..af88452 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -30,21 +30,11 @@ GtkUIManager   *UIManager;
 GtkActionGroup *ActionGroup;
 
 #define POPUP_FILE              "FilePopup"
-#define POPUP_DIR               "DirPopup"
 #define POPUP_SUBMENU_SCANNER   "ScannerSubpopup"
-#define POPUP_DIR_RUN_AUDIO     "DirPopupRunAudio"
-#define POPUP_LOG               "LogPopup"
 
 #define AM_OPEN_OPTIONS_WINDOW      "Preferences"
 #define AM_CDDB_SEARCH_FILE         "CDDBSearchFile"
 
-#define AM_ARTIST_RUN_AUDIO_PLAYER  "ArtistRunAudio"
-#define AM_ARTIST_OPEN_FILE_WITH    "ArtistOpenFile"
-#define AM_ALBUM_RUN_AUDIO_PLAYER   "AlbumRunAudio"
-#define AM_ALBUM_OPEN_FILE_WITH     "AlbumOpenFile"
-
-#define AM_LOG_CLEAN                "CleanLog"
-
 #define AM_STOP                     "Stop"
 
 typedef struct _Action_Pair Action_Pair;
diff --git a/src/browser.c b/src/browser.c
index d7ec39d..dff8910 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -3617,7 +3617,10 @@ create_browser (EtBrowser *self)
     gsize i;
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *column;
-    GtkWidget *PopupMenu;
+    GtkBuilder *builder;
+    GError *error = NULL;
+    GMenuModel *menu_model;
+    GtkWidget *menu;
     const gchar *BrowserTree_Titles[] = { N_("Tree") };
     const gchar *BrowserList_Titles[] = { N_("Filename"), N_("Title"),
                                           N_("Artist"), N_("Album Artist"),
@@ -3743,11 +3746,22 @@ create_browser (EtBrowser *self)
                       G_CALLBACK (Browser_Tree_Key_Press), NULL);
 
     /* Create Popup Menu on browser tree view */
-    PopupMenu = gtk_ui_manager_get_widget(UIManager, "/DirPopup");
-    gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->tree, NULL);
-    g_signal_connect (priv->tree, "button-press-event",
-                      G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_resource (builder, "/org/gnome/EasyTAG/menus.ui",
+                                   &error);
+
+    if (error != NULL)
+    {
+        g_error ("Unable to get popup menu from resource: %s",
+                 error->message);
+    }
 
+    menu_model = G_MENU_MODEL (gtk_builder_get_object (builder,
+                                                       "directory-menu"));
+    menu = gtk_menu_new_from_model (menu_model);
+    gtk_menu_attach_to_widget (GTK_MENU (menu), priv->tree, NULL);
+    g_signal_connect (priv->tree, "button-press-event",
+                      G_CALLBACK (Browser_Popup_Menu_Handler), menu);
 
     /*
      * The ScrollWindows with the Artist and Album Lists
@@ -3836,11 +3850,13 @@ create_browser (EtBrowser *self)
 
     gtk_container_add(GTK_CONTAINER(ScrollWindowArtistList),priv->artist_list);
 
-    // Create Popup Menu on browser artist list
-    PopupMenu = gtk_ui_manager_get_widget(UIManager, "/DirArtistPopup");
-    gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->artist_list, NULL);
+    /* Create Popup Menu on browser artist list. */
+    menu_model = G_MENU_MODEL (gtk_builder_get_object (builder,
+                                                       "directory-artist-menu"));
+    menu = gtk_menu_new_from_model (menu_model);
+    gtk_menu_attach_to_widget (GTK_MENU (menu), priv->artist_list, NULL);
     g_signal_connect (priv->artist_list, "button-press-event",
-                      G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
+                      G_CALLBACK (Browser_Popup_Menu_Handler), menu);
     // Not available yet!
     //ui_widget_set_sensitive(MENU_FILE, AM_ARTIST_OPEN_FILE_WITH, FALSE);
 
@@ -3904,11 +3920,14 @@ create_browser (EtBrowser *self)
                                                              self);
     gtk_container_add(GTK_CONTAINER(ScrollWindowAlbumList),priv->album_list);
 
-    // Create Popup Menu on browser album list
-    PopupMenu = gtk_ui_manager_get_widget(UIManager, "/DirAlbumPopup");
-    gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->album_list, NULL);
+    /* Create Popup Menu on browser album list. */
+    menu_model = G_MENU_MODEL (gtk_builder_get_object (builder,
+                                                       "directory-album-menu"));
+    menu = gtk_menu_new_from_model (menu_model);
+    gtk_menu_attach_to_widget (GTK_MENU (menu), priv->album_list, NULL);
     g_signal_connect (priv->album_list, "button-press-event",
-                      G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
+                      G_CALLBACK (Browser_Popup_Menu_Handler), menu);
+
     // Not available yet!
     //ui_widget_set_sensitive(MENU_FILE, AM_ALBUM_OPEN_FILE_WITH, FALSE);
 
@@ -4001,13 +4020,14 @@ create_browser (EtBrowser *self)
                               G_CALLBACK (Browser_List_Button_Press), self);
 
 
-    /*
-     * Create Popup Menu on file list
-     */
-    PopupMenu = gtk_ui_manager_get_widget(UIManager, "/FilePopup");
-    gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->file_view, NULL);
+    /* Create Popup Menu on file list. */
+    menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "file-menu"));
+    menu = gtk_menu_new_from_model (menu_model);
+    gtk_menu_attach_to_widget (GTK_MENU (menu), priv->file_view, NULL);
     g_signal_connect(G_OBJECT(priv->file_view),"button-press-event",
-                     G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
+                     G_CALLBACK (Browser_Popup_Menu_Handler), menu);
+
+    g_object_unref (builder);
 
     /*
      * The list store for run program combos
diff --git a/src/log.c b/src/log.c
index 907e63f..4d3c551 100644
--- a/src/log.c
+++ b/src/log.c
@@ -101,7 +101,10 @@ et_log_area_init (EtLogArea *self)
     GtkWidget *ScrollWindowLogList;
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *column;
-    GtkWidget *PopupMenu;
+    GtkBuilder *builder;
+    GError *error = NULL;
+    GMenuModel *menu_model;
+    GtkWidget *menu;
 
     priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_LOG_AREA,
                                                      EtLogAreaPrivate);
@@ -152,10 +155,23 @@ et_log_area_init (EtLogArea *self)
                                         NULL);
 
     /* Create Popup Menu on browser album list. */
-    PopupMenu = gtk_ui_manager_get_widget(UIManager, "/LogPopup");
-    gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->log_view, NULL);
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_resource (builder, "/org/gnome/EasyTAG/menus.ui",
+                                   &error);
+
+    if (error != NULL)
+    {
+        g_error ("Unable to get popup menu from resource: %s",
+                 error->message);
+    }
+
+    menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "log-menu"));
+    menu = gtk_menu_new_from_model (menu_model);
+    gtk_menu_attach_to_widget (GTK_MENU (menu), priv->log_view, NULL);
     g_signal_connect (priv->log_view, "button-press-event",
-                      G_CALLBACK (Log_Popup_Menu_Handler), PopupMenu);
+                      G_CALLBACK (Log_Popup_Menu_Handler), menu);
+
+    g_object_unref (builder);
 
     /* Load pending messages in the Log list. */
     Log_Print_Tmp_List (self);
@@ -219,13 +235,13 @@ Log_List_Set_Row_Visible (EtLogArea *self, GtkTreeIter *rowIter)
  * Remove all lines in the log list
  */
 void
-et_log_area_clear (GtkAction *action, gpointer user_data)
+et_log_area_clear (EtLogArea *self)
 {
-    EtApplicationWindow *window;
     EtLogAreaPrivate *priv;
 
-    window = ET_APPLICATION_WINDOW (user_data);
-    priv = et_log_area_get_instance_private (ET_LOG_AREA (et_application_window_get_log_area (window)));
+    g_return_if_fail (ET_LOG_AREA (self));
+
+    priv = et_log_area_get_instance_private (self);
 
     if (priv->log_model)
     {
diff --git a/src/log.h b/src/log.h
index 9b1479e..f744de4 100644
--- a/src/log.h
+++ b/src/log.h
@@ -64,7 +64,7 @@ typedef enum
 
 GType et_log_area_get_type (void);
 GtkWidget * et_log_area_new (void);
-void et_log_area_clear (GtkAction *action, gpointer user_data);
+void et_log_area_clear (EtLogArea *self);
 void Log_Print (EtLogAreaKind error_type,
                 const gchar * const format, ...) G_GNUC_PRINTF (2, 3);
 
diff --git a/src/ui_manager.h b/src/ui_manager.h
index 4a63081..3126e87 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -13,135 +13,4 @@ static const gchar *ui_xml =
 "    <toolitem action='Stop'/>"
 "  </toolbar>"
 
-
-/*
- * Popup menus
- */
-// Popup in file list
-"  <popup name='FilePopup'>"
-"    <menuitem action='SelAll' />"
-"    <menuitem action='UnselAll' />"
-"    <menuitem action='SelInv' />"
-"    <separator />"
-"    <menuitem action='RunAudio' />"
-"    <separator />"
-"    <menu action='ScannerSubpopup'>"
-"      <menuitem action='ShowScanner' />"
-"    </menu>"
-"    <menuitem action='CDDBSearchFile' />"
-"    <menuitem action='SearchFile' />"
-"    <menuitem action='DeleteFile' />"
-"    <menuitem action='ReloadDir' />"
-"    <menuitem action='OpenFile' />"
-"    <separator />"
-
-"    <menu action='SortTagMenu'>"
-"      <menuitem action='SortTrackNumAsc' />"
-"      <menuitem action='SortTrackNumDesc' />"
-"      <separator />"
-"      <menuitem action='SortTitleAsc' />"
-"      <menuitem action='SortTitleDesc' />"
-"      <separator />"
-"      <menuitem action='SortArtistAsc' />"
-"      <menuitem action='SortArtistDesc' />"
-"      <separator />"
-"      <menuitem action='SortAlbumArtistAsc' />"
-"      <menuitem action='SortAlbumArtistDesc' />"
-"      <separator />"
-"      <menuitem action='SortAlbumAsc' />"
-"      <menuitem action='SortAlbumDesc' />"
-"      <separator />"
-"      <menuitem action='SortYearAsc' />"
-"      <menuitem action='SortYearDesc' />"
-"      <separator />"
-"      <menuitem action='SortYearAsc' />"
-"      <menuitem action='SortYearDesc' />"
-"      <separator />"
-"      <menuitem action='SortGenreAsc' />"
-"      <menuitem action='SortGenreDesc' />"
-"      <separator />"
-"      <menuitem action='SortCommentAsc' />"
-"      <menuitem action='SortCommentDesc' />"
-"      <separator />"
-"      <menuitem action='SortComposerAsc' />"
-"      <menuitem action='SortComposerDesc' />"
-"      <separator />"
-"      <menuitem action='SortOrigArtistAsc' />"
-"      <menuitem action='SortOrigArtistDesc' />"
-"      <separator />"
-"      <menuitem action='SortCopyrightAsc' />"
-"      <menuitem action='SortCopyrightDesc' />"
-"      <separator />"
-"      <menuitem action='SortUrlAsc' />"
-"      <menuitem action='SortUrlDesc' />"
-"      <separator />"
-"      <menuitem action='SortEncodedByAsc' />"
-"      <menuitem action='SortEncodedByDesc' />"
-"      <separator />"
-"    </menu>"
-
-"    <menu action='SortPropMenu'>"
-"      <menuitem action='SortFilenameAsc' />"
-"      <menuitem action='SortFilenameDesc' />"
-"      <separator />"
-"      <menuitem action='SortDateAsc' />"
-"      <menuitem action='SortDateDesc' />"
-"      <separator />"
-"      <menuitem action='SortTypeAsc' />"
-"      <menuitem action='SortTypeDesc' />"
-"      <separator />"
-"      <menuitem action='SortSizeAsc' />"
-"      <menuitem action='SortSizeDesc' />"
-"      <separator />"
-"      <menuitem action='SortDurationAsc' />"
-"      <menuitem action='SortDurationDesc' />"
-"      <separator />"
-"      <menuitem action='SortBitrateAsc' />"
-"      <menuitem action='SortBitrateDesc' />"
-"      <separator />"
-"      <menuitem action='SortSamplerateAsc' />"
-"      <menuitem action='SortSamplerateDesc' />"
-"    </menu>"
-"  </popup>"
-
-// Popup in browser tree
-"  <popup name='DirPopup'>"
-"    <menuitem action='DirPopupRunAudio' />"
-"    <separator />"
-"    <menuitem action='GoToHome' />"
-"    <menuitem action='GoToDefaultPath' />"
-"    <menuitem action='SetDefaultPath' />"
-"    <separator />"
-"    <menuitem action='RenameDir' />"
-"    <menuitem action='ReloadDir' />"
-"    <menuitem action='BrowseDir' />"
-"    <separator />"
-"    <menuitem action='BrowseSubdir' />"
-#ifndef G_OS_WIN32
-"    <menuitem action='BrowseHiddenDir' />"
-#endif /* !G_OS_WIN32 */
-"    <separator />"
-"    <menuitem action='CollapseTree' />"
-"    <menuitem action='RefreshTree' />"
-"  </popup>"
-
-// Popup in browser artist list
-"  <popup name='DirArtistPopup'>"
-"    <menuitem action='ArtistRunAudio' />"
-//"    <separator />"
-//"    <menuitem action='ArtistOpenFile' />"
-"  </popup>"
-
-// Popup in browser album list
-"  <popup name='DirAlbumPopup'>"
-"    <menuitem action='AlbumRunAudio' />"
-//"    <separator />"
-//"    <menuitem action='AlbumOpenFile' />"
-"  </popup>"
-
-// Popup in Log list
-"  <popup name='LogPopup'>"
-"    <menuitem action='CleanLog' />"
-"  </popup>"
-
 "</ui>";



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]