[easytag/wip/application-window: 13/16] Move file selection actions to EtApplicationWindow



commit fceeede9d1099cdc4b74c47c861c88cf5fe194bb
Author: David King <amigadave amigadave com>
Date:   Sun Jan 5 22:08:21 2014 +0000

    Move file selection actions to EtApplicationWindow

 src/application_window.c |  129 ++++++++++++++++++++++++++++++++++++++++++++++
 src/application_window.h |    4 ++
 src/bar.c                |   14 ++++--
 src/easytag.c            |  128 ---------------------------------------------
 src/easytag.h            |    4 --
 5 files changed, 143 insertions(+), 136 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index ab78494..dbf221b 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -2396,3 +2396,132 @@ et_application_window_unselect_all (GtkAction *action, gpointer user_data)
         ETCore->ETFileDisplayed = NULL;
     }
 }
+
+/*
+ * Action when First button is selected
+ */
+void
+et_application_window_select_first_file (GtkAction *action, gpointer user_data)
+{
+    GList *etfilelist;
+
+    if (!ETCore->ETFileDisplayedList)
+        return;
+
+    /* Save the current displayed data */
+    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+    /* Go to the first item of the list */
+    etfilelist = ET_Displayed_File_List_First();
+    if (etfilelist)
+    {
+        Browser_List_Unselect_All_Files(); // To avoid the last line still selected
+        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
+        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
+    }
+
+    Update_Command_Buttons_Sensivity();
+    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (user_data))));
+
+    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
+        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
+}
+
+
+/*
+ * Action when Prev button is selected
+ */
+void
+et_application_window_select_prev_file (GtkAction *action, gpointer user_data)
+{
+    GList *etfilelist;
+
+    if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->prev)
+        return;
+
+    /* Save the current displayed data */
+    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+    /* Go to the prev item of the list */
+    etfilelist = ET_Displayed_File_List_Previous();
+    if (etfilelist)
+    {
+        Browser_List_Unselect_All_Files();
+        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
+        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
+    }
+
+//    if (!ETFileList->prev)
+//        gdk_beep(); // Warm the user
+
+    Update_Command_Buttons_Sensivity();
+    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (user_data))));
+
+    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
+        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
+}
+
+
+/*
+ * Action when Next button is selected
+ */
+void
+et_application_window_select_next_file (GtkAction *acton, gpointer user_data)
+{
+    GList *etfilelist;
+
+    if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->next)
+        return;
+
+    /* Save the current displayed data */
+    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+    /* Go to the next item of the list */
+    etfilelist = ET_Displayed_File_List_Next();
+    if (etfilelist)
+    {
+        Browser_List_Unselect_All_Files();
+        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
+        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
+    }
+
+//    if (!ETFileList->next)
+//        gdk_beep(); // Warm the user
+
+    Update_Command_Buttons_Sensivity();
+    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (user_data))));
+
+    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
+        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
+}
+
+
+/*
+ * Action when Last button is selected
+ */
+void
+et_application_window_select_last_file (GtkAction *action, gpointer user_data)
+{
+    GList *etfilelist;
+
+    if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->next)
+        return;
+
+    /* Save the current displayed data */
+    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+    /* Go to the last item of the list */
+    etfilelist = ET_Displayed_File_List_Last();
+    if (etfilelist)
+    {
+        Browser_List_Unselect_All_Files();
+        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
+        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
+    }
+
+    Update_Command_Buttons_Sensivity();
+    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (user_data))));
+
+    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
+        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
+}
diff --git a/src/application_window.h b/src/application_window.h
index 66ea032..f5804e3 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -69,6 +69,10 @@ void et_application_window_scan_selected_files (GtkAction *action, gpointer user
 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_select_prev_file (GtkAction *action, gpointer user_data);
+void et_application_window_select_next_file (GtkAction *action, gpointer user_data);
+void et_application_window_select_first_file (GtkAction *action, gpointer user_data);
+void et_application_window_select_last_file (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 a340cd5..67e8246 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -217,11 +217,17 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
           G_CALLBACK (Action_Invert_Files_Selection) },
         { AM_DELETE_FILE,        GTK_STOCK_DELETE,           _("Delete Files"),             NULL,            
    _("Delete files"),            G_CALLBACK(Action_Delete_Selected_Files) },
         { AM_FIRST, GTK_STOCK_GOTO_FIRST, _("_First File"), "<Primary>Home",
-          _("First file"), G_CALLBACK (Action_Select_First_File) },
-        { AM_PREV,               GTK_STOCK_GO_BACK,          _("_Previous File"),             "Page_Up",     
      _("Previous file"),             G_CALLBACK(Action_Select_Prev_File) },
-        { AM_NEXT,               GTK_STOCK_GO_FORWARD,       _("_Next File"),                 "Page_Down",   
      _("Next file"),                 G_CALLBACK(Action_Select_Next_File) },
+          _("First file"),
+          G_CALLBACK (et_application_window_select_first_file) },
+        { AM_PREV, GTK_STOCK_GO_BACK, _("_Previous File"), "Page_Up",
+          _("Previous file"),
+          G_CALLBACK (et_application_window_select_prev_file) },
+        { AM_NEXT, GTK_STOCK_GO_FORWARD, _("_Next File"), "Page_Down",
+          _("Next file"),
+          G_CALLBACK (et_application_window_select_next_file) },
         { AM_LAST, GTK_STOCK_GOTO_LAST, _("_Last File"), "<Primary>End",
-          _("Last file"), G_CALLBACK (Action_Select_Last_File) },
+          _("Last file"),
+          G_CALLBACK (et_application_window_select_last_file) },
         { AM_SCAN_FILES, GTK_STOCK_APPLY, _("S_can Files"), NULL,
           _("Scan selected files"),
           G_CALLBACK (et_application_window_scan_selected_files) },
diff --git a/src/easytag.c b/src/easytag.c
index 23b940f..ddd39df 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -446,134 +446,6 @@ void Action_Invert_Files_Selection (void)
     Update_Command_Buttons_Sensivity();
 }
 
-
-
-/*
- * Action when First button is selected
- */
-void Action_Select_First_File (void)
-{
-    GList *etfilelist;
-
-    if (!ETCore->ETFileDisplayedList)
-        return;
-
-    /* Save the current displayed data */
-    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
-    /* Go to the first item of the list */
-    etfilelist = ET_Displayed_File_List_First();
-    if (etfilelist)
-    {
-        Browser_List_Unselect_All_Files(); // To avoid the last line still selected
-        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
-        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
-    }
-
-    Update_Command_Buttons_Sensivity();
-    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (MainWindow))));
-
-    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
-        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
-}
-
-
-/*
- * Action when Prev button is selected
- */
-void Action_Select_Prev_File (void)
-{
-    GList *etfilelist;
-
-    if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->prev)
-        return;
-
-    /* Save the current displayed data */
-    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
-    /* Go to the prev item of the list */
-    etfilelist = ET_Displayed_File_List_Previous();
-    if (etfilelist)
-    {
-        Browser_List_Unselect_All_Files();
-        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
-        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
-    }
-
-//    if (!ETFileList->prev)
-//        gdk_beep(); // Warm the user
-
-    Update_Command_Buttons_Sensivity();
-    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (MainWindow))));
-
-    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
-        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
-}
-
-
-/*
- * Action when Next button is selected
- */
-void Action_Select_Next_File (void)
-{
-    GList *etfilelist;
-
-    if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->next)
-        return;
-
-    /* Save the current displayed data */
-    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
-    /* Go to the next item of the list */
-    etfilelist = ET_Displayed_File_List_Next();
-    if (etfilelist)
-    {
-        Browser_List_Unselect_All_Files();
-        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
-        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
-    }
-
-//    if (!ETFileList->next)
-//        gdk_beep(); // Warm the user
-
-    Update_Command_Buttons_Sensivity();
-    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (MainWindow))));
-
-    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
-        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
-}
-
-
-/*
- * Action when Last button is selected
- */
-void Action_Select_Last_File (void)
-{
-    GList *etfilelist;
-
-    if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->next)
-        return;
-
-    /* Save the current displayed data */
-    ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
-    /* Go to the last item of the list */
-    etfilelist = ET_Displayed_File_List_Last();
-    if (etfilelist)
-    {
-        Browser_List_Unselect_All_Files();
-        Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
-        ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
-    }
-
-    Update_Command_Buttons_Sensivity();
-    et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog 
(ET_APPLICATION_WINDOW (MainWindow))));
-
-    if (SET_FOCUS_TO_FIRST_TAG_FIELD)
-        gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
-}
-
-
 /*
  * Select a file in the "main list" using the ETFile adress of each item.
  */
diff --git a/src/easytag.h b/src/easytag.h
index be384b5..f13befb 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -103,10 +103,6 @@ gboolean ReadingDirectory;
  **************/
 void Disable_Command_Buttons (void);
 void Action_Invert_Files_Selection      (void);
-void Action_Select_Prev_File            (void);
-void Action_Select_Next_File            (void);
-void Action_Select_First_File           (void);
-void Action_Select_Last_File            (void);
 void Action_Select_Nth_File_By_Position (gulong num_item);
 void Action_Select_Nth_File_By_Etfile   (ET_File *ETFile);
 


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