blob: 7bf1b034b366af3a9699370c858b4f56ef774e99 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Upstream-Status: Submitted
2Signed-off-by: Ross Burton <ross.burton@intel.com>
3
4From 43d4b19ab611d844156e26c4840cc54ddb73ae03 Mon Sep 17 00:00:00 2001
5From: Ross Burton <ross.burton@intel.com>
6Date: Thu, 26 Feb 2015 17:17:05 +0000
7Subject: [PATCH] gtk-play: show a file chooser if no URIs were passed
8
9---
10 gtk/gtk-play.c | 28 ++++++++++++++++++++++++++--
11 1 file changed, 26 insertions(+), 2 deletions(-)
12
13diff --git a/gtk/gtk-play.c b/gtk/gtk-play.c
14index f015077..9766a72 100644
15--- a/gtk/gtk-play.c
16+++ b/gtk/gtk-play.c
17@@ -319,8 +319,32 @@ main (gint argc, gchar ** argv)
18 // FIXME: Add support for playlists and stuff
19 /* Parse the list of the file names we have to play. */
20 if (!file_names) {
21- g_print ("Usage: %s FILE(s)|URI(s)\n", APP_NAME);
22- return 1;
23+ GtkWidget *chooser;
24+ int res;
25+
26+ chooser = gtk_file_chooser_dialog_new ("Select files to play", NULL,
27+ GTK_FILE_CHOOSER_ACTION_OPEN,
28+ "_Cancel", GTK_RESPONSE_CANCEL,
29+ "_Open", GTK_RESPONSE_ACCEPT,
30+ NULL);
31+ g_object_set (chooser,
32+ "local-only", FALSE,
33+ "select-multiple", TRUE,
34+ NULL);
35+
36+ res = gtk_dialog_run (GTK_DIALOG (chooser));
37+ if (res == GTK_RESPONSE_ACCEPT) {
38+ GSList *l;
39+
40+ l = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser));
41+ while (l) {
42+ play.uris = g_list_append (play.uris, l->data);
43+ l = g_slist_delete_link (l, l);
44+ }
45+ } else {
46+ return 0;
47+ }
48+ gtk_widget_destroy (chooser);
49 } else {
50 guint i;
51
52--
531.7.10.4
54