[easytag/wip/application-window: 17/17] Move browser to EtBrowser object
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 17/17] Move browser to EtBrowser object
- Date: Mon, 21 Apr 2014 09:25:01 +0000 (UTC)
commit 1fdd70698b0f96271e05ff13d20a37ea3b8c71d9
Author: David King <amigadave amigadave com>
Date: Wed Feb 12 23:06:30 2014 +0000
Move browser to EtBrowser object
src/application_window.c | 815 +++++++++++++++++++++++++++++-
src/application_window.h | 31 ++
src/bar.c | 79 ++-
src/browser.c | 1235 ++++++++++++++++++++++++++++++----------------
src/browser.h | 182 ++-----
src/cddb_dialog.c | 10 +-
src/easytag.c | 473 +-----------------
src/easytag.h | 4 +-
src/load_files_dialog.c | 6 +-
src/misc.c | 90 ----
src/misc.h | 3 -
src/playlist_dialog.c | 3 +-
src/scan_dialog.c | 45 +--
src/scan_dialog.h | 1 -
src/search_dialog.c | 5 +-
src/setting.c | 2 +-
16 files changed, 1773 insertions(+), 1211 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index f8bee71..d9c5c8f 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -46,6 +46,8 @@ G_DEFINE_TYPE (EtApplicationWindow, et_application_window, GTK_TYPE_APPLICATION_
struct _EtApplicationWindowPrivate
{
+ GtkWidget *browser;
+
GtkWidget *file_area;
GtkWidget *log_area;
GtkWidget *tag_area;
@@ -89,6 +91,11 @@ struct _EtApplicationWindowPrivate
GtkToolItem *apply_image_toolitem;
};
+/* Used to force to hide the msgbox when deleting file */
+static gboolean SF_HideMsgbox_Delete_File;
+/* To remember which button was pressed when deleting file */
+static gint SF_ButtonPressed_Delete_File;
+
static gboolean et_tag_field_on_key_press_event (GtkEntry *entry,
GdkEventKey *event,
gpointer user_data);
@@ -876,8 +883,8 @@ Mini_Button_Clicked (GObject *object)
g_list_free(etfilelist);
- // Refresh the whole list (faster than file by file) to show changes
- Browser_List_Refresh_Whole_List();
+ /* Refresh the whole list (faster than file by file) to show changes. */
+ et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (toplevel));
/* Display the current file (Needed when sequencing tracks) */
ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
@@ -895,6 +902,45 @@ Mini_Button_Clicked (GObject *object)
Update_Command_Buttons_Sensivity();
}
+/*
+ * Action when Redo button is pressed.
+ * Action_Redo_Selected_Files: Redo the last changes for the selected files.
+ * Action_Redo_From_History_List: Redo the changes of the last modified file of the list.
+ */
+void
+et_application_window_redo_selected_files (GtkAction *action,
+ gpointer user_data)
+{
+ GList *selfilelist = NULL;
+ GList *l;
+ gboolean state = FALSE;
+ ET_File *etfile;
+ GtkTreeSelection *selection;
+
+ g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
+ BrowserList != NULL, FALSE);
+
+ /* Save the current displayed data */
+ ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
+ selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
+
+ for (l = selfilelist; l != NULL; l = g_list_next (l))
+ {
+ etfile = Browser_List_Get_ETFile_From_Path (l->data);
+ state |= ET_Redo_File_Data(etfile);
+ }
+
+ 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));
+
+ /* Display the current file */
+ ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
+ Update_Command_Buttons_Sensivity();
+}
/*
* et_tag_field_connect_signals:
@@ -947,16 +993,18 @@ et_tag_field_on_key_press_event (GtkEntry *entry, GdkEventKey *event,
}
static GtkWidget *
-create_browser_area (void)
+create_browser_area (EtApplicationWindow *self)
{
+ EtApplicationWindowPrivate *priv;
GtkWidget *frame;
- GtkWidget *tree;
+
+ priv = et_application_window_get_instance_private (self);
frame = gtk_frame_new (_("Browser"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
- tree = Create_Browser_Items (MainWindow);
- gtk_container_add (GTK_CONTAINER (frame), tree);
+ priv->browser = GTK_WIDGET (et_browser_new ());
+ gtk_container_add (GTK_CONTAINER (frame), priv->browser);
/* Don't load init dir here because Tag area hasn't been yet created!.
* It will be load at the end of the main function */
@@ -1711,7 +1759,7 @@ et_application_window_init (EtApplicationWindow *self)
priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
/* Browser (Tree + File list + Entry) */
- widget = create_browser_area ();
+ widget = create_browser_area (self);
gtk_paned_pack1 (GTK_PANED (priv->hpaned), widget, TRUE, TRUE);
/* Vertical box for FileArea + TagArea */
@@ -2001,6 +2049,272 @@ et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action
et_cddb_dialog_search_from_selection (ET_CDDB_DIALOG (priv->cddb_dialog));
}
+void
+et_application_window_browser_collapse (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);
+
+ et_browser_collapse (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_browser_reload (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);
+
+ et_browser_reload (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_browser_toggle_display_mode (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_toggle_display_mode (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_browser_set_sensitive (EtApplicationWindow *self,
+ gboolean sensitive)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ g_return_if_fail (priv->browser != NULL);
+
+ et_browser_set_sensitive (ET_BROWSER (priv->browser), sensitive);
+}
+
+void
+et_application_window_browser_clear (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ g_return_if_fail (priv->browser != NULL);
+
+ et_browser_clear (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_home (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);
+
+ et_browser_go_home (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_desktop (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);
+
+ et_browser_go_desktop (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_documents (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);
+
+ et_browser_go_documents (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_download (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);
+
+ et_browser_go_download (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_music (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);
+
+ et_browser_go_music (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_parent (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);
+
+ et_browser_go_parent (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_run_player_for_album_list (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);
+
+ et_browser_run_player_for_album_list (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_run_player_for_artist_list (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);
+
+ et_browser_run_player_for_artist_list (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_run_player_for_selection (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);
+
+ et_browser_run_player_for_selection (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_reload_directory (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);
+
+ et_browser_reload_directory (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_select_dir (EtApplicationWindow *self, const gchar *path)
+{
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_select_dir (ET_BROWSER (priv->browser), path);
+}
+
+void
+et_application_window_load_default_dir (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);
+
+ et_browser_load_default_dir (ET_BROWSER (priv->browser));
+}
+
+
+void
+et_application_window_set_current_path_default (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);
+
+ et_browser_set_current_path_default (ET_BROWSER (priv->browser));
+}
+
+const gchar *
+et_application_window_get_current_path (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_val_if_fail (ET_APPLICATION_WINDOW (self), NULL);
+
+ priv = et_application_window_get_instance_private (self);
+
+ return et_browser_get_current_path (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_open_directory_with_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);
+
+ et_browser_show_open_directory_with_dialog (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_open_files_with_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);
+
+ et_browser_show_open_files_with_dialog (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_rename_directory_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);
+
+ et_browser_show_rename_directory_dialog (ET_BROWSER (priv->browser));
+}
+
GtkWidget *
et_application_window_get_scan_dialog (EtApplicationWindow *self)
{
@@ -2090,6 +2404,21 @@ et_on_action_select_scan_mode (GtkRadioAction *action, GtkRadioAction *current,
et_scan_dialog_open (ET_SCAN_DIALOG (priv->scan_dialog), SCANNER_TYPE);
}
+void
+et_on_action_select_browser_mode (G_GNUC_UNUSED GtkRadioAction *action,
+ G_GNUC_UNUSED GtkRadioAction *current,
+ gpointer user_data)
+{
+ g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
+
+ /* Save the current displayed data */
+ ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+ et_application_window_browser_toggle_display_mode (ET_APPLICATION_WINDOW (user_data));
+
+ Update_Command_Buttons_Sensivity();
+}
+
/*
* Disable (FALSE) / Enable (TRUE) all user widgets in the tag area
*/
@@ -2373,14 +2702,57 @@ et_application_window_select_all (GtkAction *action, gpointer user_data)
}
else /* Assume that other widgets should select all in the file view. */
{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *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);
- Browser_List_Select_All_Files ();
+ et_browser_select_all (ET_BROWSER (priv->browser));
Update_Command_Buttons_Sensivity ();
}
}
+ET_File *
+et_application_window_browser_select_file_by_dlm (EtApplicationWindow *self,
+ const gchar *string,
+ gboolean select)
+{
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ return et_browser_select_file_by_dlm (ET_BROWSER (priv->browser), string,
+ select);
+}
+
+void
+et_application_window_browser_unselect_all (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ /* Save the current displayed data */
+ ET_Save_File_Data_From_UI (ETCore->ETFileDisplayed);
+
+ et_browser_unselect_all (ET_BROWSER (priv->browser));
+ ETCore->ETFileDisplayed = NULL;
+}
+
+void
+et_application_window_browser_refresh_list (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_refresh_list (ET_BROWSER (priv->browser));
+}
/*
* Action when unselecting all
*/
@@ -2406,27 +2778,44 @@ et_application_window_unselect_all (GtkAction *action, gpointer user_data)
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. */
+ else /* Assume that other widgets should unselect 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;
+ et_application_window_browser_unselect_all (ET_APPLICATION_WINDOW (user_data));
}
}
/*
+ * Action when inverting files selection
+ */
+void
+et_application_window_invert_selection (GtkAction *action, gpointer user_data)
+{
+ EtApplicationWindowPrivate *priv;
+ EtApplicationWindow *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);
+
+ et_browser_invert_selection (ET_BROWSER (priv->browser));
+ Update_Command_Buttons_Sensivity();
+}
+
+/*
* Action when First button is selected
*/
void
et_application_window_select_first_file (GtkAction *action, gpointer user_data)
{
+ EtApplicationWindow *self;
GList *etfilelist;
if (!ETCore->ETFileDisplayedList)
return;
+ self = ET_APPLICATION_WINDOW (user_data);
+
/* Save the current displayed data */
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2434,13 +2823,18 @@ et_application_window_select_first_file (GtkAction *action, gpointer user_data)
etfilelist = ET_Displayed_File_List_First();
if (etfilelist)
{
- Browser_List_Unselect_All_Files(); // To avoid the last line still selected
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ /* To avoid the last line still selected. */
+ et_browser_unselect_all (ET_BROWSER (priv->browser));
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))));
+ et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
if (SET_FOCUS_TO_FIRST_TAG_FIELD)
gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
@@ -2453,11 +2847,14 @@ et_application_window_select_first_file (GtkAction *action, gpointer user_data)
void
et_application_window_select_prev_file (GtkAction *action, gpointer user_data)
{
+ EtApplicationWindow *self;
GList *etfilelist;
if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->prev)
return;
+ self = ET_APPLICATION_WINDOW (user_data);
+
/* Save the current displayed data */
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2465,7 +2862,11 @@ et_application_window_select_prev_file (GtkAction *action, gpointer user_data)
etfilelist = ET_Displayed_File_List_Previous();
if (etfilelist)
{
- Browser_List_Unselect_All_Files();
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_unselect_all (ET_BROWSER (priv->browser));
Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
}
@@ -2474,7 +2875,7 @@ et_application_window_select_prev_file (GtkAction *action, gpointer user_data)
// 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))));
+ et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
if (SET_FOCUS_TO_FIRST_TAG_FIELD)
gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
@@ -2487,11 +2888,14 @@ et_application_window_select_prev_file (GtkAction *action, gpointer user_data)
void
et_application_window_select_next_file (GtkAction *acton, gpointer user_data)
{
+ EtApplicationWindow *self;
GList *etfilelist;
if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->next)
return;
+ self = ET_APPLICATION_WINDOW (user_data);
+
/* Save the current displayed data */
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2499,7 +2903,11 @@ et_application_window_select_next_file (GtkAction *acton, gpointer user_data)
etfilelist = ET_Displayed_File_List_Next();
if (etfilelist)
{
- Browser_List_Unselect_All_Files();
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_unselect_all (ET_BROWSER (priv->browser));
Browser_List_Select_File_By_Etfile((ET_File *)etfilelist->data,TRUE);
ET_Display_File_Data_To_UI((ET_File *)etfilelist->data);
}
@@ -2508,7 +2916,7 @@ et_application_window_select_next_file (GtkAction *acton, gpointer user_data)
// 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))));
+ et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
if (SET_FOCUS_TO_FIRST_TAG_FIELD)
gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
@@ -2521,11 +2929,14 @@ et_application_window_select_next_file (GtkAction *acton, gpointer user_data)
void
et_application_window_select_last_file (GtkAction *action, gpointer user_data)
{
+ EtApplicationWindow *self;
GList *etfilelist;
if (!ETCore->ETFileDisplayedList || !ETCore->ETFileDisplayedList->next)
return;
+ self = ET_APPLICATION_WINDOW (user_data);
+
/* Save the current displayed data */
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
@@ -2533,14 +2944,374 @@ et_application_window_select_last_file (GtkAction *action, gpointer user_data)
etfilelist = ET_Displayed_File_List_Last();
if (etfilelist)
{
- Browser_List_Unselect_All_Files();
+ EtApplicationWindowPrivate *priv;
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_browser_unselect_all (ET_BROWSER (priv->browser));
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))));
+ et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog (self)));
if (SET_FOCUS_TO_FIRST_TAG_FIELD)
gtk_widget_grab_focus(GTK_WIDGET(TitleEntry));
}
+
+/*
+ * Action when Remove button is pressed
+ */
+void
+et_application_window_remove_selected_tags (GtkAction *action,
+ gpointer user_data)
+{
+ GList *selfilelist = NULL;
+ GList *l;
+ ET_File *etfile;
+ File_Tag *FileTag;
+ gint progress_bar_index;
+ gint selectcount;
+ double fraction;
+ GtkTreeSelection *selection;
+
+ g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
+ BrowserList != NULL);
+
+ /* 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);
+ selectcount =
gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)));
+ progress_bar_index = 0;
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
+ selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
+
+ for (l = selfilelist; l != NULL; l = g_list_next (l))
+ {
+ etfile = Browser_List_Get_ETFile_From_Path (l->data);
+ FileTag = ET_File_Tag_Item_New();
+ ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
+
+ fraction = (++progress_bar_index) / (double) selectcount;
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
+ /* Needed to refresh status bar */
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ }
+
+ 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));
+
+ /* Display the current file */
+ ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
+ Update_Command_Buttons_Sensivity();
+
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
+ Statusbar_Message(_("All tags have been removed"),TRUE);
+}
+
+
+
+/*
+ * Action when Undo button is pressed.
+ * Action_Undo_Selected_Files: Undo the last changes for the selected files.
+ * Action_Undo_From_History_List: Undo the changes of the last modified file of the list.
+ */
+void
+et_application_window_undo_selected_files (GtkAction *action,
+ gpointer user_data)
+{
+ GList *selfilelist = NULL;
+ GList *l;
+ gboolean state = FALSE;
+ ET_File *etfile;
+ GtkTreeSelection *selection;
+
+ g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
+ BrowserList != NULL, FALSE);
+
+ /* Save the current displayed data */
+ ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
+ selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
+
+ for (l = selfilelist; l != NULL; l = g_list_next (l))
+ {
+ etfile = Browser_List_Get_ETFile_From_Path (l->data);
+ state |= ET_Undo_File_Data(etfile);
+ }
+
+ 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));
+
+ /* Display the current file */
+ ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
+ Update_Command_Buttons_Sensivity();
+
+ //ET_Debug_Print_File_List(ETCore->ETFileList,__FILE__,__LINE__,__FUNCTION__);
+}
+
+/*
+ * Delete the file ETFile
+ */
+static gint
+delete_file (ET_File *ETFile, gboolean multiple_files, GError **error)
+{
+ GtkWidget *msgdialog;
+ GtkWidget *msgdialog_check_button = NULL;
+ gchar *cur_filename;
+ gchar *cur_filename_utf8;
+ gchar *basename_utf8;
+ gint response;
+ gint stop_loop;
+
+ g_return_val_if_fail (ETFile != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ /* Filename of the file to delete. */
+ cur_filename = ((File_Name *)(ETFile->FileNameCur)->data)->value;
+ cur_filename_utf8 = ((File_Name *)(ETFile->FileNameCur)->data)->value_utf8;
+ basename_utf8 = g_path_get_basename (cur_filename_utf8);
+
+ /*
+ * Remove the file
+ */
+ if (CONFIRM_DELETE_FILE && !SF_HideMsgbox_Delete_File)
+ {
+ if (multiple_files)
+ {
+ GtkWidget *message_area;
+ msgdialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("Do you really want to delete the file '%s'?"),
+ basename_utf8);
+ message_area = gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(msgdialog));
+ msgdialog_check_button = gtk_check_button_new_with_label(_("Repeat action for the remaining
files"));
+ gtk_container_add(GTK_CONTAINER(message_area),msgdialog_check_button);
+
gtk_dialog_add_buttons(GTK_DIALOG(msgdialog),GTK_STOCK_NO,GTK_RESPONSE_NO,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_DELETE,GTK_RESPONSE_YES,NULL);
+ gtk_window_set_title(GTK_WINDOW(msgdialog),_("Delete File"));
+ //GTK_TOGGLE_BUTTON(msgbox_check_button)->active = TRUE; // Checked by default
+ }else
+ {
+ msgdialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("Do you really want to delete the file '%s'?"),
+ basename_utf8);
+ gtk_window_set_title(GTK_WINDOW(msgdialog),_("Delete File"));
+
gtk_dialog_add_buttons(GTK_DIALOG(msgdialog),GTK_STOCK_CANCEL,GTK_RESPONSE_NO,GTK_STOCK_DELETE,GTK_RESPONSE_YES,NULL);
+ }
+ gtk_dialog_set_default_response (GTK_DIALOG (msgdialog),
+ GTK_RESPONSE_YES);
+ SF_ButtonPressed_Delete_File = response = gtk_dialog_run(GTK_DIALOG(msgdialog));
+ if (msgdialog_check_button &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msgdialog_check_button)))
+ SF_HideMsgbox_Delete_File =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msgdialog_check_button));
+ gtk_widget_destroy(msgdialog);
+ }else
+ {
+ if (SF_HideMsgbox_Delete_File)
+ response = SF_ButtonPressed_Delete_File;
+ else
+ response = GTK_RESPONSE_YES;
+ }
+
+ switch (response)
+ {
+ case GTK_RESPONSE_YES:
+ {
+ GFile *cur_file = g_file_new_for_path (cur_filename);
+
+ if (g_file_delete (cur_file, NULL, error))
+ {
+ gchar *msg = g_strdup_printf(_("File '%s' deleted"), basename_utf8);
+ Statusbar_Message(msg,FALSE);
+ g_free(msg);
+ g_free(basename_utf8);
+ g_object_unref (cur_file);
+ g_assert (error == NULL || *error == NULL);
+ return 1;
+ }
+
+ /* Error in deleting file. */
+ g_assert (error == NULL || *error != NULL);
+ break;
+ }
+ case GTK_RESPONSE_NO:
+ break;
+ case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
+ stop_loop = -1;
+ g_free(basename_utf8);
+ return stop_loop;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ g_free(basename_utf8);
+ return 0;
+}
+
+/*
+ * Delete a file on the hard disk
+ */
+void
+et_application_window_delete_selected_files (GtkAction *action,
+ gpointer user_data)
+{
+ EtApplicationWindow *self;
+ EtApplicationWindowPrivate *priv;
+ GList *selfilelist;
+ GList *rowreflist = NULL;
+ GList *l;
+ gint progress_bar_index;
+ gint saving_answer;
+ gint nb_files_to_delete;
+ gint nb_files_deleted = 0;
+ gchar *msg;
+ gchar progress_bar_text[30];
+ double fraction;
+ GtkTreeModel *treemodel;
+ GtkTreeRowReference *rowref;
+ GtkTreeSelection *selection;
+ GError *error = NULL;
+
+ g_return_if_fail (ETCore->ETFileDisplayedList != NULL
+ && BrowserList != NULL);
+
+ 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);
+
+ /* Number of files to save */
+ nb_files_to_delete =
gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)));
+
+ /* Initialize status bar */
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0);
+ progress_bar_index = 0;
+ g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_delete);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+
+ /* Set to unsensitive all command buttons (except Quit button) */
+ Disable_Command_Buttons();
+ et_application_window_browser_set_sensitive (self, FALSE);
+ et_application_window_tag_area_set_sensitive (self, FALSE);
+ et_application_window_file_area_set_sensitive (self, FALSE);
+
+ /* Show msgbox (if needed) to ask confirmation */
+ SF_HideMsgbox_Delete_File = 0;
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
+ selfilelist = gtk_tree_selection_get_selected_rows(selection, &treemodel);
+
+ for (l = selfilelist; l != NULL; l = g_list_next (l))
+ {
+ rowref = gtk_tree_row_reference_new (treemodel, l->data);
+ rowreflist = g_list_prepend (rowreflist, rowref);
+ }
+
+ g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
+ rowreflist = g_list_reverse (rowreflist);
+
+ for (l = rowreflist; l != NULL; l = g_list_next (l))
+ {
+ GtkTreePath *path;
+ ET_File *ETFile;
+
+ path = gtk_tree_row_reference_get_path (l->data);
+ ETFile = Browser_List_Get_ETFile_From_Path(path);
+ gtk_tree_path_free(path);
+
+ ET_Display_File_Data_To_UI(ETFile);
+ Browser_List_Select_File_By_Etfile(ETFile,FALSE);
+ fraction = (++progress_bar_index) / (double) nb_files_to_delete;
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
+ g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_delete);
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
+ /* Needed to refresh status bar */
+ while (gtk_events_pending())
+ gtk_main_iteration();
+
+ saving_answer = delete_file (ETFile,
+ nb_files_to_delete > 1 ? TRUE : FALSE,
+ &error);
+
+ switch (saving_answer)
+ {
+ case 1:
+ nb_files_deleted += saving_answer;
+ // Remove file in the browser (corresponding line in the clist)
+ et_browser_remove_file (ET_BROWSER (priv->browser), ETFile);
+ // Remove file from file list
+ ET_Remove_File_From_File_List(ETFile);
+ break;
+ case 0:
+ /* Distinguish between the file being skipped, and there being
+ * an error during deletion. */
+ if (error)
+ {
+ Log_Print (LOG_ERROR, _("Cannot delete file (%s)"),
+ error->message);
+ g_clear_error (&error);
+ }
+ break;
+ 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();
+ 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);
+
+ return; /*We stop all actions. */
+ }
+ }
+
+ g_list_free_full (rowreflist, (GDestroyNotify)gtk_tree_row_reference_free);
+
+ if (nb_files_deleted < nb_files_to_delete)
+ msg = g_strdup (_("Files have been partially deleted"));
+ else
+ msg = g_strdup (_("All files have been deleted"));
+
+ /* It's important to displayed the new item, as it'll check the changes in
et_browser_toggle_display_mode. */
+ if (ETCore->ETFileDisplayed)
+ ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
+ /*else if (ET_Displayed_File_List_Current())
+ ET_Display_File_Data_To_UI((ET_File *)ET_Displayed_File_List_Current()->data);*/
+
+ /* Load list... */
+ et_browser_load_file_list (ET_BROWSER (priv->browser),
+ ETCore->ETFileDisplayedList, NULL);
+ /* Rebuild the list... */
+ et_browser_toggle_display_mode (ET_BROWSER (priv->browser));
+
+ /* To update state of command buttons */
+ Update_Command_Buttons_Sensivity();
+ 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);
+
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
+ Statusbar_Message(msg,TRUE);
+ g_free(msg);
+
+ return;
+}
diff --git a/src/application_window.h b/src/application_window.h
index b3a6c7a..8cb5407 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -63,16 +63,47 @@ void et_application_window_show_preferences_dialog_scanner (GtkAction *action, g
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);
+void et_application_window_browser_toggle_display_mode (EtApplicationWindow *self);
+void et_application_window_browser_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
+void et_application_window_browser_clear (EtApplicationWindow *self);
+void et_application_window_go_home (GtkAction *action, gpointer user_data);
+void et_application_window_go_desktop (GtkAction *action, gpointer user_data);
+void et_application_window_go_documents (GtkAction *action, gpointer user_data);
+void et_application_window_go_download (GtkAction *action, gpointer user_data);
+void et_application_window_go_music (GtkAction *action, gpointer user_data);
+void et_application_window_go_parent (GtkAction *action, gpointer user_data);
+void et_application_window_run_player_for_album_list (GtkAction *action, gpointer user_data);
+void et_application_window_run_player_for_artist_list (GtkAction *action, gpointer user_data);
+void et_application_window_run_player_for_selection (GtkAction *action, gpointer user_data);
+void et_application_window_reload_directory (GtkAction *action, gpointer user_data);
+void et_application_window_select_dir (EtApplicationWindow *self, const gchar *path);
+void et_application_window_load_default_dir (GtkAction *action, gpointer user_data);
+void et_application_window_set_current_path_default (GtkAction *action, gpointer user_data);
+const gchar * et_application_window_get_current_path (EtApplicationWindow *self);
+void et_application_window_show_open_directory_with_dialog (GtkAction *action, gpointer user_data);
+void et_application_window_show_open_files_with_dialog (GtkAction *action, gpointer user_data);
+void et_application_window_show_rename_directory_dialog (GtkAction *action, gpointer user_data);
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_on_action_select_browser_mode (GtkRadioAction *action, GtkRadioAction *current, gpointer user_data);
void et_application_window_select_all (GtkAction *action, gpointer user_data);
+ET_File * et_application_window_browser_select_file_by_dlm (EtApplicationWindow *self, const gchar *string,
gboolean select);
+void et_application_window_browser_unselect_all (EtApplicationWindow *self);
+void et_application_window_browser_refresh_list (EtApplicationWindow *self);
void et_application_window_unselect_all (GtkAction *action, gpointer user_data);
+void et_application_window_invert_selection (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_delete_selected_files (GtkAction *action, gpointer user_data);
+void et_application_window_remove_selected_tags (GtkAction *action, gpointer user_data);
+void et_application_window_undo_selected_files (GtkAction *action, gpointer user_data);
+void et_application_window_redo_selected_files (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 9ee416b..0aa32ff 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -80,6 +80,16 @@ static void on_menu_item_deselect (GtkMenuItem *item, gpointer user_data);
#define QCASE(string,callback) if (quark == g_quark_from_string((string))) { (callback)(); }
#define QCASE_DATA(string,callback,data) if (quark == g_quark_from_string((string))) { (callback)((data)); }
+static void
+reload_browser (gpointer data)
+{
+ EtApplicationWindow *window;
+
+ window = ET_APPLICATION_WINDOW (data);
+
+ et_application_window_browser_reload (NULL, window);
+}
+
/*
* Menu bar
*/
@@ -129,7 +139,7 @@ Menu_Sort_Action (GtkAction *item, gpointer data)
QCASE_DATA(AM_SORT_DESCENDING_FILE_BITRATE, ET_Sort_Displayed_File_List_And_Update_UI,
SORTING_BY_DESCENDING_FILE_BITRATE);
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);
+ QCASE_DATA(AM_INITIALIZE_TREE, reload_browser, data);
Browser_List_Refresh_Sort ();
}
@@ -206,17 +216,18 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ AM_OPEN_FILE_WITH, GTK_STOCK_OPEN, _("Open Files With…"),
"<Primary><Shift>O", _("Run a command on the selected files"),
- G_CALLBACK (Browser_Open_Run_Program_List_Window) },
+ G_CALLBACK (et_application_window_show_open_files_with_dialog) },
{ AM_SELECT_ALL, GTK_STOCK_SELECT_ALL, NULL, "<Primary>A",
_("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_application_window_unselect_all) },
{ AM_INVERT_SELECTION, "easytag-invert-selection",
- _("Invert File Selection"), "<Primary>I",
- _("Invert file selection"),
- G_CALLBACK (Action_Invert_Files_Selection) },
- { AM_DELETE_FILE, GTK_STOCK_DELETE, _("Delete Files"), NULL,
_("Delete files"), G_CALLBACK(Action_Delete_Selected_Files) },
+ _("Invert File Selection"), "<Primary>I", _("Invert file selection"),
+ G_CALLBACK (et_application_window_invert_selection) },
+ { AM_DELETE_FILE, GTK_STOCK_DELETE, _("Delete Files"), NULL,
+ _("Delete files"),
+ G_CALLBACK (et_application_window_delete_selected_files) },
{ AM_FIRST, GTK_STOCK_GOTO_FIRST, _("_First File"), "<Primary>Home",
_("First file"),
G_CALLBACK (et_application_window_select_first_file) },
@@ -233,13 +244,14 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
_("Scan selected files"),
G_CALLBACK (et_application_window_scan_selected_files) },
{ AM_REMOVE, GTK_STOCK_CLEAR, _("_Remove Tags"), "<Primary>E",
- _("Remove tags"), G_CALLBACK (Action_Remove_Selected_Tags) },
+ _("Remove tags"),
+ G_CALLBACK (et_application_window_remove_selected_tags) },
{ AM_UNDO, GTK_STOCK_UNDO, _("_Undo Last Files Changes"), "<Primary>Z",
_("Undo last files changes"),
- G_CALLBACK(Action_Undo_Selected_Files) },
+ G_CALLBACK (et_application_window_undo_selected_files) },
{ AM_REDO, GTK_STOCK_REDO, _("R_edo Last Files Changes"),
"<Primary><Shift>Z", _("Redo last files changes"),
- G_CALLBACK (Action_Redo_Selected_File) },
+ G_CALLBACK (et_application_window_redo_selected_files) },
{ AM_SAVE, GTK_STOCK_SAVE, _("_Save Files"), "<Primary>S",
_("Save changes to selected files"),
G_CALLBACK(Action_Save_Selected_Files) },
@@ -254,39 +266,45 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ MENU_BROWSER, NULL, _("_Browser"), NULL,
NULL, NULL },
{ AM_LOAD_HOME_DIR, GTK_STOCK_HOME, _("_Home Directory"), "<Alt>Home",
_("Go to home directory"),
- G_CALLBACK (Browser_Load_Home_Directory) },
+ G_CALLBACK (et_application_window_go_home) },
{ AM_LOAD_DESKTOP_DIR, "user-desktop", _("Desktop Directory"), NULL,
_("Go to desktop directory"),
- G_CALLBACK (Browser_Load_Desktop_Directory) },
+ G_CALLBACK (et_application_window_go_desktop) },
{ AM_LOAD_DOCUMENTS_DIR, "folder-documents", _("Documents Directory"),
NULL, _("Go to documents directory"),
- G_CALLBACK (Browser_Load_Documents_Directory) },
+ G_CALLBACK (et_application_window_go_documents) },
{ AM_LOAD_DOWNLOADS_DIR, "folder-download", _("Downloads Directory"),
NULL, _("Go to downloads directory"),
- G_CALLBACK (Browser_Load_Downloads_Directory) },
+ G_CALLBACK (et_application_window_go_download) },
{ AM_LOAD_MUSIC_DIR, "folder-music", _("Music Directory"), NULL,
_("Go to music directory"),
- G_CALLBACK (Browser_Load_Music_Directory) },
+ G_CALLBACK (et_application_window_go_music) },
{ AM_LOAD_PARENT_DIR, GTK_STOCK_GO_UP, _("_Parent Directory"),
"<Alt>Up", _("Go to parent directory"),
- G_CALLBACK (et_browser_on_action_parent_directory) },
+ G_CALLBACK (et_application_window_go_parent) },
{ AM_LOAD_DEFAULT_DIR, GTK_STOCK_JUMP_TO, _("_Default Directory"),
"<Primary>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_RENAME_DIR, GTK_STOCK_INDEX, _("Rename Directory…"), "F2",
_("Rename directory"), G_CALLBACK(Browser_Open_Rename_Directory_Window) },
+ G_CALLBACK (et_application_window_load_default_dir) },
+ { AM_SET_PATH_AS_DEFAULT, GTK_STOCK_DIRECTORY,
+ _("Set _Current Path as Default"), NULL,
+ _("Set current path as default"),
+ G_CALLBACK (et_application_window_set_current_path_default) },
+ { AM_RENAME_DIR, GTK_STOCK_INDEX, _("Rename Directory…"), "F2",
+ _("Rename directory"),
+ G_CALLBACK (et_application_window_show_rename_directory_dialog) },
{ AM_RELOAD_DIRECTORY, GTK_STOCK_REFRESH, _("Reload Directory"),
"<Primary>R", _("Reload directory"),
- G_CALLBACK (Browser_Reload_Directory) },
+ G_CALLBACK (et_application_window_reload_directory) },
{ AM_BROWSE_DIRECTORY_WITH, GTK_STOCK_EXECUTE,
_("Browse Directory With…"), NULL,
_("Run a command on the directory"),
- G_CALLBACK (Browser_Open_Run_Program_Tree_Window) },
+ G_CALLBACK (et_application_window_show_open_directory_with_dialog) },
{ AM_COLLAPSE_TREE, NULL, _("_Collapse Tree"), "<Primary><Shift>C",
- _("Collapse directory tree"), G_CALLBACK (Browser_Tree_Collapse) },
+ _("Collapse directory tree"),
+ G_CALLBACK (et_application_window_browser_collapse) },
{ AM_INITIALIZE_TREE, GTK_STOCK_REFRESH, _("_Reload Tree"),
"<Primary><Shift>R", _("Reload directory tree"),
- G_CALLBACK (Browser_Tree_Rebuild) },
+ G_CALLBACK (et_application_window_browser_reload) },
{ MENU_SCANNER, NULL, _("S_canner Mode"), NULL, NULL, NULL },
@@ -306,7 +324,7 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
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 (Run_Audio_Player_Using_Selection) },
+ G_CALLBACK (et_browser_run_player_for_selection) },
{ MENU_EDIT, NULL, _("_Edit"), NULL, NULL, NULL },
{ AM_OPEN_OPTIONS_WINDOW, GTK_STOCK_PREFERENCES, _("_Preferences"),
@@ -337,8 +355,12 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ POPUP_FILE, NULL, _("_File Operations"), NULL, NULL,
NULL },
{ POPUP_SUBMENU_SCANNER, "document-properties", _("S_canner"), NULL,
NULL, NULL },
{ POPUP_DIR_RUN_AUDIO, GTK_STOCK_MEDIA_PLAY, _("Run Audio Player"), NULL, _("Run
audio player"), G_CALLBACK(Run_Audio_Player_Using_Directory) },
- { AM_ARTIST_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY, _("Run Audio Player"), NULL, _("Run
audio player"), G_CALLBACK(Run_Audio_Player_Using_Browser_Artist_List) },
- { AM_ALBUM_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY, _("Run Audio Player"), NULL, _("Run
audio player"), G_CALLBACK(Run_Audio_Player_Using_Browser_Album_List) },
+ { AM_ARTIST_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY,
+ _("Run Audio Player"), NULL, _("Run audio player"),
+ G_CALLBACK (et_application_window_run_player_for_artist_list) },
+ { AM_ALBUM_RUN_AUDIO_PLAYER, GTK_STOCK_MEDIA_PLAY,
+ _("Run Audio Player"), NULL, _("Run audio player"),
+ G_CALLBACK (et_application_window_run_player_for_album_list) },
{ AM_CDDB_SEARCH_FILE, GTK_STOCK_CDROM, _("CDDB Search Files…"), NULL,
_("CDDB search files…"),
G_CALLBACK (et_application_window_search_cddb_for_selection) },
@@ -357,7 +379,7 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
#ifndef G_OS_WIN32 /* No sense here for Win32, "hidden" means : starts with a
* '.'
*/
- { AM_BROWSER_HIDDEN_DIR, NULL, _("Show Hidden Directories"),
NULL, _("Show hidden directories"), G_CALLBACK(Browser_Tree_Rebuild),
BROWSE_HIDDEN_DIR },
+ { AM_BROWSER_HIDDEN_DIR, NULL, _("Show Hidden Directories"),
NULL, _("Show hidden directories"),
G_CALLBACK(et_application_window_browser_reload), BROWSE_HIDDEN_DIR },
#endif /* !G_OS_WIN32 */
{ AM_SCANNER_SHOW, "document-properties", _("_Show Scanner"), NULL,
_("Show scanner"),
@@ -425,7 +447,8 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
gtk_action_group_add_toggle_actions(ActionGroup, ToggleActionEntries, num_toggle_entries, window);
gtk_action_group_add_radio_actions (ActionGroup, view_mode_entries,
n_view_mode_entries, 0,
- Action_Select_Browser_Style, window);
+ G_CALLBACK (et_on_action_select_browser_mode),
+ window);
gtk_action_group_add_radio_actions (ActionGroup, scanner_mode_entries,
n_scanner_mode_entries, 0,
G_CALLBACK (et_on_action_select_scan_mode),
@@ -514,7 +537,7 @@ Check_Menu_Item_Toggled_Browse_Hidden_Dir (GtkWidget *checkmenuitem)
Check_Menu_Item_Update_Browse_Hidden_Dir();
// Reload directory, in case we have changed BROWSE_HIDDEN_DIR
- //Browser_Tree_Rebuild(NULL); // Commented, as already done in GtkToggleActionEntry for
AM_BROWSER_HIDDEN_DIR
+ //et_application_window_browser_reload(NULL); // Commented, as already done in GtkToggleActionEntry for
AM_BROWSER_HIDDEN_DIR
}
void
diff --git a/src/browser.c b/src/browser.c
index ae66670..32f7852 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -24,24 +24,23 @@
* Thomas Nilsson and 4Front Technologies
*/
-#include <config.h>
+#include "config.h"
+
+#include "browser.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#include <glib/gi18n.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
-#include <stdio.h>
#include <errno.h>
#include "application_window.h"
#include "gtk2_compat.h"
#include "easytag.h"
-#include "browser.h"
#include "et_core.h"
#include "scan_dialog.h"
#include "bar.h"
@@ -51,16 +50,43 @@
#include "charset.h"
#include "dlm.h"
-#include <assert.h>
-
#include "win32/win32dep.h"
+/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
+G_DEFINE_TYPE (EtBrowser, et_browser, GTK_TYPE_BOX)
+
+#define et_browser_get_instance_private(browser) (browser->priv)
+
+struct _EtBrowserPrivate
+{
+ GtkListStore *entry_model;
+
+ GtkWidget *album_list;
+ GtkWidget *artist_list;
+
+ GtkWidget *tree; /* Tree of directories. */
+ GtkListStore *run_program_model;
+
+ GtkWidget *open_directory_with_dialog;
+ GtkWidget *open_directory_with_combobox;
+
+ GtkWidget *open_files_with_dialog;
+ GtkWidget *open_files_with_combobox;
+
+ /* The Rename Directory window. */
+ GtkWidget *rename_directory_dialog;
+ GtkWidget *rename_directory_combo;
+ GtkWidget *rename_directory_mask_toggle;
+ GtkWidget *rename_directory_mask_combo;
+ GtkListStore *rename_directory_mask_model;
+ GtkWidget *rename_directory_preview_label;
+};
/****************
* Declarations *
****************/
-static GtkWidget *BrowserTree; /* Tree of directories. */
+static GtkWidget *BrowserEntryCombo;
static GtkTreeStore *directoryTreeModel;
static GtkListStore *fileListModel;
static GtkWidget *BrowserLabel;
@@ -68,21 +94,9 @@ static GtkWidget *BrowserButton;
static GtkWidget *BrowserNoteBook;
static GtkListStore *artistListModel;
static GtkListStore *albumListModel;
-/* Path selected in the browser area (BrowserEntry or BrowserTree). */
+/* Path selected in the browser area (BrowserEntry or priv->tree). */
static gchar *BrowserCurrentPath = NULL;
-static GtkListStore *RunProgramModel;
-
-static GtkWidget *RunProgramTreeWindow = NULL;
-static GtkWidget *RunProgramListWindow = NULL;
-
-/* The Rename Directory window. */
-GtkWidget *RenameDirectoryWindow = NULL;
-static GtkWidget *RenameDirectoryCombo;
-static GtkWidget *RenameDirectoryWithMask;
-static GtkListStore *RenameDirectoryMaskModel = NULL;
-GtkWidget *RenameDirectoryPreviewLabel = NULL;
-
/* The last ETFile selected in the BrowserList. */
static ET_File *LastBrowserListETFileSelected;
@@ -113,83 +127,109 @@ typedef enum
ET_PATH_STATE_CLOSED
} EtPathState;
+enum
+{
+ LIST_FILE_NAME,
+ /* Tag fields. */
+ LIST_FILE_TITLE,
+ LIST_FILE_ARTIST,
+ LIST_FILE_ALBUM_ARTIST,
+ LIST_FILE_ALBUM,
+ LIST_FILE_YEAR,
+ LIST_FILE_DISCNO,
+ LIST_FILE_TRACK,
+ LIST_FILE_GENRE,
+ LIST_FILE_COMMENT,
+ LIST_FILE_COMPOSER,
+ LIST_FILE_ORIG_ARTIST,
+ LIST_FILE_COPYRIGHT,
+ LIST_FILE_URL,
+ LIST_FILE_ENCODED_BY,
+ /* End of columns with associated UI columns. */
+ LIST_FILE_POINTER,
+ LIST_FILE_KEY,
+ LIST_FILE_OTHERDIR, /* To change color for alternate directories. */
+ LIST_FONT_WEIGHT,
+ LIST_ROW_BACKGROUND,
+ LIST_ROW_FOREGROUND,
+ LIST_COLUMN_COUNT
+};
+
+enum
+{
+ ALBUM_GICON,
+ ALBUM_NAME,
+ ALBUM_NUM_FILES,
+ ALBUM_ETFILE_LIST_POINTER,
+ ALBUM_FONT_STYLE,
+ ALBUM_FONT_WEIGHT,
+ ALBUM_ROW_FOREGROUND,
+ ALBUM_COLUMN_COUNT
+};
+
+enum
+{
+ ARTIST_PIXBUF,
+ ARTIST_NAME,
+ ARTIST_NUM_ALBUMS,
+ ARTIST_NUM_FILES,
+ ARTIST_ALBUM_LIST_POINTER,
+ ARTIST_FONT_STYLE,
+ ARTIST_FONT_WEIGHT,
+ ARTIST_ROW_FOREGROUND,
+ ARTIST_COLUMN_COUNT
+};
+
+enum
+{
+ TREE_COLUMN_DIR_NAME,
+ TREE_COLUMN_FULL_PATH,
+ TREE_COLUMN_SCANNED,
+ TREE_COLUMN_HAS_SUBDIR,
+ TREE_COLUMN_ICON,
+ TREE_COLUMN_COUNT
+};
+
/**************
* Prototypes *
**************/
-static gboolean Browser_Tree_Key_Press (GtkWidget *tree, GdkEvent *event,
- gpointer data);
-static void Browser_Tree_Set_Node_Visible (GtkWidget *directoryView,
- GtkTreePath *path);
-static void Browser_List_Set_Row_Visible (GtkTreeModel *treeModel,
- GtkTreeIter *rowIter);
-static void Browser_Tree_Initialize (void);
-static gboolean Browser_Tree_Node_Selected (GtkTreeSelection *selection,
- gpointer user_data);
-static void Browser_Tree_Rename_Directory (const gchar *last_path,
- const gchar *new_path);
static void Browser_Tree_Handle_Rename (GtkTreeIter *parentnode,
const gchar *old_path,
const gchar *new_path);
-static gint Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data);
-static gboolean Browser_List_Button_Press (GtkTreeView *treeView,
- GdkEventButton *event);
-static void Browser_List_Row_Selected (GtkTreeSelection * selection,
- gpointer data);
static void Browser_List_Set_Row_Appearance (GtkTreeIter *iter);
static gint Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a,
GtkTreeIter *b, gpointer data);
static void Browser_List_Select_File_By_Iter (GtkTreeIter *iter,
gboolean select_it);
-static void Browser_Entry_Activated (void);
-
-static void Browser_Artist_List_Load_Files (ET_File *etfile_to_select);
-static void Browser_Artist_List_Row_Selected (GtkTreeSelection *selection,
- gpointer data);
+static void Browser_Artist_List_Row_Selected (EtBrowser *self,
+ GtkTreeSelection *selection);
static void Browser_Artist_List_Set_Row_Appearance (GtkTreeIter *row);
-static void Browser_Album_List_Load_Files (GList *albumlist,
+static void Browser_Album_List_Load_Files (EtBrowser *self, GList *albumlist,
ET_File *etfile_to_select);
-static void Browser_Album_List_Row_Selected (GtkTreeSelection *selection,
- gpointer data);
+static void Browser_Album_List_Row_Selected (EtBrowser *self,
+ GtkTreeSelection *selection);
static void Browser_Album_List_Set_Row_Appearance (GtkTreeIter *row);
-static void Browser_Update_Current_Path (const gchar *path);
-
-#ifdef G_OS_WIN32
-static gboolean Browser_Win32_Get_Drive_Root (gchar *drive,
- GtkTreeIter *rootNode,
- GtkTreePath **rootPath);
-#endif /* G_OS_WIN32 */
-
static gboolean check_for_subdir (const gchar *path);
static GtkTreePath *Find_Child_Node(GtkTreeIter *parent, gchar *searchtext);
static GIcon *get_gicon_for_path (const gchar *path, EtPathState path_state);
-static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *path, gpointer data);
-static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data);
-
-/* Pop up menus */
-static gboolean Browser_Popup_Menu_Handler (GtkWidget *widget,
- GdkEventButton *event,
- GtkMenu *menu);
-
/* For window to rename a directory */
-static void Destroy_Rename_Directory_Window (void);
-static void Rename_Directory (void);
-static void Rename_Directory_With_Mask_Toggled (void);
+static void Destroy_Rename_Directory_Window (EtBrowser *self);
+static void Rename_Directory_With_Mask_Toggled (EtBrowser *self);
/* For window to run a program with the directory */
-static void Destroy_Run_Program_Tree_Window (void);
-static void Run_Program_With_Directory (GtkWidget *combobox);
+static void Destroy_Run_Program_Tree_Window (EtBrowser *self);
+static void Run_Program_With_Directory (EtBrowser *self);
/* For window to run a program with the file */
-static void Destroy_Run_Program_List_Window (void);
-static void Run_Program_With_Selected_Files (GtkWidget *combobox);
+static void Destroy_Run_Program_List_Window (EtBrowser *self);
static void empty_entry_disable_widget (GtkWidget *widget, GtkEntry *entry);
@@ -213,48 +253,58 @@ static void et_browser_set_sorting_file_mode (GtkTreeViewColumn *column,
/*
* Load home directory
*/
-void Browser_Load_Home_Directory (void)
+void
+et_browser_go_home (EtBrowser *self)
{
- Browser_Tree_Select_Dir (g_get_home_dir ());
+ et_browser_select_dir (self, g_get_home_dir ());
}
/*
* Load desktop directory
*/
-void Browser_Load_Desktop_Directory (void)
+void
+et_browser_go_desktop (EtBrowser *self)
{
- Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP));
+ et_browser_select_dir (self,
+ g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
}
/*
* Load documents directory
*/
-void Browser_Load_Documents_Directory (void)
+void
+et_browser_go_documents (EtBrowser *self)
{
- Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS));
+ et_browser_select_dir (self,
+ g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
}
/*
* Load downloads directory
*/
-void Browser_Load_Downloads_Directory (void)
+void
+et_browser_go_download (EtBrowser *self)
{
- Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD));
+ et_browser_select_dir (self,
+ g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD));
}
/*
* Load music directory
*/
-void Browser_Load_Music_Directory (void)
+void
+et_browser_go_music (EtBrowser *self)
{
- Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC));
+ et_browser_select_dir (self,
+ g_get_user_special_dir (G_USER_DIRECTORY_MUSIC));
}
/*
* Load default directory
*/
-void Browser_Load_Default_Directory (void)
+void
+et_browser_load_default_dir (EtBrowser *self)
{
GFile **files;
gchar *path_utf8;
@@ -283,6 +333,104 @@ void Browser_Load_Default_Directory (void)
g_free (files);
}
+void
+et_browser_run_player_for_album_list (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *albumListModel;
+ GList *l;
+ GList *path_list = NULL;
+
+ priv = et_browser_get_instance_private (self);
+
+ g_return_if_fail (priv->album_list != NULL);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->album_list));
+
+ if (!gtk_tree_selection_get_selected (selection, &albumListModel, &iter))
+ return;
+
+ gtk_tree_model_get (albumListModel, &iter, ALBUM_ETFILE_LIST_POINTER, &l,
+ -1);
+
+ for (; l != NULL; l = g_list_next (l))
+ {
+ ET_File *etfile = (ET_File *)l->data;
+ gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ path_list = g_list_prepend (path_list, path);
+ }
+
+ path_list = g_list_reverse (path_list);
+
+ et_run_program (AUDIO_FILE_PLAYER, path_list);
+ g_list_free (path_list);
+}
+
+void
+et_browser_run_player_for_artist_list (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GtkTreeModel *artistListModel;
+ GList *l, *m;
+ GList *path_list = NULL;
+
+ priv = et_browser_get_instance_private (self);
+
+ g_return_if_fail (priv->artist_list != NULL);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->artist_list));
+ if (!gtk_tree_selection_get_selected(selection, &artistListModel, &iter))
+ return;
+
+ gtk_tree_model_get (artistListModel, &iter, ARTIST_ALBUM_LIST_POINTER, &l,
+ -1);
+
+ for (; l != NULL; l = g_list_next (l))
+ {
+ for (m = l->data; m != NULL; m = g_list_next (m))
+ {
+ ET_File *etfile = (ET_File *)m->data;
+ gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ path_list = g_list_prepend (path_list, path);
+ }
+ }
+
+ path_list = g_list_reverse (path_list);
+
+ et_run_program (AUDIO_FILE_PLAYER, path_list);
+ g_list_free (path_list);
+}
+
+void
+et_browser_run_player_for_selection (EtBrowser *self)
+{
+ GList *selfilelist = NULL;
+ GList *l;
+ GList *path_list = NULL;
+ GtkTreeSelection *selection;
+
+ g_return_if_fail (BrowserList != NULL);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
+ selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
+
+ for (l = selfilelist; l != NULL; l = g_list_next (l))
+ {
+ ET_File *etfile = Browser_List_Get_ETFile_From_Path (l->data);
+ gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ path_list = g_list_prepend (path_list, path);
+ }
+
+ path_list = g_list_reverse (path_list);
+
+ et_run_program (AUDIO_FILE_PLAYER, path_list);
+ g_list_free (path_list);
+ g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
+}
/*
* Get the path from the selected node (row) in the browser
@@ -290,15 +438,18 @@ void Browser_Load_Default_Directory (void)
* Remember to free the value returned from this function!
*/
static gchar *
-Browser_Tree_Get_Path_Of_Selected_Node (void)
+Browser_Tree_Get_Path_Of_Selected_Node (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
GtkTreeSelection *selection;
GtkTreeIter selectedIter;
gchar *path;
- g_return_val_if_fail (BrowserTree != NULL, NULL);
+ priv = et_browser_get_instance_private (self);
+
+ g_return_val_if_fail (priv->tree != NULL, NULL);
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserTree));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tree));
if (selection
&& gtk_tree_selection_get_selected(selection, NULL, &selectedIter))
{
@@ -343,7 +494,8 @@ Browser_Update_Current_Path (const gchar *path)
/*
* Return the current path
*/
-gchar *Browser_Get_Current_Path (void)
+const gchar *
+et_browser_get_current_path (EtBrowser *self)
{
return BrowserCurrentPath;
}
@@ -351,24 +503,30 @@ gchar *Browser_Get_Current_Path (void)
/*
* Reload the current directory.
*/
-void Browser_Reload_Directory (void)
+void
+et_browser_reload_directory (EtBrowser *self)
{
- if (BrowserTree && BrowserCurrentPath != NULL)
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->tree && BrowserCurrentPath != NULL)
{
// Unselect files, to automatically reload the file of the directory
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserTree));
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tree));
if (selection)
{
gtk_tree_selection_unselect_all(selection);
}
- Browser_Tree_Select_Dir(BrowserCurrentPath);
+ et_browser_select_dir (self, BrowserCurrentPath);
}
}
/*
* Set the current path (selected node) in browser as default path (within config variable).
*/
-void Set_Current_Path_As_Default (void)
+void
+et_browser_set_current_path_default (EtBrowser *self)
{
if (DEFAULT_PATH_TO_MP3 != NULL)
g_free(DEFAULT_PATH_TO_MP3);
@@ -380,17 +538,20 @@ void Set_Current_Path_As_Default (void)
* When you press the key 'enter' in the BrowserEntry to validate the text (browse the directory)
*/
static void
-Browser_Entry_Activated (void)
+Browser_Entry_Activated (EtBrowser *self, GtkEntry *entry)
{
+ EtBrowserPrivate *priv;
const gchar *path_utf8;
gchar *path;
- path_utf8 = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(BrowserEntryCombo))));
- Add_String_To_Combo_List(GTK_LIST_STORE(BrowserEntryModel), (gchar *)path_utf8);
+ priv = et_browser_get_instance_private (self);
+
+ path_utf8 = gtk_entry_get_text (entry);
+ Add_String_To_Combo_List (GTK_LIST_STORE (priv->entry_model), path_utf8);
path = filename_from_display(path_utf8);
- Browser_Tree_Select_Dir(path);
+ et_browser_select_dir (self, path);
g_free(path);
}
@@ -409,20 +570,24 @@ void Browser_Entry_Set_Text (gchar *text)
* Button to go to parent directory
*/
void
-et_browser_on_action_parent_directory (void)
+et_browser_go_parent (EtBrowser *self)
{
gchar *parent_dir, *path;
- parent_dir = Browser_Get_Current_Path();
+ /* TODO: Replace this with g_file_get_parent(). */
+ parent_dir = g_strdup (et_browser_get_current_path (self));
+
if (strlen(parent_dir)>1)
{
if ( parent_dir[strlen(parent_dir)-1]==G_DIR_SEPARATOR )
parent_dir[strlen(parent_dir)-1] = '\0';
path = g_path_get_dirname(parent_dir);
- Browser_Tree_Select_Dir(path);
+ et_browser_select_dir (self, path);
g_free(path);
}
+
+ g_free (parent_dir);
}
/*
@@ -497,7 +662,8 @@ Browser_Tree_Key_Press (GtkWidget *tree, GdkEvent *event, gpointer data)
* - Delete = delete file
* Also tries to capture text input and relate it to files
*/
-gboolean Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data)
+static gboolean
+Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data)
{
GdkEventKey *kevent;
GtkTreeSelection *fileSelection;
@@ -514,7 +680,8 @@ gboolean Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data
switch(kevent->keyval)
{
case GDK_KEY_Delete:
- Action_Delete_Selected_Files();
+ et_application_window_delete_selected_files (NULL,
+ MainWindow);
return TRUE;
}
}
@@ -577,20 +744,24 @@ Browser_List_Button_Press (GtkTreeView *treeView, GdkEventButton *event)
/*
* Collapse (close) tree recursively up to the root node.
*/
-void Browser_Tree_Collapse (void)
+void
+et_browser_collapse (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
#ifndef G_OS_WIN32
GtkTreePath *rootPath;
#endif /* !G_OS_WIN32 */
- g_return_if_fail (BrowserTree != NULL);
+ priv = et_browser_get_instance_private (self);
+
+ g_return_if_fail (priv->tree != NULL);
- gtk_tree_view_collapse_all(GTK_TREE_VIEW(BrowserTree));
+ gtk_tree_view_collapse_all(GTK_TREE_VIEW(priv->tree));
#ifndef G_OS_WIN32
/* But keep the main directory opened */
rootPath = gtk_tree_path_new_first();
- gtk_tree_view_expand_to_path(GTK_TREE_VIEW(BrowserTree), rootPath);
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(priv->tree), rootPath);
gtk_tree_path_free(rootPath);
#endif /* !G_OS_WIN32 */
}
@@ -611,7 +782,8 @@ Browser_Tree_Set_Node_Visible (GtkWidget *directoryView, GtkTreePath *path)
/*
* Set a row visible in the file list (by scrolling the list)
*/
-void Browser_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter)
+static void
+Browser_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter)
{
/*
* TODO: Make this only scroll to the row if it is not visible
@@ -632,13 +804,16 @@ void Browser_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter
* Do file-save confirmation, and then prompt the new dir to be loaded
*/
static gboolean
-Browser_Tree_Node_Selected (GtkTreeSelection *selection, gpointer user_data)
+Browser_Tree_Node_Selected (EtBrowser *self, GtkTreeSelection *selection)
{
+ EtBrowserPrivate *priv;
gchar *pathName, *pathName_utf8;
static int counter = 0;
GtkTreeIter selectedIter;
GtkTreePath *selectedPath;
+ priv = et_browser_get_instance_private (self);
+
if (!gtk_tree_selection_get_selected(selection, NULL, &selectedIter))
return TRUE;
selectedPath = gtk_tree_model_get_path(GTK_TREE_MODEL(directoryTreeModel), &selectedIter);
@@ -646,7 +821,7 @@ Browser_Tree_Node_Selected (GtkTreeSelection *selection, gpointer user_data)
/* Open the node */
if (OPEN_SELECTED_BROWSER_NODE)
{
- gtk_tree_view_expand_row(GTK_TREE_VIEW(BrowserTree), selectedPath, FALSE);
+ gtk_tree_view_expand_row(GTK_TREE_VIEW(priv->tree), selectedPath, FALSE);
}
gtk_tree_path_free(selectedPath);
@@ -654,7 +829,7 @@ Browser_Tree_Node_Selected (GtkTreeSelection *selection, gpointer user_data)
if (ReadingDirectory == TRUE)
return TRUE;
- //Browser_Tree_Set_Node_Visible(BrowserTree, selectedPath);
+ //Browser_Tree_Set_Node_Visible(priv->tree, selectedPath);
gtk_tree_model_get(GTK_TREE_MODEL(directoryTreeModel), &selectedIter,
TREE_COLUMN_FULL_PATH, &pathName, -1);
if (!pathName)
@@ -738,11 +913,11 @@ Browser_Tree_Node_Selected (GtkTreeSelection *selection, gpointer user_data)
&selectedIter) == FALSE
&& !g_file_query_exists (file, NULL))
{
- gtk_tree_view_collapse_row (GTK_TREE_VIEW (BrowserTree),
+ gtk_tree_view_collapse_row (GTK_TREE_VIEW (priv->tree),
selectedPath);
if (OPEN_SELECTED_BROWSER_NODE)
{
- gtk_tree_view_expand_row (GTK_TREE_VIEW (BrowserTree),
+ gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->tree),
selectedPath, FALSE);
}
gtk_tree_path_free (selectedPath);
@@ -803,15 +978,16 @@ Browser_Win32_Get_Drive_Root (gchar *drive, GtkTreeIter *rootNode, GtkTreePath *
/*
- * Browser_Tree_Select_Dir: Select the directory corresponding to the 'path' in
+ * et_browser_select_dir: Select the directory corresponding to the 'path' in
* the tree browser, but it doesn't read it!
- * Check if path is correct before selecting it. And returns TRUE on success,
- * else FALSE.
+ * Check if path is correct before selecting it.
*
* - "current_path" is in file system encoding (not UTF-8)
*/
-gboolean Browser_Tree_Select_Dir (const gchar *current_path)
+void
+et_browser_select_dir (EtBrowser *self, const gchar *current_path)
{
+ EtBrowserPrivate *priv;
GtkTreePath *rootPath = NULL;
GtkTreeIter parentNode, currentNode;
gint index = 1; // Skip the first token as it is NULL due to leading /
@@ -819,12 +995,14 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
gchar *nodeName;
gchar *temp;
- g_return_val_if_fail (BrowserTree != NULL, FALSE);
+ priv = et_browser_get_instance_private (self);
+
+ g_return_if_fail (priv->tree != NULL);
/* Load current_path */
if(!current_path || !*current_path)
{
- return TRUE;
+ return;
}
#ifdef G_OS_WIN32
@@ -843,20 +1021,20 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
// Expand root node (fill parentNode and rootPath)
#ifdef G_OS_WIN32
if (!Browser_Win32_Get_Drive_Root(parts[0], &parentNode, &rootPath))
- return FALSE;
+ return;
#else /* !G_OS_WIN32 */
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (directoryTreeModel),
&parentNode))
{
g_message ("%s", "directoryTreeModel is empty");
- return FALSE;
+ return;
}
rootPath = gtk_tree_path_new_first();
#endif /* !G_OS_WIN32 */
if (rootPath)
{
- gtk_tree_view_expand_to_path(GTK_TREE_VIEW(BrowserTree), rootPath);
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(priv->tree), rootPath);
gtk_tree_path_free(rootPath);
}
@@ -937,7 +1115,7 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
rootPath = gtk_tree_model_get_path(GTK_TREE_MODEL(directoryTreeModel), &parentNode);
if (rootPath)
{
- gtk_tree_view_expand_to_path(GTK_TREE_VIEW(BrowserTree), rootPath);
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(priv->tree), rootPath);
gtk_tree_path_free(rootPath);
}
index++;
@@ -946,15 +1124,15 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
rootPath = gtk_tree_model_get_path(GTK_TREE_MODEL(directoryTreeModel), &parentNode);
if (rootPath)
{
- gtk_tree_view_expand_to_path(GTK_TREE_VIEW(BrowserTree), rootPath);
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(priv->tree), rootPath);
// Select the node to load the corresponding directory
- gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserTree)), rootPath);
- Browser_Tree_Set_Node_Visible(BrowserTree, rootPath);
+ gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tree)), rootPath);
+ Browser_Tree_Set_Node_Visible(priv->tree, rootPath);
gtk_tree_path_free(rootPath);
}
g_strfreev(parts);
- return TRUE;
+ return;
}
/*
@@ -1008,12 +1186,16 @@ Browser_List_Row_Selected (GtkTreeSelection *selection, gpointer data)
* Also supports optionally selecting a specific etfile
* but be careful, this does not call Browser_List_Row_Selected !
*/
-void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
+void
+et_browser_load_file_list (EtBrowser *self,
+ GList *etfilelist,
+ ET_File *etfile_to_select)
{
GList *l;
gboolean activate_bg_color = 0;
GtkTreeIter rowIter;
+ g_return_if_fail (ET_BROWSER (self));
g_return_if_fail (BrowserList != NULL);
gtk_list_store_clear(fileListModel);
@@ -1098,7 +1280,8 @@ void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select)
* - Refresh 'filename' is file saved,
* - Change color is something changed on the file
*/
-void Browser_List_Refresh_Whole_List (void)
+void
+et_browser_refresh_list (EtBrowser *self)
{
ET_File *ETFile;
File_Tag *FileTag;
@@ -1113,6 +1296,8 @@ void Browser_List_Refresh_Whole_List (void)
gboolean valid;
GtkWidget *artist_radio;
+ g_return_if_fail (ET_BROWSER (self));
+
if (!ETCore->ETFileDisplayedList || !BrowserList
|| gtk_tree_model_iter_n_children(GTK_TREE_MODEL(fileListModel), NULL) == 0)
{
@@ -1481,7 +1666,8 @@ Browser_List_Set_Row_Appearance (GtkTreeIter *iter)
/*
* Remove a file from the list, by ETFile
*/
-void Browser_List_Remove_File (ET_File *searchETFile)
+void
+et_browser_remove_file (EtBrowser *self, ET_File *searchETFile)
{
gint row;
GtkTreePath *currentPath = NULL;
@@ -1676,7 +1862,10 @@ ET_File *Browser_List_Select_File_By_Iter_String (const gchar* stringIter, gbool
* Select the specified file in the list, by fuzzy string matching based on
* the Damerau-Levenshtein Metric (patch from Santtu Lakkala - 23/08/2004)
*/
-ET_File *Browser_List_Select_File_By_DLM (const gchar* string, gboolean select_it)
+ET_File *
+et_browser_select_file_by_dlm (EtBrowser *self,
+ const gchar* string,
+ gboolean select_it)
{
GtkTreeIter iter;
GtkTreeIter iter2;
@@ -1723,12 +1912,12 @@ ET_File *Browser_List_Select_File_By_DLM (const gchar* string, gboolean select_i
/*
* Clear all entries on the file list
*/
-void Browser_List_Clear()
+void
+et_browser_clear (EtBrowser *self)
{
- gtk_list_store_clear(fileListModel);
- gtk_list_store_clear(artistListModel);
- gtk_list_store_clear(albumListModel);
-
+ gtk_list_store_clear (fileListModel);
+ gtk_list_store_clear (artistListModel);
+ gtk_list_store_clear (albumListModel);
}
/*
@@ -1894,7 +2083,8 @@ Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
/*
* Select all files on the file list
*/
-void Browser_List_Select_All_Files (void)
+void
+et_browser_select_all (EtBrowser *self)
{
GtkTreeSelection *selection;
@@ -1913,7 +2103,8 @@ void Browser_List_Select_All_Files (void)
/*
* Unselect all files on the file list
*/
-void Browser_List_Unselect_All_Files (void)
+void
+et_browser_unselect_all (EtBrowser *self)
{
GtkTreeSelection *selection;
@@ -1929,7 +2120,8 @@ void Browser_List_Unselect_All_Files (void)
/*
* Invert the selection of the file list
*/
-void Browser_List_Invert_File_Selection (void)
+void
+et_browser_invert_selection (EtBrowser *self)
{
GtkTreeIter iter;
GtkTreeSelection *selection;
@@ -1959,8 +2151,10 @@ void Browser_List_Invert_File_Selection (void)
}
-void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
+static void
+Browser_Artist_List_Load_Files (EtBrowser *self, ET_File *etfile_to_select)
{
+ EtBrowserPrivate *priv;
GList *AlbumList;
GList *etfilelist;
ET_File *etfile;
@@ -1970,13 +2164,15 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
GtkTreeSelection *selection;
gchar *artistname, *artist_to_select = NULL;
- g_return_if_fail (BrowserArtistList != NULL);
+ priv = et_browser_get_instance_private (self);
+
+ g_return_if_fail (priv->artist_list != NULL);
if (etfile_to_select)
artist_to_select = ((File_Tag *)etfile_to_select->FileTag->data)->artist;
gtk_list_store_clear(artistListModel);
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserArtistList));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->artist_list));
for (l = ETCore->ETArtistAlbumFileList; l != NULL; l = g_list_next (l))
{
@@ -2014,10 +2210,10 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
gtk_tree_selection_select_iter(selection, &iter);
g_signal_handlers_unblock_by_func(G_OBJECT(selection),G_CALLBACK(Browser_Artist_List_Row_Selected),NULL);
- gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(BrowserArtistList), path, NULL, FALSE, 0, 0);
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->artist_list), path, NULL, FALSE, 0, 0);
gtk_tree_path_free(path);
- Browser_Album_List_Load_Files(AlbumList, etfile_to_select);
+ Browser_Album_List_Load_Files (self, AlbumList, etfile_to_select);
// Now that we've found the artist, no need to continue searching
artist_to_select = NULL;
@@ -2034,7 +2230,7 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
ARTIST_ALBUM_LIST_POINTER, &AlbumList,
-1);
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
- Browser_Album_List_Load_Files(AlbumList,NULL);
+ Browser_Album_List_Load_Files (self, AlbumList,NULL);
}
}
@@ -2043,7 +2239,7 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
* Callback to select-row event
*/
static void
-Browser_Artist_List_Row_Selected (GtkTreeSelection* selection, gpointer data)
+Browser_Artist_List_Row_Selected (EtBrowser *self, GtkTreeSelection* selection)
{
GList *AlbumList;
GtkTreeIter iter;
@@ -2057,11 +2253,11 @@ Browser_Artist_List_Row_Selected (GtkTreeSelection* selection, gpointer data)
gtk_tree_model_get(GTK_TREE_MODEL(artistListModel), &iter,
ARTIST_ALBUM_LIST_POINTER, &AlbumList, -1);
- Browser_Album_List_Load_Files(AlbumList, NULL);
+ Browser_Album_List_Load_Files (self, AlbumList, NULL);
}
/*
- * Set the color of the row of BrowserArtistList
+ * Set the color of the row of priv->artist_list
*/
static void
Browser_Artist_List_Set_Row_Appearance (GtkTreeIter *iter)
@@ -2113,8 +2309,11 @@ Browser_Artist_List_Set_Row_Appearance (GtkTreeIter *iter)
* Load the list of Albums for each Artist
*/
static void
-Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
+Browser_Album_List_Load_Files (EtBrowser *self,
+ GList *albumlist,
+ ET_File *etfile_to_select)
{
+ EtBrowserPrivate *priv;
GList *l;
GList *etfilelist = NULL;
ET_File *etfile;
@@ -2122,13 +2321,15 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
GtkTreeSelection *selection;
gchar *albumname, *album_to_select = NULL;
- g_return_if_fail (BrowserAlbumList != NULL);
+ priv = et_browser_get_instance_private (self);
+
+ g_return_if_fail (priv->album_list != NULL);
if (etfile_to_select)
album_to_select = ((File_Tag *)etfile_to_select->FileTag->data)->album;
gtk_list_store_clear(albumListModel);
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserAlbumList));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->album_list));
// Create a first row to select all albums of the artist
// FIX ME : the attached list must be freed!
@@ -2182,11 +2383,11 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
gtk_tree_selection_select_iter(selection, &iter);
g_signal_handlers_unblock_by_func(G_OBJECT(selection),G_CALLBACK(Browser_Album_List_Row_Selected),NULL);
- gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(BrowserAlbumList), path, NULL, FALSE, 0, 0);
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->album_list), path, NULL, FALSE, 0, 0);
gtk_tree_path_free(path);
ET_Set_Displayed_File_List(etfilelist);
- Browser_List_Load_File_List(etfilelist,etfile_to_select);
+ et_browser_load_file_list (self, etfilelist, etfile_to_select);
// Now that we've found the album, no need to continue searching
album_to_select = NULL;
@@ -2206,7 +2407,7 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
// Set the attached list as "Displayed List"
ET_Set_Displayed_File_List(etfilelist);
- Browser_List_Load_File_List(etfilelist, NULL);
+ et_browser_load_file_list (self, etfilelist, NULL);
// Displays the first item
Action_Select_Nth_File_By_Etfile((ET_File *)etfilelist->data);
@@ -2217,7 +2418,7 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
* Callback to select-row event
*/
static void
-Browser_Album_List_Row_Selected (GtkTreeSelection *selection, gpointer data)
+Browser_Album_List_Row_Selected (EtBrowser *self, GtkTreeSelection *selection)
{
GList *etfilelist;
GtkTreeIter iter;
@@ -2236,7 +2437,7 @@ Browser_Album_List_Row_Selected (GtkTreeSelection *selection, gpointer data)
// Set the attached list as "Displayed List"
ET_Set_Displayed_File_List(etfilelist);
- Browser_List_Load_File_List(etfilelist, NULL);
+ et_browser_load_file_list (self, etfilelist, NULL);
// Displays the first item
Action_Select_Nth_File_By_Etfile((ET_File *)etfilelist->data);
@@ -2244,7 +2445,7 @@ Browser_Album_List_Row_Selected (GtkTreeSelection *selection, gpointer data)
/*
- * Set the color of the row of BrowserAlbumList
+ * Set the color of the row of priv->album_list
*/
static void
Browser_Album_List_Set_Row_Appearance (GtkTreeIter *iter)
@@ -2286,7 +2487,8 @@ Browser_Album_List_Set_Row_Appearance (GtkTreeIter *iter)
}
}
-void Browser_Display_Tree_Or_Artist_Album_List (void)
+void
+et_browser_toggle_display_mode (EtBrowser *self)
{
ET_File *etfile = ETCore->ETFileDisplayed; // ETFile to display again after changing browser view
GtkWidget *artist_radio;
@@ -2308,7 +2510,7 @@ void Browser_Display_Tree_Or_Artist_Album_List (void)
// Display Artist + Album lists
gtk_notebook_set_current_page(GTK_NOTEBOOK(BrowserNoteBook),1);
ET_Create_Artist_Album_File_List();
- Browser_Artist_List_Load_Files(etfile);
+ Browser_Artist_List_Load_Files (self, etfile);
}else
{
@@ -2321,7 +2523,7 @@ void Browser_Display_Tree_Or_Artist_Album_List (void)
// Display Tree Browser
gtk_notebook_set_current_page(GTK_NOTEBOOK(BrowserNoteBook),0);
- Browser_List_Load_File_List(ETCore->ETFileDisplayedList, etfile);
+ et_browser_load_file_list (self, ETCore->ETFileDisplayedList, etfile);
// Displays the first file if nothing specified
if (!etfile)
@@ -2339,15 +2541,20 @@ void Browser_Display_Tree_Or_Artist_Album_List (void)
/*
* Disable (FALSE) / Enable (TRUE) all user widgets in the browser area (Tree + List + Entry)
*/
-void Browser_Area_Set_Sensitive (gboolean activate)
+void
+et_browser_set_sensitive (EtBrowser *self, gboolean sensitive)
{
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserEntryCombo),activate);
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserTree), activate);
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserList), activate);
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserArtistList),activate);
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserAlbumList), activate);
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserButton), activate);
- gtk_widget_set_sensitive(GTK_WIDGET(BrowserLabel), activate);
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (self);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserEntryCombo), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->tree), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserList), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->artist_list), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->album_list), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserButton), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserLabel), sensitive);
}
@@ -2506,28 +2713,21 @@ Browser_Tree_Initialize (void)
}
/*
- * Browser_Tree_Rebuild: Refresh the tree browser by destroying it and rebuilding it.
- * Opens tree nodes corresponding to 'path_to_load' if this parameter isn't NULL.
- * If NULL, selects the current path.
+ * et_browser_reload: Refresh the tree browser by destroying it and rebuilding it.
+ * Opens tree nodes corresponding to the current path.
*/
-void Browser_Tree_Rebuild (gchar *path_to_load)
+void
+et_browser_reload (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
gchar *current_path = NULL;
GtkTreeSelection *selection;
- /* May be called from GtkUIManager callback */
- if (GTK_IS_ACTION(path_to_load))
- path_to_load = NULL;
-
- if (path_to_load != NULL)
- {
- Browser_Tree_Initialize();
- Browser_Tree_Select_Dir(path_to_load);
- return;
- }
+ priv = et_browser_get_instance_private (self);
/* Memorize the current path to load it again at the end */
- current_path = Browser_Tree_Get_Path_Of_Selected_Node();
+ current_path = Browser_Tree_Get_Path_Of_Selected_Node (self);
+
if (current_path==NULL && BrowserEntryCombo)
{
/* If no node selected, get path from BrowserEntry or default path */
@@ -2541,12 +2741,16 @@ void Browser_Tree_Rebuild (gchar *path_to_load)
Browser_Tree_Initialize();
/* Select again the memorized path without loading files */
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserTree));
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tree));
if (selection)
{
- g_signal_handlers_block_by_func(G_OBJECT(selection),G_CALLBACK(Browser_Tree_Node_Selected),NULL);
- Browser_Tree_Select_Dir(current_path);
- g_signal_handlers_unblock_by_func(G_OBJECT(selection),G_CALLBACK(Browser_Tree_Node_Selected),NULL);
+ g_signal_handlers_block_by_func (selection,
+ G_CALLBACK (Browser_Tree_Node_Selected),
+ self);
+ et_browser_select_dir (self, current_path);
+ g_signal_handlers_unblock_by_func (selection,
+ G_CALLBACK (Browser_Tree_Node_Selected),
+ self);
}
g_free(current_path);
@@ -2560,7 +2764,9 @@ void Browser_Tree_Rebuild (gchar *path_to_load)
* Parameters are non-utf8!
*/
static void
-Browser_Tree_Rename_Directory (const gchar *last_path, const gchar *new_path)
+Browser_Tree_Rename_Directory (EtBrowser *self,
+ const gchar *last_path,
+ const gchar *new_path)
{
gchar **textsplit;
@@ -2628,7 +2834,7 @@ Browser_Tree_Rename_Directory (const gchar *last_path, const gchar *new_path)
Browser_Tree_Handle_Rename(&iter, last_path, new_path);
/* Update the variable of the current path */
- path = Browser_Tree_Get_Path_Of_Selected_Node();
+ path = Browser_Tree_Get_Path_Of_Selected_Node (self);
Browser_Update_Current_Path(path);
g_free(path);
@@ -2880,7 +3086,8 @@ Browser_List_Select_Func (GtkTreeSelection *selection, GtkTreeModel *model, GtkT
* Open up a node on the browser tree
* Scanning and showing all subdirectories
*/
-static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePath, gpointer data)
+static void
+expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePath, gpointer data)
{
GFile *dir;
GFileEnumerator *enumerator;
@@ -3002,7 +3209,8 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
g_free(parentPath);
}
-static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data)
+static void
+collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data)
{
GtkTreeIter subNodeIter;
gchar *path;
@@ -3085,15 +3293,19 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
/*
* Create item of the browser (Entry + Tree + List).
*/
-GtkWidget *Create_Browser_Items (GtkWidget *parent)
+static void
+create_browser (EtBrowser *self)
{
- GtkWidget *VerticalBox;
+ EtBrowserPrivate *priv;
+ GtkWidget *VerticalBox;
GtkWidget *HBox;
GtkWidget *ScrollWindowDirectoryTree;
GtkWidget *ScrollWindowFileList;
GtkWidget *ScrollWindowArtistList;
GtkWidget *ScrollWindowAlbumList;
GtkWidget *Label;
+ GtkWidget *ArtistAlbumVPaned;
+ GtkWidget *BrowserHPaned;
gsize i;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
@@ -3111,9 +3323,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
N_("# Files") };
const gchar *AlbumList_Titles[] = { N_("Album"), N_("# Files") };
- VerticalBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2);
- gtk_container_set_border_width(GTK_CONTAINER(VerticalBox),2);
+ priv = et_browser_get_instance_private (self);
+ VerticalBox = GTK_WIDGET (self);
+ gtk_container_set_border_width(GTK_CONTAINER(VerticalBox),2);
// HBox for BrowserEntry + BrowserLabel
HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
@@ -3122,17 +3335,19 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
/*
* The entry box for displaying path
*/
- g_assert (BrowserEntryModel == NULL);
- BrowserEntryModel = gtk_list_store_new (MISC_COMBO_COUNT, G_TYPE_STRING);
+ g_assert (priv->entry_model == NULL);
+ priv->entry_model = gtk_list_store_new (MISC_COMBO_COUNT, G_TYPE_STRING);
- BrowserEntryCombo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(BrowserEntryModel));
- g_object_unref (BrowserEntryModel);
+ BrowserEntryCombo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->entry_model));
+ g_object_unref (priv->entry_model);
gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(BrowserEntryCombo), MISC_COMBO_TEXT);
/* History list */
- Load_Path_Entry_List(BrowserEntryModel, MISC_COMBO_TEXT);
+ Load_Path_Entry_List(priv->entry_model, MISC_COMBO_TEXT);
//gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(BrowserEntryCombo),2); // Two columns to display paths
-
g_signal_connect(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(BrowserEntryCombo)))),"activate",G_CALLBACK(Browser_Entry_Activated),NULL);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (BrowserEntryCombo)),
+ "activate", G_CALLBACK (Browser_Entry_Activated),
+ self);
gtk_box_pack_start(GTK_BOX(HBox),BrowserEntryCombo,TRUE,TRUE,1);
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(BrowserEntryCombo)))),_("Enter a
directory to browse."));
@@ -3154,8 +3369,8 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
gtk_box_pack_start(GTK_BOX(HBox),BrowserLabel,FALSE,FALSE,2);
/* Browser NoteBook :
- * - one tab for the BrowserTree
- * - one tab for the BrowserArtistList and the BrowserAlbumList
+ * - one tab for the priv->tree
+ * - one tab for the priv->artist_list and the priv->album_list
*/
BrowserNoteBook = gtk_notebook_new();
//gtk_notebook_popup_enable(GTK_NOTEBOOK(BrowserNoteBook));
@@ -3180,10 +3395,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
gtk_notebook_append_page(GTK_NOTEBOOK(BrowserNoteBook),ScrollWindowDirectoryTree,Label);
/* The tree view */
- BrowserTree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(directoryTreeModel));
+ priv->tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(directoryTreeModel));
g_object_unref (directoryTreeModel);
- gtk_container_add(GTK_CONTAINER(ScrollWindowDirectoryTree),BrowserTree);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(BrowserTree), TRUE);
+ gtk_container_add(GTK_CONTAINER(ScrollWindowDirectoryTree),priv->tree);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->tree), TRUE);
// Column for the pixbuf + text
column = gtk_tree_view_column_new();
@@ -3201,24 +3416,25 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
gtk_tree_view_column_set_attributes(column, renderer,
"text", TREE_COLUMN_DIR_NAME,
NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserTree), column);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(priv->tree), column);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
Browser_Tree_Initialize();
/* Signals */
- g_signal_connect(G_OBJECT(BrowserTree), "row-expanded", G_CALLBACK(expand_cb),NULL);
- g_signal_connect(G_OBJECT(BrowserTree), "row-collapsed", G_CALLBACK(collapse_cb),NULL);
- g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserTree))),
- "changed", G_CALLBACK(Browser_Tree_Node_Selected), NULL);
+ g_signal_connect(G_OBJECT(priv->tree), "row-expanded", G_CALLBACK(expand_cb),NULL);
+ g_signal_connect(G_OBJECT(priv->tree), "row-collapsed", G_CALLBACK(collapse_cb),NULL);
+ g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree)),
+ "changed",
+ G_CALLBACK (Browser_Tree_Node_Selected), self);
- g_signal_connect(G_OBJECT(BrowserTree),"key_press_event", G_CALLBACK(Browser_Tree_Key_Press),NULL);
+ g_signal_connect(G_OBJECT(priv->tree),"key_press_event", G_CALLBACK(Browser_Tree_Key_Press),NULL);
/* Create Popup Menu on browser tree view */
PopupMenu = gtk_ui_manager_get_widget(UIManager, "/DirPopup");
- gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), BrowserTree, NULL);
- g_signal_connect (G_OBJECT (BrowserTree), "button-press-event",
+ gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->tree, NULL);
+ g_signal_connect (priv->tree, "button-press-event",
G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
@@ -3245,10 +3461,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
G_TYPE_INT,
GDK_TYPE_COLOR);
- BrowserArtistList = gtk_tree_view_new_with_model(GTK_TREE_MODEL(artistListModel));
+ priv->artist_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(artistListModel));
g_object_unref (artistListModel);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(BrowserArtistList), TRUE);
-
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserArtistList)),GTK_SELECTION_SINGLE);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->artist_list), TRUE);
+
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->artist_list)),GTK_SELECTION_SINGLE);
// Artist column
@@ -3268,7 +3484,7 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
"style", ARTIST_FONT_STYLE,
"foreground-gdk", ARTIST_ROW_FOREGROUND,
NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserArtistList), column);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(priv->artist_list), column);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
// # Albums of Artist column
@@ -3283,7 +3499,7 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
"style", ARTIST_FONT_STYLE,
"foreground-gdk", ARTIST_ROW_FOREGROUND,
NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserArtistList), column);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(priv->artist_list), column);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
// # Files of Artist column
@@ -3298,17 +3514,20 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
"style", ARTIST_FONT_STYLE,
"foreground-gdk", ARTIST_ROW_FOREGROUND,
NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserArtistList), column);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(priv->artist_list), column);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserArtistList))),"changed",G_CALLBACK(Browser_Artist_List_Row_Selected),NULL);
+ g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->artist_list)),
+ "changed",
+ G_CALLBACK (Browser_Artist_List_Row_Selected),
+ self);
- gtk_container_add(GTK_CONTAINER(ScrollWindowArtistList),BrowserArtistList);
+ gtk_container_add(GTK_CONTAINER(ScrollWindowArtistList),priv->artist_list);
// Create Popup Menu on browser artist list
PopupMenu = gtk_ui_manager_get_widget(UIManager, "/DirArtistPopup");
- gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), BrowserArtistList, NULL);
- g_signal_connect (G_OBJECT (BrowserArtistList), "button-press-event",
+ gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->artist_list, NULL);
+ g_signal_connect (priv->artist_list, "button-press-event",
G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
// Not available yet!
//ui_widget_set_sensitive(MENU_FILE, AM_ARTIST_OPEN_FILE_WITH, FALSE);
@@ -3326,11 +3545,11 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
G_TYPE_INT,
GDK_TYPE_COLOR);
- BrowserAlbumList = gtk_tree_view_new_with_model(GTK_TREE_MODEL(albumListModel));
+ priv->album_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(albumListModel));
g_object_unref (albumListModel);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(BrowserAlbumList), TRUE);
- gtk_tree_view_set_reorderable(GTK_TREE_VIEW(BrowserAlbumList), FALSE);
- gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserAlbumList)),
GTK_SELECTION_SINGLE);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->album_list), TRUE);
+ gtk_tree_view_set_reorderable(GTK_TREE_VIEW(priv->album_list), FALSE);
+ gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->album_list)),
GTK_SELECTION_SINGLE);
// Album column
column = gtk_tree_view_column_new();
@@ -3348,7 +3567,7 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
"style", ALBUM_FONT_STYLE,
"foreground-gdk", ALBUM_ROW_FOREGROUND,
NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserAlbumList), column);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(priv->album_list), column);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
// # files column
@@ -3363,16 +3582,19 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
"style", ALBUM_FONT_STYLE,
"foreground-gdk", ALBUM_ROW_FOREGROUND,
NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserAlbumList), column);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(priv->album_list), column);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserAlbumList))),"changed",G_CALLBACK(Browser_Album_List_Row_Selected),NULL);
- gtk_container_add(GTK_CONTAINER(ScrollWindowAlbumList),BrowserAlbumList);
+ g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->album_list)),
+ "changed",
+ G_CALLBACK (Browser_Album_List_Row_Selected),
+ self);
+ gtk_container_add(GTK_CONTAINER(ScrollWindowAlbumList),priv->album_list);
// Create Popup Menu on browser album list
PopupMenu = gtk_ui_manager_get_widget(UIManager, "/DirAlbumPopup");
- gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), BrowserAlbumList, NULL);
- g_signal_connect (G_OBJECT (BrowserAlbumList), "button-press-event",
+ gtk_menu_attach_to_widget (GTK_MENU (PopupMenu), priv->album_list, NULL);
+ g_signal_connect (priv->album_list, "button-press-event",
G_CALLBACK (Browser_Popup_Menu_Handler), PopupMenu);
// Not available yet!
//ui_widget_set_sensitive(MENU_FILE, AM_ALBUM_OPEN_FILE_WITH, FALSE);
@@ -3470,7 +3692,7 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
/*
* The list store for run program combos
*/
- RunProgramModel = gtk_list_store_new(MISC_COMBO_COUNT, G_TYPE_STRING);
+ priv->run_program_model = gtk_list_store_new(MISC_COMBO_COUNT, G_TYPE_STRING);
/*
* The pane for the tree and list
@@ -3482,12 +3704,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
/* TODO: Give the browser area a sensible default size. */
gtk_paned_set_position (GTK_PANED (BrowserHPaned), 250);
- gtk_widget_show_all(VerticalBox);
+ gtk_widget_show_all (GTK_WIDGET (self));
/* Set home variable as current path */
Browser_Update_Current_Path (g_get_home_dir ());
-
- return VerticalBox;
}
/*
@@ -3544,12 +3764,58 @@ et_browser_set_sorting_file_mode (GtkTreeViewColumn *column, gpointer data)
Browser_List_Refresh_Sort ();
}
+/*******************************
+ * Scanner To Rename Directory *
+ *******************************/
+static void
+rename_directory_generate_preview (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+ gchar *preview_text = NULL;
+ gchar *mask = NULL;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (!ETCore->ETFileDisplayed
+ || !priv->rename_directory_dialog || !priv->rename_directory_mask_combo ||
!priv->rename_directory_preview_label)
+ return;
+
+ mask =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))));
+ if (!mask)
+ return;
+
+ preview_text = Scan_Generate_New_Filename_From_Mask(ETCore->ETFileDisplayed,mask,FALSE);
+
+ if (GTK_IS_LABEL(priv->rename_directory_preview_label))
+ {
+ if (preview_text)
+ {
+ //gtk_label_set_text(GTK_LABEL(priv->rename_file_preview_label),preview_text);
+ gchar *tmp_string = g_markup_printf_escaped("%s",preview_text); // To avoid problem with strings
containing characters like '&'
+ gchar *str = g_strdup_printf("<i>%s</i>",tmp_string);
+ gtk_label_set_markup(GTK_LABEL(priv->rename_directory_preview_label),str);
+ g_free(tmp_string);
+ g_free(str);
+ } else
+ {
+ gtk_label_set_text(GTK_LABEL(priv->rename_directory_preview_label),"");
+ }
+
+ // Force the window to be redrawed else the preview label may be not placed correctly
+ gtk_widget_queue_resize(priv->rename_directory_dialog);
+ }
+
+ g_free(mask);
+ g_free(preview_text);
+}
/*
* The window to Rename a directory into the browser.
*/
-void Browser_Open_Rename_Directory_Window (void)
+void
+et_browser_show_rename_directory_dialog (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
GtkWidget *VBox;
GtkWidget *HBox;
GtkWidget *Label;
@@ -3560,9 +3826,11 @@ void Browser_Open_Rename_Directory_Window (void)
gchar *address = NULL;
gchar *string;
- if (RenameDirectoryWindow != NULL)
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->rename_directory_dialog != NULL)
{
- gtk_window_present(GTK_WINDOW(RenameDirectoryWindow));
+ gtk_window_present(GTK_WINDOW(priv->rename_directory_dialog));
return;
}
@@ -3592,7 +3860,7 @@ void Browser_Open_Rename_Directory_Window (void)
directory_name_utf8 = filename_to_display(directory_name);
- RenameDirectoryWindow = gtk_dialog_new_with_buttons (_("Rename Directory"),
+ priv->rename_directory_dialog = gtk_dialog_new_with_buttons (_("Rename Directory"),
GTK_WINDOW (MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
@@ -3601,17 +3869,17 @@ void Browser_Open_Rename_Directory_Window (void)
GTK_RESPONSE_APPLY,
NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (RenameDirectoryWindow),
+ gtk_dialog_set_default_response (GTK_DIALOG (priv->rename_directory_dialog),
GTK_RESPONSE_APPLY);
/* We attach useful data to the combobox */
- g_object_set_data(G_OBJECT(RenameDirectoryWindow), "Parent_Directory", directory_parent);
- g_object_set_data(G_OBJECT(RenameDirectoryWindow), "Current_Directory", directory_name);
- g_signal_connect (RenameDirectoryWindow, "response",
- G_CALLBACK (et_rename_directory_on_response), NULL);
+ g_object_set_data(G_OBJECT(priv->rename_directory_dialog), "Parent_Directory", directory_parent);
+ g_object_set_data(G_OBJECT(priv->rename_directory_dialog), "Current_Directory", directory_name);
+ g_signal_connect (priv->rename_directory_dialog, "response",
+ G_CALLBACK (et_rename_directory_on_response), self);
- VBox = gtk_dialog_get_content_area (GTK_DIALOG (RenameDirectoryWindow));
- gtk_container_set_border_width (GTK_CONTAINER (RenameDirectoryWindow),
+ VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->rename_directory_dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (priv->rename_directory_dialog),
BOX_SPACING);
string = g_strdup_printf(_("Rename the directory '%s' to:"),directory_name_utf8);
@@ -3621,112 +3889,121 @@ void Browser_Open_Rename_Directory_Window (void)
gtk_label_set_line_wrap(GTK_LABEL(Label),TRUE);
/* The combobox to rename the directory */
- RenameDirectoryCombo = gtk_combo_box_text_new_with_entry();
- gtk_box_pack_start(GTK_BOX(VBox),RenameDirectoryCombo,FALSE,FALSE,0);
+ priv->rename_directory_combo = gtk_combo_box_text_new_with_entry();
+ gtk_box_pack_start(GTK_BOX(VBox),priv->rename_directory_combo,FALSE,FALSE,0);
/* Set the directory into the combobox */
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(RenameDirectoryCombo), directory_name_utf8);
- gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(RenameDirectoryCombo), "");
- gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryCombo))),directory_name_utf8);
+ gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(priv->rename_directory_combo), directory_name_utf8);
+ gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(priv->rename_directory_combo), "");
+
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_combo))),directory_name_utf8);
/* Rename directory : check box + combo box + Status icon */
HBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
gtk_box_pack_start(GTK_BOX(VBox),HBox,TRUE,TRUE,0);
- RenameDirectoryWithMask = gtk_check_button_new_with_label(_("Use mask:"));
- gtk_box_pack_start(GTK_BOX(HBox),RenameDirectoryWithMask,FALSE,FALSE,0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask),RENAME_DIRECTORY_WITH_MASK);
- gtk_widget_set_tooltip_text(RenameDirectoryWithMask,_("If activated, it will use masks to rename
directory."));
-
g_signal_connect(G_OBJECT(RenameDirectoryWithMask),"toggled",G_CALLBACK(Rename_Directory_With_Mask_Toggled),NULL);
+ priv->rename_directory_mask_toggle = gtk_check_button_new_with_label(_("Use mask:"));
+ gtk_box_pack_start(GTK_BOX(HBox),priv->rename_directory_mask_toggle,FALSE,FALSE,0);
+
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle),RENAME_DIRECTORY_WITH_MASK);
+ gtk_widget_set_tooltip_text(priv->rename_directory_mask_toggle,_("If activated, it will use masks to
rename directory."));
+ g_signal_connect_swapped (priv->rename_directory_mask_toggle, "toggled",
+ G_CALLBACK (Rename_Directory_With_Mask_Toggled),
+ self);
// Set up list model which is used by the combobox
/* Rename directory from mask */
- if (!RenameDirectoryMaskModel)
- RenameDirectoryMaskModel = gtk_list_store_new(MASK_EDITOR_COUNT, G_TYPE_STRING);
+ if (!priv->rename_directory_mask_model)
+ priv->rename_directory_mask_model = gtk_list_store_new(MASK_EDITOR_COUNT, G_TYPE_STRING);
else
- gtk_list_store_clear(RenameDirectoryMaskModel);
+ gtk_list_store_clear(priv->rename_directory_mask_model);
// The combo box to select the mask to apply
- RenameDirectoryMaskCombo = gtk_combo_box_new_with_entry();
- gtk_combo_box_set_model(GTK_COMBO_BOX(RenameDirectoryMaskCombo),
GTK_TREE_MODEL(RenameDirectoryMaskModel));
- gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RenameDirectoryMaskCombo), MASK_EDITOR_TEXT);
- gtk_widget_set_size_request(RenameDirectoryMaskCombo, 80, -1);
+ priv->rename_directory_mask_combo = gtk_combo_box_new_with_entry();
+ gtk_combo_box_set_model(GTK_COMBO_BOX(priv->rename_directory_mask_combo),
GTK_TREE_MODEL(priv->rename_directory_mask_model));
+ gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(priv->rename_directory_mask_combo), MASK_EDITOR_TEXT);
+ gtk_widget_set_size_request(priv->rename_directory_mask_combo, 80, -1);
- gtk_box_pack_start(GTK_BOX(HBox),RenameDirectoryMaskCombo,TRUE,TRUE,0);
- gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))),
+ gtk_box_pack_start(GTK_BOX(HBox),priv->rename_directory_mask_combo,TRUE,TRUE,0);
+
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))),
_("Select or type in a mask using codes (see Legend in Scanner Window) to rename "
"the directory from tag fields."));
// Signal to generate preview (preview of the new directory)
-
g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))),"changed",
- G_CALLBACK(Scan_Rename_Directory_Generate_Preview),NULL);
+ g_signal_connect_swapped (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->rename_directory_mask_combo))),
+ "changed",
+ G_CALLBACK (rename_directory_generate_preview),
+ self);
// Load masks into the combobox from a file
- Load_Rename_Directory_Masks_List(RenameDirectoryMaskModel, MASK_EDITOR_TEXT, Rename_Directory_Masks);
+ Load_Rename_Directory_Masks_List(priv->rename_directory_mask_model, MASK_EDITOR_TEXT,
Rename_Directory_Masks);
if (RENAME_DIRECTORY_DEFAULT_MASK)
{
- Add_String_To_Combo_List(RenameDirectoryMaskModel, RENAME_DIRECTORY_DEFAULT_MASK);
- gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo))),
RENAME_DIRECTORY_DEFAULT_MASK);
+ Add_String_To_Combo_List(priv->rename_directory_mask_model, RENAME_DIRECTORY_DEFAULT_MASK);
+ gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo))),
RENAME_DIRECTORY_DEFAULT_MASK);
}else
{
- gtk_combo_box_set_active(GTK_COMBO_BOX(RenameDirectoryMaskCombo), 0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(priv->rename_directory_mask_combo), 0);
}
// Mask status icon
// Signal connection to check if mask is correct into the mask entry
- g_signal_connect (gtk_bin_get_child (GTK_BIN (RenameDirectoryMaskCombo)),
+ g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->rename_directory_mask_combo)),
"changed", G_CALLBACK (entry_check_rename_file_mask),
NULL);
// Preview label
- RenameDirectoryPreviewLabel = gtk_label_new (_("Rename directory preview"));
- gtk_label_set_line_wrap(GTK_LABEL(RenameDirectoryPreviewLabel),TRUE);
+ priv->rename_directory_preview_label = gtk_label_new (_("Rename directory preview"));
+ gtk_label_set_line_wrap(GTK_LABEL(priv->rename_directory_preview_label),TRUE);
////gtk_widget_show(FillTagPreviewLabel);
- gtk_box_pack_start(GTK_BOX(VBox),RenameDirectoryPreviewLabel,TRUE,TRUE,0);
+ gtk_box_pack_start(GTK_BOX(VBox),priv->rename_directory_preview_label,TRUE,TRUE,0);
/* Button to save: to rename directory */
- Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RenameDirectoryWindow),
+ Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->rename_directory_dialog),
GTK_RESPONSE_APPLY);
- g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RenameDirectoryCombo)),
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->rename_directory_combo)),
"changed",
G_CALLBACK (empty_entry_disable_widget),
G_OBJECT (Button));
- gtk_widget_show_all(RenameDirectoryWindow);
+ gtk_widget_show_all(priv->rename_directory_dialog);
// To initialize the 'Use mask' check button state
- g_signal_emit_by_name(G_OBJECT(RenameDirectoryWithMask),"toggled");
+ g_signal_emit_by_name(G_OBJECT(priv->rename_directory_mask_toggle),"toggled");
// To initialize PreviewLabel + MaskStatusIconBox
- g_signal_emit_by_name(G_OBJECT(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo))),"changed");
+ g_signal_emit_by_name(G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo))),"changed");
g_free(directory_name_utf8);
}
static void
-Destroy_Rename_Directory_Window (void)
+Destroy_Rename_Directory_Window (EtBrowser *self)
{
- if (RenameDirectoryWindow)
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->rename_directory_dialog)
{
- g_free(g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Parent_Directory"));
- g_free(g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Current_Directory"));
+ g_free(g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Parent_Directory"));
+ g_free(g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Current_Directory"));
if (RENAME_DIRECTORY_DEFAULT_MASK) g_free(RENAME_DIRECTORY_DEFAULT_MASK);
- RENAME_DIRECTORY_DEFAULT_MASK =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))));
- Add_String_To_Combo_List(RenameDirectoryMaskModel, RENAME_DIRECTORY_DEFAULT_MASK);
- Save_Rename_Directory_Masks_List(RenameDirectoryMaskModel, MASK_EDITOR_TEXT);
+ RENAME_DIRECTORY_DEFAULT_MASK =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))));
+ Add_String_To_Combo_List(priv->rename_directory_mask_model, RENAME_DIRECTORY_DEFAULT_MASK);
+ Save_Rename_Directory_Masks_List(priv->rename_directory_mask_model, MASK_EDITOR_TEXT);
- RENAME_DIRECTORY_WITH_MASK =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask));
+ RENAME_DIRECTORY_WITH_MASK =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle));
- gtk_list_store_clear(RenameDirectoryMaskModel);
+ gtk_list_store_clear(priv->rename_directory_mask_model);
- gtk_widget_destroy(RenameDirectoryWindow);
- RenameDirectoryPreviewLabel = NULL;
- RenameDirectoryWindow = NULL;
+ gtk_widget_destroy(priv->rename_directory_dialog);
+ priv->rename_directory_preview_label = NULL;
+ priv->rename_directory_dialog = NULL;
}
}
static void
-Rename_Directory (void)
+Rename_Directory (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
DIR *dir;
gchar *directory_parent;
gchar *directory_last_name;
@@ -3740,23 +4017,24 @@ Rename_Directory (void)
gchar *tmp_path_utf8;
gint fd_tmp;
+ priv = et_browser_get_instance_private (self);
- g_return_if_fail (RenameDirectoryWindow != NULL);
+ g_return_if_fail (priv->rename_directory_dialog != NULL);
- directory_parent = g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Parent_Directory");
- directory_last_name = g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Current_Directory");
+ directory_parent = g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Parent_Directory");
+ directory_last_name = g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Current_Directory");
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)))
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)))
{
// Renamed from mask
- gchar *mask =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))));
+ gchar *mask =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))));
directory_new_name = Scan_Generate_New_Directory_Name_From_Mask(ETCore->ETFileDisplayed,mask,FALSE);
g_free(mask);
}else
{
// Renamed 'manually'
- directory_new_name =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryCombo)))));
+ directory_new_name =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_combo)))));
}
/* Check if a name for the directory have been supplied */
@@ -3804,7 +4082,7 @@ Rename_Directory (void)
if (directory_last_name && directory_new_name_file
&& strcmp(directory_last_name,directory_new_name_file)==0)
{
- Destroy_Rename_Directory_Window();
+ Destroy_Rename_Directory_Window (self);
g_free(directory_new_name_file);
return;
}
@@ -3945,7 +4223,7 @@ Rename_Directory (void)
}
ET_Update_Directory_Name_Into_File_List(last_path,new_path);
- Browser_Tree_Rename_Directory(last_path,new_path);
+ Browser_Tree_Rename_Directory (self, last_path, new_path);
// To update file path in the browser entry
if (ETCore->ETFileDisplayedList)
@@ -3953,12 +4231,12 @@ Rename_Directory (void)
ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
}else
{
- gchar *tmp = filename_to_display(Browser_Get_Current_Path());
+ gchar *tmp = filename_to_display (et_browser_get_current_path (self));
Browser_Entry_Set_Text(tmp);
g_free(tmp);
}
- Destroy_Rename_Directory_Window();
+ Destroy_Rename_Directory_Window (self);
g_free(last_path);
g_free(last_path_utf8);
g_free(new_path);
@@ -3970,11 +4248,15 @@ Rename_Directory (void)
}
static void
-Rename_Directory_With_Mask_Toggled (void)
+Rename_Directory_With_Mask_Toggled (EtBrowser *self)
{
- gtk_widget_set_sensitive(GTK_WIDGET(RenameDirectoryCombo),
!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)));
- gtk_widget_set_sensitive(GTK_WIDGET(RenameDirectoryMaskCombo),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)));
- gtk_widget_set_sensitive(GTK_WIDGET(RenameDirectoryPreviewLabel),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)));
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (self);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->rename_directory_combo),
!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)));
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->rename_directory_mask_combo),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)));
+ gtk_widget_set_sensitive(GTK_WIDGET(priv->rename_directory_preview_label),
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)));
}
@@ -3982,18 +4264,23 @@ Rename_Directory_With_Mask_Toggled (void)
* Window where is typed the name of the program to run, which
* receives the current directory as parameter.
*/
-void Browser_Open_Run_Program_Tree_Window (void)
+void
+et_browser_show_open_directory_with_dialog (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
GtkWidget *VBox;
GtkWidget *HBox;
GtkWidget *Label;
- GtkWidget *RunProgramComboBox;
GtkWidget *Button;
gchar *current_directory = NULL;
- if (RunProgramTreeWindow != NULL)
+ g_return_if_fail (ET_BROWSER (self));
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->open_directory_with_dialog != NULL)
{
- gtk_window_present(GTK_WINDOW(RunProgramTreeWindow));
+ gtk_window_present(GTK_WINDOW(priv->open_directory_with_dialog));
return;
}
@@ -4002,7 +4289,7 @@ void Browser_Open_Run_Program_Tree_Window (void)
if (!current_directory || strlen(current_directory)==0)
return;
- RunProgramTreeWindow = gtk_dialog_new_with_buttons (_("Browse Directory With"),
+ priv->open_directory_with_dialog = gtk_dialog_new_with_buttons (_("Browse Directory With"),
GTK_WINDOW (MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
@@ -4010,12 +4297,12 @@ void Browser_Open_Run_Program_Tree_Window (void)
GTK_STOCK_EXECUTE,
GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (RunProgramTreeWindow),
+ gtk_dialog_set_default_response (GTK_DIALOG (priv->open_directory_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect (RunProgramTreeWindow, "response",
- G_CALLBACK (et_run_program_tree_on_response), NULL);
- VBox = gtk_dialog_get_content_area (GTK_DIALOG (RunProgramTreeWindow));
- gtk_container_set_border_width (GTK_CONTAINER (RunProgramTreeWindow),
+ g_signal_connect (priv->open_directory_with_dialog, "response",
+ G_CALLBACK (et_run_program_tree_on_response), self);
+ VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->open_directory_with_dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (priv->open_directory_with_dialog),
BOX_SPACING);
Label = gtk_label_new(_("Program to run:"));
@@ -4026,62 +4313,72 @@ void Browser_Open_Run_Program_Tree_Window (void)
gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,2);
/* The combobox to enter the program to run */
- RunProgramComboBox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
- gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RunProgramComboBox), MISC_COMBO_TEXT);
- gtk_box_pack_start(GTK_BOX(HBox),RunProgramComboBox,TRUE,TRUE,0);
- gtk_widget_set_size_request(GTK_WIDGET(RunProgramComboBox),250,-1);
-
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),_("Enter
the program to run. "
+ priv->open_directory_with_combobox =
gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->run_program_model));
+ gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(priv->open_directory_with_combobox), MISC_COMBO_TEXT);
+ gtk_box_pack_start(GTK_BOX(HBox),priv->open_directory_with_combobox,TRUE,TRUE,0);
+ gtk_widget_set_size_request(GTK_WIDGET(priv->open_directory_with_combobox),250,-1);
+
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox)))),_("Enter
the program to run. "
"It will receive the current directory as parameter."));
/* History list */
- gtk_list_store_clear(RunProgramModel);
- Load_Run_Program_With_Directory_List(RunProgramModel, MISC_COMBO_TEXT);
- g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"activate",
- G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
+ gtk_list_store_clear(priv->run_program_model);
+ Load_Run_Program_With_Directory_List(priv->run_program_model, MISC_COMBO_TEXT);
+ g_signal_connect_swapped (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->open_directory_with_combobox))),
+ "activate",
+ G_CALLBACK (Run_Program_With_Directory),
+ self);
/* The button to Browse */
Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
gtk_box_pack_start(GTK_BOX(HBox),Button,FALSE,FALSE,0);
g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(RunProgramComboBox))));
+
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox))));
/* We attach useful data to the combobox (into Run_Program_With_Directory) */
- g_object_set_data(G_OBJECT(RunProgramComboBox), "Current_Directory", current_directory);
+ g_object_set_data(G_OBJECT(priv->open_directory_with_combobox), "Current_Directory", current_directory);
/* Button to execute */
- Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramTreeWindow),
+ Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->open_directory_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect_swapped(G_OBJECT(Button),"clicked",
G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
- g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+ g_signal_connect_swapped (Button, "clicked",
+ G_CALLBACK (Run_Program_With_Directory),
+ self);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_directory_with_combobox)),
"changed",
G_CALLBACK (empty_entry_disable_widget),
G_OBJECT (Button));
-
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",NULL);
+
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox)))),"changed",NULL);
- gtk_widget_show_all(RunProgramTreeWindow);
+ gtk_widget_show_all(priv->open_directory_with_dialog);
}
static void
-Destroy_Run_Program_Tree_Window (void)
+Destroy_Run_Program_Tree_Window (EtBrowser *self)
{
- if (RunProgramTreeWindow)
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->open_directory_with_dialog)
{
- gtk_widget_destroy(RunProgramTreeWindow);
- RunProgramTreeWindow = NULL;
+ gtk_widget_hide (priv->open_directory_with_dialog);
}
}
-void Run_Program_With_Directory (GtkWidget *combobox)
+void
+Run_Program_With_Directory (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
gchar *program_name;
gchar *current_directory;
GList *args_list = NULL;
gboolean program_ran;
- g_return_if_fail (GTK_IS_COMBO_BOX (combobox));
+ priv = et_browser_get_instance_private (self);
- program_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
- current_directory = g_object_get_data(G_OBJECT(combobox), "Current_Directory");
+ program_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN
(priv->open_directory_with_combobox)))));
+ current_directory = g_object_get_data (G_OBJECT (priv->open_directory_with_combobox),
+ "Current_Directory");
#ifdef G_OS_WIN32
/* On win32 : 'winamp.exe "c:\path\to\dir"' succeed, while 'winamp.exe "c:\path\to\dir\"' fails */
ET_Win32_Path_Remove_Trailing_Backslash(current_directory);
@@ -4096,12 +4393,71 @@ void Run_Program_With_Directory (GtkWidget *combobox)
if (program_ran)
{
// Append newest choice to the drop down list
- Add_String_To_Combo_List(RunProgramModel, program_name);
+ Add_String_To_Combo_List(priv->run_program_model, program_name);
// Save list attached to the combobox
- Save_Run_Program_With_Directory_List(RunProgramModel, MISC_COMBO_TEXT);
+ Save_Run_Program_With_Directory_List(priv->run_program_model, MISC_COMBO_TEXT);
- Destroy_Run_Program_Tree_Window();
+ Destroy_Run_Program_Tree_Window (self);
+ }
+ g_free(program_name);
+}
+
+static void
+Run_Program_With_Selected_Files (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+ gchar *program_name;
+ ET_File *ETFile;
+ GList *selected_paths;
+ GList *l;
+ GList *args_list = NULL;
+ GtkTreeIter iter;
+ gboolean program_ran;
+
+ priv = et_browser_get_instance_private (self);
+
+ if (!GTK_IS_COMBO_BOX (priv->open_files_with_combobox) || !ETCore->ETFileDisplayedList)
+ return;
+
+ // Programe name to run
+ program_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN
(priv->open_files_with_combobox)))));
+
+ // List of files to pass as parameters
+ selected_paths =
gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)), NULL);
+
+ for (l = selected_paths; l != NULL; l = g_list_next (l))
+ {
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fileListModel), &iter,
+ (GtkTreePath *)l->data))
+ {
+ gtk_tree_model_get(GTK_TREE_MODEL(fileListModel), &iter,
+ LIST_FILE_POINTER, &ETFile,
+ -1);
+
+ args_list = g_list_prepend (args_list,
+ ((File_Name *)ETFile->FileNameCur->data)->value);
+ //args_list = g_list_append(args_list,((File_Name *)ETFile->FileNameCur->data)->value_utf8);
+ }
+ }
+
+ args_list = g_list_reverse (args_list);
+ program_ran = et_run_program (program_name, args_list);
+
+ g_list_free_full (selected_paths, (GDestroyNotify)gtk_tree_path_free);
+ g_list_free(args_list);
+
+ if (program_ran)
+ {
+ // Append newest choice to the drop down list
+ //gtk_list_store_prepend(GTK_LIST_STORE(priv->run_program_model), &iter);
+ //gtk_list_store_set(priv->run_program_model, &iter, MISC_COMBO_TEXT, program_name, -1);
+ Add_String_To_Combo_List(GTK_LIST_STORE(priv->run_program_model), program_name);
+
+ // Save list attached to the combobox
+ Save_Run_Program_With_File_List(priv->run_program_model, MISC_COMBO_TEXT);
+
+ Destroy_Run_Program_List_Window (self);
}
g_free(program_name);
}
@@ -4110,21 +4466,26 @@ void Run_Program_With_Directory (GtkWidget *combobox)
* Window where is typed the name of the program to run, which
* receives the current file as parameter.
*/
-void Browser_Open_Run_Program_List_Window (void)
+void
+et_browser_show_open_files_with_dialog (EtBrowser *self)
{
+ EtBrowserPrivate *priv;
GtkWidget *VBox;
GtkWidget *HBox;
GtkWidget *Label;
- GtkWidget *RunProgramComboBox;
GtkWidget *Button;
- if (RunProgramListWindow != NULL)
+ g_return_if_fail (ET_BROWSER (self));
+
+ priv = et_browser_get_instance_private (self);
+
+ if (priv->open_files_with_dialog != NULL)
{
- gtk_window_present(GTK_WINDOW(RunProgramListWindow));
+ gtk_window_present(GTK_WINDOW(priv->open_files_with_dialog));
return;
}
- RunProgramListWindow = gtk_dialog_new_with_buttons (_("Open Files With"),
+ priv->open_files_with_dialog = gtk_dialog_new_with_buttons (_("Open Files With"),
GTK_WINDOW (MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
@@ -4133,15 +4494,15 @@ void Browser_Open_Run_Program_List_Window (void)
GTK_RESPONSE_OK,
NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (RunProgramListWindow),
+ gtk_dialog_set_default_response (GTK_DIALOG (priv->open_files_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect ((RunProgramListWindow), "response",
- G_CALLBACK (et_run_program_list_on_response), NULL);
+ g_signal_connect ((priv->open_files_with_dialog), "response",
+ G_CALLBACK (et_run_program_list_on_response), self);
- gtk_container_set_border_width (GTK_CONTAINER (RunProgramListWindow),
+ gtk_container_set_border_width (GTK_CONTAINER (priv->open_files_with_dialog),
BOX_SPACING);
- VBox = gtk_dialog_get_content_area (GTK_DIALOG (RunProgramListWindow));
+ VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->open_files_with_dialog));
gtk_container_set_border_width (GTK_CONTAINER(VBox), BOX_SPACING);
Label = gtk_label_new(_("Program to run:"));
@@ -4152,102 +4513,57 @@ void Browser_Open_Run_Program_List_Window (void)
gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,0);
/* The combobox to enter the program to run */
- RunProgramComboBox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
- gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RunProgramComboBox),MISC_COMBO_TEXT);
- gtk_box_pack_start(GTK_BOX(HBox),RunProgramComboBox,TRUE,TRUE,0);
- gtk_widget_set_size_request(GTK_WIDGET(RunProgramComboBox),250,-1);
-
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),_("Enter
the program to run. "
- "It will receive the current file as parameter."));
+ priv->open_files_with_combobox =
gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->run_program_model));
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->open_files_with_combobox),
+ MISC_COMBO_TEXT);
+ gtk_box_pack_start (GTK_BOX (HBox), priv->open_files_with_combobox, TRUE,
+ TRUE, 0);
+ gtk_widget_set_size_request (GTK_WIDGET (priv->open_files_with_combobox),
+ 250, -1);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox))),
+ _("Enter the program to run. It will receive the current file as
parameter."));
/* History list */
- gtk_list_store_clear(RunProgramModel);
- Load_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
- g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"activate",
- G_CALLBACK(Run_Program_With_Selected_Files),G_OBJECT(RunProgramComboBox));
+ gtk_list_store_clear(priv->run_program_model);
+ Load_Run_Program_With_File_List(priv->run_program_model, MISC_COMBO_TEXT);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
+ "activate",
+ G_CALLBACK (Run_Program_With_Selected_Files),
+ self);
/* The button to Browse */
Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
gtk_box_pack_start(GTK_BOX(HBox),Button,FALSE,FALSE,0);
g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(RunProgramComboBox))));
+
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->open_files_with_combobox))));
/* Button to execute */
- Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramListWindow),
+ Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->open_files_with_dialog),
GTK_RESPONSE_OK);
- g_signal_connect_swapped(G_OBJECT(Button),"clicked",
G_CALLBACK(Run_Program_With_Selected_Files),G_OBJECT(RunProgramComboBox));
- g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+ g_signal_connect_swapped (Button, "clicked",
+ G_CALLBACK (Run_Program_With_Selected_Files),
+ self);
+ g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
"changed",
G_CALLBACK (empty_entry_disable_widget),
G_OBJECT (Button));
-
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",NULL);
-
- gtk_widget_show_all(RunProgramListWindow);
-}
+ g_signal_emit_by_name (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
+ "changed", NULL);
-static void
-Destroy_Run_Program_List_Window (void)
-{
- if (RunProgramListWindow)
- {
- gtk_widget_destroy(RunProgramListWindow);
- RunProgramListWindow = NULL;
- }
+ gtk_widget_show_all(priv->open_files_with_dialog);
}
static void
-Run_Program_With_Selected_Files (GtkWidget *combobox)
+Destroy_Run_Program_List_Window (EtBrowser *self)
{
- gchar *program_name;
- ET_File *ETFile;
- GList *selected_paths;
- GList *l;
- GList *args_list = NULL;
- GtkTreeIter iter;
- gboolean program_ran;
-
- if (!GTK_IS_COMBO_BOX(combobox) || !ETCore->ETFileDisplayedList)
- return;
-
- // Programe name to run
- program_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
+ EtBrowserPrivate *priv;
- // List of files to pass as parameters
- selected_paths =
gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)), NULL);
+ priv = et_browser_get_instance_private (self);
- for (l = selected_paths; l != NULL; l = g_list_next (l))
+ if (priv->open_files_with_dialog)
{
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fileListModel), &iter,
- (GtkTreePath *)l->data))
- {
- gtk_tree_model_get(GTK_TREE_MODEL(fileListModel), &iter,
- LIST_FILE_POINTER, &ETFile,
- -1);
-
- args_list = g_list_prepend (args_list,
- ((File_Name *)ETFile->FileNameCur->data)->value);
- //args_list = g_list_append(args_list,((File_Name *)ETFile->FileNameCur->data)->value_utf8);
- }
+ gtk_widget_hide (priv->open_files_with_dialog);
}
-
- args_list = g_list_reverse (args_list);
- program_ran = et_run_program (program_name, args_list);
-
- g_list_free_full (selected_paths, (GDestroyNotify)gtk_tree_path_free);
- g_list_free(args_list);
-
- if (program_ran)
- {
- // Append newest choice to the drop down list
- //gtk_list_store_prepend(GTK_LIST_STORE(RunProgramModel), &iter);
- //gtk_list_store_set(RunProgramModel, &iter, MISC_COMBO_TEXT, program_name, -1);
- Add_String_To_Combo_List(GTK_LIST_STORE(RunProgramModel), program_name);
-
- // Save list attached to the combobox
- Save_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
-
- Destroy_Run_Program_List_Window();
- }
- g_free(program_name);
}
/*
@@ -4281,14 +4597,18 @@ static void
et_rename_directory_on_response (GtkDialog *dialog, gint response_id,
gpointer user_data)
{
+ EtBrowser *self;
+
+ self = ET_BROWSER (user_data);
+
switch (response_id)
{
case GTK_RESPONSE_APPLY:
- Rename_Directory ();
+ Rename_Directory (self);
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
- Destroy_Rename_Directory_Window ();
+ Destroy_Rename_Directory_Window (self);
break;
default:
g_assert_not_reached ();
@@ -4307,6 +4627,10 @@ static void
et_run_program_tree_on_response (GtkDialog *dialog, gint response_id,
gpointer user_data)
{
+ EtBrowser *self;
+
+ self = ET_BROWSER (user_data);
+
switch (response_id)
{
case GTK_RESPONSE_OK:
@@ -4314,7 +4638,7 @@ et_run_program_tree_on_response (GtkDialog *dialog, gint response_id,
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
- Destroy_Run_Program_Tree_Window ();
+ Destroy_Run_Program_Tree_Window (self);
break;
default:
g_assert_not_reached ();
@@ -4332,6 +4656,10 @@ static void
et_run_program_list_on_response (GtkDialog *dialog, gint response_id,
gpointer user_data)
{
+ EtBrowser *self;
+
+ self = ET_BROWSER (user_data);
+
switch (response_id)
{
case GTK_RESPONSE_OK:
@@ -4339,7 +4667,7 @@ et_run_program_list_on_response (GtkDialog *dialog, gint response_id,
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
- Destroy_Run_Program_List_Window ();
+ Destroy_Run_Program_List_Window (self);
break;
default:
g_assert_not_reached ();
@@ -4374,3 +4702,54 @@ get_column_for_column_id (gint column_id)
{
return gtk_tree_view_get_column (GTK_TREE_VIEW (BrowserList), column_id);
}
+
+static void
+et_browser_finalize (GObject *object)
+{
+ EtBrowserPrivate *priv;
+
+ priv = et_browser_get_instance_private (ET_BROWSER (object));
+
+ /* Save combobox history list before exit. */
+ Save_Path_Entry_List (priv->entry_model, MISC_COMBO_TEXT);
+
+ G_OBJECT_CLASS (et_browser_parent_class)->finalize (object);
+}
+
+static void
+et_browser_init (EtBrowser *self)
+{
+ EtBrowserPrivate *priv;
+
+ priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_BROWSER,
+ EtBrowserPrivate);
+
+ priv->open_directory_with_dialog = NULL;
+ priv->open_directory_with_combobox = NULL;
+ priv->open_files_with_dialog = NULL;
+ priv->open_files_with_combobox = NULL;
+
+ create_browser (self);
+}
+
+static void
+et_browser_class_init (EtBrowserClass *klass)
+{
+ G_OBJECT_CLASS (klass)->finalize = et_browser_finalize;
+
+ g_type_class_add_private (klass, sizeof (EtBrowserPrivate));
+}
+
+/*
+ * et_browser_new:
+ *
+ * Create a new EtBrowser instance.
+ *
+ * Returns: a new #EtBrowser
+ */
+EtBrowser *
+et_browser_new (void)
+{
+ return g_object_new (ET_TYPE_BROWSER, "orientation",
+ GTK_ORIENTATION_VERTICAL, NULL);
+}
diff --git a/src/browser.h b/src/browser.h
index 5965379..fb37070 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -1,4 +1,3 @@
-/* browser.h - 2000/04/28 */
/*
* EasyTAG - Tag editor for MP3 and Ogg Vorbis files
* Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
@@ -19,37 +18,40 @@
*/
-#ifndef __BROWSER_H__
-#define __BROWSER_H__
+#ifndef ET_BROWSER_H_
+#define ET_BROWSER_H_
#include "et_core.h"
+#include <gtk/gtk.h>
-/****************
- * Declarations *
- ****************/
+G_BEGIN_DECLS
-/*
- * Data attached to each row of the artist list
- */
-#if 0
-typedef struct _ArtistRow ArtistRow;
-struct _ArtistRow
+#define ET_TYPE_BROWSER (et_browser_get_type ())
+#define ET_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_BROWSER, EtBrowser))
+
+typedef struct _EtBrowser EtBrowser;
+typedef struct _EtBrowserClass EtBrowserClass;
+typedef struct _EtBrowserPrivate EtBrowserPrivate;
+
+struct _EtBrowser
{
- GList *AlbumList; // It's a list of AlbumList items...
+ /*< private >*/
+ GtkBox parent_instance;
+ EtBrowserPrivate *priv;
};
-#endif
-/*
- * Data attached to each row of the artist list
- */
-#if 0
-typedef struct _AlbumRow AlbumRow;
-struct _AlbumRow
+struct _EtBrowserClass
{
- GList *ETFileList; // It's a list of ETFile items...
+ /*< private >*/
+ GtkBoxClass parent_class;
};
-#endif
+
+GType et_browser_get_type (void);
+EtBrowser *et_browser_new (void);
+void et_browser_show_open_directory_with_dialog (EtBrowser *self);
+void et_browser_show_open_files_with_dialog (EtBrowser *self);
+void et_browser_show_rename_directory_dialog (EtBrowser *self);
/*
* To number columns of ComboBox
@@ -61,132 +63,54 @@ enum
};
-enum
-{
- TREE_COLUMN_DIR_NAME,
- TREE_COLUMN_FULL_PATH,
- TREE_COLUMN_SCANNED,
- TREE_COLUMN_HAS_SUBDIR,
- TREE_COLUMN_ICON,
- TREE_COLUMN_COUNT
-};
-
-enum
-{
- LIST_FILE_NAME,
- /* Tag fields. */
- LIST_FILE_TITLE,
- LIST_FILE_ARTIST,
- LIST_FILE_ALBUM_ARTIST,
- LIST_FILE_ALBUM,
- LIST_FILE_YEAR,
- LIST_FILE_DISCNO,
- LIST_FILE_TRACK,
- LIST_FILE_GENRE,
- LIST_FILE_COMMENT,
- LIST_FILE_COMPOSER,
- LIST_FILE_ORIG_ARTIST,
- LIST_FILE_COPYRIGHT,
- LIST_FILE_URL,
- LIST_FILE_ENCODED_BY,
- /* End of columns with associated UI columns. */
- LIST_FILE_POINTER,
- LIST_FILE_KEY,
- LIST_FILE_OTHERDIR, /* To change color for alternate directories. */
- LIST_FONT_WEIGHT,
- LIST_ROW_BACKGROUND,
- LIST_ROW_FOREGROUND,
- LIST_COLUMN_COUNT
-};
-
-enum
-{
- ARTIST_PIXBUF,
- ARTIST_NAME,
- ARTIST_NUM_ALBUMS,
- ARTIST_NUM_FILES,
- ARTIST_ALBUM_LIST_POINTER,
- ARTIST_FONT_STYLE,
- ARTIST_FONT_WEIGHT,
- ARTIST_ROW_FOREGROUND,
- ARTIST_COLUMN_COUNT
-};
-
-enum
-{
- ALBUM_GICON,
- ALBUM_NAME,
- ALBUM_NUM_FILES,
- ALBUM_ETFILE_LIST_POINTER,
- ALBUM_FONT_STYLE,
- ALBUM_FONT_WEIGHT,
- ALBUM_ROW_FOREGROUND,
- ALBUM_COLUMN_COUNT
-};
-
-
GtkWidget *BrowserList;
-GtkWidget *BrowserAlbumList;
-GtkWidget *BrowserArtistList;
-GtkWidget *BrowserEntryCombo;
-GtkListStore *BrowserEntryModel;
-GtkWidget *BrowserHPaned;
-GtkWidget *ArtistAlbumVPaned;
-
-GtkWidget *RenameDirectoryWindow;
-GtkWidget *RenameDirectoryMaskCombo;
-GtkWidget *RenameDirectoryPreviewLabel;
-/**************
- * Prototypes *
- **************/
+void et_browser_select_dir (EtBrowser *self, const gchar *current_path);
+void et_browser_reload (EtBrowser *self);
+void et_browser_collapse (EtBrowser *self);
+void et_browser_set_sensitive (EtBrowser *self, gboolean sensitive);
-GtkWidget *Create_Browser_Items (GtkWidget *parent);
-gboolean Browser_Tree_Select_Dir (const gchar *current_path);
-void Browser_Tree_Rebuild (gchar *path_to_load);
-void Browser_Tree_Collapse (void);
-
-void Browser_List_Load_File_List (GList *etfilelist, ET_File *etfile_to_select);
-void Browser_List_Refresh_Whole_List (void);
+void et_browser_load_file_list (EtBrowser *self, GList *etfilelist, ET_File *etfile_to_select);
+void et_browser_refresh_list (EtBrowser *self);
void Browser_List_Refresh_File_In_List (ET_File *ETFile);
-void Browser_List_Clear (void);
+void et_browser_clear (EtBrowser *self);
void Browser_List_Select_File_By_Etfile (ET_File *ETFile, gboolean select_it);
GtkTreePath *Browser_List_Select_File_By_Etfile2 (ET_File *searchETFile, gboolean select_it, GtkTreePath
*startPath);
ET_File *Browser_List_Select_File_By_Iter_String(const gchar* stringiter, gboolean select_it);
-ET_File *Browser_List_Select_File_By_DLM (const gchar* string, gboolean select_it);
+ET_File *et_browser_select_file_by_dlm (EtBrowser *self, const gchar* string, gboolean select_it);
void Browser_List_Refresh_Sort (void);
-void Browser_List_Select_All_Files (void);
-void Browser_List_Unselect_All_Files (void);
-void Browser_List_Invert_File_Selection (void);
-void Browser_List_Remove_File (ET_File *ETFile);
+void et_browser_select_all (EtBrowser *self);
+void et_browser_unselect_all (EtBrowser *self);
+void et_browser_invert_selection (EtBrowser *self);
+void et_browser_remove_file (EtBrowser *self, ET_File *ETFile);
ET_File *Browser_List_Get_ETFile_From_Path (GtkTreePath *path);
ET_File *Browser_List_Get_ETFile_From_Iter (GtkTreeIter *iter);
void Browser_Entry_Set_Text (gchar *text);
void Browser_Label_Set_Text (gchar *text);
-void Browser_Display_Tree_Or_Artist_Album_List (void);
-
-void Browser_Area_Set_Sensitive (gboolean activate);
+void et_browser_toggle_display_mode (EtBrowser *self);
-void Browser_Load_Home_Directory (void);
-void Browser_Load_Desktop_Directory (void);
-void Browser_Load_Documents_Directory (void);
-void Browser_Load_Downloads_Directory (void);
-void Browser_Load_Music_Directory (void);
-void et_browser_on_action_parent_directory (void);
+void et_browser_go_home (EtBrowser *self);
+void et_browser_go_desktop (EtBrowser *self);
+void et_browser_go_documents (EtBrowser *self);
+void et_browser_go_download (EtBrowser *self);
+void et_browser_go_music (EtBrowser *self);
+void et_browser_go_parent (EtBrowser *self);
-void Browser_Load_Default_Directory (void);
-void Browser_Reload_Directory (void);
-void Set_Current_Path_As_Default (void);
-gchar *Browser_Get_Current_Path (void);
+void et_browser_run_player_for_album_list (EtBrowser *self);
+void et_browser_run_player_for_artist_list (EtBrowser *self);
+void et_browser_run_player_for_selection (EtBrowser *self);
-void Browser_Open_Rename_Directory_Window (void);
-void Browser_Open_Run_Program_Tree_Window (void);
-void Browser_Open_Run_Program_List_Window (void);
+void et_browser_load_default_dir (EtBrowser *self);
+void et_browser_reload_directory (EtBrowser *self);
+void et_browser_set_current_path_default (EtBrowser *self);
+const gchar * et_browser_get_current_path (EtBrowser *self);
GtkTreeViewColumn *get_column_for_column_id (gint column_id);
GtkSortType get_sort_order_for_column_id (gint column_id);
-#endif /* __BROWSER_H__ */
+G_END_DECLS
+
+#endif /* ET_BROWSER_H_ */
diff --git a/src/cddb_dialog.c b/src/cddb_dialog.c
index 2044fac..bd6bd54 100644
--- a/src/cddb_dialog.c
+++ b/src/cddb_dialog.c
@@ -612,8 +612,8 @@ Cddb_Track_List_Row_Selected (EtCDDBDialog *self, GtkTreeSelection *selection)
return;
}
- // Unselect files in the main list before re-selecting them...
- Browser_List_Unselect_All_Files();
+ /* Unselect files in the main list before re-selecting them... */
+ et_application_window_browser_unselect_all (ET_APPLICATION_WINDOW (MainWindow));
for (l = selectedRows; l != NULL; l = g_list_next (l))
{
@@ -629,7 +629,9 @@ Cddb_Track_List_Row_Selected (EtCDDBDialog *self, GtkTreeSelection *selection)
gtk_tree_model_get(GTK_TREE_MODEL(priv->track_list_model), ¤tFile,
CDDB_TRACK_LIST_NAME, &text_path,
CDDB_TRACK_LIST_ETFILE, &etfile, -1);
- *etfile = Browser_List_Select_File_By_DLM(text_path, TRUE);
+ *etfile = et_application_window_browser_select_file_by_dlm (ET_APPLICATION_WINDOW
(MainWindow),
+ text_path,
+ TRUE);
} else
{
text_path = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(priv->track_list_model),
¤tFile);
@@ -2717,7 +2719,7 @@ Cddb_Set_Track_Infos_To_File_List (EtCDDBDialog *self)
g_list_free_full (file_iterlist, (GDestroyNotify)g_free);
- Browser_List_Refresh_Whole_List();
+ et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
return TRUE;
diff --git a/src/easytag.c b/src/easytag.c
index dc9b578..3eeef24 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -73,10 +73,6 @@ static gint SF_ButtonPressed_Write_Tag;
static gboolean SF_HideMsgbox_Rename_File;
/* To remember which button was pressed when renaming file */
static gint SF_ButtonPressed_Rename_File;
-/* Used to force to hide the msgbox when deleting file */
-static gboolean SF_HideMsgbox_Delete_File;
-/* To remember which button was pressed when deleting file */
-static gint SF_ButtonPressed_Delete_File;
#ifdef ENABLE_FLAC
#include <FLAC/metadata.h>
@@ -89,12 +85,9 @@ static gint SF_ButtonPressed_Delete_File;
static gboolean Write_File_Tag (ET_File *ETFile, gboolean hide_msgbox);
static gint Save_File (ET_File *ETFile, gboolean multiple_files,
gboolean force_saving_files);
-static gint delete_file (ET_File *ETFile, gboolean multiple_files,
- GError **error);
static gint Save_Selected_Files_With_Answer (gboolean force_saving_files);
static gint Save_List_Of_Files (GList *etfilelist,
gboolean force_saving_files);
-static gint Delete_Selected_Files_With_Answer (void);
static void Init_Load_Default_Dir (void);
static void EasyTAG_Exit (void);
@@ -134,7 +127,6 @@ common_init (GApplication *application)
Main_Stop_Button_Pressed = FALSE;
Init_Custom_Icons();
Init_Mouse_Cursor();
- BrowserEntryModel = NULL;
TrackEntryComboModel = NULL;
GenreComboModel = NULL;
@@ -307,7 +299,7 @@ on_application_open (GApplication *application, GFile **files, gint n_files,
case G_FILE_TYPE_DIRECTORY:
if (activated)
{
- Browser_Tree_Select_Dir (path);
+ et_application_window_select_dir (windows->data, path);
g_free (path);
}
else
@@ -332,7 +324,8 @@ on_application_open (GApplication *application, GFile **files, gint n_files,
gchar *parent_path;
parent_path = g_file_get_path (arg);
- Browser_Tree_Select_Dir (parent_path);
+ et_application_window_select_dir (windows->data,
+ parent_path);
g_free (parent_path);
}
@@ -434,18 +427,6 @@ int main (int argc, char *argv[])
}
/*
- * Action when inverting files selection
- */
-void Action_Invert_Files_Selection (void)
-{
- /* Save the current displayed data */
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- Browser_List_Invert_File_Selection();
- Update_Command_Buttons_Sensivity();
-}
-
-/*
* Select a file in the "main list" using the ETFile adress of each item.
*/
void Action_Select_Nth_File_By_Etfile (ET_File *ETFile)
@@ -465,105 +446,6 @@ void Action_Select_Nth_File_By_Etfile (ET_File *ETFile)
et_scan_dialog_update_previews (ET_SCAN_DIALOG (et_application_window_get_scan_dialog
(ET_APPLICATION_WINDOW (MainWindow))));
}
-/*
- * Action when Remove button is pressed
- */
-void Action_Remove_Selected_Tags (void)
-{
- GList *selfilelist = NULL;
- GList *l;
- ET_File *etfile;
- File_Tag *FileTag;
- gint progress_bar_index;
- gint selectcount;
- double fraction;
- GtkTreeSelection *selection;
-
- g_return_if_fail (ETCore->ETFileDisplayedList != NULL ||
- BrowserList != NULL);
-
- /* 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);
- selectcount =
gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)));
- progress_bar_index = 0;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
- selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
-
- for (l = selfilelist; l != NULL; l = g_list_next (l))
- {
- etfile = Browser_List_Get_ETFile_From_Path (l->data);
- FileTag = ET_File_Tag_Item_New();
- ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
-
- fraction = (++progress_bar_index) / (double) selectcount;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
- /* Needed to refresh status bar */
- while (gtk_events_pending())
- gtk_main_iteration();
- }
-
- g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
-
- // Refresh the whole list (faster than file by file) to show changes
- Browser_List_Refresh_Whole_List();
-
- /* Display the current file */
- ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
- Update_Command_Buttons_Sensivity();
-
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
- Statusbar_Message(_("All tags have been removed"),TRUE);
-}
-
-
-
-/*
- * Action when Undo button is pressed.
- * Action_Undo_Selected_Files: Undo the last changes for the selected files.
- * Action_Undo_From_History_List: Undo the changes of the last modified file of the list.
- */
-gint Action_Undo_Selected_Files (void)
-{
- GList *selfilelist = NULL;
- GList *l;
- gboolean state = FALSE;
- ET_File *etfile;
- GtkTreeSelection *selection;
-
- g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
- BrowserList != NULL, FALSE);
-
- /* Save the current displayed data */
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
- selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
-
- for (l = selfilelist; l != NULL; l = g_list_next (l))
- {
- etfile = Browser_List_Get_ETFile_From_Path (l->data);
- state |= ET_Undo_File_Data(etfile);
- }
-
- g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
-
- // Refresh the whole list (faster than file by file) to show changes
- Browser_List_Refresh_Whole_List();
-
- /* Display the current file */
- ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
- Update_Command_Buttons_Sensivity();
-
- //ET_Debug_Print_File_List(ETCore->ETFileList,__FILE__,__LINE__,__FUNCTION__);
-
- return state;
-}
-
-
void Action_Undo_From_History_List (void)
{
ET_File *ETFile;
@@ -586,47 +468,6 @@ void Action_Undo_From_History_List (void)
-/*
- * Action when Redo button is pressed.
- * Action_Redo_Selected_Files: Redo the last changes for the selected files.
- * Action_Redo_From_History_List: Redo the changes of the last modified file of the list.
- */
-gint Action_Redo_Selected_File (void)
-{
- GList *selfilelist = NULL;
- GList *l;
- gboolean state = FALSE;
- ET_File *etfile;
- GtkTreeSelection *selection;
-
- g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL ||
- BrowserList != NULL, FALSE);
-
- /* Save the current displayed data */
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
- selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
-
- for (l = selfilelist; l != NULL; l = g_list_next (l))
- {
- etfile = Browser_List_Get_ETFile_From_Path (l->data);
- state |= ET_Redo_File_Data(etfile);
- }
-
- g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
-
- // Refresh the whole list (faster than file by file) to show changes
- Browser_List_Refresh_Whole_List();
-
- /* Display the current file */
- ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
- Update_Command_Buttons_Sensivity();
-
- return state;
-}
-
-
void Action_Redo_From_History_List (void)
{
ET_File *ETFile;
@@ -648,8 +489,6 @@ void Action_Redo_From_History_List (void)
}
-
-
/*
* Action when Save button is pressed
*/
@@ -799,7 +638,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
/* Set to unsensitive all command buttons (except Quit button) */
Disable_Command_Buttons();
- Browser_Area_Set_Sensitive(FALSE);
+ et_application_window_browser_set_sensitive (window, FALSE);
et_application_window_tag_area_set_sensitive (window, FALSE);
et_application_window_file_area_set_sensitive (window, FALSE);
@@ -890,7 +729,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
Statusbar_Message (_("Saving files was stopped"), TRUE);
/* To update state of command buttons */
Update_Command_Buttons_Sensivity();
- Browser_Area_Set_Sensitive(TRUE);
+ 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);
@@ -923,11 +762,11 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
toggle_radio = gtk_ui_manager_get_widget (UIManager,
"/ToolBar/ArtistViewMode");
if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (toggle_radio)))
- Browser_Display_Tree_Or_Artist_Album_List();
+ et_application_window_browser_toggle_display_mode (window);
/* To update state of command buttons */
Update_Command_Buttons_Sensivity();
- Browser_Area_Set_Sensitive(TRUE);
+ 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);
@@ -938,162 +777,7 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
Statusbar_Message(msg,TRUE);
g_free(msg);
- Browser_List_Refresh_Whole_List();
- return TRUE;
-}
-
-
-
-/*
- * Delete a file on the hard disk
- */
-void Action_Delete_Selected_Files (void)
-{
- Delete_Selected_Files_With_Answer();
-}
-
-
-static gint
-Delete_Selected_Files_With_Answer (void)
-{
- EtApplicationWindow *window;
- GList *selfilelist;
- GList *rowreflist = NULL;
- GList *l;
- gint progress_bar_index;
- gint saving_answer;
- gint nb_files_to_delete;
- gint nb_files_deleted = 0;
- gchar *msg;
- gchar progress_bar_text[30];
- double fraction;
- GtkTreeModel *treemodel;
- GtkTreeRowReference *rowref;
- GtkTreeSelection *selection;
- GError *error = NULL;
-
- g_return_val_if_fail (ETCore->ETFileDisplayedList != NULL
- && BrowserList != NULL, FALSE);
-
- window = ET_APPLICATION_WINDOW (MainWindow);
-
- /* Save the current displayed data */
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- /* Number of files to save */
- nb_files_to_delete =
gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)));
-
- /* Initialize status bar */
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar),0);
- progress_bar_index = 0;
- g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_delete);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
-
- /* Set to unsensitive all command buttons (except Quit button) */
- Disable_Command_Buttons();
- Browser_Area_Set_Sensitive(FALSE);
- et_application_window_tag_area_set_sensitive (window, FALSE);
- et_application_window_file_area_set_sensitive (window, FALSE);
-
- /* Show msgbox (if needed) to ask confirmation */
- SF_HideMsgbox_Delete_File = 0;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
- selfilelist = gtk_tree_selection_get_selected_rows(selection, &treemodel);
-
- for (l = selfilelist; l != NULL; l = g_list_next (l))
- {
- rowref = gtk_tree_row_reference_new (treemodel, l->data);
- rowreflist = g_list_prepend (rowreflist, rowref);
- }
-
- g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
- rowreflist = g_list_reverse (rowreflist);
-
- for (l = rowreflist; l != NULL; l = g_list_next (l))
- {
- GtkTreePath *path;
- ET_File *ETFile;
-
- path = gtk_tree_row_reference_get_path (l->data);
- ETFile = Browser_List_Get_ETFile_From_Path(path);
- gtk_tree_path_free(path);
-
- ET_Display_File_Data_To_UI(ETFile);
- Browser_List_Select_File_By_Etfile(ETFile,FALSE);
- fraction = (++progress_bar_index) / (double) nb_files_to_delete;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), fraction);
- g_snprintf(progress_bar_text, 30, "%d/%d", progress_bar_index, nb_files_to_delete);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), progress_bar_text);
- /* Needed to refresh status bar */
- while (gtk_events_pending())
- gtk_main_iteration();
-
- saving_answer = delete_file (ETFile,
- nb_files_to_delete > 1 ? TRUE : FALSE,
- &error);
-
- switch (saving_answer)
- {
- case 1:
- nb_files_deleted += saving_answer;
- // Remove file in the browser (corresponding line in the clist)
- Browser_List_Remove_File(ETFile);
- // Remove file from file list
- ET_Remove_File_From_File_List(ETFile);
- break;
- case 0:
- /* Distinguish between the file being skipped, and there being
- * an error during deletion. */
- if (error)
- {
- Log_Print (LOG_ERROR, _("Cannot delete file (%s)"),
- error->message);
- g_clear_error (&error);
- }
- break;
- 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();
- Browser_Area_Set_Sensitive(TRUE);
- et_application_window_tag_area_set_sensitive (window, TRUE);
- et_application_window_file_area_set_sensitive (window, TRUE);
-
- return -1; // We stop all actions
- }
- }
-
- g_list_free_full (rowreflist, (GDestroyNotify)gtk_tree_row_reference_free);
-
- if (nb_files_deleted < nb_files_to_delete)
- msg = g_strdup (_("Files have been partially deleted"));
- else
- msg = g_strdup (_("All files have been deleted"));
-
- // It's important to displayed the new item, as it'll check the changes in
Browser_Display_Tree_Or_Artist_Album_List
- if (ETCore->ETFileDisplayed)
- ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
- /*else if (ET_Displayed_File_List_Current())
- ET_Display_File_Data_To_UI((ET_File *)ET_Displayed_File_List_Current()->data);*/
-
- // Load list...
- Browser_List_Load_File_List(ETCore->ETFileDisplayedList, NULL);
- // Rebuild the list...
- Browser_Display_Tree_Or_Artist_Album_List();
-
- /* To update state of command buttons */
- Update_Command_Buttons_Sensivity();
- Browser_Area_Set_Sensitive(TRUE);
- et_application_window_tag_area_set_sensitive (window, TRUE);
- et_application_window_file_area_set_sensitive (window, TRUE);
-
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ProgressBar), "");
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0);
- Statusbar_Message(msg,TRUE);
- g_free(msg);
-
+ et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
return TRUE;
}
@@ -1540,124 +1224,6 @@ Write_File_Tag (ET_File *ETFile, gboolean hide_msgbox)
}
/*
- * Delete the file ETFile
- */
-static gint
-delete_file (ET_File *ETFile, gboolean multiple_files, GError **error)
-{
- GtkWidget *msgdialog;
- GtkWidget *msgdialog_check_button = NULL;
- gchar *cur_filename;
- gchar *cur_filename_utf8;
- gchar *basename_utf8;
- gint response;
- gint stop_loop;
-
- g_return_val_if_fail (ETFile != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* Filename of the file to delete. */
- cur_filename = ((File_Name *)(ETFile->FileNameCur)->data)->value;
- cur_filename_utf8 = ((File_Name *)(ETFile->FileNameCur)->data)->value_utf8;
- basename_utf8 = g_path_get_basename (cur_filename_utf8);
-
- /*
- * Remove the file
- */
- if (CONFIRM_DELETE_FILE && !SF_HideMsgbox_Delete_File)
- {
- if (multiple_files)
- {
- GtkWidget *message_area;
- msgdialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("Do you really want to delete the file '%s'?"),
- basename_utf8);
- message_area = gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(msgdialog));
- msgdialog_check_button = gtk_check_button_new_with_label(_("Repeat action for the remaining
files"));
- gtk_container_add(GTK_CONTAINER(message_area),msgdialog_check_button);
-
gtk_dialog_add_buttons(GTK_DIALOG(msgdialog),GTK_STOCK_NO,GTK_RESPONSE_NO,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_DELETE,GTK_RESPONSE_YES,NULL);
- gtk_window_set_title(GTK_WINDOW(msgdialog),_("Delete File"));
- //GTK_TOGGLE_BUTTON(msgbox_check_button)->active = TRUE; // Checked by default
- }else
- {
- msgdialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("Do you really want to delete the file '%s'?"),
- basename_utf8);
- gtk_window_set_title(GTK_WINDOW(msgdialog),_("Delete File"));
-
gtk_dialog_add_buttons(GTK_DIALOG(msgdialog),GTK_STOCK_CANCEL,GTK_RESPONSE_NO,GTK_STOCK_DELETE,GTK_RESPONSE_YES,NULL);
- }
- gtk_dialog_set_default_response (GTK_DIALOG (msgdialog),
- GTK_RESPONSE_YES);
- SF_ButtonPressed_Delete_File = response = gtk_dialog_run(GTK_DIALOG(msgdialog));
- if (msgdialog_check_button &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msgdialog_check_button)))
- SF_HideMsgbox_Delete_File =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msgdialog_check_button));
- gtk_widget_destroy(msgdialog);
- }else
- {
- if (SF_HideMsgbox_Delete_File)
- response = SF_ButtonPressed_Delete_File;
- else
- response = GTK_RESPONSE_YES;
- }
-
- switch (response)
- {
- case GTK_RESPONSE_YES:
- {
- GFile *cur_file = g_file_new_for_path (cur_filename);
-
- if (g_file_delete (cur_file, NULL, error))
- {
- gchar *msg = g_strdup_printf(_("File '%s' deleted"), basename_utf8);
- Statusbar_Message(msg,FALSE);
- g_free(msg);
- g_free(basename_utf8);
- g_object_unref (cur_file);
- g_assert (error == NULL || *error == NULL);
- return 1;
- }
-
- /* Error in deleting file. */
- g_assert (error == NULL || *error != NULL);
- break;
- }
- case GTK_RESPONSE_NO:
- break;
- case GTK_RESPONSE_CANCEL:
- case GTK_RESPONSE_DELETE_EVENT:
- stop_loop = -1;
- g_free(basename_utf8);
- return stop_loop;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- g_free(basename_utf8);
- return 0;
-}
-
-void
-Action_Select_Browser_Style (void)
-{
- g_return_if_fail (ETCore->ETFileDisplayedList != NULL);
-
- /* Save the current displayed data */
- ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed);
-
- Browser_Display_Tree_Or_Artist_Album_List();
-
- Update_Command_Buttons_Sensivity();
-}
-
-/*
* Scans the specified directory: and load files into a list.
* If the path doesn't exist, we free the previous loaded list of files.
*/
@@ -1679,6 +1245,7 @@ gboolean Read_Directory (gchar *path_real)
gint progress_bar_index = 0;
GtkAction *uiaction;
GtkWidget *artist_radio;
+ EtApplicationWindow *window;
g_return_val_if_fail (path_real != NULL, FALSE);
@@ -1689,8 +1256,10 @@ gboolean Read_Directory (gchar *path_real)
ET_Core_Initialize();
Update_Command_Buttons_Sensivity();
+ window = ET_APPLICATION_WINDOW (MainWindow);
+
/* Initialize browser list */
- Browser_List_Clear();
+ et_application_window_browser_clear (window);
/* Clear entry boxes */
Clear_File_Entry_Field();
@@ -1701,10 +1270,9 @@ gboolean Read_Directory (gchar *path_real)
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
- Browser_Area_Set_Sensitive(FALSE);
+ et_application_window_browser_set_sensitive (window, FALSE);
/* Placed only here, to empty the previous list of files */
dir = g_file_new_for_path (path_real);
@@ -1735,7 +1303,7 @@ gboolean Read_Directory (gchar *path_real)
g_free(path_utf8);
ReadingDirectory = FALSE; //Allow a new reading
- Browser_Area_Set_Sensitive(TRUE);
+ et_application_window_browser_set_sensitive (window, TRUE);
g_object_unref (dir);
g_error_free (error);
return FALSE;
@@ -1805,7 +1373,7 @@ gboolean Read_Directory (gchar *path_real)
{
//GList *etfilelist;
/* Load the list of file into the browser list widget */
- Browser_Display_Tree_Or_Artist_Album_List();
+ et_application_window_browser_toggle_display_mode (window);
/* Load the list attached to the TrackEntry */
Load_Track_List_To_UI();
@@ -1859,7 +1427,7 @@ gboolean Read_Directory (gchar *path_real)
/* Update sensitivity of buttons and menus */
Update_Command_Buttons_Sensivity();
- Browser_Area_Set_Sensitive(TRUE);
+ et_application_window_browser_set_sensitive (window, TRUE);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ProgressBar), 0.0);
Statusbar_Message(msg,FALSE);
@@ -2361,12 +1929,14 @@ Init_Load_Default_Dir (void)
if (INIT_DIRECTORY)
{
- Browser_Tree_Select_Dir(INIT_DIRECTORY);
+ et_application_window_select_dir (ET_APPLICATION_WINDOW (MainWindow),
+ INIT_DIRECTORY);
}
else
{
Statusbar_Message(_("Select a directory to browse"),FALSE);
- Browser_Load_Default_Directory();
+ et_application_window_load_default_dir (NULL,
+ ET_APPLICATION_WINDOW (MainWindow));
}
// To set sensivity of buttons in the case if the default directory is invalid
@@ -2418,9 +1988,6 @@ void Quit_MainWindow (void)
if (ETCore->ETFileList)
ET_Save_File_Data_From_UI(ETCore->ETFileDisplayed); // To detect change before exiting
- /* Save combobox history list before exit */
- Save_Path_Entry_List(BrowserEntryModel, MISC_COMBO_TEXT);
-
/* Check if all files have been saved before exit */
if (CONFIRM_WHEN_UNSAVED_FILES && ET_Check_If_All_Files_Are_Saved() != TRUE)
{
diff --git a/src/easytag.h b/src/easytag.h
index f13befb..0eabd80 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -106,8 +106,6 @@ void Action_Invert_Files_Selection (void);
void Action_Select_Nth_File_By_Position (gulong num_item);
void Action_Select_Nth_File_By_Etfile (ET_File *ETFile);
-void Action_Remove_Selected_Tags (void);
-gint Action_Undo_Selected_Files (void);
gint Action_Redo_Selected_File (void);
void Action_Undo_All_Files (void);
void Action_Redo_All_Files (void);
@@ -115,7 +113,7 @@ void Action_Save_Selected_Files (void);
void Action_Force_Saving_Selected_Files (void);
void Action_Undo_From_History_List (void);
void Action_Redo_From_History_List (void);
-void Action_Delete_Selected_Files (void);
+gint et_delete_file (ET_File *ETFile, gboolean multiple_files, GError **error);
gint Save_All_Files_With_Answer (gboolean force_saving_files);
void Action_Main_Stop_Button_Pressed (void);
diff --git a/src/load_files_dialog.c b/src/load_files_dialog.c
index 4e70cd6..906088d 100644
--- a/src/load_files_dialog.c
+++ b/src/load_files_dialog.c
@@ -155,7 +155,7 @@ Load_Filename_Set_Filenames (EtLoadFilesDialog *self)
gtk_tree_path_free(currentPath);
- Browser_List_Refresh_Whole_List();
+ et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
}
@@ -830,7 +830,7 @@ create_load_files_dialog (EtLoadFilesDialog *self)
GtkWidget *loadedvbox;
GtkWidget *filelistvbox;
GtkWidget *vboxpaned;
- gchar *path;
+ const gchar *path;
GtkCellRenderer* renderer;
GtkTreeViewColumn* column;
@@ -871,7 +871,7 @@ create_load_files_dialog (EtLoadFilesDialog *self)
// History List
Load_File_To_Load_List(priv->file_to_load_model, MISC_COMBO_TEXT);
// Initial value
- if ((path=Browser_Get_Current_Path())!=NULL)
+ if ((path = et_application_window_get_current_path (ET_APPLICATION_WINDOW (MainWindow))) != NULL)
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->file_to_load_combo))),path);
// the 'changed' signal is attached below to enable/disable the button to load
// Button 'browse'
diff --git a/src/misc.c b/src/misc.c
index 5c7ab71..ac0f7e2 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -752,96 +752,6 @@ void Run_Audio_Player_Using_Directory (void)
g_list_free (path_list);
}
-void Run_Audio_Player_Using_Selection (void)
-{
- GList *selfilelist = NULL;
- GList *l;
- GList *path_list = NULL;
- GtkTreeSelection *selection;
-
- g_return_if_fail (BrowserList != NULL);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList));
- selfilelist = gtk_tree_selection_get_selected_rows(selection, NULL);
-
- for (l = selfilelist; l != NULL; l = g_list_next (l))
- {
- ET_File *etfile = Browser_List_Get_ETFile_From_Path (l->data);
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
- path_list = g_list_prepend (path_list, path);
- }
-
- path_list = g_list_reverse (path_list);
-
- et_run_program (AUDIO_FILE_PLAYER, path_list);
- g_list_free (path_list);
- g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
-}
-
-void Run_Audio_Player_Using_Browser_Artist_List (void)
-{
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkTreeModel *artistListModel;
- GList *l, *m;
- GList *path_list = NULL;
-
- g_return_if_fail (BrowserArtistList != NULL);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserArtistList));
- if (!gtk_tree_selection_get_selected(selection, &artistListModel, &iter))
- return;
-
- gtk_tree_model_get (artistListModel, &iter, ARTIST_ALBUM_LIST_POINTER, &l,
- -1);
-
- for (; l != NULL; l = g_list_next (l))
- {
- for (m = l->data; m != NULL; m = g_list_next (m))
- {
- ET_File *etfile = (ET_File *)m->data;
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
- path_list = g_list_prepend (path_list, path);
- }
- }
-
- path_list = g_list_reverse (path_list);
-
- et_run_program (AUDIO_FILE_PLAYER, path_list);
- g_list_free (path_list);
-}
-
-void Run_Audio_Player_Using_Browser_Album_List (void)
-{
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkTreeModel *albumListModel;
- GList *l;
- GList *path_list = NULL;
-
- g_return_if_fail (BrowserAlbumList != NULL);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserAlbumList));
- if (!gtk_tree_selection_get_selected(selection, &albumListModel, &iter))
- return;
-
- gtk_tree_model_get (albumListModel, &iter, ALBUM_ETFILE_LIST_POINTER, &l,
- -1);
-
- for (; l != NULL; l = g_list_next (l))
- {
- ET_File *etfile = (ET_File *)l->data;
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
- path_list = g_list_prepend (path_list, path);
- }
-
- path_list = g_list_reverse (path_list);
-
- et_run_program (AUDIO_FILE_PLAYER, path_list);
- g_list_free (path_list);
-}
-
-
/*
* Check if the executable passed in parameter can be launched
* Returns the full path of the file (must be freed if not used)
diff --git a/src/misc.h b/src/misc.h
index 6526a9f..ec4496f 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -62,9 +62,6 @@ void Set_Unbusy_Cursor (void);
// Run Audio Player
void Run_Audio_Player_Using_Directory (void);
-void Run_Audio_Player_Using_Selection (void);
-void Run_Audio_Player_Using_Browser_Artist_List (void);
-void Run_Audio_Player_Using_Browser_Album_List (void);
gchar *Convert_Duration (gulong duration);
diff --git a/src/playlist_dialog.c b/src/playlist_dialog.c
index 31c2eb5..036b44b 100644
--- a/src/playlist_dialog.c
+++ b/src/playlist_dialog.c
@@ -22,6 +22,7 @@
#include <glib/gi18n.h>
+#include "application_window.h"
#include "bar.h"
#include "browser.h"
#include "charset.h"
@@ -422,7 +423,7 @@ write_button_clicked (EtPlaylistDialog *self)
et_playlist_dialog_apply_changes (self);
// Path of the playlist file (may be truncated later if PLAYLIST_CREATE_IN_PARENT_DIR is TRUE)
- playlist_path_utf8 = filename_to_display (Browser_Get_Current_Path ());
+ playlist_path_utf8 = filename_to_display (et_application_window_get_current_path (ET_APPLICATION_WINDOW
(MainWindow)));
/* Build the playlist filename. */
if (PLAYLIST_USE_MASK_NAME)
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 242dc8d..99bf7db 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -1024,47 +1024,6 @@ Scan_Rename_File_Prefix_Path (EtScanDialog *self)
}
-/*******************************
- * Scanner To Rename Directory *
- *******************************/
-void Scan_Rename_Directory_Generate_Preview (void)
-{
- gchar *preview_text = NULL;
- gchar *mask = NULL;
-
- if (!ETCore->ETFileDisplayed
- || !RenameDirectoryWindow || !RenameDirectoryMaskCombo || !RenameDirectoryPreviewLabel)
- return;
-
- mask = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))));
- if (!mask)
- return;
-
- preview_text = Scan_Generate_New_Filename_From_Mask(ETCore->ETFileDisplayed,mask,FALSE);
-
- if (GTK_IS_LABEL(RenameDirectoryPreviewLabel))
- {
- if (preview_text)
- {
- //gtk_label_set_text(GTK_LABEL(priv->rename_file_preview_label),preview_text);
- gchar *tmp_string = g_markup_printf_escaped("%s",preview_text); // To avoid problem with strings
containing characters like '&'
- gchar *str = g_strdup_printf("<i>%s</i>",tmp_string);
- gtk_label_set_markup(GTK_LABEL(RenameDirectoryPreviewLabel),str);
- g_free(tmp_string);
- g_free(str);
- } else
- {
- gtk_label_set_text(GTK_LABEL(RenameDirectoryPreviewLabel),"");
- }
-
- // Force the window to be redrawed else the preview label may be not placed correctly
- gtk_widget_queue_resize(RenameDirectoryWindow);
- }
-
- g_free(mask);
- g_free(preview_text);
-}
-
gchar *Scan_Generate_New_Directory_Name_From_Mask (ET_File *ETFile, gchar *mask, gboolean
no_dir_check_or_conversion)
{
return Scan_Generate_New_Filename_From_Mask(ETFile,mask,no_dir_check_or_conversion);
@@ -3519,8 +3478,8 @@ et_scan_dialog_scan_selected_files (EtScanDialog *self)
g_list_free_full (selfilelist, (GDestroyNotify)gtk_tree_path_free);
- // Refresh the whole list (faster than file by file) to show changes
- Browser_List_Refresh_Whole_List();
+ /* Refresh the whole list (faster than file by file) to show changes. */
+ et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
/* Display the current file */
ET_Display_File_Data_To_UI(ETCore->ETFileDisplayed);
diff --git a/src/scan_dialog.h b/src/scan_dialog.h
index 626b91c..4998047 100644
--- a/src/scan_dialog.h
+++ b/src/scan_dialog.h
@@ -75,7 +75,6 @@ enum {
void Scan_Select_Mode_And_Run_Scanner (EtScanDialog *self, ET_File *ETFile);
gchar *Scan_Generate_New_Filename_From_Mask (ET_File *ETFile, gchar *mask, gboolean
no_dir_check_or_conversion);
gchar *Scan_Generate_New_Directory_Name_From_Mask (ET_File *ETFile, gchar *mask, gboolean
no_dir_check_or_conversion);
-void Scan_Rename_Directory_Generate_Preview (void);
void entry_check_rename_file_mask (GtkEntry *entry, gpointer user_data);
diff --git a/src/search_dialog.c b/src/search_dialog.c
index ab99c7a..cbb7451 100644
--- a/src/search_dialog.c
+++ b/src/search_dialog.c
@@ -22,6 +22,7 @@
#include <glib/gi18n.h>
+#include "application_window.h"
#include "bar.h"
#include "browser.h"
#include "charset.h"
@@ -134,8 +135,8 @@ Search_Result_List_Row_Selected (GtkTreeSelection *selection,
return;
}
- // Unselect files in the main list before re-selecting them...
- Browser_List_Unselect_All_Files();
+ /* Unselect files in the main list before re-selecting them... */
+ et_application_window_browser_unselect_all (ET_APPLICATION_WINDOW (MainWindow));
for (l = selectedRows; l != NULL; l = g_list_next (l))
{
diff --git a/src/setting.c b/src/setting.c
index a004491..d417e4f 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -610,7 +610,7 @@ Apply_Changes_Of_Preferences_Window (void)
{
CHANGED_FILES_DISPLAYED_TO_RED =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ChangedFilesDisplayedToRed));
CHANGED_FILES_DISPLAYED_TO_BOLD =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ChangedFilesDisplayedToBold));
- Browser_List_Refresh_Whole_List();
+ et_application_window_browser_refresh_list (ET_APPLICATION_WINDOW (MainWindow));
}
/* Misc */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]