[easytag/wip/application-window: 36/62] Use GAction for browser menu items



commit 640f57aa44df2acd4ec987830615395c81179d1c
Author: David King <amigadave amigadave com>
Date:   Sun Jul 13 11:51:25 2014 +0100

    Use GAction for browser menu items

 data/menus.ui            |    5 +++
 src/application_window.c |   87 +++++++++++++++++++++++++++-------------------
 src/application_window.h |    3 --
 src/bar.c                |   15 --------
 src/bar.h                |    5 ---
 src/ui_manager.h         |   11 ------
 6 files changed, 56 insertions(+), 70 deletions(-)
---
diff --git a/data/menus.ui b/data/menus.ui
index c73d3ad..4e1f36e 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -301,19 +301,24 @@
             <attribute name="label" translatable="yes">_Browser</attribute>
             <section>
                 <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="accel">F2</attribute>
+                    <attribute name="action">win.rename-directory</attribute>
                     <attribute name="label" translatable="yes">Rename 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>
             </section>
diff --git a/src/application_window.c b/src/application_window.c
index 66bf07b..34e9167 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -1717,6 +1717,48 @@ et_application_window_show_cddb_dialog (EtApplicationWindow *self)
 }
 
 static void
+on_set_default_path (GSimpleAction *action,
+                     GVariant *variant,
+                     gpointer user_data)
+{
+    EtApplicationWindow *self;
+    EtApplicationWindowPrivate *priv;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_set_current_path_default (ET_BROWSER (priv->browser));
+}
+
+static void
+on_rename_directory (GSimpleAction *action,
+                     GVariant *variant,
+                     gpointer user_data)
+{
+    EtApplicationWindow *self;
+    EtApplicationWindowPrivate *priv;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_show_rename_directory_dialog (ET_BROWSER (priv->browser));
+}
+
+static void
+on_browse_directory (GSimpleAction *action,
+                     GVariant *variant,
+                     gpointer user_data)
+{
+    EtApplicationWindow *self;
+    EtApplicationWindowPrivate *priv;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_show_open_directory_with_dialog (ET_BROWSER (priv->browser));
+}
+
+static void
 on_show_cddb (GSimpleAction *action,
               GVariant *variant,
               gpointer user_data)
@@ -2029,6 +2071,11 @@ on_go_last (GSimpleAction *action,
 
 static const GActionEntry actions[] =
 {
+    /* Browser menu. */
+    { "set-default-path", on_set_default_path },
+    { "rename-directory", on_rename_directory },
+    { "browse-directory", on_browse_directory },
+    /* { "browse-subdir", on_browse_subdir }, Created from GSetting. */
     /* Miscellaneous menu. */
     { "show-cddb", on_show_cddb },
     { "show-load-filenames", on_show_load_filenames },
@@ -2068,6 +2115,7 @@ static void
 et_application_window_init (EtApplicationWindow *self)
 {
     EtApplicationWindowPrivate *priv;
+    GAction *action;
     GtkWindow *window;
     GtkWidget *main_vbox;
     GtkWidget *hbox, *vbox;
@@ -2087,6 +2135,9 @@ et_application_window_init (EtApplicationWindow *self)
     g_action_map_add_action_entries (G_ACTION_MAP (self), actions,
                                      G_N_ELEMENTS (actions), self);
 
+    action = g_settings_create_action (MainSettings, "browse-subdir");
+    g_action_map_add_action (G_ACTION_MAP (self), action);
+
     window = GTK_WINDOW (self);
 
     gtk_window_set_default_size (window, 1024, 768);
@@ -2505,18 +2556,6 @@ et_application_window_select_dir (EtApplicationWindow *self, const gchar *path)
     et_browser_select_dir (ET_BROWSER (priv->browser), path);
 }
 
-void
-et_application_window_set_current_path_default (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_set_current_path_default (ET_BROWSER (priv->browser));
-}
-
 const gchar *
 et_application_window_get_current_path (EtApplicationWindow *self)
 {
@@ -2530,18 +2569,6 @@ et_application_window_get_current_path (EtApplicationWindow *self)
 }
 
 void
-et_application_window_show_open_directory_with_dialog (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_show_open_directory_with_dialog (ET_BROWSER (priv->browser));
-}
-
-void
 et_application_window_show_open_files_with_dialog (G_GNUC_UNUSED GtkAction *action,
                                                    gpointer user_data)
 {
@@ -2553,18 +2580,6 @@ et_application_window_show_open_files_with_dialog (G_GNUC_UNUSED GtkAction *acti
     et_browser_show_open_files_with_dialog (ET_BROWSER (priv->browser));
 }
 
-void
-et_application_window_show_rename_directory_dialog (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_show_rename_directory_dialog (ET_BROWSER (priv->browser));
-}
-
 GtkWidget *
 et_application_window_get_scan_dialog (EtApplicationWindow *self)
 {
diff --git a/src/application_window.h b/src/application_window.h
index e642104..8093f02 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -73,11 +73,8 @@ void et_application_window_run_player_for_artist_list (GtkAction *action, gpoint
 void et_application_window_run_player_for_selection (GtkAction *action, gpointer user_data);
 void et_application_window_reload_directory (GtkAction *action, gpointer user_data);
 void et_application_window_select_dir (EtApplicationWindow *self, const gchar *path);
-void et_application_window_set_current_path_default (GtkAction *action, gpointer user_data);
 const gchar * et_application_window_get_current_path (EtApplicationWindow *self);
-void et_application_window_show_open_directory_with_dialog (GtkAction *action, gpointer user_data);
 void et_application_window_show_open_files_with_dialog (GtkAction *action, gpointer user_data);
-void et_application_window_show_rename_directory_dialog (GtkAction *action, gpointer user_data);
 GtkWidget * et_application_window_get_scan_dialog (EtApplicationWindow *self);
 void et_application_window_show_scan_dialog (GtkAction *action, gpointer user_data);
 void et_application_window_scan_selected_files (GtkAction *action, gpointer user_data);
diff --git a/src/bar.c b/src/bar.c
index 90cb6c2..9f59985 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -247,21 +247,9 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
         { AM_QUIT, GTK_STOCK_QUIT, _("_Quit"), "<Primary>Q", _("Quit"),
           G_CALLBACK (Quit_MainWindow) },
 
-        { MENU_BROWSER,                NULL,                   _("_Browser"),                      NULL,     
           NULL,                               NULL },
-        { AM_SET_PATH_AS_DEFAULT, GTK_STOCK_DIRECTORY,
-          _("Set _Current Path as Default"), NULL,
-          _("Set current path as default"),
-          G_CALLBACK (et_application_window_set_current_path_default) },
-        { AM_RENAME_DIR, GTK_STOCK_INDEX, _("Rename Directory…"), "F2",
-          _("Rename directory"),
-          G_CALLBACK (et_application_window_show_rename_directory_dialog) },
         { AM_RELOAD_DIRECTORY, GTK_STOCK_REFRESH, _("Reload Directory"),
           "<Primary>R", _("Reload directory"),
           G_CALLBACK (et_application_window_reload_directory) },
-        { AM_BROWSE_DIRECTORY_WITH, GTK_STOCK_EXECUTE,
-          _("Browse Directory With…"), NULL,
-          _("Run a command on the directory"),
-          G_CALLBACK (et_application_window_show_open_directory_with_dialog) },
         { AM_COLLAPSE_TREE, NULL, _("_Collapse Tree"), "<Primary><Shift>C",
           _("Collapse directory tree"),
           G_CALLBACK (et_application_window_browser_collapse) },
@@ -317,9 +305,6 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
 
     GtkToggleActionEntry ToggleActionEntries[] =
     {
-        { AM_BROWSE_SUBDIR, NULL, _("Browse _Subdirectories"), NULL,
-          _("Browse subdirectories"), NULL,
-          g_settings_get_boolean (MainSettings, "browse-subdir") },
 #ifndef G_OS_WIN32 /* No sense here for Win32, "hidden" means : starts with a
                     * '.'
                     */
diff --git a/src/bar.h b/src/bar.h
index fb6cdbd..91dea89 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -36,7 +36,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define MENU_FILE       "FileMenu"
 #define MENU_EDIT "EditMenu"
 #define MENU_VIEW "ViewMenu"
-#define MENU_BROWSER    "BrowserMenu"
 #define MENU_SCANNER    "ScannerMenu"
 
 #define MENU_FILE_SORT_TAG      "SortTagMenu"
@@ -63,16 +62,12 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define AM_UNSELECT_ALL "UnselAll"
 #define AM_INVERT_SELECTION         "SelInv"
 #define AM_DELETE_FILE              "DeleteFile"
-#define AM_SET_PATH_AS_DEFAULT      "SetDefaultPath"
-#define AM_RENAME_DIR               "RenameDir"
-#define AM_BROWSE_SUBDIR            "BrowseSubdir"
 #define AM_BROWSER_HIDDEN_DIR       "BrowseHiddenDir"
 #define AM_COLLAPSE_TREE            "CollapseTree"
 #define AM_INITIALIZE_TREE          "RefreshTree"
 #define AM_RELOAD_DIRECTORY         "ReloadDir"
 #define AM_TREE_VIEW_MODE "TreeViewMode"
 #define AM_ARTIST_VIEW_MODE "ArtistViewMode"
-#define AM_BROWSE_DIRECTORY_WITH    "BrowseDir"
 #define AM_OPEN_FILE_WITH           "OpenFile"
 #define AM_OPEN_OPTIONS_WINDOW      "Preferences"
 #define AM_SCANNER_FILL_TAG         "FillTag"
diff --git a/src/ui_manager.h b/src/ui_manager.h
index 7232761..366d879 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -141,17 +141,6 @@ static const gchar *ui_xml =
 #endif /* !G_OS_WIN32 */
 "    </menu>"
 
-"    <menu action='BrowserMenu'>"
-"      <menuitem action='SetDefaultPath' />"
-"      <separator />"
-
-"      <menuitem action='RenameDir' />"
-"      <menuitem action='BrowseDir' />"
-"      <separator />"
-
-"      <menuitem action='BrowseSubdir' />"
-"    </menu>"
-
 "  </menubar>"
 
 


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