brasero r1315 - in trunk: . po src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1315 - in trunk: . po src
- Date: Sun, 28 Sep 2008 13:27:05 +0000 (UTC)
Author: philippr
Date: Sun Sep 28 13:27:05 2008
New Revision: 1315
URL: http://svn.gnome.org/viewvc/brasero?rev=1315&view=rev
Log:
Fix for a few bugs (mostly added by latest changes) and improvements
Fix #538298 â Burn image dialog history
Fix #551938 â Image burning dialog
* src/Makefile.am:
* src/brasero-app.c (brasero_app_get_ui_manager):
* src/brasero-app.h:
* src/brasero-burn-dialog.c:
* src/brasero-burn-options.c (brasero_burn_options_add_source),
(brasero_burn_options_lock_selection),
(brasero_burn_options_set_type_shown),
(brasero_burn_options_valid_media_cb), (brasero_burn_options_init):
* src/brasero-data-disc.c (brasero_data_disc_import_button_new),
(brasero_data_disc_session_available_cb),
(brasero_data_disc_clear):
* src/brasero-dest-selection.c (brasero_dest_selection_lock),
(brasero_dest_selection_valid_session),
(brasero_dest_selection_medium_changed),
(brasero_dest_selection_init), (brasero_dest_selection_finalize),
(brasero_dest_selection_set_property),
(brasero_dest_selection_get_output_path),
(brasero_dest_selection_format_medium_string),
(brasero_dest_selection_class_init), (brasero_dest_selection_new):
* src/brasero-dest-selection.h:
* src/brasero-disc-copy-dialog.c
(brasero_disc_copy_dialog_set_drive),
(brasero_disc_copy_dialog_init):
* src/brasero-drive-info.c:
* src/brasero-drive-info.h:
* src/brasero-drive-properties.h:
* src/brasero-drive-selection.c:
* src/brasero-drive-selection.h:
* src/brasero-image-option-dialog.c
(brasero_image_option_dialog_set_image_uri),
(brasero_image_option_dialog_init),
(brasero_image_option_dialog_finalize):
* src/brasero-image-option-dialog.h:
* src/brasero-medium-properties.c
(brasero_medium_properties_drive_properties),
(brasero_medium_properties_get_output_path),
(brasero_medium_properties_set_output_path),
(brasero_medium_properties_get_possible_output_formats),
(brasero_medium_properties_image_format_changed_cb),
(brasero_medium_properties_image_check_extension),
(brasero_medium_properties_image_extension_ask),
(brasero_medium_properties_image_properties),
(brasero_medium_properties_clicked),
(brasero_medium_properties_update_image_output),
(brasero_medium_properties_valid_session),
(brasero_medium_properties_init),
(brasero_medium_properties_finalize),
(brasero_medium_properties_set_property),
(brasero_medium_properties_get_property),
(brasero_medium_properties_class_init),
(brasero_medium_properties_new):
* src/brasero-medium-properties.h:
* src/brasero-medium-selection.c
(brasero_medium_selection_get_medium_string),
(brasero_medium_selection_update_media_string),
(brasero_drive_selection_set_tooltip),
(brasero_medium_selection_changed),
(brasero_medium_selection_set_active),
(brasero_medium_selection_get_active_drive),
(brasero_medium_selection_show_type),
(brasero_medium_selection_medium_added_cb),
(brasero_medium_selection_medium_removed_cb),
(brasero_medium_selection_init),
(brasero_medium_selection_class_init):
* src/brasero-medium-selection.h:
* src/brasero-project-manager.c
(brasero_project_manager_burn_iso_dialog):
* src/brasero-project.c
(brasero_project_file_chooser_activated_cb),
(brasero_project_file_chooser_response_cb):
* src/brasero-session-cfg.h:
* src/brasero-src-image.c (brasero_src_image_save),
(brasero_src_image_set_track), (brasero_src_image_image_info_cb),
(brasero_src_image_get_format), (brasero_src_image_changed),
(brasero_src_image_set_formats), (brasero_src_image_clicked),
(brasero_src_image_set_uri), (brasero_src_image_init),
(brasero_src_image_finalize), (brasero_src_image_set_property),
(brasero_src_image_get_property), (brasero_src_image_class_init),
(brasero_src_image_new):
* src/brasero-src-image.h:
* src/brasero-src-info.c:
* src/brasero-src-info.h:
* src/brasero-src-selection.c
(brasero_src_selection_medium_changed),
(brasero_src_selection_init), (brasero_src_selection_finalize),
(brasero_src_selection_set_property),
(brasero_src_selection_class_init):
* src/brasero-src-selection.h:
* src/brasero-tool-dialog.c (brasero_tool_dialog_run),
(brasero_tool_dialog_set_medium_type_shown),
(brasero_tool_dialog_get_medium),
(brasero_tool_dialog_drive_changed_cb), (brasero_tool_dialog_init):
* src/burn-medium.c (brasero_medium_get_tooltip):
* src/burn-medium.h:
* src/burn-volume-obj.c (brasero_volume_get_name):
* src/burn-volume-obj.h:
Added:
trunk/src/brasero-medium-properties.c
trunk/src/brasero-medium-properties.h
trunk/src/brasero-src-image.c
trunk/src/brasero-src-image.h
Removed:
trunk/src/brasero-drive-info.c
trunk/src/brasero-drive-info.h
trunk/src/brasero-drive-selection.c
trunk/src/brasero-drive-selection.h
trunk/src/brasero-src-info.c
trunk/src/brasero-src-info.h
Modified:
trunk/ChangeLog
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/brasero-app.c
trunk/src/brasero-app.h
trunk/src/brasero-burn-dialog.c
trunk/src/brasero-burn-options.c
trunk/src/brasero-data-disc.c
trunk/src/brasero-dest-selection.c
trunk/src/brasero-dest-selection.h
trunk/src/brasero-disc-copy-dialog.c
trunk/src/brasero-drive-properties.h
trunk/src/brasero-image-option-dialog.c
trunk/src/brasero-image-option-dialog.h
trunk/src/brasero-medium-selection.c
trunk/src/brasero-medium-selection.h
trunk/src/brasero-project-manager.c
trunk/src/brasero-project.c
trunk/src/brasero-session-cfg.h
trunk/src/brasero-src-selection.c
trunk/src/brasero-src-selection.h
trunk/src/brasero-tool-dialog.c
trunk/src/burn-medium.c
trunk/src/burn-medium.h
trunk/src/burn-volume-obj.c
trunk/src/burn-volume-obj.h
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sun Sep 28 13:27:05 2008
@@ -1,9 +1,10 @@
# List of source files containing translatable strings.
[encoding: UTF-8]
+src/brasero-medium-properties.c
+src/brasero-src-image.c
src/brasero-project-name.c
src/brasero-burn-options.c
-src/brasero-src-info.c
src/brasero-app.c
data/brasero.desktop.in.in
data/brasero.schemas.in
@@ -26,9 +27,7 @@
src/brasero-burn-dialog.c
src/brasero-data-disc.c
src/brasero-disc-option-dialog.c
-src/brasero-drive-info.c
src/brasero-drive-properties.c
-src/brasero-drive-selection.c
src/brasero-file-chooser.c
src/brasero-image-option-dialog.c
src/brasero-image-properties.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Sep 28 13:27:05 2008
@@ -173,14 +173,10 @@
burn-task-ctx.c \
burn-mkisofs-base.c \
burn-mkisofs-base.h \
- brasero-drive-selection.h \
- brasero-drive-selection.c \
brasero-src-selection.h \
brasero-src-selection.c \
brasero-dest-selection.h \
brasero-dest-selection.c \
- brasero-drive-info.c \
- brasero-drive-info.h \
brasero-drive-properties.h \
brasero-drive-properties.c \
brasero-image-properties.h \
@@ -269,14 +265,16 @@
scsi-sbc.h \
brasero-app.c \
brasero-app.h \
- brasero-src-info.c \
- brasero-src-info.h \
brasero-session-cfg.h \
brasero-session-cfg.c \
brasero-burn-options.h \
brasero-burn-options.c \
brasero-project-name.c \
- brasero-project-name.h
+ brasero-project-name.h \
+ brasero-medium-properties.h \
+ brasero-medium-properties.c \
+ brasero-src-image.h \
+ brasero-src-image.c
if BUILD_INOTIFY
brasero_SOURCES += brasero-file-monitor.c brasero-file-monitor.h
Modified: trunk/src/brasero-app.c
==============================================================================
--- trunk/src/brasero-app.c (original)
+++ trunk/src/brasero-app.c Sun Sep 28 13:27:05 2008
@@ -161,6 +161,15 @@
"</ui>"
};
+GtkUIManager *
+brasero_app_get_ui_manager (BraseroApp *app)
+{
+ BraseroAppPrivate *priv;
+
+ priv = BRASERO_APP_PRIVATE (app);
+ return priv->manager;
+}
+
GtkWidget *
brasero_app_get_statusbar1 (BraseroApp *app)
{
Modified: trunk/src/brasero-app.h
==============================================================================
--- trunk/src/brasero-app.h (original)
+++ trunk/src/brasero-app.h Sun Sep 28 13:27:05 2008
@@ -22,6 +22,8 @@
#include <glib-object.h>
+#include <gtk/gtk.h>
+
G_BEGIN_DECLS
#define BRASERO_TYPE_APP (brasero_app_get_type ())
@@ -64,6 +66,9 @@
GtkWidget *
brasero_app_get_statusbar2 (BraseroApp *app);
+GtkUIManager *
+brasero_app_get_ui_manager (BraseroApp *app);
+
GtkWidget *
brasero_app_get_project_manager (BraseroApp *app);
Modified: trunk/src/brasero-burn-dialog.c
==============================================================================
--- trunk/src/brasero-burn-dialog.c (original)
+++ trunk/src/brasero-burn-dialog.c Sun Sep 28 13:27:05 2008
@@ -57,7 +57,6 @@
#include "burn-debug.h"
#include "burn-session.h"
#include "burn-medium.h"
-#include "brasero-drive-selection.h"
#include "brasero-progress.h"
#include "burn-drive.h"
Modified: trunk/src/brasero-burn-options.c
==============================================================================
--- trunk/src/brasero-burn-options.c (original)
+++ trunk/src/brasero-burn-options.c Sun Sep 28 13:27:05 2008
@@ -37,7 +37,7 @@
#include "brasero-notify.h"
#include "brasero-dest-selection.h"
#include "brasero-utils.h"
-#include "brasero-drive-info.h"
+#include "brasero-medium-properties.h"
typedef struct _BraseroBurnOptionsPrivate BraseroBurnOptionsPrivate;
struct _BraseroBurnOptionsPrivate
@@ -49,7 +49,8 @@
GtkWidget *source;
GtkWidget *message_input;
GtkWidget *selection;
- GtkWidget *info;
+ GtkWidget *properties;
+ GtkWidget *warning;
GtkWidget *copies_box;
GtkWidget *copies_spin;
GtkWidget *message_output;
@@ -76,7 +77,6 @@
priv = BRASERO_BURN_OPTIONS_PRIVATE (self);
- priv->message_input = brasero_notify_new ();
list = g_slist_prepend (list, priv->message_input);
va_start (vlist, title);
@@ -134,7 +134,7 @@
BraseroBurnOptionsPrivate *priv;
priv = BRASERO_BURN_OPTIONS_PRIVATE (self);
- brasero_drive_selection_lock (BRASERO_DRIVE_SELECTION (priv->selection), TRUE);
+ brasero_dest_selection_lock (BRASERO_DEST_SELECTION (priv->selection), TRUE);
}
void
@@ -144,7 +144,7 @@
BraseroBurnOptionsPrivate *priv;
priv = BRASERO_BURN_OPTIONS_PRIVATE (self);
- brasero_drive_selection_set_type_shown (BRASERO_DRIVE_SELECTION (priv->selection), type);
+ brasero_medium_selection_show_type (BRASERO_MEDIUM_SELECTION (priv->selection), type);
}
BraseroBurnSession *
@@ -195,46 +195,38 @@
gtk_widget_set_sensitive (priv->button, valid == BRASERO_SESSION_VALID);
gtk_widget_set_sensitive (priv->options, valid == BRASERO_SESSION_VALID);
+ gtk_widget_set_sensitive (priv->properties, valid == BRASERO_SESSION_VALID);
if (valid != BRASERO_SESSION_VALID) {
+ gtk_widget_hide (priv->warning);
gtk_widget_hide (priv->copies_box);
- gtk_widget_hide (priv->info);
}
else if (brasero_burn_session_is_dest_file (BRASERO_BURN_SESSION (priv->session))) {
- gchar *path;
- BraseroDrive *burner;
-
- brasero_burn_session_get_output (BRASERO_BURN_SESSION (priv->session),
- &path,
- NULL,
- NULL);
-
- burner = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (priv->session));
- brasero_drive_info_set_medium (BRASERO_DRIVE_INFO (priv->info),
- brasero_drive_get_medium (burner));
- brasero_drive_info_set_image_path (BRASERO_DRIVE_INFO (priv->info), path);
- g_free (path);
-
+ gtk_widget_hide (priv->warning);
gtk_widget_hide (priv->copies_box);
- gtk_widget_show (priv->info);
}
else {
- BraseroDrive *burner;
-
numcopies = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->copies_spin));
brasero_burn_session_set_num_copies (BRASERO_BURN_SESSION (priv->session), numcopies);
gtk_widget_set_sensitive (priv->copies_box, TRUE);
- burner = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (priv->session));
- brasero_drive_info_set_medium (BRASERO_DRIVE_INFO (priv->info),
- brasero_drive_get_medium (burner));
- brasero_drive_info_set_same_src_dest (BRASERO_DRIVE_INFO (priv->info),
- brasero_burn_session_same_src_dest_drive (BRASERO_BURN_SESSION (priv->session)));
+ if (brasero_burn_session_same_src_dest_drive (BRASERO_BURN_SESSION (priv->session)))
+ gtk_widget_show (priv->warning);
+ else
+ gtk_widget_hide (priv->warning);
gtk_widget_show (priv->copies_box);
- gtk_widget_show (priv->info);
}
+ if (priv->message_input) {
+ gtk_widget_hide (priv->message_input);
+ brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_input),
+ BRASERO_NOTIFY_CONTEXT_SIZE);
+ }
+
+ brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_output),
+ BRASERO_NOTIFY_CONTEXT_SIZE);
+
if (valid == BRASERO_SESSION_INSUFFICIENT_SPACE) {
brasero_notify_message_add (BRASERO_NOTIFY (priv->message_output),
_("Please, choose another CD or DVD or insert a new one."),
@@ -273,6 +265,18 @@
BRASERO_NOTIFY_CONTEXT_SIZE);
}
}
+ else if (valid == BRASERO_SESSION_UNKNOWN_IMAGE) {
+ GtkWidget *message;
+
+ if (priv->message_input) {
+ gtk_widget_show (priv->message_input);
+ message = brasero_notify_message_add (BRASERO_NOTIFY (priv->message_input),
+ _("Please, select another image."),
+ _("It doesn't appear to be a valid image or a valid cue file."),
+ -1,
+ BRASERO_NOTIFY_CONTEXT_SIZE);
+ }
+ }
else if (valid == BRASERO_SESSION_NOT_SUPPORTED) {
brasero_notify_message_add (BRASERO_NOTIFY (priv->message_output),
_("Please, replace the disc with a recordable CD or DVD."),
@@ -307,17 +311,7 @@
else if (valid == BRASERO_SESSION_APPENDING) {
}
-*/ else {
- if (priv->message_input) {
- gtk_widget_hide (priv->message_input);
- brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_input),
- BRASERO_NOTIFY_CONTEXT_SIZE);
- }
-
- brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_output),
- BRASERO_NOTIFY_CONTEXT_SIZE);
- }
-
+*/
gtk_window_resize (GTK_WINDOW (self), 10, 10);
}
@@ -366,13 +360,42 @@
TRUE,
0);
+ /* create message queue for input */
+ priv->message_input = brasero_notify_new ();
+
/* Medium selection box */
+ selection = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (selection);
+
priv->selection = brasero_dest_selection_new (BRASERO_BURN_SESSION (priv->session));
gtk_widget_show (priv->selection);
+ gtk_box_pack_start (GTK_BOX (selection),
+ priv->selection,
+ TRUE,
+ TRUE,
+ 0);
+
+ priv->properties = brasero_medium_properties_new (BRASERO_BURN_SESSION (priv->session));
+ gtk_widget_show (priv->properties);
+ gtk_box_pack_start (GTK_BOX (selection),
+ priv->properties,
+ TRUE,
+ TRUE,
+ 0);
/* Medium info */
- priv->info = brasero_drive_info_new ();
- gtk_widget_show (priv->info);
+ string = g_strdup_printf ("<b><i>%s</i></b><i>%s</i>",
+ _("The drive that holds the source media will also be the one used to record.\n"),
+ _("A new recordable media will be required once the one currently loaded has been copied."));
+ priv->warning = gtk_label_new (string);
+ g_free (string);
+
+ gtk_misc_set_alignment (GTK_MISC (priv->warning), 0.0, 0.5);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (priv->warning), PANGO_WRAP_WORD);
+ gtk_label_set_line_wrap (GTK_LABEL (priv->warning), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (priv->warning), TRUE);
+
+ gtk_widget_show (priv->warning);
/* Number of copies */
priv->copies_box = gtk_hbox_new (FALSE, 0);
@@ -398,8 +421,8 @@
selection = brasero_utils_pack_properties (string,
priv->message_output,
priv->copies_box,
- priv->info,
- priv->selection,
+ priv->warning,
+ selection,
NULL);
g_free (string);
gtk_widget_show (selection);
Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c (original)
+++ trunk/src/brasero-data-disc.c Sun Sep 28 13:27:05 2008
@@ -1188,6 +1188,7 @@
{
int merge_id;
gchar *string;
+ gchar *tooltip;
GtkAction *action;
gchar *action_name;
gchar *volume_name;
@@ -1197,24 +1198,36 @@
priv = BRASERO_DATA_DISC_PRIVATE (self);
+ if (!priv->manager)
+ return;
+
action_name = g_strdup_printf ("Import_%s", brasero_medium_get_udi (medium));
- volume_name = brasero_volume_get_display_label (BRASERO_VOLUME (medium), FALSE);
+ tooltip = brasero_medium_get_tooltip (medium);
+ /* Translators: %s is a string describing the type of medium and the
+ * drive it is in. */
+ string = g_strdup_printf (_("Import %s"), tooltip);
+ g_free (tooltip);
+ tooltip = string;
+
+ volume_name = brasero_volume_get_name (BRASERO_VOLUME (medium));
/* Translators: %s is the name of the volume to import */
string = g_strdup_printf (_("Import %s"), volume_name);
g_free (volume_name);
+ volume_name = string;
toggle_entry.name = action_name;
toggle_entry.stock_id = "drive-optical";
toggle_entry.label = string;
- toggle_entry.tooltip = string;
+ toggle_entry.tooltip = tooltip;
toggle_entry.callback = G_CALLBACK (brasero_data_disc_import_session_cb);
gtk_action_group_add_toggle_actions (priv->import_group,
&toggle_entry,
1,
self);
- g_free (string);
+ g_free (volume_name);
+ g_free (tooltip);
action = gtk_action_group_get_action (priv->import_group, action_name);
if (!action) {
@@ -1270,6 +1283,9 @@
priv = BRASERO_DATA_DISC_PRIVATE (self);
+ if (!priv->manager)
+ return;
+
if (available) {
gchar *string;
gchar *volume_name;
@@ -1279,19 +1295,15 @@
brasero_data_disc_import_button_new (self, medium);
/* ask user */
- volume_name = brasero_volume_get_display_label (BRASERO_VOLUME (medium), FALSE);
-
+ volume_name = brasero_volume_get_name (BRASERO_VOLUME (medium));
/* Translators: %s is the name of the volume to import */
- string = g_strdup_printf (_("Import %s"), volume_name);
- g_free (volume_name);
-
string = g_strdup_printf (_("Do you want to import the session from \'%s\'?"), volume_name);
message = brasero_notify_message_add (BRASERO_NOTIFY (priv->message),
string,
_("That way, old files from previous sessions will be usable after burning."),
10000,
BRASERO_NOTIFY_CONTEXT_MULTISESSION);
- g_free (string);
+ g_free (volume_name);
brasero_disc_message_set_image (BRASERO_DISC_MESSAGE (message),
GTK_STOCK_DIALOG_INFO);
@@ -1368,17 +1380,12 @@
brasero_data_disc_clear (BraseroDisc *disc)
{
BraseroDataDiscPrivate *priv;
- GtkAction *action;
priv = BRASERO_DATA_DISC_PRIVATE (disc);
if (priv->loading)
return;
- action = gtk_action_group_get_action (priv->disc_group, "ImportSession");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
-
if (brasero_data_session_get_loaded_medium (BRASERO_DATA_SESSION (priv->project)))
brasero_data_session_remove_last (BRASERO_DATA_SESSION (priv->project));
@@ -1389,7 +1396,6 @@
}
priv->overburning = FALSE;
-
priv->G2_files = FALSE;
priv->deep_directory = FALSE;
Modified: trunk/src/brasero-dest-selection.c
==============================================================================
--- trunk/src/brasero-dest-selection.c (original)
+++ trunk/src/brasero-dest-selection.c Sun Sep 28 13:27:05 2008
@@ -47,30 +47,23 @@
#include "burn-track.h"
#include "burn-medium.h"
#include "burn-session.h"
-#include "brasero-session-cfg.h"
#include "burn-plugin-manager.h"
#include "burn-drive.h"
-#include "brasero-drive-selection.h"
-#include "brasero-drive-properties.h"
-#include "brasero-drive-info.h"
-#include "brasero-image-properties.h"
-#include "brasero-dest-selection.h"
+#include "burn-volume-obj.h"
+#include "brasero-dest-selection.h"
+#include "brasero-session-cfg.h"
+#include "brasero-utils.h"
typedef struct _BraseroDestSelectionPrivate BraseroDestSelectionPrivate;
struct _BraseroDestSelectionPrivate
{
- BraseroBurnCaps *caps;
BraseroBurnSession *session;
+ BraseroBurnCaps *caps;
- GtkWidget *drive_prop;
- GtkWidget *button;
-
- glong valid_sig;
+ BraseroDrive *locked_drive;
- guint default_format:1;
- guint default_path:1;
- guint default_ext:1;
+ gulong valid_sig;
};
#define BRASERO_DEST_SELECTION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DEST_SELECTION, BraseroDestSelectionPrivate))
@@ -80,555 +73,99 @@
PROP_SESSION
};
-static BraseroDriveSelectionClass* parent_class = NULL;
-
-G_DEFINE_TYPE (BraseroDestSelection, brasero_dest_selection, BRASERO_TYPE_DRIVE_SELECTION);
-
-#define BRASERO_DEST_SAVED_FLAGS (BRASERO_DRIVE_PROPERTIES_FLAGS|BRASERO_BURN_FLAG_MULTI)
-
-static void
-brasero_dest_selection_drive_properties (BraseroDestSelection *self)
-{
- BraseroDestSelectionPrivate *priv;
- BraseroBurnFlag compulsory = 0;
- BraseroBurnFlag supported = 0;
- BraseroBurnFlag flags = 0;
- BraseroDrive *drive;
- GtkWidget *toplevel;
- const gchar *path;
- gint result;
- gint64 rate;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
-
- /* Build dialog */
- priv->drive_prop = brasero_drive_properties_new ();
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- gtk_window_set_transient_for (GTK_WINDOW (priv->drive_prop), GTK_WINDOW (toplevel));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (priv->drive_prop), TRUE);
- gtk_window_set_position (GTK_WINDOW (toplevel), GTK_WIN_POS_CENTER_ON_PARENT);
-
- /* get information */
- drive = brasero_burn_session_get_burner (priv->session);
- rate = brasero_burn_session_get_rate (priv->session);
-
- brasero_drive_properties_set_drive (BRASERO_DRIVE_PROPERTIES (priv->drive_prop),
- drive,
- rate);
-
- flags = brasero_burn_session_get_flags (priv->session);
- brasero_burn_caps_get_flags (priv->caps,
- priv->session,
- &supported,
- &compulsory);
-
- brasero_drive_properties_set_flags (BRASERO_DRIVE_PROPERTIES (priv->drive_prop),
- flags,
- supported,
- compulsory);
-
- path = brasero_burn_session_get_tmpdir (priv->session);
- brasero_drive_properties_set_tmpdir (BRASERO_DRIVE_PROPERTIES (priv->drive_prop),
- path);
-
- /* launch the dialog */
- gtk_widget_show_all (priv->drive_prop);
- result = gtk_dialog_run (GTK_DIALOG (priv->drive_prop));
- if (result != GTK_RESPONSE_ACCEPT) {
- gtk_widget_destroy (priv->drive_prop);
- priv->drive_prop = NULL;
- return;
- }
-
- rate = brasero_drive_properties_get_rate (BRASERO_DRIVE_PROPERTIES (priv->drive_prop));
- brasero_burn_session_set_rate (priv->session, rate);
-
- brasero_burn_session_remove_flag (priv->session, BRASERO_DRIVE_PROPERTIES_FLAGS);
- flags = brasero_drive_properties_get_flags (BRASERO_DRIVE_PROPERTIES (priv->drive_prop));
- brasero_burn_session_add_flag (priv->session, flags);
-
- path = brasero_drive_properties_get_tmpdir (BRASERO_DRIVE_PROPERTIES (priv->drive_prop));
- brasero_burn_session_set_tmpdir (priv->session, path);
-
- gtk_widget_destroy (priv->drive_prop);
- priv->drive_prop = NULL;
-}
-
-static gchar *
-brasero_dest_selection_get_output_path (BraseroDestSelection *self)
-{
- gchar *path = NULL;
- BraseroImageFormat format;
- BraseroDestSelectionPrivate *priv;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
-
- format = brasero_burn_session_get_output_format (priv->session);
- switch (format) {
- case BRASERO_IMAGE_FORMAT_BIN:
- brasero_burn_session_get_output (priv->session,
- &path,
- NULL,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CLONE:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CDRDAO:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CUE:
- brasero_burn_session_get_output (priv->session,
- NULL,
- &path,
- NULL);
- break;
-
- default:
- break;
- }
-
- return path;
-}
-
-static void
-brasero_dest_selection_set_output_path (BraseroDestSelection *self,
- BraseroImageFormat format,
- const gchar *path)
-{
- BraseroDestSelectionPrivate *priv;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
+G_DEFINE_TYPE (BraseroDestSelection, brasero_dest_selection, BRASERO_TYPE_MEDIUM_SELECTION);
- switch (format) {
- case BRASERO_IMAGE_FORMAT_BIN:
- brasero_burn_session_set_image_output_full (priv->session,
- format,
- path,
- NULL);
- break;
-
- case BRASERO_IMAGE_FORMAT_CDRDAO:
- case BRASERO_IMAGE_FORMAT_CLONE:
- case BRASERO_IMAGE_FORMAT_CUE:
- brasero_burn_session_set_image_output_full (priv->session,
- format,
- NULL,
- path);
- break;
- default:
- break;
- }
-}
-
-static guint
-brasero_dest_selection_get_possible_output_formats (BraseroDestSelection *self,
- BraseroImageFormat *formats)
+void
+brasero_dest_selection_lock (BraseroDestSelection *self,
+ gboolean locked)
{
- guint num = 0;
- BraseroTrackType output;
- BraseroImageFormat format;
BraseroDestSelectionPrivate *priv;
priv = BRASERO_DEST_SELECTION_PRIVATE (self);
- /* see how many output format are available */
- format = BRASERO_IMAGE_FORMAT_CDRDAO;
- (*formats) = BRASERO_IMAGE_FORMAT_NONE;
- output.type = BRASERO_TRACK_TYPE_IMAGE;
-
- for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
- BraseroBurnResult result;
-
- output.subtype.img_format = format;
- result = brasero_burn_caps_is_output_supported (priv->caps,
- priv->session,
- &output);
- if (result == BRASERO_BURN_OK) {
- (*formats) |= format;
- num ++;
- }
- }
-
- return num;
-}
-
-static void
-brasero_dest_selection_image_format_changed_cb (BraseroImageProperties *dialog,
- BraseroDestSelection *self)
-{
- BraseroDestSelectionPrivate *priv;
- BraseroImageFormat format;
- gchar *image_path;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
+ gtk_widget_set_sensitive (GTK_WIDGET (self), (locked != TRUE));
- /* make sure the extension is still valid */
- image_path = brasero_image_properties_get_path (dialog);
- if (!image_path)
- return;
-
- format = brasero_image_properties_get_format (dialog);
-
- if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE)
- format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
-
- if (priv->default_path && !brasero_image_properties_is_path_edited (dialog)) {
- /* not changed: get a new default path */
- g_free (image_path);
- image_path = brasero_image_format_get_default_path (format);
- }
- else if (image_path) {
- gchar *tmp;
-
- tmp = image_path;
- image_path = brasero_image_format_fix_path_extension (format, FALSE, image_path);
- g_free (tmp);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+ if (priv->locked_drive) {
+ brasero_drive_unlock (priv->locked_drive);
+ g_object_unref (priv->locked_drive);
+ }
+
+ if (locked) {
+ BraseroDrive *drive;
+
+ drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (self));
+ priv->locked_drive = drive;
+ if (priv->locked_drive)
+ brasero_drive_lock (priv->locked_drive,
+ _("ongoing burning process"),
+ NULL);
}
- else {
- priv->default_path = TRUE;
- image_path = brasero_image_format_get_default_path (format);
- }
-
- brasero_image_properties_set_path (dialog, image_path);
-}
-
-static gboolean
-brasero_dest_selection_image_check_extension (BraseroDestSelection *self,
- BraseroImageFormat format,
- const gchar *path)
-{
- gchar *dot;
- const gchar *suffixes [] = {".iso",
- ".toc",
- ".cue",
- ".toc",
- NULL };
-
- dot = g_utf8_strrchr (path, -1, '.');
- if (dot) {
- if (format & BRASERO_IMAGE_FORMAT_BIN
- && !strcmp (suffixes [0], dot))
- return TRUE;
- else if (format & BRASERO_IMAGE_FORMAT_CLONE
- && !strcmp (suffixes [1], dot))
- return TRUE;
- else if (format & BRASERO_IMAGE_FORMAT_CUE
- && !strcmp (suffixes [2], dot))
- return TRUE;
- else if (format & BRASERO_IMAGE_FORMAT_CDRDAO
- && !strcmp (suffixes [3], dot))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-brasero_dest_selection_image_extension_ask (BraseroDestSelection *self)
-{
- GtkWidget *dialog;
- GtkWidget *toplevel;
- GtkResponseType answer;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- _("Do you really want to keep the current extension for the disc image name?"));
-
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Image Extension"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you choose to keep it programs may not be able to recognize the file type properly."));
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Don't change extension"),
- GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("Change _extension"),
- GTK_RESPONSE_YES);
-
- answer = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- if (answer == GTK_RESPONSE_YES)
- return TRUE;
-
- return FALSE;
}
static void
-brasero_dest_selection_image_properties (BraseroDestSelection *self)
-{
- BraseroDestSelectionPrivate *priv;
- BraseroImageFormat formats;
- BraseroImageFormat format;
- gulong format_changed;
- gchar *original_path;
- GtkWindow *toplevel;
- gchar *image_path;
- gint answer;
- guint num;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
-
- priv->drive_prop = brasero_image_properties_new ();
-
- toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
- gtk_window_set_transient_for (GTK_WINDOW (priv->drive_prop), GTK_WINDOW (toplevel));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (priv->drive_prop), TRUE);
- gtk_window_set_position (GTK_WINDOW (toplevel), GTK_WIN_POS_CENTER_ON_PARENT);
-
- /* set all information namely path and format */
- original_path = brasero_dest_selection_get_output_path (self);
- brasero_image_properties_set_path (BRASERO_IMAGE_PROPERTIES (priv->drive_prop), original_path);
- g_free (original_path);
-
- if (!priv->default_format)
- format = brasero_burn_session_get_output_format (priv->session);
- else
- format = BRASERO_IMAGE_FORMAT_ANY;
-
- num = brasero_dest_selection_get_possible_output_formats (self, &formats);
- brasero_image_properties_set_formats (BRASERO_IMAGE_PROPERTIES (priv->drive_prop),
- num > 0 ? formats:BRASERO_IMAGE_FORMAT_NONE,
- format);
-
- format_changed = g_signal_connect (priv->drive_prop,
- "format-changed",
- G_CALLBACK (brasero_dest_selection_image_format_changed_cb),
- self);
-
- /* and here we go ... run the thing */
- gtk_widget_show (priv->drive_prop);
- answer = gtk_dialog_run (GTK_DIALOG (priv->drive_prop));
-
- g_signal_handler_disconnect (priv->drive_prop, format_changed);
-
- if (answer != GTK_RESPONSE_OK) {
- gtk_widget_destroy (priv->drive_prop);
- priv->drive_prop = NULL;
- return;
- }
-
- /* get and check format */
- format = brasero_image_properties_get_format (BRASERO_IMAGE_PROPERTIES (priv->drive_prop));
-
- /* see if we are to choose the format ourselves */
- if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE) {
- format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
- priv->default_format = TRUE;
- }
- else
- priv->default_format = FALSE;
-
- /* see if the user has changed the path */
- if (brasero_image_properties_is_path_edited (BRASERO_IMAGE_PROPERTIES (priv->drive_prop)))
- priv->default_path = FALSE;
-
- if (!priv->default_path) {
- /* check the extension */
- image_path = brasero_image_properties_get_path (BRASERO_IMAGE_PROPERTIES (priv->drive_prop));
-
- /* there is one special case: CLONE image tocs _must_ have a
- * correct suffix ".toc" so don't ask, fix it */
- if (!brasero_dest_selection_image_check_extension (self, format, image_path)) {
- if (format == BRASERO_IMAGE_FORMAT_CLONE
- || brasero_dest_selection_image_extension_ask (self)) {
- gchar *tmp;
-
- priv->default_ext = TRUE;
- tmp = image_path;
- image_path = brasero_image_format_fix_path_extension (format, TRUE, image_path);
- g_free (tmp);
- }
- else
- priv->default_ext = FALSE;
- }
- }
- else
- image_path = brasero_image_format_get_default_path (format);
-
- gtk_widget_destroy (priv->drive_prop);
- priv->drive_prop = NULL;
-
- brasero_dest_selection_set_output_path (self,
- format,
- image_path);
- g_free (image_path);
-}
-
-static void
-brasero_dest_selection_properties_button_cb (GtkWidget *button,
- BraseroDestSelection *self)
+brasero_dest_selection_valid_session (BraseroBurnSession *session,
+ BraseroSessionError is_valid,
+ BraseroDestSelection *self)
{
BraseroDestSelectionPrivate *priv;
+ BraseroDrive *burner;
BraseroDrive *drive;
priv = BRASERO_DEST_SELECTION_PRIVATE (self);
- drive = brasero_burn_session_get_burner (priv->session);
- if (!drive)
- return;
-
- if (brasero_drive_is_fake (drive))
- brasero_dest_selection_image_properties (self);
- else
- brasero_dest_selection_drive_properties (self);
-}
-
-static void
-brasero_dest_selection_update_image_output (BraseroDestSelection *self,
- gboolean is_valid)
-{
- BraseroDestSelectionPrivate *priv;
- BraseroImageFormat valid_format;
- BraseroImageFormat format;
- gchar *path = NULL;
-
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
-
- /* Get session current state */
- format = brasero_burn_session_get_output_format (priv->session);
- valid_format = format;
-
- /* Check current set format if it's invalid */
- if (format != BRASERO_IMAGE_FORMAT_NONE) {
- /* The user set a format. There is nothing to do about it except
- * checking if the format is still available. If not, then set
- * default and remove the current one */
- if (!is_valid) {
- priv->default_format = TRUE;
- valid_format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
- }
- else if (priv->default_format) {
- /* since input, or caps changed, check if there isn't a
- * better format available. */
- valid_format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
- }
- }
- else {
- /* This is always invalid; find one */
- priv->default_format = TRUE;
- valid_format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
- }
-
- /* see if we have a workable format */
- if (valid_format == BRASERO_IMAGE_FORMAT_NONE) {
- if (priv->drive_prop) {
- gtk_widget_destroy (priv->drive_prop);
- priv->drive_prop = NULL;
- }
-
- return;
- }
-
- path = brasero_dest_selection_get_output_path (self);
-
- /* Now check, fix the output path, _provided__the__format__changed_ */
- if (valid_format == format) {
- g_free (path);
- return;
- }
-
- if (!path) {
- priv->default_path = TRUE;
- priv->default_ext = TRUE;
- path = brasero_image_format_get_default_path (valid_format);
- }
- else if (priv->default_ext
- && brasero_dest_selection_image_check_extension (self, format, path)) {
- gchar *tmp;
-
- priv->default_ext = TRUE;
+ /* make sure the current displayed drive reflects that */
+ burner = brasero_burn_session_get_burner (priv->session);
+ drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (self));
+ if (burner != drive) {
+ BraseroMedium *medium;
- tmp = path;
- path = brasero_image_format_fix_path_extension (format, TRUE, path);
- g_free (tmp);
+ medium = brasero_drive_get_medium (drive);
+ brasero_medium_selection_set_active (BRASERO_MEDIUM_SELECTION (self), medium);
}
- /* we always need to do this */
- brasero_dest_selection_set_output_path (self,
- valid_format,
- path);
-
- g_free (path);
-
- if (priv->drive_prop) {
- BraseroImageFormat formats;
- guint num;
+ if (drive)
+ g_object_unref (drive);
- /* update image settings dialog if needed */
- num = brasero_dest_selection_get_possible_output_formats (self, &formats);
- brasero_image_properties_set_formats (BRASERO_IMAGE_PROPERTIES (priv->drive_prop),
- num > 1 ? formats:BRASERO_IMAGE_FORMAT_NONE,
- BRASERO_IMAGE_FORMAT_ANY);
- }
+ brasero_medium_selection_update_media_string (BRASERO_MEDIUM_SELECTION (self));
}
static void
-brasero_dest_selection_valid_session (BraseroBurnSession *session,
- BraseroSessionError is_valid,
- BraseroDestSelection *self)
+brasero_dest_selection_medium_changed (GtkComboBox *combo)
{
BraseroDestSelectionPrivate *priv;
- BraseroDrive *burner;
BraseroDrive *drive;
- priv = BRASERO_DEST_SELECTION_PRIVATE (self);
+ priv = BRASERO_DEST_SELECTION_PRIVATE (combo);
- /* make sure the current displayed drive reflects that */
- burner = brasero_burn_session_get_burner (priv->session);
- drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (self));
- if (burner != drive) {
- brasero_drive_selection_set_drive (BRASERO_DRIVE_SELECTION (self), drive);
+ if (!priv->session)
+ goto chain;
- if (priv->drive_prop) {
- /* cancel the drive properties dialog as it's not the same drive */
- gtk_dialog_response (GTK_DIALOG (priv->drive_prop), GTK_RESPONSE_CANCEL);
- }
+ drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (combo));
+ if (!drive) {
+ gtk_widget_set_sensitive (GTK_WIDGET (combo), FALSE);
+ goto chain;
}
- if (drive)
+ if (drive == brasero_burn_session_get_burner (priv->session)) {
g_object_unref (drive);
-
- if (!burner) {
- gtk_widget_set_sensitive (priv->button, is_valid == BRASERO_SESSION_VALID);
- return;
+ goto chain;
}
- /* do it now !!! */
- gtk_widget_set_sensitive (priv->button, is_valid == BRASERO_SESSION_VALID);
-
- if (brasero_drive_is_fake (burner))
- /* need to update the format and perhaps the path */
- brasero_dest_selection_update_image_output (self, is_valid == BRASERO_SESSION_VALID);
-}
+ brasero_burn_session_set_burner (priv->session, drive);
+ if (priv->locked_drive && priv->locked_drive != drive) {
+ brasero_drive_unlock (priv->locked_drive);
+ g_object_unref (priv->locked_drive);
+ priv->locked_drive = NULL;
+ }
-static void
-brasero_dest_selection_drive_changed (BraseroDriveSelection *selection,
- BraseroDrive *drive)
-{
- BraseroDestSelectionPrivate *priv;
+ gtk_widget_set_sensitive (GTK_WIDGET (combo), (priv->locked_drive == NULL));
- priv = BRASERO_DEST_SELECTION_PRIVATE (selection);
+chain:
- if (priv->session)
- brasero_burn_session_set_burner (priv->session, drive);
+ if (GTK_COMBO_BOX_CLASS (brasero_dest_selection_parent_class)->changed)
+ GTK_COMBO_BOX_CLASS (brasero_dest_selection_parent_class)->changed (combo);
}
static void
@@ -640,29 +177,11 @@
priv->caps = brasero_burn_caps_get_default ();
- priv->button = gtk_button_new_from_stock (GTK_STOCK_PROPERTIES);
- gtk_widget_show (priv->button);
- gtk_widget_set_tooltip_text (priv->button, _("Configure some options for the recording"));
- g_signal_connect (G_OBJECT (priv->button),
- "clicked",
- G_CALLBACK (brasero_dest_selection_properties_button_cb),
- object);
-
- brasero_drive_selection_set_tooltip (BRASERO_DRIVE_SELECTION (object),
- _("Choose the disc to write to"));
-
- brasero_drive_selection_set_button (BRASERO_DRIVE_SELECTION (object),
- priv->button);
-
/* Only show media on which we can write and which are in a burner.
* There is one exception though, when we're copying media and when the
* burning device is the same as the dest device. */
- brasero_drive_selection_set_type_shown (BRASERO_DRIVE_SELECTION (object),
- BRASERO_MEDIA_TYPE_WRITABLE);
-
- priv->default_ext = TRUE;
- priv->default_path = TRUE;
- priv->default_format = TRUE;
+ brasero_medium_selection_show_type (BRASERO_MEDIUM_SELECTION (object),
+ BRASERO_MEDIA_TYPE_WRITABLE);
}
static void
@@ -688,7 +207,7 @@
priv->session = NULL;
}
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (brasero_dest_selection_parent_class)->finalize (object);
}
static void
@@ -719,12 +238,13 @@
G_CALLBACK (brasero_dest_selection_valid_session),
object);
- drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (object));
+ drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (object));
brasero_burn_session_set_burner (session, drive);
if (drive)
g_object_unref (drive);
+ brasero_medium_selection_update_media_string (BRASERO_MEDIUM_SELECTION (object));
break;
default:
@@ -752,13 +272,140 @@
}
}
+static gchar *
+brasero_dest_selection_get_output_path (BraseroDestSelection *self)
+{
+ gchar *path = NULL;
+ BraseroImageFormat format;
+ BraseroDestSelectionPrivate *priv;
+
+ priv = BRASERO_DEST_SELECTION_PRIVATE (self);
+
+ format = brasero_burn_session_get_output_format (priv->session);
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ brasero_burn_session_get_output (priv->session,
+ &path,
+ NULL,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ brasero_burn_session_get_output (priv->session,
+ NULL,
+ &path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ brasero_burn_session_get_output (priv->session,
+ NULL,
+ &path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CUE:
+ brasero_burn_session_get_output (priv->session,
+ NULL,
+ &path,
+ NULL);
+ break;
+
+ default:
+ break;
+ }
+
+ return path;
+}
+
+static gchar *
+brasero_dest_selection_format_medium_string (BraseroMediumSelection *selection,
+ BraseroMedium *medium)
+{
+ gchar *label;
+ gint64 size = 0;
+ gchar *medium_name;
+ gchar *size_string;
+ BraseroMedia media;
+ BraseroBurnFlag flags;
+ BraseroTrackDataType input;
+ BraseroDestSelectionPrivate *priv;
+
+ priv = BRASERO_DEST_SELECTION_PRIVATE (selection);
+
+ medium_name = brasero_volume_get_name (BRASERO_VOLUME (medium));
+ if (brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE) {
+ gchar *path;
+
+ /* get the set path for the image file */
+ path = brasero_dest_selection_get_output_path (BRASERO_DEST_SELECTION (selection));
+
+ if (!path)
+ return medium_name;
+
+ /* NOTE for translators: the first %s is medium_name ("File
+ * Image") and the second the path for the image file */
+ label = g_strdup_printf (_("%s: \"%s\""),
+ medium_name,
+ path);
+ g_free (medium_name);
+ g_free (path);
+ return label;
+ }
+
+ if (!priv->session)
+ return NULL;
+
+ media = brasero_medium_get_status (medium);
+ flags = brasero_burn_session_get_flags (priv->session);
+
+ if ((media & BRASERO_MEDIUM_BLANK)
+ || (flags & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE)) {
+ brasero_medium_get_capacity (medium,
+ &size,
+ NULL);
+ }
+ else if (flags & (BRASERO_BURN_FLAG_MERGE|BRASERO_BURN_FLAG_APPEND)) {
+ brasero_medium_get_free_space (medium,
+ &size,
+ NULL);
+ }
+ else if (media & BRASERO_MEDIUM_CLOSED) {
+ /* NOTE for translators, the first %s is the medium name */
+ label = g_strdup_printf (_("%s: no free space"), medium_name);
+ g_free (medium_name);
+ return label;
+ }
+ else {
+ brasero_medium_get_capacity (medium,
+ &size,
+ NULL);
+ }
+
+ /* format the size */
+ input = brasero_burn_session_get_input_type (priv->session, NULL);
+ if (input == BRASERO_TRACK_TYPE_AUDIO)
+ size_string = brasero_utils_get_size_string (size,
+ TRUE,
+ TRUE);
+ else
+ size_string = g_format_size_for_display (size);
+
+ /* NOTE for translators: the first %s is the medium name, the second %s
+ * is its available free space. "Free" here is the free space available. */
+ label = g_strdup_printf (_("%s: %s of free space"), medium_name, size_string);
+ g_free (medium_name);
+ g_free (size_string);
+
+ return label;
+}
+
static void
brasero_dest_selection_class_init (BraseroDestSelectionClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- BraseroDriveSelectionClass *select_class = BRASERO_DRIVE_SELECTION_CLASS (klass);
-
- parent_class = BRASERO_DRIVE_SELECTION_CLASS (g_type_class_peek_parent (klass));
+ GtkComboBoxClass *combo_box_class = GTK_COMBO_BOX_CLASS (klass);
+ BraseroMediumSelectionClass *medium_selection_class = BRASERO_MEDIUM_SELECTION_CLASS (klass);
g_type_class_add_private (klass, sizeof (BraseroDestSelectionPrivate));
@@ -766,7 +413,9 @@
object_class->set_property = brasero_dest_selection_set_property;
object_class->get_property = brasero_dest_selection_get_property;
- select_class->drive_changed = brasero_dest_selection_drive_changed;
+ combo_box_class->changed = brasero_dest_selection_medium_changed;
+
+ medium_selection_class->format_medium_string = brasero_dest_selection_format_medium_string;
g_object_class_install_property (object_class,
PROP_SESSION,
@@ -782,7 +431,7 @@
{
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (session), NULL);
- return GTK_WIDGET (g_object_new (BRASERO_TYPE_DEST_SELECTION,
- "session", session,
- NULL));
+ return g_object_new (BRASERO_TYPE_DEST_SELECTION,
+ "session", session,
+ NULL);
}
Modified: trunk/src/brasero-dest-selection.h
==============================================================================
--- trunk/src/brasero-dest-selection.h (original)
+++ trunk/src/brasero-dest-selection.h Sun Sep 28 13:27:05 2008
@@ -27,7 +27,7 @@
#include <gtk/gtkwidget.h>
-#include "brasero-drive-selection.h"
+#include "brasero-medium-selection.h"
#include "burn-session.h"
G_BEGIN_DECLS
@@ -44,12 +44,12 @@
struct _BraseroDestSelectionClass
{
- BraseroDriveSelectionClass parent_class;
+ BraseroMediumSelectionClass parent_class;
};
struct _BraseroDestSelection
{
- BraseroDriveSelection parent_instance;
+ BraseroMediumSelection parent_instance;
};
GType brasero_dest_selection_get_type (void) G_GNUC_CONST;
@@ -57,6 +57,10 @@
GtkWidget *
brasero_dest_selection_new (BraseroBurnSession *session);
+void
+brasero_dest_selection_lock (BraseroDestSelection *session,
+ gboolean locked);
+
G_END_DECLS
#endif /* _BRASERO_DEST_SELECTION_H_ */
Modified: trunk/src/brasero-disc-copy-dialog.c
==============================================================================
--- trunk/src/brasero-disc-copy-dialog.c (original)
+++ trunk/src/brasero-disc-copy-dialog.c Sun Sep 28 13:27:05 2008
@@ -73,7 +73,8 @@
BraseroDiscCopyDialogPrivate *priv;
priv = BRASERO_DISC_COPY_DIALOG_PRIVATE (self);
- return brasero_drive_selection_set_drive (BRASERO_DRIVE_SELECTION (priv->source), drive);
+ return brasero_medium_selection_set_active (BRASERO_MEDIUM_SELECTION (priv->source),
+ brasero_drive_get_medium (drive));
}
static void
@@ -86,7 +87,6 @@
priv = BRASERO_DISC_COPY_DIALOG_PRIVATE (obj);
gtk_window_set_title (GTK_WINDOW (obj), _("CD/DVD Copy Options"));
-
brasero_burn_options_add_burn_button (BRASERO_BURN_OPTIONS (obj),
_("_Copy"),
"media-optical-burn");
@@ -94,6 +94,7 @@
/* take care of source media */
session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (obj));
priv->source = brasero_src_selection_new (session);
+ gtk_widget_show (priv->source);
g_object_unref (session);
title_str = g_strdup_printf ("<b>%s</b>", _("Select disc to copy"));
@@ -104,8 +105,8 @@
g_free (title_str);
/* only show media with something to be read on them */
- brasero_drive_selection_set_type_shown (BRASERO_DRIVE_SELECTION (priv->source),
- BRASERO_MEDIA_TYPE_READABLE);
+ brasero_medium_selection_show_type (BRASERO_MEDIUM_SELECTION (priv->source),
+ BRASERO_MEDIA_TYPE_READABLE);
/* This is a special case. When we're copying, someone may want to read
* and burn to the same drive so provided that the drive is a burner
Modified: trunk/src/brasero-drive-properties.h
==============================================================================
--- trunk/src/brasero-drive-properties.h (original)
+++ trunk/src/brasero-drive-properties.h Sun Sep 28 13:27:05 2008
@@ -27,6 +27,8 @@
#include <gtk/gtkdialog.h>
+#include "burn-drive.h"
+
G_BEGIN_DECLS
#define BRASERO_TYPE_DRIVE_PROPERTIES (brasero_drive_properties_get_type ())
Modified: trunk/src/brasero-image-option-dialog.c
==============================================================================
--- trunk/src/brasero-image-option-dialog.c (original)
+++ trunk/src/brasero-image-option-dialog.c Sun Sep 28 13:27:05 2008
@@ -42,33 +42,17 @@
#include <gconf/gconf-client.h>
#include "burn-basics.h"
-#include "burn-caps.h"
#include "burn-drive.h"
#include "brasero-utils.h"
-#include "brasero-session-cfg.h"
#include "brasero-image-option-dialog.h"
-#include "brasero-image-type-chooser.h"
-#include "brasero-dest-selection.h"
-#include "brasero-io.h"
+#include "brasero-src-image.h"
#include "brasero-burn-options.h"
-
-#define BRASERO_KEY_ISO_DIRECTORY "/apps/brasero/display/iso_folder"
G_DEFINE_TYPE (BraseroImageOptionDialog, brasero_image_option_dialog, BRASERO_TYPE_BURN_OPTIONS);
struct _BraseroImageOptionDialogPrivate {
- BraseroTrack *track;
-
- BraseroBurnCaps *caps;
-
- BraseroIO *io;
- BraseroIOJobBase *info_type;
-
- GtkWidget *format;
GtkWidget *file;
-
- gulong valid_sig;
};
typedef struct _BraseroImageOptionDialogPrivate BraseroImageOptionDialogPrivate;
@@ -76,282 +60,6 @@
static GtkDialogClass *parent_class = NULL;
-static const gchar *mimes [] = { "application/x-cd-image",
- "application/x-cue",
- "application/x-toc",
- "application/x-cdrdao-toc" };
-
-static void
-brasero_image_option_dialog_set_track (BraseroImageOptionDialog *dialog,
- BraseroImageFormat format,
- const gchar *image,
- const gchar *toc)
-{
- BraseroImageOptionDialogPrivate *priv;
- BraseroBurnSession *session;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
- session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (dialog));
-
- /* add a track every time to send a signal */
- if (priv->track) {
- gchar *uri = NULL;
- BraseroTrackType type = { 0, };
-
- /* make sure something actually changed */
- brasero_track_get_type (priv->track, &type);
-
- if (image)
- uri = brasero_track_get_image_source (priv->track, TRUE);
- else if (toc)
- uri = brasero_track_get_toc_source (priv->track, TRUE);
-
- if (!toc && !image && !uri) {
- g_object_unref (session);
- return;
- }
-
- if((format == type.subtype.img_format)
- && uri && (image || toc)
- && !strcmp (uri, image? image:toc)) {
- g_object_unref (session);
- g_free (uri);
- return;
- }
-
- g_free (uri);
-
- brasero_burn_session_clear_current_track (session);
- brasero_track_unref (priv->track);
- }
-
- /* set image type before adding so that signal has the right type */
- priv->track = brasero_track_new (BRASERO_TRACK_TYPE_IMAGE);
- brasero_track_set_image_source (priv->track,
- image,
- toc,
- format);
- brasero_burn_session_add_track (session, priv->track);
- g_object_unref (session);
-}
-
-static void
-brasero_image_option_dialog_image_info_cb (GObject *object,
- GError *error,
- const gchar *uri,
- GFileInfo *info,
- gpointer null_data)
-{
- BraseroImageOptionDialog *dialog = BRASERO_IMAGE_OPTION_DIALOG (object);
- BraseroImageOptionDialogPrivate *priv;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
-
- if (error) {
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_NONE,
- NULL,
- NULL);
- return;
- }
-
- if (!strcmp (g_file_info_get_content_type (info), "application/x-toc")
- || !strcmp (g_file_info_get_content_type (info), "application/x-cdrdao-toc")
- || !strcmp (g_file_info_get_content_type (info), "application/x-cue")) {
- BraseroImageFormat format;
- gchar *path;
-
- path = g_filename_from_uri (uri, NULL, NULL);
- format = brasero_image_format_identify_cuesheet (path);
- g_free (path);
-
- if (format != BRASERO_IMAGE_FORMAT_NONE)
- brasero_image_option_dialog_set_track (dialog,
- format,
- NULL,
- uri);
- else if (g_str_has_suffix (path, ".toc"))
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_CLONE,
- NULL,
- uri);
- else
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_NONE,
- NULL,
- uri);
- }
- else if (!strcmp (g_file_info_get_content_type (info), "application/octet-stream")) {
- /* that could be an image, so here is the deal:
- * if we can find the type through the extension, fine.
- * if not default to CLONE */
- if (g_str_has_suffix (uri, ".bin"))
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_CDRDAO,
- uri,
- NULL);
- else if (g_str_has_suffix (uri, ".raw"))
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_CLONE,
- uri,
- NULL);
- else
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_BIN,
- uri,
- NULL);
- }
- else if (!strcmp (g_file_info_get_content_type (info), "application/x-cd-image"))
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_BIN,
- uri,
- NULL);
- else
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_NONE,
- NULL,
- uri);
-}
-
-static void
-brasero_image_option_dialog_get_format (BraseroImageOptionDialog *dialog,
- gchar *uri)
-{
- BraseroImageOptionDialogPrivate *priv;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
-
- if (!uri) {
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_NONE,
- NULL,
- NULL);
- return;
- }
-
- if (!priv->io)
- priv->io = brasero_io_get_default ();
-
- if (!priv->info_type)
- priv->info_type = brasero_io_register (G_OBJECT (dialog),
- brasero_image_option_dialog_image_info_cb,
- NULL,
- NULL);
-
- brasero_io_get_file_info (priv->io,
- uri,
- priv->info_type,
- BRASERO_IO_INFO_MIME,
- NULL);
-}
-
-static void
-brasero_image_option_dialog_changed (BraseroImageOptionDialog *dialog)
-{
- gchar *uri;
- BraseroImageFormat format;
- BraseroImageOptionDialogPrivate *priv;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
-
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->file));
- brasero_image_type_chooser_get_format (BRASERO_IMAGE_TYPE_CHOOSER (priv->format), &format);
-
- switch (format) {
- case BRASERO_IMAGE_FORMAT_NONE:
- brasero_image_option_dialog_get_format (dialog, uri);
- break;
- case BRASERO_IMAGE_FORMAT_BIN:
- brasero_image_option_dialog_set_track (dialog,
- format,
- uri,
- NULL);
- break;
- case BRASERO_IMAGE_FORMAT_CUE:
- brasero_image_option_dialog_set_track (dialog,
- format,
- NULL,
- uri);
- break;
- case BRASERO_IMAGE_FORMAT_CDRDAO:
- brasero_image_option_dialog_set_track (dialog,
- format,
- NULL,
- uri);
- break;
- case BRASERO_IMAGE_FORMAT_CLONE:
- brasero_image_option_dialog_set_track (dialog,
- format,
- NULL,
- uri);
- break;
- default:
- break;
- }
- g_free (uri);
-}
-
-static void
-brasero_image_option_dialog_format_changed (BraseroImageTypeChooser *format,
- BraseroImageOptionDialog *dialog)
-{
- brasero_image_option_dialog_changed (dialog);
-}
-
-static void
-brasero_image_option_dialog_file_changed (GtkFileChooser *chooser,
- BraseroImageOptionDialog *dialog)
-{
- brasero_image_option_dialog_changed (dialog);
-}
-
-static void
-brasero_image_option_dialog_set_formats (BraseroImageOptionDialog *dialog)
-{
- BraseroImageOptionDialogPrivate *priv;
- BraseroBurnSession *session;
- BraseroImageFormat formats;
- BraseroImageFormat format;
- BraseroTrackType output;
- BraseroTrackType input;
- BraseroMedium *medium;
- BraseroDrive *drive;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
-
- if (!priv->format)
- return;
-
- session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (dialog));
-
- /* get the available image types */
- output.type = BRASERO_TRACK_TYPE_DISC;
- drive = brasero_burn_session_get_burner (session);
- medium = brasero_drive_get_medium (drive);
- output.subtype.media = brasero_medium_get_status (medium);
-
- input.type = BRASERO_TRACK_TYPE_IMAGE;
- formats = BRASERO_IMAGE_FORMAT_NONE;
- format = BRASERO_IMAGE_FORMAT_CDRDAO;
-
- for (; format != BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
- BraseroBurnResult result;
-
- input.subtype.img_format = format;
- result = brasero_burn_caps_is_input_supported (priv->caps,
- session,
- &input,
- FALSE);
- if (result == BRASERO_BURN_OK)
- formats |= format;
- }
-
- brasero_image_type_chooser_set_formats (BRASERO_IMAGE_TYPE_CHOOSER (priv->format),
- formats);
-
- g_object_unref (session);
-}
-
void
brasero_image_option_dialog_set_image_uri (BraseroImageOptionDialog *dialog,
const gchar *uri)
@@ -360,335 +68,40 @@
priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
- brasero_image_option_dialog_set_formats (dialog);
- if (uri)
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (priv->file), uri);
- else
- brasero_image_option_dialog_set_track (dialog,
- BRASERO_IMAGE_FORMAT_NONE,
- NULL,
- NULL);
-}
-
-static void
-brasero_image_option_dialog_image_info_error (BraseroImageOptionDialog *dialog)
-{
- GtkWidget *message;
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (dialog));
- message = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("This image can't be burnt:"));
-
- gtk_window_set_title (GTK_WINDOW (message), _("Invalid Image"));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
- _("it doesn't appear to be a valid image or a valid cue file."));
-
- gtk_dialog_run (GTK_DIALOG (message));
- gtk_widget_destroy (message);
-}
-
-static void
-brasero_image_option_dialog_image_empty (BraseroImageOptionDialog *dialog)
-{
- GtkWidget *message;
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (dialog));
- message = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("There is no specified image:"));
-
- gtk_window_set_title (GTK_WINDOW (message), _("No Image"));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
- _("Please, choose an image and retry."));
-
- gtk_dialog_run (GTK_DIALOG (message));
- gtk_widget_destroy (message);
-}
-
-BraseroBurnSession *
-brasero_image_option_dialog_get_session (BraseroImageOptionDialog *dialog)
-{
- gchar *uri = NULL;
- gchar *groups [] = { "brasero",
- NULL };
- GtkRecentData recent_data = { NULL,
- NULL,
- NULL,
- "brasero",
- "brasero -p %u",
- groups,
- FALSE };
- BraseroImageOptionDialogPrivate *priv;
- BraseroTrackType type;
- gchar *image;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (dialog);
-
- /* check that all could be set for the session */
- image = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->file));
- if (!image) {
- brasero_image_option_dialog_image_empty (dialog);
- return NULL;
- }
- g_free (image);
-
- brasero_track_get_type (priv->track, &type);
- if (type.type == BRASERO_TRACK_TYPE_NONE
- || type.subtype.img_format == BRASERO_IMAGE_FORMAT_NONE) {
- brasero_image_option_dialog_image_info_error (dialog);
- return NULL;
- }
-
- /* Add it to recent file manager */
- switch (type.subtype.img_format) {
- case BRASERO_IMAGE_FORMAT_BIN:
- recent_data.mime_type = (gchar *) mimes [0];
- uri = brasero_track_get_image_source (priv->track, TRUE);
- break;
-
- case BRASERO_IMAGE_FORMAT_CUE:
- recent_data.mime_type = (gchar *) mimes [1];
- uri = brasero_track_get_toc_source (priv->track, TRUE);
- break;
-
- case BRASERO_IMAGE_FORMAT_CLONE:
- recent_data.mime_type = (gchar *) mimes [2];
- uri = brasero_track_get_toc_source (priv->track, TRUE);
- break;
-
- case BRASERO_IMAGE_FORMAT_CDRDAO:
- recent_data.mime_type = (gchar *) mimes [3];
- uri = brasero_track_get_toc_source (priv->track, TRUE);
- break;
-
- default:
- break;
- }
-
- if (uri) {
- GtkRecentManager *recent;
-
- recent = gtk_recent_manager_get_default ();
- gtk_recent_manager_add_full (recent,
- uri,
- &recent_data);
- g_free (uri);
- }
-
- return brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (dialog));
-}
-
-static void
-brasero_image_option_dialog_valid_media_cb (BraseroBurnSession *session,
- BraseroSessionError valid,
- BraseroImageOptionDialog *self)
-{
- brasero_image_option_dialog_set_formats (self);
-}
-
-static void
-brasero_image_option_dialog_file_chooser_destroy (GtkWidget *file,
- BraseroImageOptionDialog *self)
-{
- BraseroImageOptionDialogPrivate *priv;
- GConfClient *client;
- gchar *uri;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (self);
-
- uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (priv->file));
- if (uri) {
- client = gconf_client_get_default ();
- gconf_client_set_string (client, BRASERO_KEY_ISO_DIRECTORY, uri, NULL);
- g_object_unref (client);
- g_free (uri);
- }
+ brasero_src_image_set_uri (BRASERO_SRC_IMAGE (priv->file), uri);
}
static void
brasero_image_option_dialog_init (BraseroImageOptionDialog *obj)
{
- gchar *uri;
gchar *string;
- GtkWidget *box1;
- GtkWidget *label;
- GConfClient *client;
- GtkFileFilter *filter;
BraseroBurnSession *session;
BraseroImageOptionDialogPrivate *priv;
priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (obj);
- priv->caps = brasero_burn_caps_get_default ();
-
- session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (obj));
- priv->valid_sig = g_signal_connect (session,
- "is-valid",
- G_CALLBACK (brasero_image_option_dialog_valid_media_cb),
- obj);
- g_object_unref (session);
-
brasero_burn_options_set_type_shown (BRASERO_BURN_OPTIONS (obj),
BRASERO_MEDIA_TYPE_WRITABLE);
/* Image properties */
- box1 = gtk_table_new (2, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (box1), 6);
- gtk_widget_show (box1);
-
- label = gtk_label_new (_("Path:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (box1),
- label,
- 0,
- 1,
- 0,
- 1,
- GTK_FILL,
- GTK_FILL,
- 0,
- 0);
-
- priv->file = gtk_file_chooser_button_new (_("Open an image"), GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (priv->file), FALSE);
-
- client = gconf_client_get_default ();
- uri = gconf_client_get_string (client, BRASERO_KEY_ISO_DIRECTORY, NULL);
- g_object_unref (client);
- if (uri) {
- if (!gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (priv->file), uri))
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (priv->file), g_get_home_dir ());
-
- g_free (uri);
- }
- else
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (priv->file), g_get_home_dir ());
-
- g_signal_connect (priv->file,
- "destroy",
- G_CALLBACK (brasero_image_option_dialog_file_chooser_destroy),
- obj);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("All files"));
- gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (priv->file), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Image files only"));
- gtk_file_filter_add_mime_type (filter, mimes [0]);
- gtk_file_filter_add_mime_type (filter, mimes [1]);
- gtk_file_filter_add_mime_type (filter, mimes [2]);
- gtk_file_filter_add_mime_type (filter, mimes [3]);
- gtk_file_filter_add_mime_type (filter, "image/*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (priv->file), filter);
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (priv->file), filter);
-
- gtk_table_attach (GTK_TABLE (box1),
- priv->file,
- 1,
- 2,
- 0,
- 1,
- GTK_EXPAND|GTK_FILL,
- GTK_EXPAND|GTK_FILL,
- 0,
- 0);
- g_signal_connect (priv->file,
- "selection-changed",
- G_CALLBACK (brasero_image_option_dialog_file_changed),
- obj);
-
- label = gtk_label_new (_("Image type:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_table_attach (GTK_TABLE (box1),
- label,
- 0,
- 1,
- 1,
- 2,
- GTK_FILL,
- GTK_FILL,
- 0,
- 0);
-
- priv->format = brasero_image_type_chooser_new ();
- gtk_table_attach (GTK_TABLE (box1),
- priv->format,
- 1,
- 2,
- 1,
- 2,
- GTK_EXPAND|GTK_FILL,
- GTK_EXPAND|GTK_FILL,
- 0,
- 0);
- g_signal_connect (priv->format,
- "changed",
- G_CALLBACK (brasero_image_option_dialog_format_changed),
- obj);
+ session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (obj));
+ priv->file = brasero_src_image_new (session);
+ g_object_unref (session);
- string = g_strdup_printf ("<b>%s</b>", _("Image"));
+ gtk_widget_show (priv->file);
+
+ /* pack everything */
+ string = g_strdup_printf ("<b>%s</b>", _("Select an image to write"));
brasero_burn_options_add_source (BRASERO_BURN_OPTIONS (obj),
string,
- box1,
+ priv->file,
NULL);
g_free (string);
-
- gtk_widget_show_all (box1);
-
- brasero_image_option_dialog_set_formats (obj);
}
static void
brasero_image_option_dialog_finalize (GObject *object)
{
- BraseroImageOptionDialogPrivate *priv;
-
- priv = BRASERO_IMAGE_OPTION_DIALOG_PRIVATE (object);
-
- if (priv->io) {
- brasero_io_cancel_by_base (priv->io, priv->info_type);
-
- g_free (priv->info_type);
- priv->info_type = NULL;
-
- g_object_unref (priv->io);
- priv->io = NULL;
- }
-
- if (priv->track) {
- brasero_track_unref (priv->track);
- priv->track = NULL;
- }
-
- if (priv->valid_sig) {
- BraseroBurnSession *session;
-
- session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (object));
- g_signal_handler_disconnect (session, priv->valid_sig);
- g_object_unref (session);
-
- priv->valid_sig = 0;
- }
-
- if (priv->caps) {
- g_object_unref (priv->caps);
- priv->caps = NULL;
- }
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
Modified: trunk/src/brasero-image-option-dialog.h
==============================================================================
--- trunk/src/brasero-image-option-dialog.h (original)
+++ trunk/src/brasero-image-option-dialog.h Sun Sep 28 13:27:05 2008
@@ -32,6 +32,8 @@
#include <gtk/gtkwidget.h>
+#include "burn-session.h"
+
#include "brasero-burn-options.h"
G_BEGIN_DECLS
@@ -60,8 +62,6 @@
void
brasero_image_option_dialog_set_image_uri (BraseroImageOptionDialog *dialog,
const gchar *uri);
-BraseroBurnSession *
-brasero_image_option_dialog_get_session (BraseroImageOptionDialog *dialog);
G_END_DECLS
Added: trunk/src/brasero-medium-properties.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-medium-properties.c Sun Sep 28 13:27:05 2008
@@ -0,0 +1,702 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#include "brasero-medium-properties.h"
+#include "brasero-drive-properties.h"
+#include "brasero-image-properties.h"
+#include "brasero-session-cfg.h"
+
+#include "burn-basics.h"
+#include "burn-caps.h"
+#include "burn-track.h"
+#include "burn-medium.h"
+#include "burn-session.h"
+
+typedef struct _BraseroMediumPropertiesPrivate BraseroMediumPropertiesPrivate;
+struct _BraseroMediumPropertiesPrivate
+{
+ BraseroBurnSession *session;
+ BraseroBurnCaps *caps;
+
+ GtkWidget *medium_prop;
+
+ glong valid_sig;
+
+ guint default_format:1;
+ guint default_path:1;
+ guint default_ext:1;
+};
+
+#define BRASERO_MEDIUM_PROPERTIES_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_MEDIUM_PROPERTIES, BraseroMediumPropertiesPrivate))
+
+enum {
+ PROP_0,
+ PROP_SESSION
+};
+
+G_DEFINE_TYPE (BraseroMediumProperties, brasero_medium_properties, GTK_TYPE_BUTTON);
+
+static void
+brasero_medium_properties_drive_properties (BraseroMediumProperties *self)
+{
+ BraseroMediumPropertiesPrivate *priv;
+ BraseroBurnFlag compulsory = 0;
+ BraseroBurnFlag supported = 0;
+ BraseroBurnFlag flags = 0;
+ BraseroDrive *drive;
+ GtkWidget *toplevel;
+ const gchar *path;
+ gint result;
+ gint64 rate;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ /* Build dialog */
+ priv->medium_prop = brasero_drive_properties_new ();
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ gtk_window_set_transient_for (GTK_WINDOW (priv->medium_prop), GTK_WINDOW (toplevel));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (priv->medium_prop), TRUE);
+ gtk_window_set_position (GTK_WINDOW (toplevel), GTK_WIN_POS_CENTER_ON_PARENT);
+
+ /* get information */
+ drive = brasero_burn_session_get_burner (priv->session);
+ rate = brasero_burn_session_get_rate (priv->session);
+
+ brasero_drive_properties_set_drive (BRASERO_DRIVE_PROPERTIES (priv->medium_prop),
+ drive,
+ rate);
+
+ flags = brasero_burn_session_get_flags (priv->session);
+ brasero_burn_caps_get_flags (priv->caps,
+ priv->session,
+ &supported,
+ &compulsory);
+
+ brasero_drive_properties_set_flags (BRASERO_DRIVE_PROPERTIES (priv->medium_prop),
+ flags,
+ supported,
+ compulsory);
+
+ path = brasero_burn_session_get_tmpdir (priv->session);
+ brasero_drive_properties_set_tmpdir (BRASERO_DRIVE_PROPERTIES (priv->medium_prop),
+ path);
+
+ /* launch the dialog */
+ gtk_widget_show_all (priv->medium_prop);
+ result = gtk_dialog_run (GTK_DIALOG (priv->medium_prop));
+ if (result != GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy (priv->medium_prop);
+ priv->medium_prop = NULL;
+ return;
+ }
+
+ rate = brasero_drive_properties_get_rate (BRASERO_DRIVE_PROPERTIES (priv->medium_prop));
+ brasero_burn_session_set_rate (priv->session, rate);
+
+ brasero_burn_session_remove_flag (priv->session, BRASERO_DRIVE_PROPERTIES_FLAGS);
+ flags = brasero_drive_properties_get_flags (BRASERO_DRIVE_PROPERTIES (priv->medium_prop));
+ brasero_burn_session_add_flag (priv->session, flags);
+
+ path = brasero_drive_properties_get_tmpdir (BRASERO_DRIVE_PROPERTIES (priv->medium_prop));
+ brasero_burn_session_set_tmpdir (priv->session, path);
+
+ gtk_widget_destroy (priv->medium_prop);
+ priv->medium_prop = NULL;
+}
+
+static gchar *
+brasero_medium_properties_get_output_path (BraseroMediumProperties *self)
+{
+ gchar *path = NULL;
+ BraseroImageFormat format;
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ format = brasero_burn_session_get_output_format (priv->session);
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ brasero_burn_session_get_output (priv->session,
+ &path,
+ NULL,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ brasero_burn_session_get_output (priv->session,
+ NULL,
+ &path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ brasero_burn_session_get_output (priv->session,
+ NULL,
+ &path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CUE:
+ brasero_burn_session_get_output (priv->session,
+ NULL,
+ &path,
+ NULL);
+ break;
+
+ default:
+ break;
+ }
+
+ return path;
+}
+
+static void
+brasero_medium_properties_set_output_path (BraseroMediumProperties *self,
+ BraseroImageFormat format,
+ const gchar *path)
+{
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ brasero_burn_session_set_image_output_full (priv->session,
+ format,
+ path,
+ NULL);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ case BRASERO_IMAGE_FORMAT_CUE:
+ brasero_burn_session_set_image_output_full (priv->session,
+ format,
+ NULL,
+ path);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static guint
+brasero_medium_properties_get_possible_output_formats (BraseroMediumProperties *self,
+ BraseroImageFormat *formats)
+{
+ guint num = 0;
+ BraseroTrackType output;
+ BraseroImageFormat format;
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ /* see how many output format are available */
+ format = BRASERO_IMAGE_FORMAT_CDRDAO;
+ (*formats) = BRASERO_IMAGE_FORMAT_NONE;
+ output.type = BRASERO_TRACK_TYPE_IMAGE;
+
+ for (; format > BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
+ BraseroBurnResult result;
+
+ output.subtype.img_format = format;
+ result = brasero_burn_caps_is_output_supported (priv->caps,
+ priv->session,
+ &output);
+ if (result == BRASERO_BURN_OK) {
+ (*formats) |= format;
+ num ++;
+ }
+ }
+
+ return num;
+}
+
+static void
+brasero_medium_properties_image_format_changed_cb (BraseroImageProperties *dialog,
+ BraseroMediumProperties *self)
+{
+ BraseroMediumPropertiesPrivate *priv;
+ BraseroImageFormat format;
+ gchar *image_path;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ /* make sure the extension is still valid */
+ image_path = brasero_image_properties_get_path (dialog);
+ if (!image_path)
+ return;
+
+ format = brasero_image_properties_get_format (dialog);
+
+ if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE)
+ format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
+
+ if (priv->default_path && !brasero_image_properties_is_path_edited (dialog)) {
+ /* not changed: get a new default path */
+ g_free (image_path);
+ image_path = brasero_image_format_get_default_path (format);
+ }
+ else if (image_path) {
+ gchar *tmp;
+
+ tmp = image_path;
+ image_path = brasero_image_format_fix_path_extension (format, FALSE, image_path);
+ g_free (tmp);
+ }
+ else {
+ priv->default_path = TRUE;
+ image_path = brasero_image_format_get_default_path (format);
+ }
+
+ brasero_image_properties_set_path (dialog, image_path);
+}
+
+static gboolean
+brasero_medium_properties_image_check_extension (BraseroMediumProperties *self,
+ BraseroImageFormat format,
+ const gchar *path)
+{
+ gchar *dot;
+ const gchar *suffixes [] = {".iso",
+ ".toc",
+ ".cue",
+ ".toc",
+ NULL };
+
+ dot = g_utf8_strrchr (path, -1, '.');
+ if (dot) {
+ if (format & BRASERO_IMAGE_FORMAT_BIN
+ && !strcmp (suffixes [0], dot))
+ return TRUE;
+ else if (format & BRASERO_IMAGE_FORMAT_CLONE
+ && !strcmp (suffixes [1], dot))
+ return TRUE;
+ else if (format & BRASERO_IMAGE_FORMAT_CUE
+ && !strcmp (suffixes [2], dot))
+ return TRUE;
+ else if (format & BRASERO_IMAGE_FORMAT_CDRDAO
+ && !strcmp (suffixes [3], dot))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+brasero_medium_properties_image_extension_ask (BraseroMediumProperties *self)
+{
+ GtkWidget *dialog;
+ GtkWidget *toplevel;
+ GtkResponseType answer;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _("Do you really want to keep the current extension for the disc image name?"));
+
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Image Extension"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("If you choose to keep it programs may not be able to recognize the file type properly."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Don't change extension"),
+ GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("Change _extension"),
+ GTK_RESPONSE_YES);
+
+ answer = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (answer == GTK_RESPONSE_YES)
+ return TRUE;
+
+ return FALSE;
+}
+
+static void
+brasero_medium_properties_image_properties (BraseroMediumProperties *self)
+{
+ BraseroMediumPropertiesPrivate *priv;
+ BraseroImageFormat formats;
+ BraseroImageFormat format;
+ gulong format_changed;
+ gchar *original_path;
+ GtkWindow *toplevel;
+ gchar *image_path;
+ gint answer;
+ guint num;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ priv->medium_prop = brasero_image_properties_new ();
+
+ toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
+ gtk_window_set_transient_for (GTK_WINDOW (priv->medium_prop), GTK_WINDOW (toplevel));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (priv->medium_prop), TRUE);
+ gtk_window_set_position (GTK_WINDOW (toplevel), GTK_WIN_POS_CENTER_ON_PARENT);
+
+ /* set all information namely path and format */
+ original_path = brasero_medium_properties_get_output_path (self);
+ brasero_image_properties_set_path (BRASERO_IMAGE_PROPERTIES (priv->medium_prop), original_path);
+ g_free (original_path);
+
+ if (!priv->default_format)
+ format = brasero_burn_session_get_output_format (priv->session);
+ else
+ format = BRASERO_IMAGE_FORMAT_ANY;
+
+ num = brasero_medium_properties_get_possible_output_formats (self, &formats);
+ brasero_image_properties_set_formats (BRASERO_IMAGE_PROPERTIES (priv->medium_prop),
+ num > 0 ? formats:BRASERO_IMAGE_FORMAT_NONE,
+ format);
+
+ format_changed = g_signal_connect (priv->medium_prop,
+ "format-changed",
+ G_CALLBACK (brasero_medium_properties_image_format_changed_cb),
+ self);
+
+ /* and here we go ... run the thing */
+ gtk_widget_show (priv->medium_prop);
+ answer = gtk_dialog_run (GTK_DIALOG (priv->medium_prop));
+
+ g_signal_handler_disconnect (priv->medium_prop, format_changed);
+
+ if (answer != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (priv->medium_prop);
+ priv->medium_prop = NULL;
+ return;
+ }
+
+ /* get and check format */
+ format = brasero_image_properties_get_format (BRASERO_IMAGE_PROPERTIES (priv->medium_prop));
+
+ /* see if we are to choose the format ourselves */
+ if (format == BRASERO_IMAGE_FORMAT_ANY || format == BRASERO_IMAGE_FORMAT_NONE) {
+ format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
+ priv->default_format = TRUE;
+ }
+ else
+ priv->default_format = FALSE;
+
+ /* see if the user has changed the path */
+ if (brasero_image_properties_is_path_edited (BRASERO_IMAGE_PROPERTIES (priv->medium_prop)))
+ priv->default_path = FALSE;
+
+ if (!priv->default_path) {
+ /* check the extension */
+ image_path = brasero_image_properties_get_path (BRASERO_IMAGE_PROPERTIES (priv->medium_prop));
+
+ /* there is one special case: CLONE image tocs _must_ have a
+ * correct suffix ".toc" so don't ask, fix it */
+ if (!brasero_medium_properties_image_check_extension (self, format, image_path)) {
+ if (format == BRASERO_IMAGE_FORMAT_CLONE
+ || brasero_medium_properties_image_extension_ask (self)) {
+ gchar *tmp;
+
+ priv->default_ext = TRUE;
+ tmp = image_path;
+ image_path = brasero_image_format_fix_path_extension (format, TRUE, image_path);
+ g_free (tmp);
+ }
+ else
+ priv->default_ext = FALSE;
+ }
+ }
+ else
+ image_path = brasero_image_format_get_default_path (format);
+
+ gtk_widget_destroy (priv->medium_prop);
+ priv->medium_prop = NULL;
+
+ brasero_medium_properties_set_output_path (self,
+ format,
+ image_path);
+ g_free (image_path);
+}
+
+static void
+brasero_medium_properties_clicked (GtkButton *button)
+{
+ BraseroMediumPropertiesPrivate *priv;
+ BraseroDrive *drive;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (button);
+
+ drive = brasero_burn_session_get_burner (priv->session);
+ if (!drive)
+ return;
+
+ if (brasero_drive_is_fake (drive))
+ brasero_medium_properties_image_properties (BRASERO_MEDIUM_PROPERTIES (button));
+ else
+ brasero_medium_properties_drive_properties (BRASERO_MEDIUM_PROPERTIES (button));
+}
+
+static void
+brasero_medium_properties_update_image_output (BraseroMediumProperties *self,
+ gboolean is_valid)
+{
+ BraseroMediumPropertiesPrivate *priv;
+ BraseroImageFormat valid_format;
+ BraseroImageFormat format;
+ gchar *path = NULL;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ /* Get session current state */
+ format = brasero_burn_session_get_output_format (priv->session);
+ valid_format = format;
+
+ /* Check current set format if it's invalid */
+ if (format != BRASERO_IMAGE_FORMAT_NONE) {
+ /* The user set a format. There is nothing to do about it except
+ * checking if the format is still available. If not, then set
+ * default and remove the current one */
+ if (!is_valid) {
+ priv->default_format = TRUE;
+ valid_format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
+ }
+ else if (priv->default_format) {
+ /* since input, or caps changed, check if there isn't a
+ * better format available. */
+ valid_format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
+ }
+ }
+ else {
+ /* This is always invalid; find one */
+ priv->default_format = TRUE;
+ valid_format = brasero_burn_caps_get_default_output_format (priv->caps, priv->session);
+ }
+
+ /* see if we have a workable format */
+ if (valid_format == BRASERO_IMAGE_FORMAT_NONE) {
+ if (priv->medium_prop) {
+ gtk_widget_destroy (priv->medium_prop);
+ priv->medium_prop = NULL;
+ }
+
+ return;
+ }
+
+ path = brasero_medium_properties_get_output_path (self);
+
+ /* Now check, fix the output path, _provided__the__format__changed_ */
+ if (valid_format == format) {
+ g_free (path);
+ return;
+ }
+
+ if (!path) {
+ priv->default_path = TRUE;
+ priv->default_ext = TRUE;
+ path = brasero_image_format_get_default_path (valid_format);
+ }
+ else if (priv->default_ext
+ && brasero_medium_properties_image_check_extension (self, format, path)) {
+ gchar *tmp;
+
+ priv->default_ext = TRUE;
+
+ tmp = path;
+ path = brasero_image_format_fix_path_extension (format, TRUE, path);
+ g_free (tmp);
+ }
+
+ /* we always need to do this */
+ brasero_medium_properties_set_output_path (self,
+ valid_format,
+ path);
+
+ g_free (path);
+
+ if (priv->medium_prop) {
+ BraseroImageFormat formats;
+ guint num;
+
+ /* update image settings dialog if needed */
+ num = brasero_medium_properties_get_possible_output_formats (self, &formats);
+ brasero_image_properties_set_formats (BRASERO_IMAGE_PROPERTIES (priv->medium_prop),
+ num > 1 ? formats:BRASERO_IMAGE_FORMAT_NONE,
+ BRASERO_IMAGE_FORMAT_ANY);
+ }
+}
+
+static void
+brasero_medium_properties_valid_session (BraseroBurnSession *session,
+ BraseroSessionError is_valid,
+ BraseroMediumProperties *self)
+{
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ /* make sure the current displayed path is valid */
+ if (brasero_burn_session_is_dest_file (priv->session))
+ brasero_medium_properties_update_image_output (self, is_valid == BRASERO_SESSION_VALID);
+}
+
+static void
+brasero_medium_properties_init (BraseroMediumProperties *object)
+{
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (object);
+
+ priv->caps = brasero_burn_caps_get_default ();
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (object), _("Configure some options for the recording"));
+
+ priv->default_ext = TRUE;
+ priv->default_path = TRUE;
+ priv->default_format = TRUE;
+}
+
+static void
+brasero_medium_properties_finalize (GObject *object)
+{
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (object);
+
+ if (priv->caps) {
+ g_object_unref (priv->caps);
+ priv->caps = NULL;
+ }
+
+ if (priv->valid_sig) {
+ g_signal_handler_disconnect (priv->session,
+ priv->valid_sig);
+ priv->valid_sig = 0;
+ }
+
+ if (priv->session) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
+ }
+
+ G_OBJECT_CLASS (brasero_medium_properties_parent_class)->finalize (object);
+}
+
+static void
+brasero_medium_properties_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroMediumPropertiesPrivate *priv;
+ BraseroBurnSession *session;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ if (priv->session)
+ g_object_unref (priv->session);
+
+ session = g_value_get_object (value);
+
+ /* NOTE: no need to unref a potential previous session since
+ * it's only set at construct time */
+ priv->session = session;
+ g_object_ref (session);
+
+ priv->valid_sig = g_signal_connect (session,
+ "is-valid",
+ G_CALLBACK (brasero_medium_properties_valid_session),
+ object);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_medium_properties_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ g_value_set_object (value, priv->session);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_medium_properties_class_init (BraseroMediumPropertiesClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GtkButtonClass* button_class = GTK_BUTTON_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroMediumPropertiesPrivate));
+
+ object_class->finalize = brasero_medium_properties_finalize;
+ object_class->set_property = brasero_medium_properties_set_property;
+ object_class->get_property = brasero_medium_properties_get_property;
+
+ button_class->clicked = brasero_medium_properties_clicked;
+ g_object_class_install_property (object_class,
+ PROP_SESSION,
+ g_param_spec_object ("session",
+ "The session to work with",
+ "The session to work with",
+ BRASERO_TYPE_BURN_SESSION,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+
+}
+
+GtkWidget *
+brasero_medium_properties_new (BraseroBurnSession *session)
+{
+ return g_object_new (BRASERO_TYPE_MEDIUM_PROPERTIES,
+ "session", session,
+ "use-stock", TRUE,
+ "label", GTK_STOCK_PROPERTIES,
+ "focus-on-click", FALSE,
+ NULL);
+}
Added: trunk/src/brasero-medium-properties.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-medium-properties.h Sun Sep 28 13:27:05 2008
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BRASERO_MEDIUM_PROPERTIES_H_
+#define _BRASERO_MEDIUM_PROPERTIES_H_
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "burn-session.h"
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_MEDIUM_PROPERTIES (brasero_medium_properties_get_type ())
+#define BRASERO_MEDIUM_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_MEDIUM_PROPERTIES, BraseroMediumProperties))
+#define BRASERO_MEDIUM_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_MEDIUM_PROPERTIES, BraseroMediumPropertiesClass))
+#define BRASERO_IS_MEDIUM_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_MEDIUM_PROPERTIES))
+#define BRASERO_IS_MEDIUM_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_MEDIUM_PROPERTIES))
+#define BRASERO_MEDIUM_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_MEDIUM_PROPERTIES, BraseroMediumPropertiesClass))
+
+typedef struct _BraseroMediumPropertiesClass BraseroMediumPropertiesClass;
+typedef struct _BraseroMediumProperties BraseroMediumProperties;
+
+struct _BraseroMediumPropertiesClass
+{
+ GtkButtonClass parent_class;
+};
+
+struct _BraseroMediumProperties
+{
+ GtkButton parent_instance;
+};
+
+GType brasero_medium_properties_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+brasero_medium_properties_new (BraseroBurnSession *session);
+
+G_END_DECLS
+
+#endif /* _BRASERO_MEDIUM_PROPERTIES_H_ */
Modified: trunk/src/brasero-medium-selection.c
==============================================================================
--- trunk/src/brasero-medium-selection.c (original)
+++ trunk/src/brasero-medium-selection.c Sun Sep 28 13:27:05 2008
@@ -31,9 +31,12 @@
#include <gtk/gtk.h>
#include "brasero-medium-selection.h"
+#include "brasero-utils.h"
+
#include "burn-medium.h"
#include "burn-volume-obj.h"
#include "burn-basics.h"
+#include "burn-medium-monitor.h"
typedef struct _BraseroMediumSelectionPrivate BraseroMediumSelectionPrivate;
struct _BraseroMediumSelectionPrivate
@@ -54,21 +57,117 @@
G_DEFINE_TYPE (BraseroMediumSelection, brasero_medium_selection, GTK_TYPE_COMBO_BOX);
-enum {
- MEDIUM_CHANGED,
- LAST_SIGNAL
-};
-static gulong medium_selection_signals [LAST_SIGNAL];
+static gchar *
+brasero_medium_selection_get_medium_string (BraseroMediumSelection *self,
+ BraseroMedium *medium)
+{
+ gchar *label;
+ gint64 size = 0;
+ gchar *size_string;
+ gchar *medium_name;
+ BraseroMedia media;
+ BraseroMediumSelectionClass *klass;
-static void
-brasero_medium_selection_changed (GtkComboBox *box)
+ klass = BRASERO_MEDIUM_SELECTION_GET_CLASS (self);
+ if (klass->format_medium_string) {
+ gchar *label;
+
+ label = klass->format_medium_string (self, medium);
+ if (label)
+ return label;
+ }
+
+ medium_name = brasero_volume_get_name (BRASERO_VOLUME (medium));
+ if (brasero_medium_get_status (medium) & BRASERO_MEDIUM_FILE)
+ return medium_name;
+
+ media = brasero_medium_get_status (medium);
+ if (media & BRASERO_MEDIUM_BLANK) {
+ /* NOTE for translators, the first %s is the medium name */
+ label = g_strdup_printf (_("%s: empty"), medium_name);
+ g_free (medium_name);
+
+ return label;
+ }
+
+ brasero_medium_get_data_size (medium,
+ &size,
+ NULL);
+
+ /* format the size */
+ if (media & BRASERO_MEDIUM_HAS_DATA)
+ size_string = g_format_size_for_display (size);
+ else
+ size_string = brasero_utils_get_size_string (size,
+ TRUE,
+ TRUE);
+
+ /* NOTE for translators: the first %s is the medium name, the second %s
+ * is the space used by data on the disc. */
+ label = g_strdup_printf (_("%s: %s of data"), medium_name, size_string);
+ g_free (medium_name);
+ g_free (size_string);
+
+ return label;
+}
+
+void
+brasero_medium_selection_update_media_string (BraseroMediumSelection *self)
{
+ GtkTreeModel *model;
GtkTreeIter iter;
- if (gtk_combo_box_get_active_iter (box, &iter))
- g_signal_emit (box,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return;
+
+ do {
+ BraseroMedium *medium;
+ gchar *label;
+
+ medium = NULL;
+ gtk_tree_model_get (model, &iter,
+ MEDIUM_COL, &medium,
+ -1);
+ if (!medium)
+ continue;
+
+ label = brasero_medium_selection_get_medium_string (self, medium);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ NAME_COL, label,
+ -1);
+
+ g_object_unref (medium);
+ g_free (label);
+ } while (gtk_tree_model_iter_next (model, &iter));
+
+}
+
+static void
+brasero_drive_selection_set_tooltip (BraseroMediumSelection *self)
+{
+ BraseroMediumSelectionPrivate *priv;
+ BraseroMedium *medium;
+ gchar *tooltip;
+
+ priv = BRASERO_MEDIUM_SELECTION_PRIVATE (self);
+
+ medium = brasero_medium_selection_get_active (self);
+ if (medium) {
+ tooltip = brasero_medium_get_tooltip (medium);
+ g_object_unref (medium);
+ }
+ else
+ tooltip = NULL;
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), tooltip);
+ g_free (tooltip);
+}
+
+static void
+brasero_medium_selection_changed (GtkComboBox *box)
+{
+ brasero_drive_selection_set_tooltip (BRASERO_MEDIUM_SELECTION (box));
}
gboolean
@@ -93,9 +192,6 @@
if (medium == iter_medium) {
g_object_unref (iter_medium);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
- g_signal_emit (self,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
result = TRUE;
break;
}
@@ -123,6 +219,32 @@
return medium;
}
+BraseroDrive *
+brasero_medium_selection_get_active_drive (BraseroMediumSelection *self)
+{
+ BraseroMedium *medium;
+ BraseroDrive *drive;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter))
+ return NULL;
+
+ gtk_tree_model_get (model, &iter,
+ MEDIUM_COL, &medium,
+ -1);
+
+ if (!medium)
+ return NULL;
+
+ drive = brasero_medium_get_drive (medium);
+ g_object_unref (medium);
+ g_object_ref (drive);
+
+ return drive;
+}
+
void
brasero_medium_selection_show_type (BraseroMediumSelection *self,
BraseroMediaType type)
@@ -184,7 +306,7 @@
medium = item->data;
- medium_name = brasero_volume_get_display_label (BRASERO_VOLUME (medium), TRUE);
+ medium_name = brasero_medium_selection_get_medium_string (self, medium);
medium_icon = brasero_medium_get_icon (medium);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
@@ -207,18 +329,11 @@
-1),
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
- g_signal_emit (self,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
return;
}
if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1)
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
- else
- g_signal_emit (self,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
}
static void
@@ -273,7 +388,7 @@
g_object_unref (tmp);
}
- medium_name = brasero_volume_get_display_label (BRASERO_VOLUME (medium), TRUE);
+ medium_name = brasero_medium_selection_get_medium_string (self, medium);
medium_icon = brasero_medium_get_icon (medium);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
@@ -283,12 +398,8 @@
-1);
g_free (medium_name);
- if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1) {
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1)
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
- g_signal_emit (self,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
- }
}
static void
@@ -330,18 +441,11 @@
-1),
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
- g_signal_emit (self,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
return;
}
- if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1) {
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1)
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
- g_signal_emit (self,
- medium_selection_signals [MEDIUM_CHANGED],
- 0);
- }
}
static void
@@ -375,13 +479,13 @@
gtk_combo_box_set_model (GTK_COMBO_BOX (object), GTK_TREE_MODEL (model));
g_object_unref (model);
-/* renderer = gtk_cell_renderer_pixbuf_new ();
+ renderer = gtk_cell_renderer_pixbuf_new ();
g_object_set (renderer, "follow-state", TRUE, NULL);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, FALSE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer,
"icon-name", ICON_COL,
NULL);
-*/
+
renderer = gtk_cell_renderer_text_new ();
g_object_set (renderer, "xpad", 8, NULL);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, TRUE);
@@ -421,17 +525,6 @@
object_class->finalize = brasero_medium_selection_finalize;
combo_class->changed = brasero_medium_selection_changed;
-
- medium_selection_signals [MEDIUM_CHANGED] =
- g_signal_new ("medium_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0,
- G_TYPE_NONE);
}
GtkWidget *
Modified: trunk/src/brasero-medium-selection.h
==============================================================================
--- trunk/src/brasero-medium-selection.h (original)
+++ trunk/src/brasero-medium-selection.h Sun Sep 28 13:27:05 2008
@@ -29,6 +29,7 @@
#include "burn-medium-monitor.h"
#include "burn-medium.h"
+#include "burn-drive.h"
G_BEGIN_DECLS
@@ -45,6 +46,10 @@
struct _BraseroMediumSelectionClass
{
GtkComboBoxClass parent_class;
+
+ /* virtual function */
+ gchar * (*format_medium_string) (BraseroMediumSelection *selection,
+ BraseroMedium *medium);
};
struct _BraseroMediumSelection
@@ -57,16 +62,22 @@
BraseroMedium *
-brasero_medium_selection_get_active (BraseroMediumSelection *self);
+brasero_medium_selection_get_active (BraseroMediumSelection *selection);
+
+BraseroDrive *
+brasero_medium_selection_get_active_drive (BraseroMediumSelection *selection);
gboolean
-brasero_medium_selection_set_active (BraseroMediumSelection *self,
+brasero_medium_selection_set_active (BraseroMediumSelection *selection,
BraseroMedium *medium);
void
-brasero_medium_selection_show_type (BraseroMediumSelection *self,
+brasero_medium_selection_show_type (BraseroMediumSelection *selection,
BraseroMediaType type);
+void
+brasero_medium_selection_update_media_string (BraseroMediumSelection *selection);
+
G_END_DECLS
#endif /* _BRASERO_MEDIUM_SELECTION_H_ */
Modified: trunk/src/brasero-project-manager.c
==============================================================================
--- trunk/src/brasero-project-manager.c (original)
+++ trunk/src/brasero-project-manager.c Sun Sep 28 13:27:05 2008
@@ -579,7 +579,7 @@
return;
}
- session = brasero_image_option_dialog_get_session (BRASERO_IMAGE_OPTION_DIALOG (dialog));
+ session = brasero_burn_options_get_session (BRASERO_BURN_OPTIONS (dialog));
gtk_widget_destroy (dialog);
if (!session)
Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c (original)
+++ trunk/src/brasero-project.c Sun Sep 28 13:27:05 2008
@@ -1322,6 +1322,7 @@
g_slist_free (uris);
gtk_widget_destroy (GTK_WIDGET (project->priv->chooser));
+ project->priv->chooser = NULL;
}
static void
@@ -1334,6 +1335,7 @@
if (response != BRASERO_RESPONSE_ADD) {
gtk_widget_destroy (chooser);
+ project->priv->chooser = NULL;
return;
}
@@ -1348,6 +1350,7 @@
g_slist_free (uris);
gtk_widget_destroy (GTK_WIDGET (project->priv->chooser));
+ project->priv->chooser = NULL;
}
static void
Modified: trunk/src/brasero-session-cfg.h
==============================================================================
--- trunk/src/brasero-session-cfg.h (original)
+++ trunk/src/brasero-session-cfg.h Sun Sep 28 13:27:05 2008
@@ -68,6 +68,7 @@
typedef enum {
BRASERO_SESSION_VALID = 0,
BRASERO_SESSION_NO_INPUT_IMAGE = 1,
+ BRASERO_SESSION_UNKNOWN_IMAGE,
BRASERO_SESSION_NO_INPUT_MEDIUM,
BRASERO_SESSION_NO_OUTPUT,
BRASERO_SESSION_NOT_SUPPORTED,
Added: trunk/src/brasero-src-image.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-src-image.c Sun Sep 28 13:27:05 2008
@@ -0,0 +1,669 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include <gconf/gconf-client.h>
+
+#include "burn-basics.h"
+#include "burn-caps.h"
+#include "burn-drive.h"
+
+#include "brasero-utils.h"
+#include "brasero-image-type-chooser.h"
+#include "brasero-io.h"
+#include "brasero-session-cfg.h"
+#include "brasero-src-image.h"
+
+typedef struct _BraseroSrcImagePrivate BraseroSrcImagePrivate;
+struct _BraseroSrcImagePrivate
+{
+ BraseroBurnSession *session;
+ BraseroTrack *track;
+
+ BraseroBurnCaps *caps;
+
+ BraseroIO *io;
+ BraseroIOJobBase *info_type;
+
+ GtkWidget *format;
+ GtkWidget *label;
+ GtkWidget *file;
+};
+
+#define BRASERO_SRC_IMAGE_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_SRC_IMAGE, BraseroSrcImagePrivate))
+
+G_DEFINE_TYPE (BraseroSrcImage, brasero_src_image, GTK_TYPE_BUTTON);
+
+enum {
+ PROP_0,
+ PROP_SESSION
+};
+
+#define BRASERO_KEY_ISO_DIRECTORY "/apps/brasero/display/iso_folder"
+
+static const gchar *mimes [] = { "application/x-cd-image",
+ "application/x-cue",
+ "application/x-toc",
+ "application/x-cdrdao-toc" };
+
+static void
+brasero_src_image_save (BraseroSrcImage *self)
+{
+ gchar *uri = NULL;
+ BraseroTrackType type;
+ GtkRecentManager *recent;
+ gchar *groups [] = { "brasero",
+ NULL };
+ GtkRecentData recent_data = { NULL,
+ NULL,
+ NULL,
+ "brasero",
+ "brasero -p %u",
+ groups,
+ FALSE };
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (self);
+
+ brasero_track_get_type (priv->track, &type);
+ if (type.type == BRASERO_TRACK_TYPE_NONE
+ || type.subtype.img_format == BRASERO_IMAGE_FORMAT_NONE)
+ return;
+
+ /* Add it to recent file manager */
+ switch (type.subtype.img_format) {
+ case BRASERO_IMAGE_FORMAT_BIN:
+ recent_data.mime_type = (gchar *) mimes [0];
+ uri = brasero_track_get_image_source (priv->track, TRUE);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CUE:
+ recent_data.mime_type = (gchar *) mimes [1];
+ uri = brasero_track_get_toc_source (priv->track, TRUE);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ recent_data.mime_type = (gchar *) mimes [2];
+ uri = brasero_track_get_toc_source (priv->track, TRUE);
+ break;
+
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ recent_data.mime_type = (gchar *) mimes [3];
+ uri = brasero_track_get_toc_source (priv->track, TRUE);
+ break;
+
+ default:
+ break;
+ }
+
+ if (!uri)
+ return;
+
+ /* save as recent */
+ recent = gtk_recent_manager_get_default ();
+ gtk_recent_manager_add_full (recent,
+ uri,
+ &recent_data);
+ g_free (uri);
+}
+
+static void
+brasero_src_image_set_track (BraseroSrcImage *dialog,
+ BraseroImageFormat format,
+ const gchar *image,
+ const gchar *toc)
+{
+ gint64 size;
+ gchar *path;
+ gchar *string;
+ gchar *size_string;
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (dialog);
+
+ /* add a track every time to send a signal */
+ if (priv->track) {
+ gchar *uri = NULL;
+ BraseroTrackType type = { 0, };
+
+ /* make sure something actually changed */
+ brasero_track_get_type (priv->track, &type);
+
+ if (image)
+ uri = brasero_track_get_image_source (priv->track, TRUE);
+ else if (toc)
+ uri = brasero_track_get_toc_source (priv->track, TRUE);
+
+ if (!toc && !image && !uri)
+ return;
+
+ if((format == type.subtype.img_format)
+ && uri && (image || toc)
+ && !strcmp (uri, image? image:toc)) {
+ g_free (uri);
+ return;
+ }
+
+ g_free (uri);
+
+ brasero_burn_session_clear_current_track (priv->session);
+ brasero_track_unref (priv->track);
+ }
+
+ /* set image type before adding so that signal has the right type */
+ priv->track = brasero_track_new (BRASERO_TRACK_TYPE_IMAGE);
+ brasero_track_set_image_source (priv->track,
+ image,
+ toc,
+ format);
+ brasero_burn_session_add_track (priv->session, priv->track);
+
+ if (!toc && !image && format == BRASERO_IMAGE_FORMAT_NONE)
+ return;
+
+ brasero_track_get_image_size (priv->track,
+ NULL,
+ NULL,
+ &size,
+ NULL);
+
+ size_string = g_format_size_for_display (size);
+ path = NULL;
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_NONE:
+ case BRASERO_IMAGE_FORMAT_BIN:
+ path = g_filename_from_uri (image?image:toc, NULL, NULL);
+ break;
+ case BRASERO_IMAGE_FORMAT_CUE:
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ path = g_filename_from_uri (toc, NULL, NULL);
+ break;
+ default:
+ break;
+ }
+
+ if (!path) {
+ g_free (size_string);
+ return;
+ }
+
+ /* NOTE to translators, the first %s is the path of the image
+ * file and the second its size. */
+ string = g_strdup_printf (_("\"%s\": %s"), path, size_string);
+ g_free (size_string);
+ g_free (path);
+
+ if (string) {
+ gtk_label_set_text (GTK_LABEL (priv->label), string);
+ g_free (string);
+ }
+}
+
+static void
+brasero_src_image_image_info_cb (GObject *object,
+ GError *error,
+ const gchar *uri,
+ GFileInfo *info,
+ gpointer null_data)
+{
+ BraseroSrcImage *dialog = BRASERO_SRC_IMAGE (object);
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (dialog);
+
+ if (error) {
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_NONE,
+ NULL,
+ NULL);
+ return;
+ }
+
+ if (!strcmp (g_file_info_get_content_type (info), "application/x-toc")
+ || !strcmp (g_file_info_get_content_type (info), "application/x-cdrdao-toc")
+ || !strcmp (g_file_info_get_content_type (info), "application/x-cue")) {
+ BraseroImageFormat format;
+ gchar *path;
+
+ path = g_filename_from_uri (uri, NULL, NULL);
+ format = brasero_image_format_identify_cuesheet (path);
+ g_free (path);
+
+ if (format != BRASERO_IMAGE_FORMAT_NONE)
+ brasero_src_image_set_track (dialog,
+ format,
+ NULL,
+ uri);
+ else if (g_str_has_suffix (path, ".toc"))
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_CLONE,
+ NULL,
+ uri);
+ else
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_NONE,
+ NULL,
+ uri);
+ }
+ else if (!strcmp (g_file_info_get_content_type (info), "application/octet-stream")) {
+ /* that could be an image, so here is the deal:
+ * if we can find the type through the extension, fine.
+ * if not default to CLONE */
+ if (g_str_has_suffix (uri, ".bin"))
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_CDRDAO,
+ uri,
+ NULL);
+ else if (g_str_has_suffix (uri, ".raw"))
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_CLONE,
+ uri,
+ NULL);
+ else
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_BIN,
+ uri,
+ NULL);
+ }
+ else if (!strcmp (g_file_info_get_content_type (info), "application/x-cd-image"))
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_BIN,
+ uri,
+ NULL);
+ else
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_NONE,
+ NULL,
+ uri);
+}
+
+static void
+brasero_src_image_get_format (BraseroSrcImage *dialog,
+ const gchar *uri)
+{
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (dialog);
+
+ if (!uri) {
+ brasero_src_image_set_track (dialog,
+ BRASERO_IMAGE_FORMAT_NONE,
+ NULL,
+ NULL);
+ return;
+ }
+
+ if (!priv->io)
+ priv->io = brasero_io_get_default ();
+
+ if (!priv->info_type)
+ priv->info_type = brasero_io_register (G_OBJECT (dialog),
+ brasero_src_image_image_info_cb,
+ NULL,
+ NULL);
+
+ brasero_io_get_file_info (priv->io,
+ uri,
+ priv->info_type,
+ BRASERO_IO_INFO_MIME,
+ NULL);
+}
+
+static void
+brasero_src_image_changed (BraseroSrcImage *dialog)
+{
+ gchar *uri;
+ gchar *parent;
+ GConfClient *client;
+ BraseroImageFormat format;
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (dialog);
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (priv->file));
+ brasero_image_type_chooser_get_format (BRASERO_IMAGE_TYPE_CHOOSER (priv->format), &format);
+
+ switch (format) {
+ case BRASERO_IMAGE_FORMAT_NONE:
+ brasero_src_image_get_format (dialog, uri);
+ break;
+ case BRASERO_IMAGE_FORMAT_BIN:
+ brasero_src_image_set_track (dialog,
+ format,
+ uri,
+ NULL);
+ break;
+ case BRASERO_IMAGE_FORMAT_CUE:
+ brasero_src_image_set_track (dialog,
+ format,
+ NULL,
+ uri);
+ break;
+ case BRASERO_IMAGE_FORMAT_CDRDAO:
+ brasero_src_image_set_track (dialog,
+ format,
+ NULL,
+ uri);
+ break;
+ case BRASERO_IMAGE_FORMAT_CLONE:
+ brasero_src_image_set_track (dialog,
+ format,
+ NULL,
+ uri);
+ break;
+ default:
+ break;
+ }
+
+ /* save directory path */
+ client = gconf_client_get_default ();
+ parent = g_path_get_dirname (uri);
+ gconf_client_set_string (client, BRASERO_KEY_ISO_DIRECTORY, parent, NULL);
+ g_object_unref (client);
+ g_free (parent);
+ g_free (uri);
+}
+
+static void
+brasero_src_image_set_formats (BraseroSrcImage *dialog)
+{
+ BraseroSrcImagePrivate *priv;
+ BraseroImageFormat formats;
+ BraseroImageFormat format;
+ BraseroTrackType output;
+ BraseroTrackType input;
+ BraseroMedium *medium;
+ BraseroDrive *drive;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (dialog);
+
+ if (!priv->format)
+ return;
+
+ /* get the available image types */
+ output.type = BRASERO_TRACK_TYPE_DISC;
+ drive = brasero_burn_session_get_burner (priv->session);
+ medium = brasero_drive_get_medium (drive);
+ output.subtype.media = brasero_medium_get_status (medium);
+
+ input.type = BRASERO_TRACK_TYPE_IMAGE;
+ formats = BRASERO_IMAGE_FORMAT_NONE;
+ format = BRASERO_IMAGE_FORMAT_CDRDAO;
+
+ for (; format != BRASERO_IMAGE_FORMAT_NONE; format >>= 1) {
+ BraseroBurnResult result;
+
+ input.subtype.img_format = format;
+ result = brasero_burn_caps_is_input_supported (priv->caps,
+ priv->session,
+ &input,
+ FALSE);
+ if (result == BRASERO_BURN_OK)
+ formats |= format;
+ }
+
+ brasero_image_type_chooser_set_formats (BRASERO_IMAGE_TYPE_CHOOSER (priv->format),
+ formats);
+}
+
+static void
+brasero_src_image_clicked (GtkButton *button)
+{
+ BraseroSrcImagePrivate *priv;
+ GtkResponseType response;
+ GtkFileFilter *filter;
+ GtkWidget *toplevel;
+ GConfClient *client;
+ GtkWidget *label;
+ GtkWidget *box;
+ gchar *uri;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (button);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ priv->file = gtk_file_chooser_dialog_new (_("Select Image File"),
+ GTK_WINDOW (toplevel),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (priv->file), FALSE);
+
+ client = gconf_client_get_default ();
+ uri = gconf_client_get_string (client, BRASERO_KEY_ISO_DIRECTORY, NULL);
+ g_object_unref (client);
+ if (uri) {
+ if (!gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (priv->file), uri))
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (priv->file), g_get_home_dir ());
+
+ g_free (uri);
+ }
+ else
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (priv->file), g_get_home_dir ());
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (priv->file), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Image files only"));
+ gtk_file_filter_add_mime_type (filter, mimes [0]);
+ gtk_file_filter_add_mime_type (filter, mimes [1]);
+ gtk_file_filter_add_mime_type (filter, mimes [2]);
+ gtk_file_filter_add_mime_type (filter, mimes [3]);
+ gtk_file_filter_add_mime_type (filter, "image/*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (priv->file), filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (priv->file), filter);
+
+ /* add the type chooser to the dialog */
+ box = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show (box);
+ gtk_box_pack_end (GTK_BOX (GTK_DIALOG (priv->file)->vbox),
+ box,
+ FALSE,
+ FALSE,
+ 0);
+
+ label = gtk_label_new (_("Image type:"));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
+ priv->format = brasero_image_type_chooser_new ();
+ gtk_widget_show (priv->format);
+ gtk_box_pack_start (GTK_BOX (box),
+ priv->format,
+ TRUE,
+ TRUE,
+ 0);
+
+ brasero_src_image_set_formats (BRASERO_SRC_IMAGE (button));
+
+ gtk_widget_show (priv->file);
+ response = gtk_dialog_run (GTK_DIALOG (priv->file));
+
+ if (response == GTK_RESPONSE_OK)
+ brasero_src_image_changed (BRASERO_SRC_IMAGE (button));
+
+ gtk_widget_destroy (priv->file);
+ priv->file = NULL;
+ priv->format = NULL;
+}
+
+void
+brasero_src_image_set_uri (BraseroSrcImage *self,
+ const gchar *uri)
+{
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (self);
+
+ if (uri)
+ brasero_src_image_get_format (self, uri);
+ else
+ brasero_src_image_set_track (self,
+ BRASERO_IMAGE_FORMAT_NONE,
+ NULL,
+ NULL);
+}
+
+static void
+brasero_src_image_init (BraseroSrcImage *object)
+{
+ BraseroSrcImagePrivate *priv;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *box;
+ gchar *string;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (object);
+
+ priv->caps = brasero_burn_caps_get_default ();
+
+ string = g_strdup_printf ("<i>%s</i>", _("Click here to select an _image"));
+ label = gtk_label_new_with_mnemonic (string);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_START);
+ gtk_widget_show (label);
+ g_free (string);
+
+ priv->label = label;
+
+ image = gtk_image_new_from_icon_name ("iso-image-new", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image);
+
+ box = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show (box);
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+
+ gtk_container_add (GTK_CONTAINER (object), box);
+}
+
+static void
+brasero_src_image_finalize (GObject *object)
+{
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (object);
+
+ brasero_src_image_save (BRASERO_SRC_IMAGE (object));
+
+ if (priv->session) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
+ }
+
+ if (priv->caps) {
+ g_object_unref (priv->caps);
+ priv->caps = NULL;
+ }
+
+ G_OBJECT_CLASS (brasero_src_image_parent_class)->finalize (object);
+}
+
+static void
+brasero_src_image_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroSrcImagePrivate *priv;
+ BraseroBurnSession *session;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ if (priv->session)
+ g_object_unref (priv->session);
+
+ session = g_value_get_object (value);
+
+ /* NOTE: no need to unref a potential previous session since
+ * it's only set at construct time */
+ priv->session = session;
+ g_object_ref (session);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_src_image_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroSrcImagePrivate *priv;
+
+ priv = BRASERO_SRC_IMAGE_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ g_value_set_object (value, priv->session);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_src_image_class_init (BraseroSrcImageClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GtkButtonClass* parent_class = GTK_BUTTON_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroSrcImagePrivate));
+
+ object_class->finalize = brasero_src_image_finalize;
+ object_class->set_property = brasero_src_image_set_property;
+ object_class->get_property = brasero_src_image_get_property;
+
+ parent_class->clicked = brasero_src_image_clicked;
+ g_object_class_install_property (object_class,
+ PROP_SESSION,
+ g_param_spec_object ("session",
+ "The session to work with",
+ "The session to work with",
+ BRASERO_TYPE_BURN_SESSION,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+}
+
+GtkWidget *
+brasero_src_image_new (BraseroBurnSession *session)
+{
+ return g_object_new (BRASERO_TYPE_SRC_IMAGE,
+ "session", session,
+ NULL);
+}
Added: trunk/src/brasero-src-image.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-src-image.h Sun Sep 28 13:27:05 2008
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BRASERO_SRC_IMAGE_H_
+#define _BRASERO_SRC_IMAGE_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_SRC_IMAGE (brasero_src_image_get_type ())
+#define BRASERO_SRC_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_SRC_IMAGE, BraseroSrcImage))
+#define BRASERO_SRC_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_SRC_IMAGE, BraseroSrcImageClass))
+#define BRASERO_IS_SRC_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_SRC_IMAGE))
+#define BRASERO_IS_SRC_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_SRC_IMAGE))
+#define BRASERO_SRC_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_SRC_IMAGE, BraseroSrcImageClass))
+
+typedef struct _BraseroSrcImageClass BraseroSrcImageClass;
+typedef struct _BraseroSrcImage BraseroSrcImage;
+
+struct _BraseroSrcImageClass
+{
+ GtkButtonClass parent_class;
+};
+
+struct _BraseroSrcImage
+{
+ GtkButton parent_instance;
+};
+
+GType brasero_src_image_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+brasero_src_image_new (BraseroBurnSession *session);
+
+void
+brasero_src_image_set_uri (BraseroSrcImage *self,
+ const gchar *uri);
+
+G_END_DECLS
+
+#endif /* _BRASERO_SRC_IMAGE_H_ */
Modified: trunk/src/brasero-src-selection.c
==============================================================================
--- trunk/src/brasero-src-selection.c (original)
+++ trunk/src/brasero-src-selection.c Sun Sep 28 13:27:05 2008
@@ -26,20 +26,22 @@
#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
#include "brasero-src-selection.h"
-#include "brasero-src-info.h"
-#include "brasero-drive-selection.h"
+#include "brasero-medium-selection.h"
+#include "brasero-utils.h"
+
#include "burn-track.h"
#include "burn-session.h"
#include "burn-drive.h"
+#include "burn-volume-obj.h"
typedef struct _BraseroSrcSelectionPrivate BraseroSrcSelectionPrivate;
struct _BraseroSrcSelectionPrivate
{
BraseroBurnSession *session;
BraseroTrack *track;
-
- GtkWidget *info;
};
#define BRASERO_SRC_SELECTION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_SRC_SELECTION, BraseroSrcSelectionPrivate))
@@ -49,23 +51,25 @@
PROP_SESSION
};
-static BraseroDriveSelectionClass* parent_class = NULL;
-
-G_DEFINE_TYPE (BraseroSrcSelection, brasero_src_selection, BRASERO_TYPE_DRIVE_SELECTION);
+G_DEFINE_TYPE (BraseroSrcSelection, brasero_src_selection, BRASERO_TYPE_MEDIUM_SELECTION);
static void
-brasero_src_selection_drive_changed (BraseroDriveSelection *selection,
- BraseroDrive *drive)
+brasero_src_selection_medium_changed (GtkComboBox *combo_box)
{
BraseroSrcSelectionPrivate *priv;
+ BraseroDrive *drive = NULL;
- priv = BRASERO_SRC_SELECTION_PRIVATE (selection);
-
- brasero_src_info_set_medium (BRASERO_SRC_INFO (priv->info),
- brasero_drive_get_medium (drive));
+ priv = BRASERO_SRC_SELECTION_PRIVATE (combo_box);
if (!priv->session)
- return;
+ goto chain;
+
+ drive = brasero_medium_selection_get_active_drive (BRASERO_MEDIUM_SELECTION (combo_box));
+
+ /* NOTE: don't check for drive == NULL to set the session input type */
+ if (priv->track
+ && drive == brasero_burn_session_get_src_drive (priv->session))
+ goto chain;
if (priv->track)
brasero_track_unref (priv->track);
@@ -78,10 +82,15 @@
brasero_burn_session_add_track (priv->session, priv->track);
- if (!drive)
- gtk_widget_set_sensitive (priv->info, FALSE);
- else
- gtk_widget_set_sensitive (priv->info, TRUE);
+chain:
+
+ if (drive)
+ g_object_unref (drive);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (combo_box), drive != NULL);
+
+ if (GTK_COMBO_BOX_CLASS (brasero_src_selection_parent_class)->changed)
+ GTK_COMBO_BOX_CLASS (brasero_src_selection_parent_class)->changed (combo_box);
}
GtkWidget *
@@ -96,24 +105,9 @@
static void
brasero_src_selection_init (BraseroSrcSelection *object)
{
- BraseroSrcSelectionPrivate *priv;
-
- priv = BRASERO_SRC_SELECTION_PRIVATE (object);
-
- priv->info = brasero_src_info_new ();
- gtk_widget_show (priv->info);
- gtk_box_pack_start (GTK_BOX (object),
- priv->info,
- FALSE,
- FALSE,
- 0);
-
- brasero_drive_selection_set_tooltip (BRASERO_DRIVE_SELECTION (object),
- _("Choose the disc to read from"));
-
/* only show media with something to be read on them */
- brasero_drive_selection_set_type_shown (BRASERO_DRIVE_SELECTION (object),
- BRASERO_MEDIA_TYPE_READABLE);
+ brasero_medium_selection_show_type (BRASERO_MEDIUM_SELECTION (object),
+ BRASERO_MEDIA_TYPE_READABLE);
}
static void
@@ -133,7 +127,7 @@
priv->track = NULL;
}
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (brasero_src_selection_parent_class)->finalize (object);
}
static void
@@ -144,7 +138,6 @@
{
BraseroSrcSelectionPrivate *priv;
BraseroBurnSession *session;
- BraseroDrive *drive;
priv = BRASERO_SRC_SELECTION_PRIVATE (object);
@@ -158,12 +151,7 @@
if (priv->track)
brasero_track_unref (priv->track);
- drive = brasero_drive_selection_get_drive (BRASERO_DRIVE_SELECTION (object));
- if (drive) {
- brasero_src_selection_drive_changed (BRASERO_DRIVE_SELECTION (object), drive);
- g_object_unref (drive);
- }
-
+ brasero_src_selection_medium_changed (GTK_COMBO_BOX (object));
break;
default:
@@ -195,9 +183,7 @@
brasero_src_selection_class_init (BraseroSrcSelectionClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- BraseroDriveSelectionClass *select_class = BRASERO_DRIVE_SELECTION_CLASS (klass);
-
- parent_class = BRASERO_DRIVE_SELECTION_CLASS (g_type_class_peek_parent (klass));
+ GtkComboBoxClass *combo_box_class = GTK_COMBO_BOX_CLASS (klass);
g_type_class_add_private (klass, sizeof (BraseroSrcSelectionPrivate));
@@ -205,7 +191,7 @@
object_class->set_property = brasero_src_selection_set_property;
object_class->get_property = brasero_src_selection_get_property;
- select_class->drive_changed = brasero_src_selection_drive_changed;
+ combo_box_class->changed = brasero_src_selection_medium_changed;
g_object_class_install_property (object_class,
PROP_SESSION,
Modified: trunk/src/brasero-src-selection.h
==============================================================================
--- trunk/src/brasero-src-selection.h (original)
+++ trunk/src/brasero-src-selection.h Sun Sep 28 13:27:05 2008
@@ -25,7 +25,7 @@
#include <glib-object.h>
-#include "brasero-drive-selection.h"
+#include "brasero-medium-selection.h"
#include "burn-session.h"
G_BEGIN_DECLS
@@ -42,12 +42,12 @@
struct _BraseroSrcSelectionClass
{
- BraseroDriveSelectionClass parent_class;
+ BraseroMediumSelectionClass parent_class;
};
struct _BraseroSrcSelection
{
- BraseroDriveSelection parent_instance;
+ BraseroMediumSelection parent_instance;
};
GType brasero_src_selection_get_type (void) G_GNUC_CONST;
Modified: trunk/src/brasero-tool-dialog.c
==============================================================================
--- trunk/src/brasero-tool-dialog.c (original)
+++ trunk/src/brasero-tool-dialog.c Sun Sep 28 13:27:05 2008
@@ -43,9 +43,8 @@
#include <gtk/gtkmessagedialog.h>
#include "brasero-utils.h"
-#include "brasero-drive-info.h"
#include "brasero-progress.h"
-#include "brasero-drive-selection.h"
+#include "brasero-medium-selection.h"
#include "brasero-tool-dialog.h"
#include "burn-session.h"
#include "burn.h"
@@ -62,7 +61,6 @@
GtkWidget *button;
GtkWidget *options;
GtkWidget *cancel;
- GtkWidget *info;
BraseroBurn *burn;
@@ -213,7 +211,7 @@
BraseroMedia media;
GdkCursor *cursor;
- medium = brasero_drive_selection_get_medium (BRASERO_DRIVE_SELECTION (self->priv->selector));
+ medium = brasero_medium_selection_get_active (BRASERO_MEDIUM_SELECTION (self->priv->selector));
/* set up */
gtk_widget_set_sensitive (self->priv->upper_box, FALSE);
@@ -345,31 +343,30 @@
brasero_tool_dialog_set_medium_type_shown (BraseroToolDialog *self,
BraseroMediaType media_type)
{
- brasero_drive_selection_set_type_shown (BRASERO_DRIVE_SELECTION (self->priv->selector),
- media_type);
+ brasero_medium_selection_show_type (BRASERO_MEDIUM_SELECTION (self->priv->selector),
+ media_type);
}
BraseroMedium *
brasero_tool_dialog_get_medium (BraseroToolDialog *self)
{
- return brasero_drive_selection_get_medium (BRASERO_DRIVE_SELECTION (self->priv->selector));
+ return brasero_medium_selection_get_active (BRASERO_MEDIUM_SELECTION (self->priv->selector));
}
static void
-brasero_tool_dialog_drive_changed_cb (BraseroDriveSelection *selection,
- BraseroDrive *drive,
+brasero_tool_dialog_drive_changed_cb (GtkComboBox *combo_box,
BraseroToolDialog *self)
{
BraseroToolDialogClass *klass;
BraseroMedium *medium;
- medium = brasero_drive_get_medium (drive);
-
- brasero_drive_info_set_medium (BRASERO_DRIVE_INFO (self->priv->info), medium);
+ medium = brasero_medium_selection_get_active (BRASERO_MEDIUM_SELECTION (combo_box));
klass = BRASERO_TOOL_DIALOG_GET_CLASS (self);
if (klass->drive_changed)
klass->drive_changed (self, medium);
+
+ g_object_unref (medium);
}
static gboolean
@@ -497,27 +494,23 @@
obj->priv->upper_box = gtk_vbox_new (FALSE, 0);
gtk_widget_show (GTK_WIDGET (obj->priv->upper_box));
- obj->priv->selector = brasero_drive_selection_new ();
+ obj->priv->selector = brasero_medium_selection_new ();
gtk_widget_show (GTK_WIDGET (obj->priv->selector));
gtk_widget_set_tooltip_text (obj->priv->selector,
_("Choose a media"));
- obj->priv->info = brasero_drive_info_new ();
- gtk_widget_show (GTK_WIDGET (obj->priv->info));
-
title_str = g_strdup_printf ("<b>%s</b>", _("Select a disc"));
gtk_box_pack_start (GTK_BOX (obj->priv->upper_box),
brasero_utils_pack_properties (title_str,
- obj->priv->info,
obj->priv->selector,
NULL),
FALSE, FALSE, 0);
g_free (title_str);
- brasero_drive_selection_set_type_shown (BRASERO_DRIVE_SELECTION (obj->priv->selector),
- BRASERO_MEDIA_TYPE_REWRITABLE|
- BRASERO_MEDIA_TYPE_WRITABLE|
- BRASERO_MEDIA_TYPE_READABLE);
+ brasero_medium_selection_show_type (BRASERO_MEDIUM_SELECTION (obj->priv->selector),
+ BRASERO_MEDIA_TYPE_REWRITABLE|
+ BRASERO_MEDIA_TYPE_WRITABLE|
+ BRASERO_MEDIA_TYPE_READABLE);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (obj)->vbox),
obj->priv->upper_box,
@@ -574,7 +567,7 @@
GTK_RESPONSE_CANCEL);
g_signal_connect (G_OBJECT (obj->priv->selector),
- "drive-changed",
+ "changed",
G_CALLBACK (brasero_tool_dialog_drive_changed_cb),
obj);
}
Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c (original)
+++ trunk/src/burn-medium.c Sun Sep 28 13:27:05 2008
@@ -140,6 +140,70 @@
static GObjectClass* parent_class = NULL;
+gchar *
+brasero_medium_get_tooltip (BraseroMedium *self)
+{
+ BraseroMediumPrivate *priv;
+ BraseroDrive *drive;
+ BraseroMedia media;
+ const gchar *type;
+ gchar *label;
+ gchar *name;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ media = brasero_medium_get_status (BRASERO_MEDIUM (self));
+ if (media & BRASERO_MEDIUM_FILE) {
+ /* Translators: This is a fake drive, a file, and means that
+ * when we're writing, we're writing to a file and create an
+ * image on the hard drive. */
+ return g_strdup (_("Image File"));
+ }
+
+ type = brasero_medium_get_type_string (BRASERO_MEDIUM (self));
+ drive = brasero_medium_get_drive (BRASERO_MEDIUM (self));
+ name = brasero_drive_get_display_name (drive);
+
+ if (media & BRASERO_MEDIUM_BLANK) {
+ /* NOTE for translators: the first %s is the disc type and the
+ * second %s the name of the drive this disc is in. */
+ label = g_strdup_printf (_("Blank %s in %s"),
+ type,
+ name);
+ }
+ else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) {
+ /* NOTE for translators: the first %s is the disc type and the
+ * second %s the name of the drive this disc is in. */
+ label = g_strdup_printf (_("Audio and data %s in %s"),
+ type,
+ name);
+ }
+ else if (media & BRASERO_MEDIUM_HAS_AUDIO) {
+ /* NOTE for translators: the first %s is the disc type and the
+ * second %s the name of the drive this disc is in. */
+ label = g_strdup_printf (_("Audio %s in %s"),
+ type,
+ name);
+ }
+ else if (media & BRASERO_MEDIUM_HAS_DATA) {
+ /* NOTE for translators: the first %s is the disc type and the
+ * second %s the name of the drive this disc is in. */
+ label = g_strdup_printf (_("Data %s in %s"),
+ type,
+ name);
+ }
+ else {
+ /* NOTE for translators: the first %s is the disc type and the
+ * second %s the name of the drive this disc is in. */
+ label = g_strdup_printf (_("%s in %s"),
+ type,
+ name);
+ }
+
+ g_free (name);
+ return label;
+}
+
const gchar *
brasero_medium_get_type_string (BraseroMedium *medium)
{
Modified: trunk/src/burn-medium.h
==============================================================================
--- trunk/src/burn-medium.h (original)
+++ trunk/src/burn-medium.h Sun Sep 28 13:27:05 2008
@@ -279,6 +279,9 @@
const gchar *
brasero_medium_get_type_string (BraseroMedium *medium);
+gchar *
+brasero_medium_get_tooltip (BraseroMedium *medium);
+
const gchar *
brasero_medium_get_icon (BraseroMedium *medium);
Modified: trunk/src/burn-volume-obj.c
==============================================================================
--- trunk/src/burn-volume-obj.c (original)
+++ trunk/src/burn-volume-obj.c Sun Sep 28 13:27:05 2008
@@ -685,6 +685,7 @@
{
BraseroVolumePrivate *priv;
BraseroMedia media;
+ const gchar *type;
GVolume *volume;
gchar *name;
@@ -692,144 +693,48 @@
media = brasero_medium_get_status (BRASERO_MEDIUM (self));
if (media & BRASERO_MEDIUM_FILE) {
- /* FIXME: here let's read the image label ?*/
- return NULL;
+ /* Translators: This is a fake drive, a file, and means that
+ * when we're writing, we're writing to a file and create an
+ * image on the hard drive. */
+ return g_strdup (_("Image File"));
}
volume = brasero_volume_get_gvolume (self);
if (!volume)
- return NULL;
+ goto last_chance;
name = g_volume_get_name (volume);
g_object_unref (volume);
- return name;
-}
+ if (name)
+ return name;
-gchar *
-brasero_volume_get_display_label (BraseroVolume *self,
- gboolean with_markup)
-{
- BraseroVolumePrivate *priv;
- BraseroDrive *drive;
- BraseroMedia media;
- const gchar *type;
- GVolume *volume;
- gchar *label;
- gchar *name;
-
- priv = BRASERO_VOLUME_PRIVATE (self);
-
- media = brasero_medium_get_status (BRASERO_MEDIUM (self));
- if (media & BRASERO_MEDIUM_FILE) {
- /* Translators: This is a fake drive, a file, and means that
- * when we're writing, we're writing to a file and create an
- * image on the hard drive. */
- label = g_strdup (_("Image File"));
- if (!with_markup)
- return label;
-
- name = label;
- label = g_strdup_printf ("<b>%s</b>", label);
- g_free (name);
-
- return label;
- }
+last_chance:
type = brasero_medium_get_type_string (BRASERO_MEDIUM (self));
-
name = NULL;
- volume = brasero_volume_get_gvolume (self);
- if (volume) {
- name = g_volume_get_name (volume);
- g_object_unref (volume);
-
- if (name && name [0] != '\0') {
- if (with_markup)
- /* NOTE for translators: the first %s is the disc type and the
- * second %s the label of the already existing session on this disc. */
- label = g_strdup_printf (_("<b>Data %s</b>: \"%s\""),
- type,
- name);
- else
- label = g_strdup_printf (_("Data %s: \"%s\""),
- type,
- name);
-
- g_free (name);
- return label;
- }
-
- if (name)
- g_free (name);
- }
-
- drive = brasero_medium_get_drive (BRASERO_MEDIUM (self));
- name = brasero_drive_get_display_name (drive);
-
if (media & BRASERO_MEDIUM_BLANK) {
- if (with_markup)
- /* NOTE for translators: the first %s is the disc type and the
- * second %s the name of the drive this disc is in. */
- label = g_strdup_printf (_("<b>Blank %s</b> in %s"),
- type,
- name);
- else
- label = g_strdup_printf (_("Blank %s in %s"),
- type,
- name);
+ /* NOTE for translators: the first %s is the disc type. */
+ name = g_strdup_printf (_("Blank %s"), type);
}
else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_HAS_AUDIO|BRASERO_MEDIUM_HAS_DATA)) {
- if (with_markup)
- /* NOTE for translators: the first %s is the disc type and the
- * second %s the name of the drive this disc is in. */
- label = g_strdup_printf (_("<b>Audio and data %s</b> in %s"),
- type,
- name);
- else
- label = g_strdup_printf (_("Audio and data %s in %s"),
- type,
- name);
+ /* NOTE for translators: the first %s is the disc type. */
+ name = g_strdup_printf (_("Audio and data %s"), type);
}
else if (media & BRASERO_MEDIUM_HAS_AUDIO) {
- if (with_markup)
- /* NOTE for translators: the first %s is the disc type and the
- * second %s the name of the drive this disc is in. */
- label = g_strdup_printf (_("<b>Audio %s</b> in %s"),
- type,
- name);
- else
- label = g_strdup_printf (_("Audio %s in %s"),
- type,
- name);
+ /* NOTE for translators: the first %s is the disc type. */
+ name = g_strdup_printf (_("Audio %s"), type);
}
else if (media & BRASERO_MEDIUM_HAS_DATA) {
- if (with_markup)
- /* NOTE for translators: the first %s is the disc type and the
- * second %s the name of the drive this disc is in. */
- label = g_strdup_printf (_("<b>Data %s</b> in %s"),
- type,
- name);
- else
- label = g_strdup_printf (_("Data %s in %s"),
- type,
- name);
+ /* NOTE for translators: the first %s is the disc type. */
+ name = g_strdup_printf (_("Data %s"), type);
}
else {
- if (with_markup)
- /* NOTE for translators: the first %s is the disc type and the
- * second %s the name of the drive this disc is in. */
- label = g_strdup_printf (_("<b>%s</b> in %s"),
- type,
- name);
- else
- label = g_strdup_printf (_("%s in %s"),
- type,
- name);
+ /* NOTE for translators: the first %s is the disc type. */
+ name = g_strdup (type);
}
- g_free (name);
- return label;
+ return name;
}
static void
Modified: trunk/src/burn-volume-obj.h
==============================================================================
--- trunk/src/burn-volume-obj.h (original)
+++ trunk/src/burn-volume-obj.h Sun Sep 28 13:27:05 2008
@@ -58,10 +58,6 @@
gchar *
brasero_volume_get_name (BraseroVolume *self);
-gchar *
-brasero_volume_get_display_label (BraseroVolume *volume,
- gboolean with_markup);
-
gboolean
brasero_volume_is_mounted (BraseroVolume *volume);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]