[Xfce4-commits] <xfburn:master> Show select file dialog on add while browser is hidden.

David Mohr noreply at xfce.org
Sat Jul 7 07:24:09 CEST 2012


Updating branch refs/heads/master
         to 36050be23614f17422afa1e9f2bded7f5d8a5abf (commit)
       from a792bd88a1caaa99b9405e5163187eebe1b49c9a (commit)

commit 36050be23614f17422afa1e9f2bded7f5d8a5abf
Author: David Mohr <david at mcbf.net>
Date:   Tue Jul 3 22:00:10 2012 -0400

    Show select file dialog on add while browser is hidden.

 xfburn/xfburn-audio-composition.c |   34 +++++++++++++++++++++++++++++++++-
 xfburn/xfburn-data-composition.c  |   21 +++++++++++++++++++--
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/xfburn/xfburn-audio-composition.c b/xfburn/xfburn-audio-composition.c
index f34ed4a..6ae76c1 100644
--- a/xfburn/xfburn-audio-composition.c
+++ b/xfburn/xfburn-audio-composition.c
@@ -52,6 +52,7 @@
 #include "xfburn-utils.h"
 #include "xfburn-burn-audio-cd-composition-dialog.h"
 #include "xfburn-transcoder.h"
+#include "xfburn-settings.h"
 
 #define XFBURN_AUDIO_COMPOSITION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFBURN_TYPE_AUDIO_COMPOSITION, XfburnAudioCompositionPrivate))
 
@@ -967,7 +968,38 @@ 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 (xfburn_settings_get_boolean("show-filebrowser", FALSE)) {
+    selected_files = xfburn_file_browser_get_selection (browser);
+  } else {
+    GtkWidget * dialog;
+
+    dialog = gtk_file_chooser_dialog_new (_("File(s) to add to composition"),
+                                          GTK_WINDOW(xfburn_main_window_get_instance()),
+                                          GTK_FILE_CHOOSER_ACTION_OPEN,
+                                          _("Add"),
+                                          GTK_RESPONSE_ACCEPT,
+                                          NULL);
+    gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER(dialog), TRUE);
+
+    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+        GSList *list = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog));
+        GString  * str = g_string_new(NULL);
+        GSList * curr;
+
+        for (curr = list; curr!=NULL; curr = curr->next) {
+            g_string_append(str, curr->data);
+            g_string_append_c(str, '\n');;
+        }
+
+        g_slist_free_full (list, g_free);
+        selected_files = str->str;
+        g_string_free (str, FALSE);
+        DBG("selected  files: %s ", selected_files);
+
+      //selected_files = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+    }
+    gtk_widget_destroy (dialog);
+  }
   
   if (selected_files) {
     GtkTreeSelection *selection;
diff --git a/xfburn/xfburn-data-composition.c b/xfburn/xfburn-data-composition.c
index fc54cd4..6be43ef 100644
--- a/xfburn/xfburn-data-composition.c
+++ b/xfburn/xfburn-data-composition.c
@@ -54,6 +54,7 @@
 #include "xfburn-data-disc-usage.h"
 #include "xfburn-main-window.h"
 #include "xfburn-utils.h"
+#include "xfburn-settings.h"
 
 #define XFBURN_DATA_COMPOSITION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFBURN_TYPE_DATA_COMPOSITION, XfburnDataCompositionPrivate))
 
@@ -910,14 +911,30 @@ action_add_selected_files (GtkAction *action, XfburnDataComposition *dc)
   } else {
     GtkWidget * dialog;
 
-    dialog = gtk_file_chooser_dialog_new (_("Files to add to composition"),
+    dialog = gtk_file_chooser_dialog_new (_("File(s) to add to composition"),
                                           GTK_WINDOW(xfburn_main_window_get_instance()),
                                           GTK_FILE_CHOOSER_ACTION_OPEN,
                                           _("Add"),
                                           GTK_RESPONSE_ACCEPT,
                                           NULL);
+    gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER(dialog), TRUE);
+
     if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
-      selected_files = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+        GSList *list = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog));
+        GString  * str = g_string_new(NULL);
+        GSList * curr;
+
+        for (curr = list; curr!=NULL; curr = curr->next) {
+            g_string_append(str, curr->data);
+            g_string_append_c(str, '\n');;
+        }
+
+        g_slist_free_full (list, g_free);
+        selected_files = str->str;
+        g_string_free (str, FALSE);
+        DBG("selected  files: %s ", selected_files);
+
+      //selected_files = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
     }
     gtk_widget_destroy (dialog);
   }


More information about the Xfce4-commits mailing list