[easytag/wip/application-window: 7/70] Move select and unselect actions to main window



commit 66325a28c4d7a76818761973efb75e628d304a86
Author: David King <amigadave amigadave com>
Date:   Sun Jan 5 21:49:55 2014 +0000

    Move select and unselect actions to main window

 src/application_window.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++
 src/application_window.h |    2 +
 src/bar.c                |    4 +-
 src/browser.c            |    3 +-
 src/easytag.c            |   66 ----------------------------------------------
 src/easytag.h            |    2 -
 6 files changed, 72 insertions(+), 71 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index dc50fad..0976cb3 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -2349,3 +2349,69 @@ et_application_window_tag_area_display_controls (EtApplicationWindow *self,
             break;
     }
 }
+
+/*
+ * Action when selecting all files
+ */
+void
+et_application_window_select_all (GtkAction *action, gpointer user_data)
+{
+    GtkWidget *focused;
+
+    /* 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 (user_data));
+
+    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 ();
+    }
+}
+
+/*
+ * Action when unselecting all
+ */
+void
+et_application_window_unselect_all (GtkAction *action, gpointer user_data)
+{
+    GtkWidget *focused;
+
+    focused = gtk_window_get_focus (GTK_WINDOW (user_data));
+
+    if (GTK_IS_EDITABLE (focused))
+    {
+        GtkEditable *editable;
+        gint pos;
+
+        editable = GTK_EDITABLE (focused);
+        pos = gtk_editable_get_position (editable);
+        gtk_editable_select_region (editable, 0, 0);
+        gtk_editable_set_position (editable, pos);
+    }
+    else if (focused == PictureEntryView)
+    {
+        GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (focused));
+        gtk_tree_selection_unselect_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_Unselect_All_Files ();
+        ETCore->ETFileDisplayed = NULL;
+    }
+}
diff --git a/src/application_window.h b/src/application_window.h
index aaf9583..73dfc3a 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -67,6 +67,8 @@ 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);
 void et_on_action_select_scan_mode (GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
+void et_application_window_select_all (GtkAction *action, gpointer user_data);
+void et_application_window_unselect_all (GtkAction *action, gpointer user_data);
 void et_application_window_hide_log_area (EtApplicationWindow *self);
 void et_application_window_show_log_area (EtApplicationWindow *self);
 
diff --git a/src/bar.c b/src/bar.c
index c9f1f51..75129a4 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -208,10 +208,10 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
           "<Primary><Shift>O", _("Run a command on the selected files"),
           G_CALLBACK (Browser_Open_Run_Program_List_Window) },
         { AM_SELECT_ALL, GTK_STOCK_SELECT_ALL, NULL, "<Primary>A",
-          _("Select all"), G_CALLBACK (et_on_action_select_all) },
+          _("Select all"), G_CALLBACK (et_application_window_select_all) },
         { AM_UNSELECT_ALL, "easytag-unselect-all", _("Unselect All"),
           "<Primary><Shift>A", _("Clear the current selection"),
-          G_CALLBACK (et_on_action_unselect_all) },
+          G_CALLBACK (et_application_window_unselect_all) },
         { AM_INVERT_SELECTION, "easytag-invert-selection",
           _("Invert File Selection"), "<Primary>I",
           _("Invert file selection"),
diff --git a/src/browser.c b/src/browser.c
index 849255e..326bcc5 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -38,6 +38,7 @@
 #include <stdio.h>
 #include <errno.h>
 
+#include "application_window.h"
 #include "gtk2_compat.h"
 #include "easytag.h"
 #include "browser.h"
@@ -568,7 +569,7 @@ Browser_List_Button_Press (GtkTreeView *treeView, GdkEventButton *event)
     }else if (event->type==GDK_3BUTTON_PRESS && event->button==1)
     {
         /* Triple left mouse click, select all files of the list. */
-        et_on_action_select_all ();
+        et_application_window_select_all (NULL, MainWindow);
     }
     return FALSE;
 }
diff --git a/src/easytag.c b/src/easytag.c
index 4a0d777..a2302e4 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -434,72 +434,6 @@ int main (int argc, char *argv[])
 }
 
 /*
- * Action when selecting all files
- */
-void
-et_on_action_select_all (void)
-{
-    GtkWidget *focused;
-
-    /* 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 ();
-    }
-}
-
-
-/*
- * Action when unselecting all
- */
-void
-et_on_action_unselect_all (void)
-{
-    GtkWidget *focused;
-
-    focused = gtk_window_get_focus (GTK_WINDOW (MainWindow));
-    if (GTK_IS_EDITABLE (focused))
-    {
-        GtkEditable *editable;
-        gint pos;
-
-        editable = GTK_EDITABLE (focused);
-        pos = gtk_editable_get_position (editable);
-        gtk_editable_select_region (editable, 0, 0);
-        gtk_editable_set_position (editable, pos);
-    }
-    else if (focused == PictureEntryView)
-    {
-        GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (focused));
-        gtk_tree_selection_unselect_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_Unselect_All_Files ();
-        ETCore->ETFileDisplayed = NULL;
-    }
-}
-
-
-/*
  * Action when inverting files selection
  */
 void Action_Invert_Files_Selection (void)
diff --git a/src/easytag.h b/src/easytag.h
index 7322871..be384b5 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -102,8 +102,6 @@ gboolean ReadingDirectory;
  * Prototypes *
  **************/
 void Disable_Command_Buttons (void);
-void et_on_action_select_all (void);
-void et_on_action_unselect_all (void);
 void Action_Invert_Files_Selection      (void);
 void Action_Select_Prev_File            (void);
 void Action_Select_Next_File            (void);


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