From ad0c34cb393b6dd793e0bc89f18be3cb913c56db Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Wed, 25 Apr 2012 00:29:41 -0300 Subject: [PATCH] Hide file browser by default. When it is hidden, select the files to add in composition with a gtk_file_chooser. --- xfburn/xfburn-audio-composition.c | 7 ++-- xfburn/xfburn-data-composition.c | 5 +-- xfburn/xfburn-file-browser.c | 64 +++++++++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/xfburn/xfburn-audio-composition.c b/xfburn/xfburn-audio-composition.c index f34ed4a..2f6df60 100644 --- a/xfburn/xfburn-audio-composition.c +++ b/xfburn/xfburn-audio-composition.c @@ -966,14 +966,15 @@ action_add_selected_files (GtkAction *action, XfburnAudioComposition *dc) gchar *selected_files = NULL; - xfburn_busy_cursor (priv->content); selected_files = xfburn_file_browser_get_selection (browser); - + if (selected_files) { GtkTreeSelection *selection; GList *selected_paths = NULL; ThreadAddFilesActionParams *params; - + + xfburn_busy_cursor (priv->content); + xfburn_adding_progress_show (XFBURN_ADDING_PROGRESS (priv->progress)); params = g_new (ThreadAddFilesActionParams, 1); diff --git a/xfburn/xfburn-data-composition.c b/xfburn/xfburn-data-composition.c index 4ee22d1..b5945cf 100644 --- a/xfburn/xfburn-data-composition.c +++ b/xfburn/xfburn-data-composition.c @@ -904,14 +904,15 @@ action_add_selected_files (GtkAction *action, XfburnDataComposition *dc) gchar *selected_files = NULL; - xfburn_busy_cursor (priv->content); selected_files = xfburn_file_browser_get_selection (browser); - + if (selected_files) { GtkTreeSelection *selection; GList *selected_paths = NULL; ThreadAddFilesActionParams *params; + xfburn_busy_cursor (priv->content); + xfburn_adding_progress_show (XFBURN_ADDING_PROGRESS (priv->progress)); params = g_new (ThreadAddFilesActionParams, 1); diff --git a/xfburn/xfburn-file-browser.c b/xfburn/xfburn-file-browser.c index 4d3b182..0cec443 100644 --- a/xfburn/xfburn-file-browser.c +++ b/xfburn/xfburn-file-browser.c @@ -235,14 +235,66 @@ xfburn_file_browser_refresh (XfburnFileBrowser *browser) } gchar * +xfburn_file_browser_get_file_chooser(void) +{ + GtkWidget *dialog; + GSList *tmp_filenames, *filenames; + gchar *full_paths = NULL; + gint resp; + + dialog = gtk_file_chooser_dialog_new(_("Add the selected file(s) to the composition"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); + + resp = gtk_dialog_run(GTK_DIALOG(dialog)); + + switch (resp) { + case GTK_RESPONSE_ACCEPT: + { + filenames = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog)); + + tmp_filenames = filenames; + + while (tmp_filenames) { + gchar *current_path = tmp_filenames->data; + gchar *temp = NULL; + + temp = g_strdup_printf ("file://%s\n%s", current_path, full_paths ? full_paths : ""); + g_free (current_path); + g_free (full_paths); + full_paths = temp; + + tmp_filenames = tmp_filenames->next; + } + break; + } + default: + break; + } + gtk_widget_destroy(dialog); + g_slist_free (filenames); + + return full_paths; +} + + +gchar * xfburn_file_browser_get_selection (XfburnFileBrowser *browser) { XfburnFileBrowserPrivate *priv = XFBURN_FILE_BROWSER_GET_PRIVATE (browser); - - if (priv->has_focus == FS_BROWSER) - return xfburn_fs_browser_get_selection (XFBURN_FS_BROWSER (browser->fs_browser)); - else if (priv->has_focus == DIRECTORY_BROWSER) - return xfburn_directory_browser_get_selection (XFBURN_DIRECTORY_BROWSER (browser->directory_browser)); - + + if(xfburn_settings_get_boolean("show-filebrowser", TRUE)) { + if (priv->has_focus == FS_BROWSER) + return xfburn_fs_browser_get_selection (XFBURN_FS_BROWSER (browser->fs_browser)); + else if (priv->has_focus == DIRECTORY_BROWSER) + return xfburn_directory_browser_get_selection (XFBURN_DIRECTORY_BROWSER (browser->directory_browser)); + } + else { + return xfburn_file_browser_get_file_chooser(); + } return NULL; } -- 1.7.10