[easytag/wip/application-window: 46/64] Use GAction for miscellaneous menu items



commit 50da1734fe5d29c82548970e839648a4d6d8ef76
Author: David King <amigadave amigadave com>
Date:   Sun Jul 13 09:15:58 2014 +0100

    Use GAction for miscellaneous menu items
    
    Move action state update function to EtApplicationWindow.

 data/menus.ui            |    6 +
 src/application_window.c |  473 ++++++++++++++++++++++++++++++++++++++--------
 src/application_window.h |    4 +-
 src/bar.c                |   11 -
 src/bar.h                |    4 -
 src/browser.c            |    7 +-
 src/easytag.c            |  266 +-------------------------
 src/easytag.h            |    1 -
 src/et_core.c            |    4 +-
 src/scan_dialog.c        |    2 +-
 src/ui_manager.h         |   13 --
 11 files changed, 417 insertions(+), 374 deletions(-)
---
diff --git a/data/menus.ui b/data/menus.ui
index 4a5f3d4..8efef36 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -321,12 +321,18 @@
         <submenu>
             <attribute name="label" translatable="yes">_Miscellaneous</attribute>
             <item>
+                <attribute name="accel">&lt;Primary&gt;b</attribute>
+                <attribute name="action">win.show-cddb</attribute>
                 <attribute name="label" translatable="yes">CDD_B Search…</attribute>
             </item>
             <item>
+                <attribute name="accel">&lt;Primary&gt;t</attribute>
+                <attribute name="action">win.show-load-filenames</attribute>
                 <attribute name="label" translatable="yes">Load Filenames From a Text File…</attribute>
             </item>
             <item>
+                <attribute name="accel">&lt;Primary&gt;w</attribute>
+                <attribute name="action">win.show-playlist</attribute>
                 <attribute name="label" translatable="yes">Generate Playlist…</attribute>
             </item>
         </submenu>
diff --git a/src/application_window.c b/src/application_window.c
index 1b612dc..edb665f 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -901,7 +901,7 @@ Mini_Button_Clicked (GObject *object)
     g_free(string_to_set1);
 
     /* To update state of Undo button */
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (toplevel));
 }
 
 /*
@@ -913,6 +913,7 @@ void
 et_application_window_redo_selected_files (GtkAction *action,
                                            gpointer user_data)
 {
+    EtApplicationWindow *self;
     EtApplicationWindowPrivate *priv;
     GList *selfilelist = NULL;
     GList *l;
@@ -922,7 +923,9 @@ et_application_window_redo_selected_files (GtkAction *action,
 
     g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL, FALSE);
 
-    priv = et_application_window_get_instance_private (ET_APPLICATION_WINDOW (user_data));
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
+
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
@@ -943,7 +946,7 @@ et_application_window_redo_selected_files (GtkAction *action,
 
     /* Display the current file */
     ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
 }
 
 /*
@@ -1696,6 +1699,77 @@ create_tag_area (EtApplicationWindow *self)
 }
 
 static void
+et_application_window_show_cddb_dialog (EtApplicationWindow *self)
+{
+    EtApplicationWindowPrivate *priv;
+
+    priv = et_application_window_get_instance_private (self);
+
+    if (priv->cddb_dialog)
+    {
+        gtk_widget_show (priv->cddb_dialog);
+    }
+    else
+    {
+        priv->cddb_dialog = GTK_WIDGET (et_cddb_dialog_new ());
+    }
+}
+
+static void
+on_show_cddb (GSimpleAction *action,
+              GVariant *variant,
+              gpointer user_data)
+{
+    EtApplicationWindow *self;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+
+    et_application_window_show_cddb_dialog (self);
+}
+
+static void
+on_show_load_filenames (GSimpleAction *action,
+                        GVariant *variant,
+                        gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
+
+    if (priv->load_files_dialog)
+    {
+        gtk_widget_show (priv->load_files_dialog);
+    }
+    else
+    {
+        priv->load_files_dialog = GTK_WIDGET (et_load_files_dialog_new ());
+    }
+}
+
+static void
+on_show_playlist (GSimpleAction *action,
+                  GVariant *variant,
+                  gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self;
+
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
+
+    if (priv->playlist_dialog)
+    {
+        gtk_widget_show (priv->playlist_dialog);
+    }
+    else
+    {
+        priv->playlist_dialog = GTK_WIDGET (et_playlist_dialog_new ());
+    }
+}
+
+static void
 on_go_home (GSimpleAction *action,
             GVariant *variant,
             gpointer user_data)
@@ -1795,6 +1869,11 @@ on_go_default (GSimpleAction *action,
 
 static const GActionEntry actions[] =
 {
+    /* Miscellaneous menu. */
+    { "show-cddb", on_show_cddb },
+    { "show-load-filenames", on_show_load_filenames },
+    { "show-playlist", on_show_playlist },
+    /* Go menu. */
     { "go-home", on_go_home },
     { "go-desktop", on_go_desktop },
     { "go-documents", on_go_documents },
@@ -1976,25 +2055,6 @@ et_application_window_get_log_area (EtApplicationWindow *self)
     return priv->log_area;
 }
 
-void
-et_application_window_show_playlist_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);
-
-    if (priv->playlist_dialog)
-    {
-        gtk_widget_show (priv->playlist_dialog);
-    }
-    else
-    {
-        priv->playlist_dialog = GTK_WIDGET (et_playlist_dialog_new ());
-    }
-}
-
 GtkWidget *
 et_application_window_get_load_files_dialog (EtApplicationWindow *self)
 {
@@ -2007,25 +2067,6 @@ et_application_window_get_load_files_dialog (EtApplicationWindow *self)
     return priv->load_files_dialog;
 }
 
-void
-et_application_window_show_load_files_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);
-
-    if (priv->load_files_dialog)
-    {
-        gtk_widget_show (priv->load_files_dialog);
-    }
-    else
-    {
-        priv->load_files_dialog = GTK_WIDGET (et_load_files_dialog_new ());
-    }
-}
-
 GtkWidget *
 et_application_window_get_search_dialog (EtApplicationWindow *self)
 {
@@ -2118,25 +2159,6 @@ et_application_window_get_cddb_dialog (EtApplicationWindow *self)
 }
 
 void
-et_application_window_show_cddb_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);
-
-    if (priv->cddb_dialog)
-    {
-        gtk_widget_show (priv->cddb_dialog);
-    }
-    else
-    {
-        priv->cddb_dialog = GTK_WIDGET (et_cddb_dialog_new ());
-    }
-}
-
-void
 et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action,
                                                  gpointer user_data)
 {
@@ -2145,7 +2167,7 @@ et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action
 
     priv = et_application_window_get_instance_private (self);
 
-    et_application_window_show_cddb_dialog (action, user_data);
+    et_application_window_show_cddb_dialog (self);
     et_cddb_dialog_search_from_selection (ET_CDDB_DIALOG (priv->cddb_dialog));
 }
 
@@ -2463,7 +2485,7 @@ et_on_action_select_browser_mode (G_GNUC_UNUSED GtkRadioAction *action,
 
     et_application_window_browser_toggle_display_mode (ET_APPLICATION_WINDOW (user_data));
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (user_data));
 }
 
 /*
@@ -2507,6 +2529,295 @@ et_application_window_file_area_set_sensitive (EtApplicationWindow *self,
 }
 
 static void
+ui_widget_set_sensitive (const gchar *menu,
+                         const gchar *action,
+                         gboolean sensitive)
+{
+    GtkAction *uiaction;
+    gchar *path;
+
+    path = g_strconcat ("/MenuBar/", menu,"/", action, NULL);
+
+    uiaction = gtk_ui_manager_get_action (UIManager, path);
+
+    if (uiaction)
+    {
+        gtk_action_set_sensitive (uiaction, sensitive);
+    }
+    else
+    {
+        g_warning ("Action not found for path '%s'", path);
+    }
+
+    g_free (path);
+}
+
+static void
+set_action_state (EtApplicationWindow *self,
+                  const gchar *action_name,
+                  gboolean enabled)
+{
+    GSimpleAction *action;
+
+    action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (self),
+                                                          action_name));
+
+    if (action == NULL)
+    {
+        g_error ("Unable to find action '%s' in application window",
+                 action_name);
+    }
+
+    g_simple_action_set_enabled (action, enabled);
+}
+
+/* et_application_window_update_actions:
+ * Set to sensitive/unsensitive the state of each button into
+ * the commands area and menu items in function of state of the "main list".
+ */
+void
+et_application_window_update_actions (EtApplicationWindow *self)
+{
+    GtkDialog *dialog;
+    GtkAction *uiaction;
+
+    dialog = GTK_DIALOG (et_application_window_get_scan_dialog (self));
+
+    if (!ETCore->ETFileDisplayedList)
+    {
+        /* No file found */
+
+        /* File and Tag frames */
+        et_application_window_file_area_set_sensitive (self, FALSE);
+        et_application_window_tag_area_set_sensitive (self, FALSE);
+
+        /* Tool bar buttons (the others are covered by the menu) */
+        uiaction = gtk_ui_manager_get_action(UIManager, "/ToolBar/Stop");
+        g_object_set(uiaction, "sensitive", FALSE, NULL);
+
+        /* Scanner Window */
+        if (dialog)
+        {
+            gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY,
+                                               FALSE);
+        }
+
+        /* Menu commands */
+        ui_widget_set_sensitive(MENU_FILE, AM_OPEN_FILE_WITH, FALSE);
+        ui_widget_set_sensitive(MENU_FILE, AM_INVERT_SELECTION, FALSE);
+        ui_widget_set_sensitive(MENU_FILE, AM_DELETE_FILE, FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILENAME, FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILENAME,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_CREATION_DATE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_CREATION_DATE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_TRACK_NUMBER,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_TRACK_NUMBER,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_TITLE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_TITLE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_ARTIST,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_ARTIST,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_ALBUM,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_ALBUM,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_YEAR,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_YEAR,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_GENRE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_GENRE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_COMMENT,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_COMMENT,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_TYPE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_TYPE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_SIZE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_SIZE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_DURATION,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_DURATION,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_BITRATE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_BITRATE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_SAMPLERATE,FALSE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_SAMPLERATE,FALSE);
+        ui_widget_set_sensitive (MENU_GO, AM_PREV, FALSE);
+        ui_widget_set_sensitive (MENU_GO, AM_NEXT, FALSE);
+        ui_widget_set_sensitive (MENU_GO, AM_FIRST, FALSE);
+        ui_widget_set_sensitive (MENU_GO, AM_LAST, FALSE);
+        ui_widget_set_sensitive (MENU_EDIT, AM_REMOVE, FALSE);
+        ui_widget_set_sensitive(MENU_FILE, AM_UNDO, FALSE);
+        ui_widget_set_sensitive(MENU_FILE, AM_REDO, FALSE);
+        ui_widget_set_sensitive(MENU_FILE, AM_SAVE, FALSE);
+        ui_widget_set_sensitive(MENU_FILE, AM_SAVE_FORCED, FALSE);
+        ui_widget_set_sensitive (MENU_EDIT, AM_UNDO_HISTORY, FALSE);
+        ui_widget_set_sensitive (MENU_EDIT, AM_REDO_HISTORY, FALSE);
+        ui_widget_set_sensitive (MENU_EDIT, AM_SEARCH_FILE, FALSE);
+        set_action_state (self, "show-load-filenames", FALSE);
+        set_action_state (self, "show-playlist", FALSE);
+        ui_widget_set_sensitive (MENU_FILE, AM_RUN_AUDIO_PLAYER, FALSE);
+        ui_widget_set_sensitive (MENU_SCANNER_PATH,
+                                 AM_SCANNER_FILL_TAG, FALSE);
+        ui_widget_set_sensitive (MENU_SCANNER_PATH,
+                                 AM_SCANNER_RENAME_FILE, FALSE);
+        ui_widget_set_sensitive (MENU_SCANNER_PATH,
+                                 AM_SCANNER_PROCESS_FIELDS, FALSE);
+        ui_widget_set_sensitive (MENU_VIEW, AM_ARTIST_VIEW_MODE, FALSE);
+
+        return;
+    }else
+    {
+        GtkWidget *artist_radio = NULL;
+        GList *selfilelist = NULL;
+        ET_File *etfile;
+        gboolean has_undo = FALSE;
+        gboolean has_redo = FALSE;
+        //gboolean has_to_save = FALSE;
+        GtkTreeSelection *selection;
+
+        /* File and Tag frames */
+        et_application_window_file_area_set_sensitive (self, TRUE);
+        et_application_window_tag_area_set_sensitive (self, TRUE);
+
+        /* Tool bar buttons */
+        uiaction = gtk_ui_manager_get_action(UIManager, "/ToolBar/Stop");
+        g_object_set(uiaction, "sensitive", FALSE, NULL);
+
+        /* Scanner Window */
+        if (dialog)
+        {
+            gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY,
+                                               TRUE);
+        }
+
+        /* Commands into menu */
+        ui_widget_set_sensitive(MENU_FILE, AM_OPEN_FILE_WITH,TRUE);
+        ui_widget_set_sensitive(MENU_FILE, AM_INVERT_SELECTION,TRUE);
+        ui_widget_set_sensitive(MENU_FILE, AM_DELETE_FILE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILENAME,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILENAME,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_CREATION_DATE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_CREATION_DATE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_TRACK_NUMBER,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_TRACK_NUMBER,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_TITLE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_TITLE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_ARTIST,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_ARTIST,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_ALBUM,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_ALBUM,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_YEAR,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_YEAR,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_GENRE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_GENRE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_COMMENT,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_COMMENT,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_TYPE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_TYPE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_SIZE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_SIZE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_DURATION,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_DURATION,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_BITRATE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_BITRATE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_SAMPLERATE,TRUE);
+        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_SAMPLERATE,TRUE);
+        ui_widget_set_sensitive (MENU_EDIT, AM_REMOVE, TRUE);
+        ui_widget_set_sensitive (MENU_EDIT, AM_SEARCH_FILE, TRUE);
+        set_action_state (self, "show-load-filenames", TRUE);
+        set_action_state (self, "show-playlist", TRUE);
+        ui_widget_set_sensitive (MENU_FILE, AM_RUN_AUDIO_PLAYER, TRUE);
+        ui_widget_set_sensitive (MENU_SCANNER_PATH,
+                                 AM_SCANNER_FILL_TAG,TRUE);
+        ui_widget_set_sensitive (MENU_SCANNER_PATH,
+                                 AM_SCANNER_RENAME_FILE, TRUE);
+        ui_widget_set_sensitive (MENU_SCANNER_PATH,
+                                 AM_SCANNER_PROCESS_FIELDS, TRUE);
+        ui_widget_set_sensitive (MENU_VIEW, AM_ARTIST_VIEW_MODE, TRUE);
+
+        /* Check if one of the selected files has undo or redo data */
+        {
+            GList *l;
+
+            selection = et_application_window_browser_get_selection (self);
+            selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
+
+            for (l = selfilelist; l != NULL; l = g_list_next (l))
+            {
+                etfile = et_application_window_browser_get_et_file_from_path (self,
+                                                                              l->data);
+                has_undo    |= ET_File_Data_Has_Undo_Data(etfile);
+                has_redo    |= ET_File_Data_Has_Redo_Data(etfile);
+                //has_to_save |= ET_Check_If_File_Is_Saved(etfile);
+                if ((has_undo && has_redo /*&& has_to_save*/) || !l->next) // Useless to check the other 
files
+                    break;
+            }
+
+            g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
+        }
+
+        /* Enable undo commands if there are undo data */
+        if (has_undo)
+            ui_widget_set_sensitive(MENU_FILE, AM_UNDO, TRUE);
+        else
+            ui_widget_set_sensitive(MENU_FILE, AM_UNDO, FALSE);
+
+        /* Enable redo commands if there are redo data */
+        if (has_redo)
+            ui_widget_set_sensitive(MENU_FILE, AM_REDO, TRUE);
+        else
+            ui_widget_set_sensitive(MENU_FILE, AM_REDO, FALSE);
+
+        /* Enable save file command if file has been changed */
+        // Desactivated because problem with only one file in the list, as we can't change the selected file 
=> can't mark file as changed
+        /*if (has_to_save)
+            ui_widget_set_sensitive(MENU_FILE, AM_SAVE, FALSE);
+        else*/
+            ui_widget_set_sensitive(MENU_FILE, AM_SAVE, TRUE);
+        
+        ui_widget_set_sensitive(MENU_FILE, AM_SAVE_FORCED, TRUE);
+
+        /* Enable undo command if there are data into main undo list (history list) */
+        if (ET_History_File_List_Has_Undo_Data())
+            ui_widget_set_sensitive (MENU_EDIT, AM_UNDO_HISTORY, TRUE);
+        else
+            ui_widget_set_sensitive (MENU_EDIT, AM_UNDO_HISTORY, FALSE);
+
+        /* Enable redo commands if there are data into main redo list (history list) */
+        if (ET_History_File_List_Has_Redo_Data())
+            ui_widget_set_sensitive (MENU_EDIT, AM_REDO_HISTORY, TRUE);
+        else
+            ui_widget_set_sensitive (MENU_EDIT, AM_REDO_HISTORY, FALSE);
+
+        artist_radio = gtk_ui_manager_get_widget (UIManager,
+                                                  "/ToolBar/ArtistViewMode");
+
+        if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
+        {
+            ui_widget_set_sensitive (MENU_VIEW, AM_COLLAPSE_TREE, FALSE);
+            ui_widget_set_sensitive (MENU_VIEW, AM_INITIALIZE_TREE, FALSE);
+        }
+        else
+        {
+            ui_widget_set_sensitive (MENU_VIEW, AM_COLLAPSE_TREE, TRUE);
+            ui_widget_set_sensitive (MENU_VIEW, AM_INITIALIZE_TREE, TRUE);
+        }
+    }
+
+    if (!ETCore->ETFileDisplayedList->prev)    /* Is it the 1st item ? */
+    {
+        ui_widget_set_sensitive (MENU_GO, AM_PREV, FALSE);
+        ui_widget_set_sensitive (MENU_GO, AM_FIRST, FALSE);
+    }else
+    {
+        ui_widget_set_sensitive (MENU_GO, AM_PREV, TRUE);
+        ui_widget_set_sensitive (MENU_GO, AM_FIRST, TRUE);
+    }
+    if (!ETCore->ETFileDisplayedList->next)    /* Is it the last item ? */
+    {
+        ui_widget_set_sensitive (MENU_GO, AM_NEXT, FALSE);
+        ui_widget_set_sensitive (MENU_GO, AM_LAST, FALSE);
+    }else
+    {
+        ui_widget_set_sensitive (MENU_GO, AM_NEXT, TRUE);
+        ui_widget_set_sensitive (MENU_GO, AM_LAST, TRUE);
+    }
+}
+
+static void
 et_application_window_hide_images_tab (EtApplicationWindow *self)
 {
     EtApplicationWindowPrivate *priv;
@@ -2758,7 +3069,7 @@ et_application_window_select_all (GtkAction *action, gpointer user_data)
         ET_Save_File_Data_From_UI (ETCore->ETFileDisplayed);
 
         et_browser_select_all (ET_BROWSER (priv->browser));
-        Update_Command_Buttons_Sensivity ();
+        et_application_window_update_actions (self);
     }
 }
 
@@ -2990,7 +3301,7 @@ et_application_window_invert_selection (GtkAction *action, gpointer user_data)
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
     et_browser_invert_selection (ET_BROWSER (priv->browser));
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
 }
 
 /*
@@ -3026,7 +3337,7 @@ et_application_window_select_first_file (GtkAction *action, gpointer user_data)
         ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
     }
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
     et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
 
     if (g_settings_get_boolean (MainSettings, "tag-preserve-focus"))
@@ -3071,7 +3382,7 @@ et_application_window_select_prev_file (GtkAction *action, gpointer user_data)
 //    if (!ETFileList->prev)
 //        gdk_beep(); // Warm the user
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
     et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
 
     if (g_settings_get_boolean (MainSettings, "tag-preserve-focus"))
@@ -3116,7 +3427,7 @@ et_application_window_select_next_file (GtkAction *acton, gpointer user_data)
 //    if (!ETFileList->next)
 //        gdk_beep(); // Warm the user
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
     et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
 
     if (g_settings_get_boolean (MainSettings, "tag-preserve-focus"))
@@ -3158,7 +3469,7 @@ et_application_window_select_last_file (GtkAction *action, gpointer user_data)
         ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
     }
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
     et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
 
     if (g_settings_get_boolean (MainSettings, "tag-preserve-focus"))
@@ -3174,6 +3485,7 @@ void
 et_application_window_remove_selected_tags (GtkAction *action,
                                             gpointer user_data)
 {
+    EtApplicationWindow *self;
     EtApplicationWindowPrivate *priv;
     GList *selfilelist = NULL;
     GList *l;
@@ -3186,14 +3498,15 @@ et_application_window_remove_selected_tags (GtkAction *action,
 
     g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
 
-    priv = et_application_window_get_instance_private (ET_APPLICATION_WINDOW (user_data));
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
     /* Initialize status bar */
     gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
-    selection = et_application_window_browser_get_selection (ET_APPLICATION_WINDOW (user_data));
+    selection = et_application_window_browser_get_selection (self);
     selectcount = gtk_tree_selection_count_selected_rows (selection);
     progress_bar_index = 0;
 
@@ -3216,11 +3529,11 @@ et_application_window_remove_selected_tags (GtkAction *action,
     g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
 
     /* Refresh the whole list (faster than file by file) to show changes. */
-    et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (user_data));
+    et_application_window_browser_refresh_list (self);
 
     /* Display the current file */
     ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
 
     gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
     Statusbar_Message(_("All tags have been removed"),TRUE);
@@ -3237,6 +3550,7 @@ void
 et_application_window_undo_selected_files (GtkAction *action,
                                            gpointer user_data)
 {
+    EtApplicationWindow *self;
     EtApplicationWindowPrivate *priv;
     GList *selfilelist = NULL;
     GList *l;
@@ -3246,12 +3560,13 @@ et_application_window_undo_selected_files (GtkAction *action,
 
     g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL, FALSE);
 
-    priv = et_application_window_get_instance_private (ET_APPLICATION_WINDOW (user_data));
+    self = ET_APPLICATION_WINDOW (user_data);
+    priv = et_application_window_get_instance_private (self);
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
-    selection = et_application_window_browser_get_selection (ET_APPLICATION_WINDOW (user_data));
+    selection = et_application_window_browser_get_selection (self);
     selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
 
     for (l = selfilelist; l != NULL; l = g_list_next (l))
@@ -3264,11 +3579,11 @@ et_application_window_undo_selected_files (GtkAction *action,
     g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
 
     /* Refresh the whole list (faster than file by file) to show changes. */
-    et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (user_data));
+    et_application_window_browser_refresh_list (self);
 
     /* Display the current file */
     ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
 
     //ET_Debug_Print_File_List(ETCore->ETFileList,__FILE__,__LINE__,__FUNCTION__);
 }
@@ -3488,8 +3803,8 @@ et_application_window_delete_selected_files (GtkAction *action,
             case -1:
                 // Stop deleting files + reinit progress bar
                 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0.0);
-                // To update state of command buttons
-                Update_Command_Buttons_Sensivity();
+                /* To update state of command buttons. */
+                et_application_window_update_actions (self);
                 et_application_window_browser_set_sensitive (self, TRUE);
                 et_application_window_tag_area_set_sensitive (self, TRUE);
                 et_application_window_file_area_set_sensitive (self, TRUE);
@@ -3518,7 +3833,7 @@ et_application_window_delete_selected_files (GtkAction *action,
     et_browser_toggle_display_mode (ET_BROWSER (priv->browser));
 
     /* To update state of command buttons */
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (self);
     et_application_window_browser_set_sensitive (self, TRUE);
     et_application_window_tag_area_set_sensitive (self, TRUE);
     et_application_window_file_area_set_sensitive (self, TRUE);
diff --git a/src/application_window.h b/src/application_window.h
index c484bc1..4d45337 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -49,18 +49,16 @@ GType et_application_window_get_type (void);
 EtApplicationWindow *et_application_window_new (GtkApplication *application);
 void et_application_window_tag_area_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
 void et_application_window_file_area_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
+void et_application_window_update_actions (EtApplicationWindow *self);
 void et_application_window_tag_area_display_controls (EtApplicationWindow *self, ET_File *ETFile);
 GtkWidget * et_application_window_get_log_area (EtApplicationWindow *self);
-void et_application_window_show_playlist_dialog (GtkAction *action, gpointer user_data);
 GtkWidget * et_application_window_get_load_files_dialog (EtApplicationWindow *self);
-void et_application_window_show_load_files_dialog (GtkAction *action, gpointer user_data);
 GtkWidget * et_application_window_get_search_dialog (EtApplicationWindow *self);
 void et_application_window_show_search_dialog (GtkAction *action, gpointer user_data);
 GtkWidget * et_application_window_get_preferences_dialog (EtApplicationWindow *self);
 void et_application_window_show_preferences_dialog (GtkAction *action, gpointer user_data);
 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_show_cddb_dialog (GtkAction *action, gpointer user_data);
 void et_application_window_search_cddb_for_selection (GtkAction *action, gpointer user_data);
 void et_application_window_browser_collapse (GtkAction *action, gpointer user_data);
 void et_application_window_browser_reload (GtkAction *action, gpointer user_data);
diff --git a/src/bar.c b/src/bar.c
index dd7d82d..f832082 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -283,20 +283,9 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
 
         { MENU_SCANNER, NULL, _("S_canner Mode"), NULL, NULL, NULL },
 
-        { MENU_MISC,                NULL,                   _("_Miscellaneous"),                             
NULL,         NULL,                                 NULL },
         { AM_SEARCH_FILE, GTK_STOCK_FIND, _("_Find…"), "<Primary>F",
           _("Search filenames and tags"),
           G_CALLBACK (et_application_window_show_search_dialog) },
-        { AM_CDDB_SEARCH, GTK_STOCK_CDROM, _("CDD_B Search…"), "<Primary>B",
-          _("CDDB search"),
-          G_CALLBACK (et_application_window_show_cddb_dialog) },
-        { AM_FILENAME_FROM_TXT, GTK_STOCK_OPEN,
-          _("Load Filenames From a Text File…"), "<Primary>T",
-          _("Load filenames from a text file"),
-          G_CALLBACK (et_application_window_show_load_files_dialog) },
-        { AM_WRITE_PLAYLIST, GTK_STOCK_SAVE_AS, _("Generate Playlist…"),
-          "<Primary>W", _("Generate a playlist"),
-          G_CALLBACK (et_application_window_show_playlist_dialog) },
         { AM_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY, _("Run Audio Player"),
           "<Primary>M", _("Run audio player"),
           G_CALLBACK (et_application_window_run_player_for_selection) },
diff --git a/src/bar.h b/src/bar.h
index d99ca61..4f79ef2 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -39,7 +39,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define MENU_GO "GoMenu"
 #define MENU_BROWSER    "BrowserMenu"
 #define MENU_SCANNER    "ScannerMenu"
-#define MENU_MISC       "MiscMenu"
 
 #define MENU_FILE_SORT_TAG      "SortTagMenu"
 #define MENU_FILE_SORT_PROP     "SortPropMenu"
@@ -87,9 +86,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define AM_SCANNER_SHOW "ShowScanner"
 #define AM_SEARCH_FILE              "SearchFile"
 #define AM_CDDB_SEARCH_FILE         "CDDBSearchFile"
-#define AM_CDDB_SEARCH              "CDDBSearch"
-#define AM_FILENAME_FROM_TXT        "LoadFilenames"
-#define AM_WRITE_PLAYLIST           "WritePlaylist"
 #define AM_RUN_AUDIO_PLAYER         "RunAudio"
 #define AM_QUIT                     "Quit"
 
diff --git a/src/browser.c b/src/browser.c
index 886d915..5a2a573 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -876,7 +876,8 @@ Browser_Tree_Node_Selected (EtBrowser *self, GtkTreeSelection *selection)
 
     /* Save the current displayed data */
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-    Update_Command_Buttons_Sensivity(); // Not clean to put this here...
+    /* FIXME: Not clean to put this here. */
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 
     /* Check if all files have been saved before changing the directory */
     if (g_settings_get_boolean (MainSettings, "confirm-when-unsaved-files")
@@ -971,7 +972,7 @@ Browser_Tree_Node_Selected (EtBrowser *self, GtkTreeSelection *selection)
     }else
     {
         /* As we don't use the function 'Read_Directory' we must add this function here */
-        Update_Command_Buttons_Sensivity();
+        et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
     }
     counter++;
 
@@ -2991,7 +2992,7 @@ et_browser_reload (EtBrowser *self)
     }
     g_free(current_path);
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 }
 
 /*
diff --git a/src/easytag.c b/src/easytag.c
index 0512b7d..4dd88c7 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -443,7 +443,7 @@ void Action_Select_Nth_File_By_Etfile (ET_File *ETFile)
     ET_Displayed_File_List_By_Etfile(ETFile); // Just to update 'ETFileDisplayedList'
     ET_Display_File_Data_To_UI(ETFile);
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
     et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (MainWindow))));
 }
 
@@ -466,7 +466,7 @@ void Action_Undo_From_History_List (void)
                                                             ETFile);
     }
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 }
 
 
@@ -490,7 +490,7 @@ void Action_Redo_From_History_List (void)
                                                             ETFile);
     }
 
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 }
 
 
@@ -733,7 +733,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
                 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
                 Statusbar_Message (_("Saving files was stopped"), TRUE);
                 /* To update state of command buttons */
-                Update_Command_Buttons_Sensivity();
+                et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
                 et_application_window_browser_set_sensitive (window, TRUE);
                 et_application_window_tag_area_set_sensitive (window, TRUE);
                 et_application_window_file_area_set_sensitive (window, TRUE);
@@ -772,7 +772,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
         et_application_window_browser_toggle_display_mode (window);
 
     /* To update state of command buttons */
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
     et_application_window_browser_set_sensitive (window, TRUE);
     et_application_window_tag_area_set_sensitive (window, TRUE);
     et_application_window_file_area_set_sensitive (window, TRUE);
@@ -1263,7 +1263,7 @@ gboolean Read_Directory (gchar *path_real)
     /* Initialize file list */
     ET_Core_Free();
     ET_Core_Initialize();
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 
     window = ET_APPLICATION_WINDOW (MainWindow);
 
@@ -1436,7 +1436,7 @@ gboolean Read_Directory (gchar *path_real)
     }
 
     /* Update sensitivity of buttons and menus */
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 
     et_application_window_browser_set_sensitive (window, TRUE);
 
@@ -1631,254 +1631,6 @@ ui_widget_set_sensitive (const gchar *menu, const gchar *action, gboolean sensit
 }
 
 /*
- * Update_Command_Buttons_Sensivity: Set to sensitive/unsensitive the state of each button into
- * the commands area and menu items in function of state of the "main list".
- */
-void
-Update_Command_Buttons_Sensivity (void)
-{
-    EtApplicationWindow *window;
-    GtkDialog *dialog;
-    GtkAction *uiaction;
-
-    window = ET_APPLICATION_WINDOW (MainWindow);
-    dialog = GTK_DIALOG (et_application_window_get_scan_dialog (window));
-
-    if (!ETCore->ETFileDisplayedList)
-    {
-        /* No file found */
-
-        /* File and Tag frames */
-        et_application_window_file_area_set_sensitive (window, FALSE);
-        et_application_window_tag_area_set_sensitive (window, FALSE);
-
-        /* Tool bar buttons (the others are covered by the menu) */
-        uiaction = gtk_ui_manager_get_action(UIManager, "/ToolBar/Stop");
-        g_object_set(uiaction, "sensitive", FALSE, NULL);
-
-        /* Scanner Window */
-        if (dialog)
-        {
-            gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY,
-                                               FALSE);
-        }
-
-        /* Menu commands */
-        ui_widget_set_sensitive(MENU_FILE, AM_OPEN_FILE_WITH, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_INVERT_SELECTION, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_DELETE_FILE, FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILENAME, FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILENAME,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_CREATION_DATE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_CREATION_DATE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_TRACK_NUMBER,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_TRACK_NUMBER,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_TITLE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_TITLE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_ARTIST,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_ARTIST,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_ALBUM,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_ALBUM,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_YEAR,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_YEAR,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_GENRE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_GENRE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_ASCENDING_COMMENT,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH, AM_SORT_DESCENDING_COMMENT,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_TYPE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_TYPE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_SIZE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_SIZE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_DURATION,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_DURATION,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_BITRATE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_BITRATE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_ASCENDING_FILE_SAMPLERATE,FALSE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH, AM_SORT_DESCENDING_FILE_SAMPLERATE,FALSE);
-        ui_widget_set_sensitive (MENU_GO, AM_PREV, FALSE);
-        ui_widget_set_sensitive (MENU_GO, AM_NEXT, FALSE);
-        ui_widget_set_sensitive (MENU_GO, AM_FIRST, FALSE);
-        ui_widget_set_sensitive (MENU_GO, AM_LAST, FALSE);
-        ui_widget_set_sensitive (MENU_EDIT, AM_REMOVE, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_UNDO, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_REDO, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_SAVE, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_SAVE_FORCED, FALSE);
-        ui_widget_set_sensitive (MENU_EDIT, AM_UNDO_HISTORY, FALSE);
-        ui_widget_set_sensitive (MENU_EDIT, AM_REDO_HISTORY, FALSE);
-        ui_widget_set_sensitive (MENU_EDIT, AM_SEARCH_FILE, FALSE);
-        ui_widget_set_sensitive(MENU_MISC, AM_FILENAME_FROM_TXT, FALSE);
-        ui_widget_set_sensitive(MENU_MISC, AM_WRITE_PLAYLIST, FALSE);
-        ui_widget_set_sensitive (MENU_FILE, AM_RUN_AUDIO_PLAYER, FALSE);
-        ui_widget_set_sensitive (MENU_SCANNER_PATH,
-                                 AM_SCANNER_FILL_TAG, FALSE);
-        ui_widget_set_sensitive (MENU_SCANNER_PATH,
-                                 AM_SCANNER_RENAME_FILE, FALSE);
-        ui_widget_set_sensitive (MENU_SCANNER_PATH,
-                                 AM_SCANNER_PROCESS_FIELDS, FALSE);
-        ui_widget_set_sensitive (MENU_VIEW, AM_ARTIST_VIEW_MODE, FALSE);
-
-        return;
-    }else
-    {
-        GtkWidget *artist_radio = NULL;
-        GList *selfilelist = NULL;
-        ET_File *etfile;
-        gboolean has_undo = FALSE;
-        gboolean has_redo = FALSE;
-        //gboolean has_to_save = FALSE;
-        GtkTreeSelection *selection;
-
-        /* File and Tag frames */
-        et_application_window_file_area_set_sensitive (window, TRUE);
-        et_application_window_tag_area_set_sensitive (window, TRUE);
-
-        /* Tool bar buttons */
-        uiaction = gtk_ui_manager_get_action(UIManager, "/ToolBar/Stop");
-        g_object_set(uiaction, "sensitive", FALSE, NULL);
-
-        /* Scanner Window */
-        if (dialog)
-        {
-            gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY,
-                                               TRUE);
-        }
-
-        /* Commands into menu */
-        ui_widget_set_sensitive(MENU_FILE, AM_OPEN_FILE_WITH,TRUE);
-        ui_widget_set_sensitive(MENU_FILE, AM_INVERT_SELECTION,TRUE);
-        ui_widget_set_sensitive(MENU_FILE, AM_DELETE_FILE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILENAME,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILENAME,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_CREATION_DATE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_CREATION_DATE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_TRACK_NUMBER,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_TRACK_NUMBER,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_TITLE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_TITLE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_ARTIST,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_ARTIST,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_ALBUM,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_ALBUM,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_YEAR,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_YEAR,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_GENRE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_GENRE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_ASCENDING_COMMENT,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_TAG_PATH,AM_SORT_DESCENDING_COMMENT,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_TYPE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_TYPE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_SIZE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_SIZE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_DURATION,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_DURATION,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_BITRATE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_BITRATE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_ASCENDING_FILE_SAMPLERATE,TRUE);
-        ui_widget_set_sensitive(MENU_SORT_PROP_PATH,AM_SORT_DESCENDING_FILE_SAMPLERATE,TRUE);
-        ui_widget_set_sensitive (MENU_EDIT, AM_REMOVE, TRUE);
-        ui_widget_set_sensitive (MENU_EDIT, AM_SEARCH_FILE, TRUE);
-        ui_widget_set_sensitive(MENU_MISC,AM_FILENAME_FROM_TXT,TRUE);
-        ui_widget_set_sensitive(MENU_MISC,AM_WRITE_PLAYLIST,TRUE);
-        ui_widget_set_sensitive (MENU_FILE, AM_RUN_AUDIO_PLAYER, TRUE);
-        ui_widget_set_sensitive (MENU_SCANNER_PATH,
-                                 AM_SCANNER_FILL_TAG,TRUE);
-        ui_widget_set_sensitive (MENU_SCANNER_PATH,
-                                 AM_SCANNER_RENAME_FILE, TRUE);
-        ui_widget_set_sensitive (MENU_SCANNER_PATH,
-                                 AM_SCANNER_PROCESS_FIELDS, TRUE);
-        ui_widget_set_sensitive (MENU_VIEW, AM_ARTIST_VIEW_MODE, TRUE);
-
-        /* Check if one of the selected files has undo or redo data */
-        {
-            GList *l;
-
-            selection = et_application_window_browser_get_selection (window);
-            selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
-
-            for (l = selfilelist; l != NULL; l = g_list_next (l))
-            {
-                etfile = et_application_window_browser_get_et_file_from_path (ET_APPLICATION_WINDOW 
(MainWindow),
-                                                                              l->data);
-                has_undo    |= ET_File_Data_Has_Undo_Data(etfile);
-                has_redo    |= ET_File_Data_Has_Redo_Data(etfile);
-                //has_to_save |= ET_Check_If_File_Is_Saved(etfile);
-                if ((has_undo && has_redo /*&& has_to_save*/) || !l->next) // Useless to check the other 
files
-                    break;
-            }
-
-            g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
-        }
-
-        /* Enable undo commands if there are undo data */
-        if (has_undo)
-            ui_widget_set_sensitive(MENU_FILE, AM_UNDO, TRUE);
-        else
-            ui_widget_set_sensitive(MENU_FILE, AM_UNDO, FALSE);
-
-        /* Enable redo commands if there are redo data */
-        if (has_redo)
-            ui_widget_set_sensitive(MENU_FILE, AM_REDO, TRUE);
-        else
-            ui_widget_set_sensitive(MENU_FILE, AM_REDO, FALSE);
-
-        /* Enable save file command if file has been changed */
-        // Desactivated because problem with only one file in the list, as we can't change the selected file 
=> can't mark file as changed
-        /*if (has_to_save)
-            ui_widget_set_sensitive(MENU_FILE, AM_SAVE, FALSE);
-        else*/
-            ui_widget_set_sensitive(MENU_FILE, AM_SAVE, TRUE);
-        
-        ui_widget_set_sensitive(MENU_FILE, AM_SAVE_FORCED, TRUE);
-
-        /* Enable undo command if there are data into main undo list (history list) */
-        if (ET_History_File_List_Has_Undo_Data())
-            ui_widget_set_sensitive (MENU_EDIT, AM_UNDO_HISTORY, TRUE);
-        else
-            ui_widget_set_sensitive (MENU_EDIT, AM_UNDO_HISTORY, FALSE);
-
-        /* Enable redo commands if there are data into main redo list (history list) */
-        if (ET_History_File_List_Has_Redo_Data())
-            ui_widget_set_sensitive (MENU_EDIT, AM_REDO_HISTORY, TRUE);
-        else
-            ui_widget_set_sensitive (MENU_EDIT, AM_REDO_HISTORY, FALSE);
-
-        artist_radio = gtk_ui_manager_get_widget (UIManager,
-                                                  "/ToolBar/ArtistViewMode");
-
-        if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
-        {
-            ui_widget_set_sensitive (MENU_VIEW, AM_COLLAPSE_TREE, FALSE);
-            ui_widget_set_sensitive (MENU_VIEW, AM_INITIALIZE_TREE, FALSE);
-        }
-        else
-        {
-            ui_widget_set_sensitive (MENU_VIEW, AM_COLLAPSE_TREE, TRUE);
-            ui_widget_set_sensitive (MENU_VIEW, AM_INITIALIZE_TREE, TRUE);
-        }
-    }
-
-    if (!ETCore->ETFileDisplayedList->prev)    /* Is it the 1st item ? */
-    {
-        ui_widget_set_sensitive (MENU_GO, AM_PREV, FALSE);
-        ui_widget_set_sensitive (MENU_GO, AM_FIRST, FALSE);
-    }else
-    {
-        ui_widget_set_sensitive (MENU_GO, AM_PREV, TRUE);
-        ui_widget_set_sensitive (MENU_GO, AM_FIRST, TRUE);
-    }
-    if (!ETCore->ETFileDisplayedList->next)    /* Is it the last item ? */
-    {
-        ui_widget_set_sensitive (MENU_GO, AM_NEXT, FALSE);
-        ui_widget_set_sensitive (MENU_GO, AM_LAST, FALSE);
-    }else
-    {
-        ui_widget_set_sensitive (MENU_GO, AM_NEXT, TRUE);
-        ui_widget_set_sensitive (MENU_GO, AM_LAST, TRUE);
-    }
-}
-
-/*
  * Just to disable buttons when we are saving files (do not disable Quit button)
  */
 void
@@ -1952,8 +1704,8 @@ Init_Load_Default_Dir (void)
                                                ET_APPLICATION_WINDOW (MainWindow));
     }
 
-    // To set sensivity of buttons in the case if the default directory is invalid
-    Update_Command_Buttons_Sensivity();
+    /* Set sensitivity of buttons if the default directory is invalid. */
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 
     g_source_remove(idle_handler_id);
 }
diff --git a/src/easytag.h b/src/easytag.h
index 0eabd80..2e379dd 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -124,7 +124,6 @@ void et_on_action_select_scan_mode (GtkRadioAction *action,
 
 gboolean Read_Directory               (gchar *path);
 void Quit_MainWindow                  (void);
-void Update_Command_Buttons_Sensivity (void);
 
 void Clear_File_Entry_Field (void);
 void Clear_Tag_Entry_Fields (void);
diff --git a/src/et_core.c b/src/et_core.c
index 998975a..4397cfb 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -906,7 +906,7 @@ gboolean ET_Remove_File_From_File_List (ET_File *ETFile)
         Clear_Header_Fields();
         Clear_Tag_Entry_Fields();
         gtk_label_set_text(GTK_LABEL(FileIndex),"0/0:");
-        Update_Command_Buttons_Sensivity();
+        et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
     }
 
     return TRUE;
@@ -1181,7 +1181,7 @@ ET_Sort_Displayed_File_List_And_Update_UI (EtSortMode Sorting_Type)
     ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
 
     et_application_window_browser_refresh_sort (ET_APPLICATION_WINDOW (MainWindow));
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 }
 
 
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index e0f8cd4..6c6dd9d 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -3474,7 +3474,7 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
     ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
 
     /* To update state of command buttons */
-    Update_Command_Buttons_Sensivity();
+    et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
 
     gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
     gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
diff --git a/src/ui_manager.h b/src/ui_manager.h
index 77c023b..d6b3c6b 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -152,14 +152,6 @@ static const gchar *ui_xml =
 "      <menuitem action='BrowseSubdir' />"
 "    </menu>"
 
-"    <menu action='MiscMenu'>"
-"      <menuitem action='CDDBSearch' />"
-"      <separator />"
-
-"      <menuitem action='LoadFilenames' />"
-"      <menuitem action='WritePlaylist' />"
-"    </menu>"
-
 "    <menu action='GoMenu'>"
 "      <menuitem action='FirstFile' />"
 "      <menuitem action='PreviousFile' />"
@@ -194,11 +186,6 @@ static const gchar *ui_xml =
 "    <toolitem action='SelInv'/>"
 "    <separator />"
 
-"    <toolitem action='SearchFile' />"
-"    <toolitem action='CDDBSearch' />"
-"    <toolitem action='WritePlaylist' />"
-"    <separator />"
-
 "    <toolitem action='Stop'/>"
 "  </toolbar>"
 


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