Commit 2191db59 authored by Ali Abdallah's avatar Ali Abdallah

Support for playing DVD/VCD ISO images from a file.

parent c0adeb10
......@@ -51,6 +51,65 @@
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="dvd-menu">
<property name="label" translatable="yes">DVD</property>
<property name="visible">True</property>
<property name="image">image14</property>
<property name="use_stock">False</property>
<child type="submenu">
<object class="GtkMenu" id="menu6">
<property name="visible">True</property>
<child>
<object class="GtkImageMenuItem" id="dvd-iso-mi">
<property name="label" translatable="yes">From ISO image</property>
<property name="visible">True</property>
<property name="image">image15</property>
<property name="use_stock">False</property>
<signal name="activate" handler="dvd_iso_mi_activated_cb"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem5">
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="cd-menu">
<property name="label">gtk-cdrom</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu7">
<property name="visible">True</property>
<child>
<object class="GtkImageMenuItem" id="cd-iso-mi">
<property name="label" translatable="yes">From ISO image</property>
<property name="visible">True</property>
<property name="image">image16</property>
<property name="use_stock">False</property>
<signal name="activate" handler="cd_iso_mi_activated_cb"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem6">
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem4">
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu-exit">
<property name="label">gtk-quit</property>
......@@ -354,7 +413,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="dvd-menu">
<object class="GtkButton" id="dvd-chapters-menu">
<property name="label" translatable="yes">DVD Menu</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -716,10 +775,6 @@
</object>
</child>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="stock">gtk-network</property>
</object>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="icon_name">audio-volume-low</property>
......@@ -773,4 +828,23 @@
<property name="visible">True</property>
<property name="stock">gtk-go-forward</property>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="stock">gtk-network</property>
</object>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="stock">gtk-cdrom</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="stock">gtk-file</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image16">
<property name="visible">True</property>
<property name="stock">gtk-file</property>
<property name="icon-size">1</property>
</object>
</interface>
......@@ -247,7 +247,7 @@ parole_disc_menu_init (ParoleDiscMenu *menu)
menu->priv->next_chapter = GTK_WIDGET (gtk_builder_get_object (builder, "next-chapter"));
menu->priv->prev_chapter = GTK_WIDGET (gtk_builder_get_object (builder, "prev-chapter"));
menu->priv->chapter_menu = GTK_WIDGET (gtk_builder_get_object (builder, "chapter-menu"));
menu->priv->dvd_menu = GTK_WIDGET (gtk_builder_get_object (builder, "dvd-menu"));
menu->priv->dvd_menu = GTK_WIDGET (gtk_builder_get_object (builder, "dvd-chapters-menu"));
menu->priv->info = GTK_WIDGET (gtk_builder_get_object (builder, "info"));
menu->priv->eventboxinfo = GTK_WIDGET (gtk_builder_get_object (builder, "eventboxinfo"));
menu->priv->disc_box = GTK_WIDGET (gtk_builder_get_object (builder, "disc-box"));
......
......@@ -53,7 +53,9 @@ struct ParoleDiscPrivate
{
GVolumeMonitor *monitor;
GPtrArray *array;
GtkWidget *media_menu;
GtkWidget *dvd_menu;
GtkWidget *cd_menu;
gboolean needs_update;
};
......@@ -103,38 +105,61 @@ parole_disc_media_activate_cb (GtkWidget *widget, ParoleDisc *disc)
g_signal_emit (G_OBJECT (disc), signals [DISC_SELECTED], 0, data->uri, data->device);
}
static MountData *
parole_disc_get_mount_data (ParoleDisc *disc,
const gchar *label,
const gchar *uri,
const gchar *device,
ParoleDiscKind kind)
static void
parole_disc_insert_menu_item (ParoleDisc *disc, MountData *data, const gchar *label)
{
MountData *data;
GtkWidget *menu;
GtkWidget *img;
data = g_new0 (MountData, 1);
data->kind = kind;
data->uri = data->device = NULL;
data->uri = g_strdup (uri);
data->device = g_strdup (device);
data->mi = gtk_image_menu_item_new_with_label (label);
img = gtk_image_new_from_stock (GTK_STOCK_CDROM, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (data->mi),
img);
img);
gtk_widget_show (data->mi);
gtk_widget_show (img);
g_object_set_data (G_OBJECT (data->mi),
"mount-data", data);
gtk_menu_shell_insert (GTK_MENU_SHELL (disc->priv->media_menu), data->mi, 2);
switch (data->kind )
{
case PAROLE_DISC_CDDA:
case PAROLE_DISC_SVCD:
case PAROLE_DISC_VCD:
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (disc->priv->cd_menu));
break;
case PAROLE_DISC_DVD:
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (disc->priv->dvd_menu));
break;
default:
g_warn_if_reached ();
break;
}
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), data->mi, 2);
g_signal_connect (data->mi, "activate",
G_CALLBACK (parole_disc_media_activate_cb), disc);
}
static MountData *
parole_disc_get_mount_data (ParoleDisc *disc,
const gchar *uri,
const gchar *device,
ParoleDiscKind kind)
{
MountData *data;
data = g_new0 (MountData, 1);
data->kind = kind;
data->uri = data->device = NULL;
data->uri = g_strdup (uri);
data->device = g_strdup (device);
return data;
}
......@@ -201,7 +226,9 @@ got_cdda:
name = g_mount_get_name (mount);
label = g_strdup_printf ("%s '%s'", _("Play Disc"), name);
data = parole_disc_get_mount_data (disc, label, uri, device, kind);
data = parole_disc_get_mount_data (disc, uri, device, kind);
parole_disc_insert_menu_item (disc, data, label);
if ( uri )
g_free (uri);
......@@ -243,7 +270,8 @@ parole_disc_check_cdrom (ParoleDisc *disc, GVolume *volume, const gchar *device)
if ( drive == CDS_AUDIO || drive == CDS_MIXED )
{
MountData *data;
data = parole_disc_get_mount_data (disc, g_volume_get_name (volume), "cdda://", device, PAROLE_DISC_CDDA);
data = parole_disc_get_mount_data (disc, "cdda://", device, PAROLE_DISC_CDDA);
parole_disc_insert_menu_item (disc, data, g_volume_get_name (volume));
g_ptr_array_add (disc->priv->array, data);
}
}
......@@ -407,7 +435,8 @@ parole_disc_init (ParoleDisc *disc)
g_signal_connect (G_OBJECT (disc->priv->monitor), "drive-eject-button",
G_CALLBACK (parole_disc_monitor_changed_cb), disc);
disc->priv->media_menu = GTK_WIDGET (gtk_builder_get_object (builder, "media-menu"));
disc->priv->dvd_menu = GTK_WIDGET (gtk_builder_get_object (builder, "dvd-menu"));
disc->priv->cd_menu = GTK_WIDGET (gtk_builder_get_object (builder, "cd-menu"));
g_signal_connect (gtk_builder_get_object (builder, "media-menu-item"), "select",
G_CALLBACK (parole_disc_select_cb), disc);
......
......@@ -70,8 +70,13 @@
/*
* DBus Glib init
*/
static void parole_player_dbus_class_init (ParolePlayerClass *klass);
static void parole_player_dbus_init (ParolePlayer *player);
static void parole_player_dbus_class_init (ParolePlayerClass *klass);
static void parole_player_dbus_init (ParolePlayer *player);
static void parole_player_disc_selected_cb (ParoleDisc *disc,
const gchar *uri,
const gchar *device,
ParolePlayer *player);
/*
* GtkBuilder Callbacks
......@@ -130,6 +135,12 @@ void parole_player_menu_add_cb (GtkWidget *widget,
void parole_player_menu_exit_cb (GtkWidget *widget,
ParolePlayer *player);
void dvd_iso_mi_activated_cb (GtkWidget *widget,
ParolePlayer *player);
void cd_iso_mi_activated_cb (GtkWidget *widget,
ParolePlayer *player);
void parole_player_volume_up (GtkWidget *widget,
ParolePlayer *player);
......@@ -333,6 +344,87 @@ 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));
}
gtk_widget_destroy (chooser);
if ( file )
{
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);
}
}
void dvd_iso_mi_activated_cb (GtkWidget *widget, ParolePlayer *player)
{
parole_player_open_iso_image (player, PAROLE_ISO_IMAGE_DVD);
}
void cd_iso_mi_activated_cb (GtkWidget *widget, ParolePlayer *player)
{
parole_player_open_iso_image (player, PAROLE_ISO_IMAGE_CD);
}
static void
parole_player_change_range_value (ParolePlayer *player, gdouble value)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment