[easytag/wip/application-window: 26/26] Move browser to EtBrowser object
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 26/26] Move browser to EtBrowser object
- Date: Tue, 15 Apr 2014 19:53:27 +0000 (UTC)
commit 782c3eda5a1521af1729fe44e7de9d3045deb807
Author: David King <amigadave amigadave com>
Date: Wed Feb 12 23:06:30 2014 +0000
Move browser to EtBrowser object
src/application_window.c | 637 +++++++++++++++++++++++++++++-
src/application_window.h | 25 ++
src/bar.c | 66 ++--
src/browser.c | 970 +++++++++++++++++++++++++++++-----------------
src/browser.h | 150 +++-----
src/cddb_dialog.c | 8 +-
src/easytag.c | 329 +---------------
src/easytag.h | 2 +-
src/load_files_dialog.c | 4 +-
src/misc.c | 31 --
src/misc.h | 1 -
src/playlist_dialog.c | 3 +-
src/scan_dialog.c | 41 --
src/scan_dialog.h | 1 -
src/search_dialog.c | 5 +-
15 files changed, 1375 insertions(+), 898 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index ed29138..7cce4b4 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -46,6 +46,8 @@ G_DEFINE_TYPE (EtApplicationWindow, et_application_window, GTK_TYPE_WINDOW)
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);
@@ -947,16 +954,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 +1720,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 */
@@ -1999,6 +2008,248 @@ 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_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)
{
@@ -2088,6 +2339,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
*/
@@ -2371,14 +2637,46 @@ 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;
+}
+
/*
* Action when unselecting all
*/
@@ -2404,27 +2702,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);
@@ -2432,13 +2747,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));
@@ -2451,11 +2771,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);
@@ -2463,7 +2786,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);
}
@@ -2472,7 +2799,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));
@@ -2485,11 +2812,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);
@@ -2497,7 +2827,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);
}
@@ -2506,7 +2840,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));
@@ -2519,11 +2853,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);
@@ -2531,14 +2868,274 @@ 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));
}
+
+/*
+ * 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 f5804e3..eceee55 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -63,16 +63,41 @@ 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_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_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_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..8cc02a1 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) },
@@ -254,39 +265,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 },
@@ -338,7 +355,9 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
{ 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_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 +376,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 +444,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 +534,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..a670efa 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,15 +50,39 @@
#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;
+
+ 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 *BrowserEntryCombo;
static GtkWidget *BrowserTree; /* Tree of directories. */
static GtkTreeStore *directoryTreeModel;
static GtkListStore *fileListModel;
@@ -71,18 +94,6 @@ static GtkListStore *albumListModel;
/* Path selected in the browser area (BrowserEntry or BrowserTree). */
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 +124,84 @@ 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
+{
+ 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 +225,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 +305,39 @@ void Browser_Load_Default_Directory (void)
g_free (files);
}
+void
+et_browser_run_player_for_album_list (EtBrowser *self)
+{
+ 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);
+}
+
+
/*
* Get the path from the selected node (row) in the browser
@@ -343,7 +398,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,7 +407,8 @@ 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)
{
@@ -361,14 +418,15 @@ void Browser_Reload_Directory (void)
{
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 +438,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 +470,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 +562,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 +580,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,7 +644,8 @@ 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)
{
#ifndef G_OS_WIN32
GtkTreePath *rootPath;
@@ -611,7 +679,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
@@ -803,14 +872,14 @@ 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)
{
GtkTreePath *rootPath = NULL;
GtkTreeIter parentNode, currentNode;
@@ -819,12 +888,12 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
gchar *nodeName;
gchar *temp;
- g_return_val_if_fail (BrowserTree != NULL, FALSE);
+ g_return_if_fail (BrowserTree != NULL);
/* Load current_path */
if(!current_path || !*current_path)
{
- return TRUE;
+ return;
}
#ifdef G_OS_WIN32
@@ -843,13 +912,13 @@ 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();
@@ -954,7 +1023,7 @@ gboolean Browser_Tree_Select_Dir (const gchar *current_path)
}
g_strfreev(parts);
- return TRUE;
+ return;
}
/*
@@ -1008,12 +1077,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);
@@ -1481,7 +1554,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 +1750,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 +1800,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 +1971,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 +1991,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 +2008,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,7 +2039,8 @@ 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)
{
GList *AlbumList;
GList *etfilelist;
@@ -2017,7 +2098,7 @@ void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(BrowserArtistList), 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 +2115,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 +2124,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,7 +2138,7 @@ 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);
}
/*
@@ -2113,7 +2194,9 @@ 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)
{
GList *l;
GList *etfilelist = NULL;
@@ -2186,7 +2269,7 @@ Browser_Album_List_Load_Files (GList *albumlist, ET_File *etfile_to_select)
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 +2289,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 +2300,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 +2319,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);
@@ -2286,7 +2369,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 +2392,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 +2405,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 +2423,16 @@ 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);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserEntryCombo), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserTree), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserList), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserArtistList), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserAlbumList), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserButton), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (BrowserLabel), sensitive);
}
@@ -2506,26 +2591,15 @@ 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)
{
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;
- }
-
/* Memorize the current path to load it again at the end */
current_path = Browser_Tree_Get_Path_Of_Selected_Node();
if (current_path==NULL && BrowserEntryCombo)
@@ -2545,7 +2619,7 @@ void Browser_Tree_Rebuild (gchar *path_to_load)
if (selection)
{
g_signal_handlers_block_by_func(G_OBJECT(selection),G_CALLBACK(Browser_Tree_Node_Selected),NULL);
- Browser_Tree_Select_Dir(current_path);
+ et_browser_select_dir (self, current_path);
g_signal_handlers_unblock_by_func(G_OBJECT(selection),G_CALLBACK(Browser_Tree_Node_Selected),NULL);
}
g_free(current_path);
@@ -2880,7 +2954,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 +3077,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 +3161,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 +3191,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 +3203,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."));
@@ -3301,7 +3384,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserArtistList), 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 (BrowserArtistList)),
+ "changed",
+ G_CALLBACK (Browser_Artist_List_Row_Selected),
+ self);
gtk_container_add(GTK_CONTAINER(ScrollWindowArtistList),BrowserArtistList);
@@ -3366,7 +3452,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
gtk_tree_view_append_column(GTK_TREE_VIEW(BrowserAlbumList), 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);
+ g_signal_connect_swapped (gtk_tree_view_get_selection (GTK_TREE_VIEW (BrowserAlbumList)),
+ "changed",
+ G_CALLBACK (Browser_Album_List_Row_Selected),
+ self);
gtk_container_add(GTK_CONTAINER(ScrollWindowAlbumList),BrowserAlbumList);
// Create Popup Menu on browser album list
@@ -3470,7 +3559,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 +3571,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 +3631,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 +3693,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 +3727,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 +3736,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 +3756,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 +3884,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 +3949,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;
}
@@ -3953,12 +4098,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 +4115,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 +4131,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 +4156,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 +4164,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 +4180,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 +4260,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 +4333,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 +4361,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 +4380,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;
+ EtBrowserPrivate *priv;
- if (!GTK_IS_COMBO_BOX(combobox) || !ETCore->ETFileDisplayedList)
- return;
+ priv = et_browser_get_instance_private (self);
- // Programe name to run
- program_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(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)
+ if (priv->open_files_with_dialog)
{
- // 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();
+ gtk_widget_hide (priv->open_files_with_dialog);
}
- g_free(program_name);
}
/*
@@ -4281,14 +4464,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 +4494,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 +4505,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 +4523,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 +4534,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 +4569,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..e7a4897 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
@@ -63,44 +65,6 @@ 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,
@@ -128,65 +92,51 @@ enum
GtkWidget *BrowserList;
GtkWidget *BrowserAlbumList;
GtkWidget *BrowserArtistList;
-GtkWidget *BrowserEntryCombo;
-GtkListStore *BrowserEntryModel;
-GtkWidget *BrowserHPaned;
-GtkWidget *ArtistAlbumVPaned;
-GtkWidget *RenameDirectoryWindow;
-GtkWidget *RenameDirectoryMaskCombo;
-GtkWidget *RenameDirectoryPreviewLabel;
+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);
-/**************
- * Prototypes *
- **************/
-
-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 et_browser_load_file_list (EtBrowser *self, GList *etfilelist, ET_File *etfile_to_select);
void Browser_List_Refresh_Whole_List (void);
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 et_browser_toggle_display_mode (EtBrowser *self);
-void Browser_Area_Set_Sensitive (gboolean activate);
+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_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_run_player_for_album_list (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 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..2436d8e 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);
diff --git a/src/easytag.c b/src/easytag.c
index dc9c815..9bf3df4 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;
@@ -309,7 +301,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
@@ -334,7 +326,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);
}
@@ -436,18 +429,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)
@@ -801,7 +782,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);
@@ -892,7 +873,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);
@@ -925,11 +906,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);
@@ -947,161 +928,6 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
/*
- * 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);
-
- return TRUE;
-}
-
-
-
-/*
* Save changes of the ETFile (write tag and rename file)
* - multiple_files = TRUE : when saving files, a msgbox appears with ability
* to do the same action for all files.
@@ -1542,124 +1368,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.
*/
@@ -1681,6 +1389,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);
@@ -1691,8 +1400,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();
@@ -1703,10 +1414,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);
@@ -1737,7 +1447,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;
@@ -1807,7 +1517,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();
@@ -1861,7 +1571,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);
@@ -2363,12 +2073,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
@@ -2420,9 +2132,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..48582ed 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -115,7 +115,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..812d7a1 100644
--- a/src/load_files_dialog.c
+++ b/src/load_files_dialog.c
@@ -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..a755e6a 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -811,37 +811,6 @@ void Run_Audio_Player_Using_Browser_Artist_List (void)
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..0d53052 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -64,7 +64,6 @@ void Set_Unbusy_Cursor (void);
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 ad4dad8..46bbdc5 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);
diff --git a/src/scan_dialog.h b/src/scan_dialog.h
index 4d539db..42e62a3 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))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]