[easytag/wip/unstable] Improve file view mode selection, bug 697457



commit 483f1ba1f7e32747270e94fadcb6d4f8d69c3f50
Author: David King <amigadave amigadave com>
Date:   Mon Apr 8 23:39:49 2013 +0100

    Improve file view mode selection, bug 697457
    
    Split the file view mode toggle action into two radio actions.

 src/bar.c        |   25 ++++++++++++++-----------
 src/bar.h        |    4 ++--
 src/browser.c    |   21 ++++++++++++---------
 src/easytag.c    |    7 ++++---
 src/ui_manager.h |   10 ++++++++--
 5 files changed, 40 insertions(+), 27 deletions(-)
---
diff --git a/src/bar.c b/src/bar.c
index f355838..a7c5604 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -69,7 +69,6 @@ static void Statusbar_Remove_Timer (void);
 static void
 Menu_Sort_Action (GtkAction *item, gpointer data)
 {
-    GtkWidget *TBViewMode;
     const gchar *action = gtk_action_get_name(item);
     GQuark quark = g_quark_from_string(action);
 
@@ -114,14 +113,6 @@ Menu_Sort_Action (GtkAction *item, gpointer data)
     QCASE_DATA(AM_SORT_ASCENDING_FILE_SAMPLERATE,  ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_SAMPLERATE);
     QCASE_DATA(AM_SORT_DESCENDING_FILE_SAMPLERATE, ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_SAMPLERATE);
     QCASE_DATA(AM_INITIALIZE_TREE,                 Browser_Tree_Rebuild,                      NULL);
-
-    if (quark == g_quark_from_string(AM_TREE_OR_ARTISTALBUM_VIEW))
-    {
-        // Toggle button to switch between Browser view and Artist / Album view
-        TBViewMode = gtk_ui_manager_get_widget(UIManager, "/ToolBar/ViewModeToggle");
-        gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(TBViewMode),
-                                          
!gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(TBViewMode)));
-    }
 }
 
 void Create_UI (GtkWidget **ppmenubar, GtkWidget **pptoolbar)
@@ -218,7 +209,6 @@ void Create_UI (GtkWidget **ppmenubar, GtkWidget **pptoolbar)
         { AM_LOAD_MUSIC_DIR,           "folder-music",      _("Go to Music Directory"),         NULL,        
          _("Go to music directory"),         G_CALLBACK(Browser_Load_Music_Directory) },
         { AM_LOAD_DEFAULT_DIR,         GTK_STOCK_JUMP_TO,      _("Go to _Default Directory"),      
"<Control>D",        _("Go to default directory"),       G_CALLBACK(Browser_Load_Default_Directory) },
         { AM_SET_PATH_AS_DEFAULT,      GTK_STOCK_DIRECTORY,    _("Set _Current Path as Default"),  NULL,     
           _("Set current path as default"),   G_CALLBACK(Set_Current_Path_As_Default) },
-        { AM_TREE_OR_ARTISTALBUM_VIEW, "easytag-artist-album", _("Tree View | Artist-Album View"), NULL,     
           _("Toggle between tree view and artist-album view"), G_CALLBACK(Menu_Sort_Action) },
         { AM_RENAME_DIR,               GTK_STOCK_INDEX,        _("Rename Directory…"),          "F2",        
        _("Rename directory"),          G_CALLBACK(Browser_Open_Rename_Directory_Window) },
         { AM_RELOAD_DIRECTORY,         GTK_STOCK_REFRESH,      _("Reload Directory"),              "F5",     
           _("Reload directory"),              G_CALLBACK(Browser_Reload_Directory) },
         { AM_BROWSE_DIRECTORY_WITH,    GTK_STOCK_EXECUTE,      _("Browse Directory with…"),     NULL,        
        _("Browse directory with…"),     G_CALLBACK(Browser_Open_Run_Program_Tree_Window) },
@@ -275,17 +265,27 @@ void Create_UI (GtkWidget **ppmenubar, GtkWidget **pptoolbar)
                     */
         { AM_BROWSER_HIDDEN_DIR, NULL,                   _("Show Hidden Directories"),                       
  NULL, _("Show hidden directories"),                         G_CALLBACK(Browser_Tree_Rebuild),     
BROWSE_HIDDEN_DIR },
 #endif /* !G_OS_WIN32 */
-        { AM_VIEWMODE_TOGGLE,    "easytag-artist-album", _("Show Tree Browser / Display by Artist and 
Album"), NULL, _("Show tree browser / display by artist and Album"), G_CALLBACK(Action_Select_Browser_Style), 
FALSE },
+    };
+
+    GtkRadioActionEntry view_mode_entries[] =
+    {
+        { AM_TREE_VIEW_MODE, "audio-x-generic", _("Tree Browser View"), NULL,
+          _("View by directory tree"), 0 },
+        { AM_ARTIST_VIEW_MODE, "easytag-artist-album",
+          _("Artist and Album View"), NULL,
+          _("View by artist and album"), 1 }
     };
 
     GError *error = NULL;
     guint num_menu_entries;
     guint num_toggle_entries;
+    guint n_view_mode_entries;
     guint i;
 
     /* Calculate number of items into the menu */
     num_menu_entries = G_N_ELEMENTS(ActionEntries);
     num_toggle_entries = G_N_ELEMENTS(ToggleActionEntries);
+    n_view_mode_entries = G_N_ELEMENTS (view_mode_entries);
 
     /* Populate quarks list with the entries */
     for(i = 0; i < num_menu_entries; i++)
@@ -308,6 +308,9 @@ void Create_UI (GtkWidget **ppmenubar, GtkWidget **pptoolbar)
     ActionGroup = gtk_action_group_new("actions");
     gtk_action_group_add_actions(ActionGroup, ActionEntries, num_menu_entries, NULL);
     gtk_action_group_add_toggle_actions(ActionGroup, ToggleActionEntries, num_toggle_entries, NULL);
+    gtk_action_group_add_radio_actions (ActionGroup, view_mode_entries,
+                                        n_view_mode_entries, 0,
+                                        Action_Select_Browser_Style, NULL);
 
     UIManager = gtk_ui_manager_new();
     if (!gtk_ui_manager_add_ui_from_string(UIManager, ui_xml, -1, &error))
diff --git a/src/bar.h b/src/bar.h
index e85000c..db5def3 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -81,7 +81,8 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define AM_COLLAPSE_TREE            "CollapseTree"
 #define AM_INITIALIZE_TREE          "RefreshTree"
 #define AM_RELOAD_DIRECTORY         "ReloadDir"
-#define AM_TREE_OR_ARTISTALBUM_VIEW "ViewMode"
+#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"
@@ -105,7 +106,6 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define AM_LOG_CLEAN                "CleanLog"
 
 #define AM_STOP                     "Stop"
-#define AM_VIEWMODE_TOGGLE          "ViewModeToggle"
 
 #define AM_SORT_ASCENDING_FILENAME          "SortFilenameAsc"
 #define AM_SORT_DESCENDING_FILENAME         "SortFilenameDesc"
diff --git a/src/browser.c b/src/browser.c
index 46b9742..17ba8e5 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -1105,7 +1105,7 @@ void Browser_List_Refresh_Whole_List (void)
     gchar *current_basename_utf8;
     gchar *track;
     gboolean valid;
-    GtkWidget *TBViewMode;
+    GtkWidget *artist_radio;
 
     if (!ETCore->ETFileDisplayedList || !BrowserList
     ||  gtk_tree_model_iter_n_children(GTK_TREE_MODEL(fileListModel), NULL) == 0)
@@ -1113,7 +1113,8 @@ void Browser_List_Refresh_Whole_List (void)
         return;
     }
 
-    TBViewMode = gtk_ui_manager_get_widget(UIManager, "/ToolBar/ViewModeToggle");
+    artist_radio = gtk_ui_manager_get_widget (UIManager,
+                                              "/ToolBar/ArtistViewMode");
 
     // Browse the full list for changes
     //gtk_tree_model_get_iter_first(GTK_TREE_MODEL(fileListModel), &iter);
@@ -1161,7 +1162,7 @@ void Browser_List_Refresh_Whole_List (void)
     gtk_tree_path_free(currentPath);
 
     // When displaying Artist + Album lists => refresh also rows color
-    if ( gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(TBViewMode)) )
+    if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
     {
 
         for (row=0; row < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(artistListModel), NULL); row++)
@@ -1200,7 +1201,7 @@ void Browser_List_Refresh_Whole_List (void)
 void Browser_List_Refresh_File_In_List (ET_File *ETFile)
 {
     GList *selectedRow = NULL;
-    GtkWidget *TBViewMode;
+    GtkWidget *artist_radio;
     GtkTreeSelection *selection;
     GtkTreeIter selectedIter;
     GtkTreePath *currentPath = NULL;
@@ -1220,7 +1221,8 @@ void Browser_List_Refresh_File_In_List (ET_File *ETFile)
         return;
     }
 
-    TBViewMode = gtk_ui_manager_get_widget(UIManager, "/ToolBar/ViewModeToggle");
+    artist_radio = gtk_ui_manager_get_widget (UIManager,
+                                              "/ToolBar/ArtistViewMode");
 
     // Search the row of the modified file to update it (when found: row_found=TRUE)
     // 1/3. Get position of ETFile in ETFileList
@@ -1315,7 +1317,7 @@ void Browser_List_Refresh_File_In_List (ET_File *ETFile)
     Browser_List_Set_Row_Appearance(&selectedIter);
 
     // When displaying Artist + Album lists => refresh also rows color
-    if ( gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(TBViewMode)) )
+    if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
     {
         gchar *current_artist = ((File_Tag *)ETFile->FileTag->data)->artist;
         gchar *current_album  = ((File_Tag *)ETFile->FileTag->data)->album;
@@ -2286,16 +2288,17 @@ Browser_Album_List_Set_Row_Appearance (GtkTreeIter *iter)
 void Browser_Display_Tree_Or_Artist_Album_List (void)
 {
     ET_File *etfile = ETCore->ETFileDisplayed; // ETFile to display again after changing browser view
-    GtkWidget *TBViewMode;
+    GtkWidget *artist_radio;
 
     // Save the current displayed data
     ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
 
     // Toggle button to switch view
-    TBViewMode = gtk_ui_manager_get_widget(UIManager, "/ToolBar/ViewModeToggle");
+    artist_radio = gtk_ui_manager_get_widget (UIManager,
+                                              "/ToolBar/ArtistViewMode");
 
     // Button pressed in the toolbar
-    if ( gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(TBViewMode)) )
+    if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio)))
     {
         /*
          * Artist + Album view
diff --git a/src/easytag.c b/src/easytag.c
index 96f0dcf..2c4d0de 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -3555,7 +3555,7 @@ gboolean Read_Directory (gchar *path_real)
     GList *FileList = NULL;
     gint   progress_bar_index = 0;
     GtkAction *uiaction;
-    GtkWidget *TBViewMode;
+    GtkWidget *artist_radio;
 
     g_return_val_if_fail (path_real != NULL, FALSE);
 
@@ -3575,8 +3575,9 @@ gboolean Read_Directory (gchar *path_real)
     Clear_Tag_Entry_Fields();
     gtk_label_set_text(GTK_LABEL(FileIndex),"0/0:");
 
-    TBViewMode = gtk_ui_manager_get_widget(UIManager, "/ToolBar/ViewModeToggle");
-    gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(TBViewMode),FALSE);
+    artist_radio = gtk_ui_manager_get_widget (UIManager, "/ToolBar/ArtistViewMode");
+    gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (artist_radio),
+                                       FALSE);
     //Browser_Display_Tree_Or_Artist_Album_List(); // To show the corresponding lists...
 
     // Set to unsensitive the Browser Area, to avoid to select another file while loading the first one
diff --git a/src/ui_manager.h b/src/ui_manager.h
index a43ed3d..f95d81d 100644
--- a/src/ui_manager.h
+++ b/src/ui_manager.h
@@ -124,7 +124,10 @@ static const gchar *ui_xml =
 "      <menuitem action='SetDefaultPath' />"
 "      <separator />"
 
-"      <menuitem action='ViewMode' />"
+"      <menuitem action='TreeViewMode'/>"
+"      <menuitem action='ArtistViewMode'/>"
+"      <separator />"
+
 "      <menuitem action='RenameDir' />"
 "      <menuitem action='ReloadDir' />"
 "      <menuitem action='BrowseDir' />"
@@ -184,7 +187,10 @@ static const gchar *ui_xml =
 "    <toolitem action='SaveFile'/>"
 "    <separator />"
 
-"    <toolitem action='ViewModeToggle'/>"
+"    <toolitem action='TreeViewMode'/>"
+"    <toolitem action='ArtistViewMode'/>"
+"    <separator />"
+
 "    <toolitem action='SelAll'/>"
 "    <toolitem action='SelInv'/>"
 "    <separator />"


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