[Xfce4-commits] <parole:0.2.2> Use XfceTitledDialog in the open location and open iso dialogs .

Ali Abdallah noreply at xfce.org
Wed Jan 20 15:10:08 CET 2010


Updating branch refs/heads/0.2.2
         to c7c81983280be97591f26b6541a17f05874d5e7e (commit)
       from eec27106e6c351699a363e8c5a33a5927aa5a67e (commit)

commit c7c81983280be97591f26b6541a17f05874d5e7e
Author: Ali Abdallah <aliov at xfce.org>
Date:   Tue Jan 19 16:07:27 2010 +0100

    Use XfceTitledDialog in the open location and open iso dialogs .

 data/interfaces/Makefile.am                |    7 +-
 data/interfaces/open-location.ui           |  178 ++++++++++++++++++++++++++++
 src/Makefile.am                            |    2 +
 src/parole-iso-image.c                     |  113 ++++++++++++++++++
 src/{parole-about.h => parole-iso-image.h} |   17 ++-
 src/parole-medialist.c                     |    6 +-
 src/parole-open-location.c                 |  107 +++++++----------
 src/parole-open-location.h                 |   21 +---
 src/parole-player.c                        |   63 +---------
 9 files changed, 363 insertions(+), 151 deletions(-)

diff --git a/data/interfaces/Makefile.am b/data/interfaces/Makefile.am
index dbb3922..c1450b6 100644
--- a/data/interfaces/Makefile.am
+++ b/data/interfaces/Makefile.am
@@ -4,7 +4,8 @@ interfaces =					\
 	playlist.ui				\
 	mediachooser.ui				\
 	save-playlist.ui			\
-	plugins.ui
+	plugins.ui				\
+	open-location.ui
 
 interfaces_h = 					\
 	$(interfaces:.ui=_ui.h)
@@ -30,6 +31,10 @@ save-playlist_ui.h: save-playlist.ui
 plugins_ui.h: plugins.ui
 	exo-csource --static --strip-comments --strip-content --name=plugins_ui $< > $@
 
+open-location_ui.h: open-location.ui
+	exo-csource --static --strip-comments --strip-content --name=open_location_ui $< > $@
+
+
 endif
 
 CLEANFILES =					\
diff --git a/data/interfaces/open-location.ui b/data/interfaces/open-location.ui
new file mode 100644
index 0000000..ca7ced4
--- /dev/null
+++ b/data/interfaces/open-location.ui
@@ -0,0 +1,178 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-requires libxfce4ui 4.5 -->
+  <!-- interface-naming-policy project-wide -->
+  <object class="XfceTitledDialog" id="open-location">
+    <property name="default_width">400</property>
+    <property name="icon_name">gtk-network</property>
+    <property name="type_hint">normal</property>
+    <property name="has_separator">False</property>
+    <property name="subtitle" translatable="yes">Open location of media file or live stream</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">5</property>
+            <child>
+              <object class="GtkHBox" id="hbox1">
+                <property name="visible">True</property>
+                <property name="spacing">5</property>
+                <child>
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Enter the address of a location to open</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkImage" id="image1">
+                    <property name="visible">True</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="stock">gtk-info</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox2">
+                <property name="visible">True</property>
+                <property name="spacing">5</property>
+                <child>
+                  <object class="GtkEntry" id="entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">&#x25CF;</property>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="clear-history">
+                    <property name="label" translatable="yes">Clear history</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="image">image2</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="open">
+                <property name="label">gtk-open</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancel</action-widget>
+      <action-widget response="-5">open</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkImage" id="image2">
+    <property name="visible">True</property>
+    <property name="stock">gtk-clear</property>
+  </object>
+  <object class="GtkDialog" id="dialog1">
+    <property name="border_width">5</property>
+    <property name="type_hint">normal</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox2">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index b3288a2..eb5aa05 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,6 +70,8 @@ parole_SOURCES =				\
 	parole-button.h				\
 	parole-plugin-player.c			\
 	parole-plugin-player.h			\
+	parole-iso-image.c			\
+	parole-iso-image.h			\
 	parole-setup.c				\
 	parole-setup.h
 
diff --git a/src/parole-iso-image.c b/src/parole-iso-image.c
new file mode 100644
index 0000000..40aa587
--- /dev/null
+++ b/src/parole-iso-image.c
@@ -0,0 +1,113 @@
+/*
+ * * Copyright (C) 2009 Ali <aliov at xfce.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include <libxfce4ui/libxfce4ui.h>
+
+#include "parole-iso-image.h"
+#include "parole-rc-utils.h"
+
+static void
+iso_files_folder_changed_cb (GtkFileChooser *widget, gpointer data)
+{
+    gchar *folder;
+    folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget));
+    
+    if ( folder )
+    {
+	parole_rc_write_entry_string ("iso-image-folder", PAROLE_RC_GROUP_GENERAL, folder);
+	g_free (folder);
+    }
+}
+
+gchar *parole_open_iso_image (GtkWindow *parent, ParoleIsoImage image)
+{
+    GtkWidget *dialog;
+    GtkWidget *chooser;
+    GtkWidget *box;
+    GtkFileFilter *filter;
+    gchar *file = NULL;
+    gchar *uri = NULL;
+    const gchar *folder;
+    gint response;
+    
+    dialog = xfce_titled_dialog_new_with_buttons (PAROLE_ISO_IMAGE_CD ? _("Open IS CD image") : _("Open ISO DVD image"), 
+						  parent,
+						  GTK_DIALOG_DESTROY_WITH_PARENT,
+						  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+						  GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+						  NULL);
+	
+    gtk_window_set_icon_name (GTK_WINDOW (dialog), "media-optical");
+    
+    box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+    chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
+    g_object_set (G_OBJECT (chooser),
+		  "border-width", 4,
+		  NULL);
+    
+    gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), FALSE);
+    
+    folder = parole_rc_read_entry_string ("iso-image-folder", PAROLE_RC_GROUP_GENERAL, NULL);
+    
+    if ( folder )
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), folder);
+    
+    g_signal_connect (chooser, "current-folder-changed",
+		      G_CALLBACK (iso_files_folder_changed_cb), NULL);
+    
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name (filter, image == PAROLE_ISO_IMAGE_CD ? _("CD image") : _("DVD image"));
+    gtk_file_filter_add_mime_type (filter, "application/x-cd-image");
+    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+
+    gtk_container_add (GTK_CONTAINER (box), chooser);
+    gtk_widget_show_all (box);
+
+    gtk_window_set_default_size (GTK_WINDOW (dialog), 680, 480);
+    
+    response = gtk_dialog_run (GTK_DIALOG (dialog));
+    
+    if ( response == GTK_RESPONSE_OK )
+    {
+	file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+    }
+    
+    gtk_widget_destroy (dialog);
+    
+    if ( file )
+    {
+	//FIXME: vcd will word for svcd?
+	uri = g_strdup_printf ("%s%s", PAROLE_ISO_IMAGE_CD ? "dvd://" : ("vcd://"), file);
+	g_free (file);
+    }
+    
+    return uri;
+}
diff --git a/src/parole-about.h b/src/parole-iso-image.h
similarity index 76%
copy from src/parole-about.h
copy to src/parole-iso-image.h
index da4251e..bad1d40 100644
--- a/src/parole-about.h
+++ b/src/parole-iso-image.h
@@ -18,12 +18,21 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef __PAROLE_ABOUT_H
-#define __PAROLE_ABOUT_H
+#ifndef __PAROLE_ISO_IMAGE_H_
+#define __PAROLE_ISO_IMAGE_H_
 
 #include <gtk/gtk.h>
 
-void 		parole_about	(GtkWindow *parent);
+typedef enum
+{
+    PAROLE_ISO_IMAGE_DVD,
+    PAROLE_ISO_IMAGE_CD
+    
+} ParoleIsoImage;
 
 
-#endif /* __PAROLE_ABOUT_H */
+gchar 		*parole_open_iso_image 		(GtkWindow *parent, 
+						 ParoleIsoImage image);
+
+
+#endif /* __PAROLE_ISO_IMAGE_ */
diff --git a/src/parole-medialist.c b/src/parole-medialist.c
index 79d42fb..89bd834 100644
--- a/src/parole-medialist.c
+++ b/src/parole-medialist.c
@@ -332,14 +332,12 @@ parole_media_list_open_internal (ParoleMediaList *list)
 static void
 parole_media_list_open_location_internal (ParoleMediaList *list)
 {
-    GtkWidget *location;
+    ParoleOpenLocation *location;
     
     location = parole_open_location (gtk_widget_get_toplevel (GTK_WIDGET (list)));
 					       
     g_signal_connect (G_OBJECT (location), "location-opened",
-		          G_CALLBACK (parole_media_list_location_opened_cb), list);
-    
-    gtk_widget_show_all (GTK_WIDGET (location));
+		      G_CALLBACK (parole_media_list_location_opened_cb), list);
 }
 
 /**
diff --git a/src/parole-open-location.c b/src/parole-open-location.c
index 4b0d955..0d0af5d 100644
--- a/src/parole-open-location.c
+++ b/src/parole-open-location.c
@@ -30,15 +30,26 @@
 
 #include "parole-open-location.h"
 #include "parole-rc-utils.h"
+#include "parole-builder.h"
+
+#include "interfaces/open-location_ui.h"
 
 static void parole_open_location_finalize   (GObject *object);
 
-#define PAROLE_OPEN_LOCATION_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), PAROLE_TYPE_OPEN_LOCATION, ParoleOpenLocationPrivate))
+struct ParoleOpenLocation
+{
+    GObject         	parent;
+    
+    
+    GtkWidget 	       *entry;
+};
 
-struct ParoleOpenLocationPrivate
+struct ParoleOpenLocationClass
 {
-    GtkWidget *entry;
+    GObjectClass 	parent_class;
+    
+    void		(*location_opened)	(ParoleOpenLocation *self,
+						 const gchar *address);
 };
 
 enum
@@ -55,7 +66,7 @@ enum
 
 static guint signals [LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (ParoleOpenLocation, parole_open_location, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (ParoleOpenLocation, parole_open_location, G_TYPE_OBJECT)
 
 static void
 parole_open_location_response_cb (GtkDialog *dialog, gint response_id, ParoleOpenLocation *self)
@@ -64,19 +75,19 @@ parole_open_location_response_cb (GtkDialog *dialog, gint response_id, ParoleOpe
 
     if ( response_id == GTK_RESPONSE_OK )
     {
-	location = gtk_entry_get_text (GTK_ENTRY (self->priv->entry));
+	location = gtk_entry_get_text (GTK_ENTRY (self->entry));
 	
 	if ( !location || strlen (location) == 0)
 	    goto out;
 
 	TRACE ("Location %s", location);
 
-	gtk_widget_hide (GTK_WIDGET (self));
+	gtk_widget_hide (GTK_WIDGET (dialog));
 	g_signal_emit (G_OBJECT (self), signals [LOCATION_OPENED], 0, location);
     }
 
     out:
-	gtk_widget_destroy (GTK_WIDGET (self));
+	gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
 static GtkTreeModel *
@@ -134,14 +145,11 @@ parole_open_location_class_init (ParoleOpenLocationClass *klass)
                       NULL, NULL,
                       g_cclosure_marshal_VOID__STRING,
                       G_TYPE_NONE, 1, G_TYPE_STRING);
-
-    g_type_class_add_private (klass, sizeof (ParoleOpenLocationPrivate));
 }
 
 static void
 parole_open_location_init (ParoleOpenLocation *self)
 {
-    self->priv = PAROLE_OPEN_LOCATION_GET_PRIVATE (self);
 }
 
 static void
@@ -161,37 +169,32 @@ parole_open_location_clear_history (GtkTreeModel *model)
     gtk_list_store_clear (GTK_LIST_STORE (model));
 }
 
-GtkWidget *parole_open_location (GtkWidget *parent)
+ParoleOpenLocation *parole_open_location (GtkWidget *parent)
 {
+    ParoleOpenLocation *self;
+    GtkWidget *dialog;
     GtkEntryCompletion *cmpl;
     GtkTreeModel *model;
-    GtkWidget *label;
-    GtkWidget *clear;
-    GtkWidget *img;
-    GtkWidget *vbox;
-    GtkWidget *hbox;
-    
-    ParoleOpenLocation *self = NULL;
+    GtkBuilder *builder;
     
     self = g_object_new (PAROLE_TYPE_OPEN_LOCATION, NULL);
     
-    if ( parent )
-	gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (parent));
+    builder = parole_builder_new_from_string (open_location_ui, open_location_ui_length);
     
-    gtk_window_set_title (GTK_WINDOW (self), _("Open location..."));
-    gtk_window_set_default_size (GTK_WINDOW (self), 360, 40);
-    gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER_ON_PARENT);
+    dialog = GTK_WIDGET (gtk_builder_get_object (builder, "open-location"));
     
-    label = gtk_label_new (NULL);
-    gtk_label_set_markup (GTK_LABEL (label), _("<b>Open location of media file or live stream:</b>"));
+    if ( parent )
+	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+	
+    gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
     
-    self->priv->entry = gtk_entry_new ();
+    self->entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
     model = parole_open_location_get_completion_model ();
     
-    gtk_entry_set_activates_default (GTK_ENTRY (self->priv->entry), TRUE);
+    gtk_entry_set_activates_default (GTK_ENTRY (self->entry), TRUE);
     cmpl = gtk_entry_completion_new ();
     
-    gtk_entry_set_completion (GTK_ENTRY (self->priv->entry), cmpl);
+    gtk_entry_set_completion (GTK_ENTRY (self->entry), cmpl);
     gtk_entry_completion_set_model (cmpl, model);
     
     gtk_entry_completion_set_text_column (cmpl, 0);
@@ -199,46 +202,20 @@ GtkWidget *parole_open_location (GtkWidget *parent)
 					 (GtkEntryCompletionMatchFunc) parole_open_location_match, 
 					 model, 
 					 NULL);
-	
-    img = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_BUTTON);
-    
-    clear = gtk_button_new_with_label (_("Clear history"));
-    g_signal_connect_swapped (clear, "clicked",
-			      G_CALLBACK (parole_open_location_clear_history), model);
-
-    g_object_set (G_OBJECT (clear),
-		  "image", img,
-		  NULL);
-
-    vbox = gtk_vbox_new (TRUE, 4);
-    hbox = gtk_hbox_new (FALSE, 8);
-    
-    gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
-    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
     
-    gtk_box_pack_start (GTK_BOX (hbox), self->priv->entry, TRUE, TRUE, 0);
-    gtk_box_pack_start (GTK_BOX (hbox), clear, FALSE, FALSE, 0);
+    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
     
-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox),
-			vbox,
-			TRUE,   
-			TRUE,
-			0);   
-    
-    gtk_dialog_add_buttons (GTK_DIALOG (self), 
-			    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-			    GTK_STOCK_OPEN, GTK_RESPONSE_OK,
-			    NULL);
-    
-    gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
+    g_signal_connect_swapped (gtk_builder_get_object (builder, "clear-history"), "clicked",
+			      G_CALLBACK (parole_open_location_clear_history), model);
     
-    g_signal_connect (self, "delete-event",
-		      G_CALLBACK (gtk_widget_destroy), self);
+    g_signal_connect (dialog, "delete-event",
+		      G_CALLBACK (gtk_widget_destroy), NULL);
 		      
-    g_signal_connect (self, "response",
+    g_signal_connect (dialog, "response",
 		      G_CALLBACK (parole_open_location_response_cb), self);
-		      
-    gtk_widget_show_all (GTK_WIDGET (self));
     
-    return GTK_WIDGET (self);
+    gtk_widget_show_all (dialog);
+    g_object_unref (builder);
+    
+    return self;
 }
diff --git a/src/parole-open-location.h b/src/parole-open-location.h
index 15ee1b1..2c25994 100644
--- a/src/parole-open-location.h
+++ b/src/parole-open-location.h
@@ -30,27 +30,12 @@ G_BEGIN_DECLS
 #define PAROLE_OPEN_LOCATION(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_OPEN_LOCATION, ParoleOpenLocation))
 #define PAROLE_IS_OPEN_LOCATION(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_OPEN_LOCATION))
 
-typedef struct ParoleOpenLocationPrivate ParoleOpenLocationPrivate;
-
-typedef struct
-{
-    GtkDialog         		   parent;
-    ParoleOpenLocationPrivate     *priv;
-    
-} ParoleOpenLocation;
-
-typedef struct
-{
-    GtkDialogClass 		   parent_class;
-    
-    void			  (*location_opened)		       (ParoleOpenLocation *self,
-								        const gchar *address);
-    
-} ParoleOpenLocationClass;
+typedef struct ParoleOpenLocation      ParoleOpenLocation;
+typedef struct ParoleOpenLocationClass ParoleOpenLocationClass;
 
 GType        			   parole_open_location_get_type       (void) G_GNUC_CONST;
 
-GtkWidget			  *parole_open_location 	       (GtkWidget *parent);
+ParoleOpenLocation		  *parole_open_location 	       (GtkWidget *parent);
 
 G_END_DECLS
 
diff --git a/src/parole-player.c b/src/parole-player.c
index 00561c0..44199cc 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -58,6 +58,7 @@
 #include "parole-conf-dialog.h"
 #include "parole-conf.h"
 #include "parole-rc-utils.h"
+#include "parole-iso-image.h"
 #include "parole-utils.h"
 #include "parole-debug.h"
 #include "parole-button.h"
@@ -354,73 +355,17 @@ void parole_player_show_hide_playlist (GtkButton *button, ParolePlayer *player)
     g_object_unref (img);
 }
 
-typedef enum
-{
-    PAROLE_ISO_IMAGE_DVD,
-    PAROLE_ISO_IMAGE_CD
-} ParoleIsoImage;
-
-static void
-iso_files_folder_changed_cb (GtkFileChooser *widget, gpointer data)
-{
-    gchar *folder;
-    folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget));
-    
-    if ( folder )
-    {
-	parole_rc_write_entry_string ("iso-image-folder", PAROLE_RC_GROUP_GENERAL, folder);
-	g_free (folder);
-    }
-}
-
 static void
 parole_player_open_iso_image (ParolePlayer *player, ParoleIsoImage image)
 {
-    GtkWidget *chooser;
-    GtkFileFilter *filter;
-    gchar *file = NULL;
-    const gchar *folder;
-    gint response;
-    
-    chooser = gtk_file_chooser_dialog_new (_("Open ISO image"), GTK_WINDOW (player->priv->window),
-					   GTK_FILE_CHOOSER_ACTION_OPEN,
-					   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					   GTK_STOCK_OPEN, GTK_RESPONSE_OK,
-					   NULL);
-				
-    gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), FALSE);
-    
-    folder = parole_rc_read_entry_string ("iso-image-folder", PAROLE_RC_GROUP_GENERAL, NULL);
-    
-    if ( folder )
-	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), folder);
-    
-    g_signal_connect (chooser, "current-folder-changed",
-		      G_CALLBACK (iso_files_folder_changed_cb), NULL);
-    
-    filter = gtk_file_filter_new ();
-    gtk_file_filter_set_name (filter, image == PAROLE_ISO_IMAGE_CD ? _("CD image") : _("DVD image"));
-    gtk_file_filter_add_mime_type (filter, "application/x-cd-image");
-    gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
-
-    gtk_window_set_default_size (GTK_WINDOW (chooser), 680, 480);
-    response = gtk_dialog_run (GTK_DIALOG (chooser));
-    
-    if ( response == GTK_RESPONSE_OK )
-    {
-	file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
-    }
+    gchar *uri;
     
-    gtk_widget_destroy (chooser);
+    uri = parole_open_iso_image (GTK_WINDOW (player->priv->window), PAROLE_ISO_IMAGE_CD);
     
-    if ( file )
+    if ( uri )
     {
-	gchar *uri;
-	//FIXME: vcd will word for svcd?
-	uri = g_strdup_printf ("%s%s", PAROLE_ISO_IMAGE_CD ? "dvd://" : ("vcd://"), file);
 	TRACE ("Playing ISO image %s", uri);
 	parole_player_disc_selected_cb (NULL, uri, NULL, player);
-	g_free (file);
 	g_free (uri);
     }
 }



More information about the Xfce4-commits mailing list