summaryrefslogtreecommitdiff
path: root/player
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2007-10-21 19:20:36 +0200
committerBenjamin Otte <otte@gnome.org>2007-10-21 19:20:36 +0200
commit9226237e9f903ea22d4eb452f9712cac57693648 (patch)
treec1aad3896ff7634a56d9955076dc99504a4fa7be /player
parent9dcaba9d6a9103c11d8f5e5de1f2db54b3f5ab3b (diff)
implement File->Open
Diffstat (limited to 'player')
-rw-r--r--player/swfdec-window-handlers.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/player/swfdec-window-handlers.c b/player/swfdec-window-handlers.c
index cdaefc0..189cb40 100644
--- a/player/swfdec-window-handlers.c
+++ b/player/swfdec-window-handlers.c
@@ -21,11 +21,47 @@
#include "config.h"
#endif
+#include <glib/gi18n.h>
+
#include "swfdec-window.h"
+static void
+menu_file_open_response (GtkFileChooser *chooser, gint response, SwfdecWindow *window)
+{
+ if (response == GTK_RESPONSE_ACCEPT) {
+ char *target = gtk_file_chooser_get_filename (chooser);
+ if (target != NULL) {
+ char *url = g_strconcat ("file://", target, NULL);
+
+ if (!swfdec_window_set_url (window, url)) {
+ SwfdecWindow *new = swfdec_window_new (url);
+ swfdec_window_set_settings (new, &window->settings);
+ }
+ g_free (url);
+ g_free (target);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (chooser));
+ return;
+}
+
void
menu_file_open (GtkAction *action, SwfdecWindow *window)
{
+ GtkWidget *chooser;
+
+ chooser = gtk_file_chooser_dialog_new (_("Select a file to play"),
+ GTK_WINDOW (window->window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
+
+ g_object_ref (window);
+ g_signal_connect (chooser, "response", G_CALLBACK (menu_file_open_response), window);
+ g_object_weak_ref (G_OBJECT (chooser), (GWeakNotify) g_object_unref, window);
+ gtk_window_present (GTK_WINDOW (chooser));
}
void