[easytag] Improve select all action handler, bug 697515



commit 4de07095ce8070f622cfd13a368722bfa4e547fc
Author: David King <amigadave amigadave com>
Date:   Sun Apr 7 23:05:56 2013 +0100

    Improve select all action handler, bug 697515
    
    As the action handler is not invoked on a widget, determine the
    currently-focused widget and call the appropriate "select all" method to
    ensure that Ctrl+A functions correctly in widgets other than the file
    list view. Adjust the strings to indicate that the select all action is
    not specific to files.

 src/bar.c     |    3 ++-
 src/bar.h     |    2 +-
 src/browser.c |    5 ++---
 src/cddb.c    |   28 ----------------------------
 src/easytag.c |   34 ++++++++++++++++++++++++++--------
 src/easytag.h |    2 +-
 6 files changed, 32 insertions(+), 42 deletions(-)
---
diff --git a/src/bar.c b/src/bar.c
index 935a354..f355838 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -189,7 +189,8 @@ void Create_UI (GtkWidget **ppmenubar, GtkWidget **pptoolbar)
         { AM_SORT_DESCENDING_FILE_SAMPLERATE, GTK_STOCK_SORT_DESCENDING, _("Descending by samplerate"),      
NULL, _("Descending by samplerate"),      G_CALLBACK(Menu_Sort_Action) },
 
         { AM_OPEN_FILE_WITH,     GTK_STOCK_OPEN,             _("Open Files With…"),      NULL,               
 _("Open files with…"),     G_CALLBACK(Browser_Open_Run_Program_List_Window) },
-        { AM_SELECT_ALL_FILES,   GTK_STOCK_SELECT_ALL,       _("Select All Files"),           "<Control>A",  
      _("Select all files"),          G_CALLBACK(Action_Select_All_Files) },
+        { AM_SELECT_ALL, GTK_STOCK_SELECT_ALL, NULL, "<Control>A",
+          _("Select all"), G_CALLBACK (et_on_action_select_all) },
         { AM_UNSELECT_ALL_FILES, "easytag-unselect-all",     _("Unselect All Files"),         
"<Shift><Control>A", _("Unselect all files"),        G_CALLBACK(Action_Unselect_All_Files) },
         { AM_INVERT_SELECTION,   "easytag-invert-selection", _("Invert Files Selection"),     "<Control>I",  
      _("Invert files selection"),    G_CALLBACK(Action_Invert_Files_Selection) },
         { AM_DELETE_FILE,        GTK_STOCK_DELETE,           _("Delete Files"),             NULL,            
    _("Delete files"),            G_CALLBACK(Action_Delete_Selected_Files) },
diff --git a/src/bar.h b/src/bar.h
index 2a7936a..e85000c 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -64,7 +64,7 @@ GtkWidget *CheckMenuItemBrowseHiddenDirMainMenu;
 #define AM_REDO_HISTORY             "Redo"
 #define AM_SAVE                     "SaveFile"
 #define AM_SAVE_FORCED              "SaveFileForced"
-#define AM_SELECT_ALL_FILES         "SelAll"
+#define AM_SELECT_ALL "SelAll"
 #define AM_UNSELECT_ALL_FILES       "UnselAll"
 #define AM_INVERT_SELECTION         "SelInv"
 #define AM_DELETE_FILE              "DeleteFile"
diff --git a/src/browser.c b/src/browser.c
index 127ce70..46b9742 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -643,9 +643,8 @@ Browser_List_Button_Press (GtkTreeView *treeView, GdkEventButton *event)
             gtk_tree_path_free(currentPath);
     }else if (event->type==GDK_3BUTTON_PRESS && event->button==1)
     {
-        /* Triple left mouse click */
-        // Select all files of the list
-        Action_Select_All_Files();
+        /* Triple left mouse click, select all files of the list. */
+        et_on_action_select_all ();
     }
     return FALSE;
 }
diff --git a/src/cddb.c b/src/cddb.c
index 6e9c542..53357e3 100644
--- a/src/cddb.c
+++ b/src/cddb.c
@@ -319,34 +319,6 @@ void Open_Cddb_Window (void)
     Separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
     gtk_box_pack_start(GTK_BOX(hbox),Separator,FALSE,FALSE,0);
 
-    // Button to select all files in list
-    Button = Create_Button_With_Icon_And_Label("easytag-select-all",NULL);
-    gtk_box_pack_start(GTK_BOX(hbox),Button,FALSE,FALSE,0);
-    gtk_button_set_relief(GTK_BUTTON(Button),GTK_RELIEF_NONE);
-    gtk_widget_set_tooltip_text(Button,_("Select All Files"));
-    g_signal_connect(G_OBJECT(Button),"clicked",G_CALLBACK(Action_Select_All_Files),NULL);
-
-    // Button to invert selection of files in list
-    Button = Create_Button_With_Icon_And_Label("easytag-invert-selection",NULL);
-    gtk_box_pack_start(GTK_BOX(hbox),Button,FALSE,FALSE,0);
-    gtk_button_set_relief(GTK_BUTTON(Button),GTK_RELIEF_NONE);
-    gtk_widget_set_tooltip_text(Button,_("Invert Files Selection"));
-    g_signal_connect(G_OBJECT(Button),"clicked",G_CALLBACK(Action_Invert_Files_Selection),NULL);
-
-/*    // Button to sort by ascending filename
-    Button = Create_Button_With_Icon_And_Label(GTK_STOCK_SORT_ASCENDING,NULL);
-    gtk_box_pack_start(GTK_BOX(hbox),Button,FALSE,FALSE,0);
-    gtk_button_set_relief(GTK_BUTTON(Button),GTK_RELIEF_NONE);
-    gtk_tooltips_set_tip(Tips,Button,_("Sort list ascending by filename"),NULL);
-    
g_signal_connect(G_OBJECT(Button),"clicked",G_CALLBACK(ET_Sort_Displayed_File_List_And_Update_UI),GINT_TO_POINTER(SORTING_BY_ASCENDING_FILENAME));
-
-    // Button to sort by ascending track number
-    Button = Create_Button_With_Icon_And_Label(GTK_STOCK_SORT_ASCENDING,NULL);
-    gtk_box_pack_start(GTK_BOX(hbox),Button,FALSE,FALSE,0);
-    gtk_button_set_relief(GTK_BUTTON(Button),GTK_RELIEF_NONE);
-    gtk_tooltips_set_tip(Tips,Button,_("Sort list ascending by track number"),NULL);
-    
g_signal_connect(G_OBJECT(Button),"clicked",G_CALLBACK(ET_Sort_Displayed_File_List_And_Update_UI),GINT_TO_POINTER(SORTING_BY_ASCENDING_TRACK_NUMBER));
-*/
     // Button to quit
     Button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
     gtk_box_pack_end(GTK_BOX(hbox),Button,FALSE,FALSE,0);
diff --git a/src/easytag.c b/src/easytag.c
index a24791d..96f0dcf 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -1695,13 +1695,31 @@ Mini_Button_Clicked (GObject *object)
 /*
  * Action when selecting all files
  */
-void Action_Select_All_Files (void)
+void
+et_on_action_select_all (void)
 {
-    /* Save the current displayed data */
-    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+    GtkWidget *focused;
 
-    Browser_List_Select_All_Files();
-    Update_Command_Buttons_Sensivity();
+    /* Use the currently-focused widget and "select all" as appropriate.
+     * https://bugzilla.gnome.org/show_bug.cgi?id=697515 */
+    focused = gtk_window_get_focus (GTK_WINDOW (MainWindow));
+    if (GTK_IS_EDITABLE (focused))
+    {
+        gtk_editable_select_region (GTK_EDITABLE (focused), 0, -1);
+    }
+    else if (focused == PictureEntryView)
+    {
+        GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (focused));
+        gtk_tree_selection_select_all (selection);
+    }
+    else /* Assume that other widgets should select all in the file view. */
+    {
+        /* Save the current displayed data */
+        ET_Save_File_Data_From_UI (ETCore->ETFileDisplayed);
+
+        Browser_List_Select_All_Files ();
+        Update_Command_Buttons_Sensivity ();
+    }
 }
 
 
@@ -3894,7 +3912,7 @@ void Update_Command_Buttons_Sensivity (void)
 
         /* Menu commands */
         ui_widget_set_sensitive(MENU_FILE, AM_OPEN_FILE_WITH, FALSE);
-        ui_widget_set_sensitive(MENU_FILE, AM_SELECT_ALL_FILES, FALSE);
+        ui_widget_set_sensitive (MENU_FILE, AM_SELECT_ALL, FALSE);
         ui_widget_set_sensitive(MENU_FILE, AM_UNSELECT_ALL_FILES, FALSE);
         ui_widget_set_sensitive(MENU_FILE, AM_INVERT_SELECTION, FALSE);
         ui_widget_set_sensitive(MENU_FILE, AM_DELETE_FILE, FALSE);
@@ -3969,7 +3987,7 @@ void Update_Command_Buttons_Sensivity (void)
 
         /* Commands into menu */
         ui_widget_set_sensitive(MENU_FILE, AM_OPEN_FILE_WITH,TRUE);
-        ui_widget_set_sensitive(MENU_FILE, AM_SELECT_ALL_FILES,TRUE);
+        ui_widget_set_sensitive (MENU_FILE, AM_SELECT_ALL, TRUE);
         ui_widget_set_sensitive(MENU_FILE, AM_UNSELECT_ALL_FILES,TRUE);
         ui_widget_set_sensitive(MENU_FILE, AM_INVERT_SELECTION,TRUE);
         ui_widget_set_sensitive(MENU_FILE, AM_DELETE_FILE,TRUE);
@@ -4096,7 +4114,7 @@ Disable_Command_Buttons (void)
 
     /* "File" menu commands */
     ui_widget_set_sensitive(MENU_FILE,AM_OPEN_FILE_WITH,FALSE);
-    ui_widget_set_sensitive(MENU_FILE,AM_SELECT_ALL_FILES,FALSE);
+    ui_widget_set_sensitive (MENU_FILE, AM_SELECT_ALL, FALSE);
     ui_widget_set_sensitive(MENU_FILE,AM_UNSELECT_ALL_FILES,FALSE);
     ui_widget_set_sensitive(MENU_FILE,AM_INVERT_SELECTION,FALSE);
     ui_widget_set_sensitive(MENU_FILE,AM_DELETE_FILE,FALSE);
diff --git a/src/easytag.h b/src/easytag.h
index 95459b2..bec9164 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -134,7 +134,7 @@ gboolean ReadingDirectory;
 /**************
  * Prototypes *
  **************/
-void Action_Select_All_Files            (void);
+void et_on_action_select_all (void);
 void Action_Unselect_All_Files          (void);
 void Action_Invert_Files_Selection      (void);
 void Action_Select_Prev_File            (void);


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