[brasero] Convert brasero-drive-properties to use BraseroBurnSession directly
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Subject: [brasero] Convert brasero-drive-properties to use BraseroBurnSession directly
- Date: Mon, 1 Jun 2009 09:17:55 -0400 (EDT)
commit 3edb513ff9071dc4be3bbbcc83f1047d437af577
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Sun May 31 11:01:34 2009 +0200
Convert brasero-drive-properties to use BraseroBurnSession directly
Drop the use of GtkFileChooserButton for a custom buttom which fixes #578175 â?? "Temporary files" location in Properties confusing when folder doesn't exist
Make sure we save all properties of the session when the medium changes
---
libbrasero-burn/brasero-blank-dialog.c | 1 +
libbrasero-burn/brasero-drive-properties.c | 566 ++++++++++++++++++++-------
libbrasero-burn/brasero-drive-properties.h | 30 +--
libbrasero-burn/brasero-medium-properties.c | 110 +++---
libbrasero-burn/brasero-session-cfg.c | 90 +++--
libbrasero-burn/brasero-session.c | 101 ++++--
libbrasero-burn/brasero-session.h | 3 +-
libbrasero-burn/brasero-src-image.c | 3 +-
8 files changed, 624 insertions(+), 280 deletions(-)
diff --git a/libbrasero-burn/brasero-blank-dialog.c b/libbrasero-burn/brasero-blank-dialog.c
index 0f9f6fc..d37e8d3 100644
--- a/libbrasero-burn/brasero-blank-dialog.c
+++ b/libbrasero-burn/brasero-blank-dialog.c
@@ -147,6 +147,7 @@ brasero_blank_dialog_caps_changed (BraseroPluginManager *manager,
static void
brasero_blank_dialog_output_changed (BraseroBurnSession *session,
+ BraseroMedium *former,
BraseroBlankDialog *dialog)
{
brasero_blank_dialog_device_opts_setup (dialog);
diff --git a/libbrasero-burn/brasero-drive-properties.c b/libbrasero-burn/brasero-drive-properties.c
index 58c5d4e..915beb5 100644
--- a/libbrasero-burn/brasero-drive-properties.c
+++ b/libbrasero-burn/brasero-drive-properties.c
@@ -55,6 +55,10 @@
typedef struct _BraseroDrivePropertiesPrivate BraseroDrivePropertiesPrivate;
struct _BraseroDrivePropertiesPrivate
{
+ BraseroSessionCfg *session;
+ gulong valid_sig;
+ gulong output_sig;
+
GtkWidget *speed;
GtkWidget *dummy;
GtkWidget *multi;
@@ -63,75 +67,106 @@ struct _BraseroDrivePropertiesPrivate
GtkWidget *eject;
GtkWidget *tmpdir;
- GtkWidget *tmpdir_size;
};
#define BRASERO_DRIVE_PROPERTIES_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DRIVE_PROPERTIES, BraseroDrivePropertiesPrivate))
enum {
- PROP_TEXT,
- PROP_RATE,
- PROP_NUM
+ TEXT_COL,
+ RATE_COL,
+ COL_NUM
};
+enum {
+ PROP_0,
+ PROP_SESSION
+};
-G_DEFINE_TYPE (BraseroDriveProperties, brasero_drive_properties, GTK_TYPE_DIALOG);
+G_DEFINE_TYPE (BraseroDriveProperties, brasero_drive_properties, GTK_TYPE_ALIGNMENT);
-BraseroBurnFlag
-brasero_drive_properties_get_flags (BraseroDriveProperties *self)
+static void
+brasero_drive_properties_no_tmp_toggled (GtkToggleButton *button,
+ BraseroDriveProperties *self)
{
- BraseroBurnFlag flags = BRASERO_BURN_FLAG_NONE;
BraseroDrivePropertiesPrivate *priv;
priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
/* retrieve the flags */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->notmp)))
- flags |= BRASERO_BURN_FLAG_NO_TMP_FILES;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->eject)))
- flags |= BRASERO_BURN_FLAG_EJECT;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->dummy)))
- flags |= BRASERO_BURN_FLAG_DUMMY;
+ brasero_session_cfg_add_flags (priv->session,
+ BRASERO_BURN_FLAG_NO_TMP_FILES);
+ else
+ brasero_session_cfg_remove_flags (priv->session,
+ BRASERO_BURN_FLAG_NO_TMP_FILES);
+}
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->burnproof)))
- flags |= BRASERO_BURN_FLAG_BURNPROOF;
+static void
+brasero_drive_properties_eject_toggled (GtkToggleButton *button,
+ BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->multi)))
- flags |= BRASERO_BURN_FLAG_MULTI;
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
- return flags;
+ /* retrieve the flags */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->eject)))
+ brasero_session_cfg_add_flags (priv->session,
+ BRASERO_BURN_FLAG_EJECT);
+ else
+ brasero_session_cfg_remove_flags (priv->session,
+ BRASERO_BURN_FLAG_EJECT);
}
-gint64
-brasero_drive_properties_get_rate (BraseroDriveProperties *self)
+static void
+brasero_drive_properties_dummy_toggled (GtkToggleButton *button,
+ BraseroDriveProperties *self)
{
BraseroDrivePropertiesPrivate *priv;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gint64 rate;
priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->speed));
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->speed), &iter))
- gtk_tree_model_get_iter_first (model, &iter);
+ /* retrieve the flags */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->dummy)))
+ brasero_session_cfg_add_flags (priv->session,
+ BRASERO_BURN_FLAG_DUMMY);
+ else
+ brasero_session_cfg_remove_flags (priv->session,
+ BRASERO_BURN_FLAG_DUMMY);
+}
- gtk_tree_model_get (model, &iter,
- PROP_RATE, &rate,
- -1);
+static void
+brasero_drive_properties_burnproof_toggled (GtkToggleButton *button,
+ BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
- return rate;
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ /* retrieve the flags */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->burnproof)))
+ brasero_session_cfg_add_flags (priv->session,
+ BRASERO_BURN_FLAG_BURNPROOF);
+ else
+ brasero_session_cfg_remove_flags (priv->session,
+ BRASERO_BURN_FLAG_BURNPROOF);
}
-gchar *
-brasero_drive_properties_get_tmpdir (BraseroDriveProperties *self)
+static void
+brasero_drive_properties_multi_toggled (GtkToggleButton *button,
+ BraseroDriveProperties *self)
{
BraseroDrivePropertiesPrivate *priv;
priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
- return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->tmpdir));
+
+ /* retrieve the flags */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->multi)))
+ brasero_session_cfg_add_flags (priv->session,
+ BRASERO_BURN_FLAG_MULTI);
+ else
+ brasero_session_cfg_remove_flags (priv->session,
+ BRASERO_BURN_FLAG_MULTI);
}
static void
@@ -141,6 +176,7 @@ brasero_drive_properties_set_tmpdir_info (BraseroDriveProperties *self,
GFile *file;
gchar *string;
GFileInfo *info;
+ gchar *string_size;
guint64 vol_size = 0;
BraseroDrivePropertiesPrivate *priv;
@@ -150,7 +186,7 @@ brasero_drive_properties_set_tmpdir_info (BraseroDriveProperties *self,
file = g_file_new_for_commandline_arg (path);
if (!file) {
BRASERO_BURN_LOG ("Impossible to retrieve size for %s", path);
- gtk_label_set_text (GTK_LABEL (priv->tmpdir_size), _("Unknown"));
+ gtk_label_set_text (GTK_LABEL (priv->tmpdir), path);
return;
}
@@ -158,52 +194,24 @@ brasero_drive_properties_set_tmpdir_info (BraseroDriveProperties *self,
G_FILE_ATTRIBUTE_FILESYSTEM_FREE,
NULL,
NULL);
- g_object_unref (file);
-
if (!info) {
BRASERO_BURN_LOG ("Impossible to retrieve size for %s", path);
- gtk_label_set_text (GTK_LABEL (priv->tmpdir_size), _("Unknown"));
+ gtk_label_set_text (GTK_LABEL (priv->tmpdir), path);
+ g_object_unref (file);
return;
}
vol_size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
g_object_unref (info);
- string = g_format_size_for_display (vol_size);
- gtk_label_set_text (GTK_LABEL (priv->tmpdir_size), string);
- g_free (string);
-}
-
-static void
-brasero_drive_properties_tmpdir_changed (GtkFileChooser *chooser,
- BraseroDriveProperties *self)
-{
- gchar *path;
- BraseroDrivePropertiesPrivate *priv;
-
- priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
-
- path = gtk_file_chooser_get_filename (chooser);
- if (!path)
- return;
-
- brasero_drive_properties_set_tmpdir_info (self, path);
- g_free (path);
-}
-
-void
-brasero_drive_properties_set_tmpdir (BraseroDriveProperties *self,
- const gchar *path)
-{
- BraseroDrivePropertiesPrivate *priv;
+ string_size = g_format_size_for_display (vol_size);
+ /* Translators: the first %s is the path of the directory where brasero
+ * will store its temporary files; the second one is the size available */
+ string = g_strdup_printf (_("%s: %s free"), path, string_size);
+ g_free (string_size);
- priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
-
- if (!path)
- path = g_get_tmp_dir ();
-
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (priv->tmpdir), path);
- brasero_drive_properties_set_tmpdir_info (self, path);
+ gtk_label_set_text (GTK_LABEL (priv->tmpdir), string);
+ g_free (string);
}
static gboolean
@@ -220,7 +228,7 @@ brasero_drive_properties_check_tmpdir (BraseroDriveProperties *self,
file = g_file_new_for_commandline_arg (path);
if (!file)
- return TRUE;
+ return FALSE;
info = g_file_query_info (file,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
@@ -350,29 +358,75 @@ brasero_drive_properties_check_tmpdir (BraseroDriveProperties *self,
else if (info)
g_object_unref (info);
- return TRUE;
+ return FALSE;
}
static void
-brasero_drive_properties_response (GtkDialog *dialog,
- gint response,
- gpointer NULL_data)
+brasero_drive_properties_tmpdir_clicked (GtkButton *button,
+ BraseroDriveProperties *self)
{
+ GtkWidget *parent;
+ const gchar *path;
+ GtkWidget *chooser;
+ GtkResponseType res;
+ const gchar *new_path;
BraseroDrivePropertiesPrivate *priv;
- gchar *path;
- priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (dialog);
- if (response != GTK_RESPONSE_ACCEPT)
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ chooser = gtk_file_chooser_dialog_new (_("Location for Temporary Files"),
+ GTK_WINDOW (parent),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+
+ path = brasero_burn_session_get_tmpdir (BRASERO_BURN_SESSION (priv->session));
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), path);
+ res = gtk_dialog_run (GTK_DIALOG (chooser));
+ if (res != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (chooser);
return;
+ }
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->tmpdir));
- if (!brasero_drive_properties_check_tmpdir (BRASERO_DRIVE_PROPERTIES (dialog), path))
- g_signal_stop_emission_by_name (dialog, "response");
- g_free (path);
+ new_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+ if (!new_path || !strcmp (new_path, path)) {
+ gtk_widget_destroy (chooser);
+ return;
+ }
+
+ if (!brasero_drive_properties_check_tmpdir (self, new_path)) {
+ brasero_burn_session_set_tmpdir (BRASERO_BURN_SESSION (priv->session), new_path);
+ brasero_drive_properties_set_tmpdir_info (self, new_path);
+ }
+
+ gtk_widget_destroy (chooser);
}
static void
-brasero_drive_properties_set_toggle_state (GtkWidget *toggle,
+brasero_drive_properties_set_tmpdir (BraseroDriveProperties *self,
+ const gchar *path)
+{
+ BraseroDrivePropertiesPrivate *priv;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ if (!path)
+ path = g_get_tmp_dir ();
+
+ brasero_drive_properties_set_tmpdir_info (self, path);
+}
+
+static void
+brasero_drive_properties_set_flags (BraseroDriveProperties *self,
+ BraseroBurnFlag flags,
+ BraseroBurnFlag supported,
+ BraseroBurnFlag compulsory);
+
+static void
+brasero_drive_properties_set_toggle_state (BraseroDriveProperties *self,
+ GtkWidget *toggle,
BraseroBurnFlag flag,
BraseroBurnFlag flags,
BraseroBurnFlag supported,
@@ -381,14 +435,23 @@ brasero_drive_properties_set_toggle_state (GtkWidget *toggle,
if (!(supported & flag)) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), FALSE);
gtk_widget_set_sensitive (toggle, FALSE);
+ gtk_widget_hide (toggle);
return;
}
+ gtk_widget_show (toggle);
+ g_signal_handlers_block_by_func (toggle,
+ brasero_drive_properties_set_flags,
+ self);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), (flags & flag));
+ g_signal_handlers_unblock_by_func (toggle,
+ brasero_drive_properties_set_flags,
+ self);
+
gtk_widget_set_sensitive (toggle, (compulsory & flag) == 0);
}
-void
+static void
brasero_drive_properties_set_flags (BraseroDriveProperties *self,
BraseroBurnFlag flags,
BraseroBurnFlag supported,
@@ -403,33 +466,75 @@ brasero_drive_properties_set_flags (BraseroDriveProperties *self,
compulsory &= BRASERO_DRIVE_PROPERTIES_FLAGS;
/* flag properties */
- brasero_drive_properties_set_toggle_state (priv->dummy,
+ brasero_drive_properties_set_toggle_state (self,
+ priv->dummy,
BRASERO_BURN_FLAG_DUMMY,
flags,
supported,
compulsory);
- brasero_drive_properties_set_toggle_state (priv->eject,
+ brasero_drive_properties_set_toggle_state (self,
+ priv->eject,
BRASERO_BURN_FLAG_EJECT,
flags,
supported,
compulsory);
- brasero_drive_properties_set_toggle_state (priv->burnproof,
+ brasero_drive_properties_set_toggle_state (self,
+ priv->burnproof,
BRASERO_BURN_FLAG_BURNPROOF,
flags,
supported,
compulsory);
- brasero_drive_properties_set_toggle_state (priv->notmp,
+ brasero_drive_properties_set_toggle_state (self,
+ priv->notmp,
BRASERO_BURN_FLAG_NO_TMP_FILES,
flags,
supported,
compulsory);
- brasero_drive_properties_set_toggle_state (priv->multi,
+ brasero_drive_properties_set_toggle_state (self,
+ priv->multi,
BRASERO_BURN_FLAG_MULTI,
flags,
supported,
compulsory);
}
+static gint64
+brasero_drive_properties_get_rate (BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint64 rate;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->speed));
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->speed), &iter)
+ && !gtk_tree_model_get_iter_first (model, &iter))
+ return 0;
+
+ gtk_tree_model_get (model, &iter,
+ RATE_COL, &rate,
+ -1);
+ return rate;
+}
+
+static void
+brasero_drive_properties_rate_changed_cb (GtkComboBox *combo,
+ BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
+ guint64 rate;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ rate = brasero_drive_properties_get_rate (self);
+ if (!rate)
+ return;
+
+ brasero_burn_session_set_rate (BRASERO_BURN_SESSION (priv->session), rate);
+}
+
static gchar *
brasero_drive_properties_format_disc_speed (BraseroMedia media,
gint64 rate)
@@ -459,7 +564,7 @@ brasero_drive_properties_format_disc_speed (BraseroMedia media,
return text;
}
-void
+static void
brasero_drive_properties_set_drive (BraseroDriveProperties *self,
BraseroDrive *drive,
gint64 default_rate)
@@ -468,35 +573,29 @@ brasero_drive_properties_set_drive (BraseroDriveProperties *self,
BraseroMedium *medium;
BraseroMedia media;
GtkTreeModel *model;
- gchar *display_name;
GtkTreeIter iter;
guint64 *rates;
- gchar *header;
gchar *text;
guint i;
priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
- /* set the header of the dialog */
- display_name = brasero_drive_get_display_name (drive);
- header = g_strdup_printf (_("Properties of %s"), display_name);
- g_free (display_name);
-
- gtk_window_set_title (GTK_WINDOW (self), header);
- g_free (header);
-
/* Speed combo */
medium = brasero_drive_get_medium (drive);
media = brasero_medium_get_status (medium);
+ if (media & BRASERO_MEDIUM_FILE)
+ return;
+
rates = brasero_medium_get_write_speeds (medium);
model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->speed));
+ gtk_list_store_clear (GTK_LIST_STORE (model));
if (!rates) {
gtk_widget_set_sensitive (priv->speed, FALSE);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PROP_TEXT, _("Impossible to retrieve speeds"),
- PROP_RATE, 1764, /* Speed 1 */
+ TEXT_COL, _("Impossible to retrieve speeds"),
+ RATE_COL, 1764, /* Speed 1 */
-1);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->speed), &iter);
return;
@@ -504,8 +603,8 @@ brasero_drive_properties_set_drive (BraseroDriveProperties *self,
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PROP_TEXT, _("Max speed"),
- PROP_RATE, rates [0],
+ TEXT_COL, _("Max speed"),
+ RATE_COL, rates [0],
-1);
/* fill model */
@@ -513,8 +612,8 @@ brasero_drive_properties_set_drive (BraseroDriveProperties *self,
text = brasero_drive_properties_format_disc_speed (media, rates [i]);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- PROP_TEXT, text,
- PROP_RATE, rates [i],
+ TEXT_COL, text,
+ RATE_COL, rates [i],
-1);
g_free (text);
}
@@ -525,7 +624,7 @@ brasero_drive_properties_set_drive (BraseroDriveProperties *self,
gint64 rate;
gtk_tree_model_get (model, &iter,
- PROP_RATE, &rate,
+ RATE_COL, &rate,
-1);
/* we do this to round things and get the closest possible speed */
@@ -544,31 +643,93 @@ brasero_drive_properties_set_drive (BraseroDriveProperties *self,
}
static void
+brasero_drive_properties_update (BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
+ BraseroBurnFlag compulsory;
+ BraseroBurnFlag supported;
+ BraseroBurnFlag flags;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+ brasero_drive_properties_set_drive (self,
+ brasero_burn_session_get_burner (BRASERO_BURN_SESSION (priv->session)),
+ brasero_burn_session_get_rate (BRASERO_BURN_SESSION (priv->session)));
+
+ flags = brasero_burn_session_get_flags (BRASERO_BURN_SESSION (priv->session));
+ brasero_burn_session_get_burn_flags (BRASERO_BURN_SESSION (priv->session),
+ &supported,
+ &compulsory);
+ brasero_drive_properties_set_flags (self,
+ flags,
+ supported,
+ compulsory);
+ brasero_drive_properties_set_tmpdir (self, brasero_burn_session_get_tmpdir (BRASERO_BURN_SESSION (priv->session)));
+}
+
+static void
+brasero_drive_properties_is_valid_cb (BraseroSessionCfg *session,
+ BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
+ BraseroBurnFlag compulsory;
+ BraseroBurnFlag supported;
+ BraseroBurnFlag flags;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ flags = brasero_burn_session_get_flags (BRASERO_BURN_SESSION (priv->session));
+ brasero_burn_session_get_burn_flags (BRASERO_BURN_SESSION (priv->session),
+ &supported,
+ &compulsory);
+ brasero_drive_properties_set_flags (self,
+ flags,
+ supported,
+ compulsory);
+}
+
+static void
+brasero_drive_properties_output_changed_cb (BraseroSessionCfg *session,
+ BraseroMedium *former,
+ BraseroDriveProperties *self)
+{
+ BraseroDrivePropertiesPrivate *priv;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (self);
+
+ /* if the drive changed update rate but only if the drive changed that's
+ * why we don't do it when the is-valid signal is emitted. */
+ brasero_drive_properties_set_drive (self,
+ brasero_burn_session_get_burner (BRASERO_BURN_SESSION (priv->session)),
+ brasero_burn_session_get_rate (BRASERO_BURN_SESSION (priv->session)));
+}
+
+static void
brasero_drive_properties_init (BraseroDriveProperties *object)
{
BraseroDrivePropertiesPrivate *priv;
GtkCellRenderer *renderer;
GtkTreeModel *model;
+ GtkWidget *button;
+ GtkWidget *image;
GtkWidget *label;
+ GtkWidget *vbox;
GtkWidget *box;
gchar *string;
priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (object);
- gtk_window_set_default_size (GTK_WINDOW (object), 340, 250);
- gtk_dialog_set_has_separator (GTK_DIALOG (object), FALSE);
- gtk_dialog_add_buttons (GTK_DIALOG (object),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- NULL);
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (object), vbox);
- model = GTK_TREE_MODEL (gtk_list_store_new (PROP_NUM,
+ model = GTK_TREE_MODEL (gtk_list_store_new (COL_NUM,
G_TYPE_STRING,
G_TYPE_INT64));
priv->speed = gtk_combo_box_new_with_model (model);
+ gtk_widget_show (priv->speed);
string = g_strdup_printf ("<b>%s</b>", _("Burning speed"));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox),
+ gtk_box_pack_start (GTK_BOX (vbox),
brasero_utils_pack_properties (string,
priv->speed, NULL),
FALSE, FALSE, 0);
@@ -577,19 +738,45 @@ brasero_drive_properties_init (BraseroDriveProperties *object)
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->speed), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->speed), renderer,
- "text", PROP_TEXT,
+ "text", TEXT_COL,
NULL);
priv->dummy = gtk_check_button_new_with_mnemonic (_("_Simulate before burning"));
gtk_widget_set_tooltip_text (priv->dummy, _("Brasero will simulate the burning and if it is successful, go on with actual burning after 10 seconds"));
+ gtk_widget_show (priv->dummy);
priv->burnproof = gtk_check_button_new_with_mnemonic (_("Use burn_proof (decrease the risk of failures)"));
+ gtk_widget_show (priv->burnproof);
priv->eject = gtk_check_button_new_with_mnemonic (_("_Eject after burning"));
+ gtk_widget_show (priv->eject);
priv->notmp = gtk_check_button_new_with_mnemonic (_("Burn the image directly _without saving it to disc"));
+ gtk_widget_show (priv->notmp);
priv->multi = gtk_check_button_new_with_mnemonic (_("Leave the disc _open to add other files later"));
gtk_widget_set_tooltip_text (priv->multi, _("Allow to add more data to the disc later"));
+ gtk_widget_show (priv->multi);
+
+ g_signal_connect (priv->dummy,
+ "toggled",
+ G_CALLBACK (brasero_drive_properties_dummy_toggled),
+ object);
+ g_signal_connect (priv->burnproof,
+ "toggled",
+ G_CALLBACK (brasero_drive_properties_burnproof_toggled),
+ object);
+ g_signal_connect (priv->eject,
+ "toggled",
+ G_CALLBACK (brasero_drive_properties_eject_toggled),
+ object);
+ g_signal_connect (priv->multi,
+ "toggled",
+ G_CALLBACK (brasero_drive_properties_multi_toggled),
+ object);
+ g_signal_connect (priv->notmp,
+ "toggled",
+ G_CALLBACK (brasero_drive_properties_no_tmp_toggled),
+ object);
string = g_strdup_printf ("<b>%s</b>", _("Options"));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox),
+ gtk_box_pack_start (GTK_BOX (vbox),
brasero_utils_pack_properties (string,
priv->eject,
priv->dummy,
@@ -601,53 +788,130 @@ brasero_drive_properties_init (BraseroDriveProperties *object)
FALSE, 0);
g_free (string);
- priv->tmpdir = gtk_file_chooser_button_new (_("Location for Temporary Files"),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ label = gtk_label_new_with_mnemonic (_("Location for _Temporary Files"));
+ gtk_widget_show (label);
+ 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);
+
+ priv->tmpdir = label;
+
+ image = gtk_image_new_from_icon_name ("folder", 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);
- label = gtk_label_new_with_mnemonic (_("_Temporary directory free space:"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->tmpdir);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
+ button = gtk_button_new ();
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (button), box);
+ gtk_widget_set_tooltip_text (button, _("Set the directory where to store temporary files"));
- priv->tmpdir_size = gtk_label_new ("");
- gtk_widget_show (priv->tmpdir_size);
- gtk_box_pack_start (GTK_BOX (box), priv->tmpdir_size, FALSE, FALSE, 0);
+ box = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show (box);
string = g_strdup_printf ("<b>%s</b>", _("Temporary files"));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox),
+ gtk_box_pack_start (GTK_BOX (vbox),
brasero_utils_pack_properties (string,
box,
- priv->tmpdir,
+ button,
NULL),
FALSE,
FALSE, 0);
g_free (string);
+ gtk_widget_show (vbox);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (priv->tmpdir),
- g_get_tmp_dir ());
-
- gtk_widget_show_all (GTK_DIALOG (object)->vbox);
-
- g_signal_connect (priv->tmpdir,
- "selection-changed",
- G_CALLBACK (brasero_drive_properties_tmpdir_changed),
+ g_signal_connect (button,
+ "clicked",
+ G_CALLBACK (brasero_drive_properties_tmpdir_clicked),
+ object);
+ g_signal_connect (priv->speed,
+ "changed",
+ G_CALLBACK (brasero_drive_properties_rate_changed_cb),
object);
- g_signal_connect (object,
- "response",
- G_CALLBACK (brasero_drive_properties_response),
- NULL);
}
static void
brasero_drive_properties_finalize (GObject *object)
{
+ BraseroDrivePropertiesPrivate *priv;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (object);
+ if (priv->valid_sig) {
+ g_signal_handler_disconnect (priv->session, priv->valid_sig);
+ priv->valid_sig = 0;
+ }
+ if (priv->output_sig) {
+ g_signal_handler_disconnect (priv->session, priv->output_sig);
+ priv->output_sig = 0;
+ }
+ if (priv->session) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
+ }
+
G_OBJECT_CLASS (brasero_drive_properties_parent_class)->finalize (object);
}
static void
+brasero_drive_properties_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroDrivePropertiesPrivate *priv;
+ BraseroBurnSession *session;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION: /* Readable and only writable at creation time */
+ /* NOTE: no need to unref a potential previous session since
+ * it's only set at construct time */
+ session = g_value_get_object (value);
+ priv->session = g_object_ref (session);
+
+ brasero_drive_properties_update (BRASERO_DRIVE_PROPERTIES (object));
+ priv->valid_sig = g_signal_connect (session,
+ "is-valid",
+ G_CALLBACK (brasero_drive_properties_is_valid_cb),
+ object);
+ priv->output_sig = g_signal_connect (session,
+ "output-changed",
+ G_CALLBACK (brasero_drive_properties_output_changed_cb),
+ object);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+brasero_drive_properties_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BraseroDrivePropertiesPrivate *priv;
+
+ priv = BRASERO_DRIVE_PROPERTIES_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_SESSION:
+ g_object_ref (priv->session);
+ g_value_set_object (value, priv->session);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
brasero_drive_properties_class_init (BraseroDrivePropertiesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -655,10 +919,22 @@ brasero_drive_properties_class_init (BraseroDrivePropertiesClass *klass)
g_type_class_add_private (klass, sizeof (BraseroDrivePropertiesPrivate));
object_class->finalize = brasero_drive_properties_finalize;
+ object_class->set_property = brasero_drive_properties_set_property;
+ object_class->get_property = brasero_drive_properties_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_SESSION,
+ g_param_spec_object ("session",
+ "The session",
+ "The session to work with",
+ BRASERO_TYPE_BURN_SESSION,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
GtkWidget *
-brasero_drive_properties_new ()
+brasero_drive_properties_new (BraseroSessionCfg *session)
{
- return GTK_WIDGET (g_object_new (BRASERO_TYPE_DRIVE_PROPERTIES, NULL));
+ return g_object_new (BRASERO_TYPE_DRIVE_PROPERTIES,
+ "session", session,
+ NULL);
}
diff --git a/libbrasero-burn/brasero-drive-properties.h b/libbrasero-burn/brasero-drive-properties.h
index 0401b2c..beda990 100644
--- a/libbrasero-burn/brasero-drive-properties.h
+++ b/libbrasero-burn/brasero-drive-properties.h
@@ -36,6 +36,7 @@
#include <gtk/gtk.h>
#include "brasero-drive.h"
+#include "brasero-session-cfg.h"
G_BEGIN_DECLS
@@ -51,39 +52,16 @@ typedef struct _BraseroDriveProperties BraseroDriveProperties;
struct _BraseroDrivePropertiesClass
{
- GtkDialogClass parent_class;
+ GtkAlignmentClass parent_class;
};
struct _BraseroDriveProperties
{
- GtkDialog parent_instance;
+ GtkAlignment parent_instance;
};
GType brasero_drive_properties_get_type (void) G_GNUC_CONST;
-GtkWidget *brasero_drive_properties_new ();
-
-void
-brasero_drive_properties_set_drive (BraseroDriveProperties *props,
- BraseroDrive *drive,
- gint64 rate);
-void
-brasero_drive_properties_set_flags (BraseroDriveProperties *props,
- BraseroBurnFlag flags,
- BraseroBurnFlag supported,
- BraseroBurnFlag compulsory);
-
-void
-brasero_drive_properties_set_tmpdir (BraseroDriveProperties *props,
- const gchar *path);
-
-BraseroBurnFlag
-brasero_drive_properties_get_flags (BraseroDriveProperties *props);
-
-gint64
-brasero_drive_properties_get_rate (BraseroDriveProperties *props);
-
-gchar *
-brasero_drive_properties_get_tmpdir (BraseroDriveProperties *props);
+GtkWidget *brasero_drive_properties_new (BraseroSessionCfg *session);
G_END_DECLS
diff --git a/libbrasero-burn/brasero-medium-properties.c b/libbrasero-burn/brasero-medium-properties.c
index 3171873..ee46d21 100644
--- a/libbrasero-burn/brasero-medium-properties.c
+++ b/libbrasero-burn/brasero-medium-properties.c
@@ -60,6 +60,7 @@ struct _BraseroMediumPropertiesPrivate
GtkWidget *medium_prop;
glong valid_sig;
+ glong output_sig;
guint default_format:1;
guint default_path:1;
@@ -79,68 +80,48 @@ static void
brasero_medium_properties_drive_properties (BraseroMediumProperties *self)
{
BraseroMediumPropertiesPrivate *priv;
- BraseroBurnFlag compulsory = 0;
- BraseroBurnFlag supported = 0;
- BraseroBurnFlag flags = 0;
+ GtkWidget *medium_prop;
BraseroDrive *drive;
GtkWidget *toplevel;
- const gchar *path;
- gint result;
- gint64 rate;
+ gchar *display_name;
+ GtkWidget *dialog;
+ GtkWidget *box;
+ gchar *header;
priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
/* Build dialog */
- priv->medium_prop = brasero_drive_properties_new ();
+ medium_prop = brasero_drive_properties_new (BRASERO_SESSION_CFG (priv->session));
+ gtk_widget_show (medium_prop);
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_session_get_burn_flags (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);
+ display_name = brasero_drive_get_display_name (drive);
+ header = g_strdup_printf (_("Properties of %s"), display_name);
+ g_free (display_name);
+
+ dialog = gtk_dialog_new_with_buttons (header,
+ GTK_WINDOW (toplevel),
+ GTK_DIALOG_MODAL|
+ GTK_DIALOG_NO_SEPARATOR|
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ NULL);
+ g_free (header);
+
+ box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_start (GTK_BOX (box), medium_prop, TRUE, TRUE, 0);
/* 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_session_cfg_add_flags (BRASERO_SESSION_CFG (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 = dialog;
+ gtk_widget_show (dialog);
+ gtk_dialog_run (GTK_DIALOG (dialog));
priv->medium_prop = NULL;
+ gtk_widget_destroy (dialog);
+
+ /* FIXME: save */
+ //brasero_session_cfg_save_drive_properties (BRASERO_SESSION_CFG (priv->session));
}
static gchar *
@@ -551,8 +532,8 @@ brasero_medium_properties_update_image_output (BraseroMediumProperties *self,
/* we always need to do this */
brasero_medium_properties_set_output_path (self,
- valid_format,
- path);
+ valid_format,
+ path);
g_free (path);
@@ -569,6 +550,23 @@ brasero_medium_properties_update_image_output (BraseroMediumProperties *self,
}
static void
+brasero_medium_properties_output_changed (BraseroBurnSession *session,
+ BraseroMedium *former,
+ BraseroMediumProperties *self)
+{
+ BraseroMediumPropertiesPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PROPERTIES_PRIVATE (self);
+
+ /* close properties dialog */
+ if (priv->medium_prop) {
+ gtk_dialog_response (GTK_DIALOG (priv->medium_prop),
+ GTK_RESPONSE_CANCEL);
+ priv->medium_prop = NULL;
+ }
+}
+
+static void
brasero_medium_properties_valid_session (BraseroSessionCfg *session,
BraseroMediumProperties *self)
{
@@ -607,7 +605,11 @@ brasero_medium_properties_finalize (GObject *object)
priv->valid_sig);
priv->valid_sig = 0;
}
-
+ if (priv->output_sig) {
+ g_signal_handler_disconnect (priv->session,
+ priv->output_sig);
+ priv->output_sig = 0;
+ }
if (priv->session) {
g_object_unref (priv->session);
priv->session = NULL;
@@ -643,6 +645,10 @@ brasero_medium_properties_set_property (GObject *object,
"is-valid",
G_CALLBACK (brasero_medium_properties_valid_session),
object);
+ priv->output_sig = g_signal_connect (session,
+ "output-changed",
+ G_CALLBACK (brasero_medium_properties_output_changed),
+ object);
break;
default:
diff --git a/libbrasero-burn/brasero-session-cfg.c b/libbrasero-burn/brasero-session-cfg.c
index 1605e6c..5184b3e 100644
--- a/libbrasero-burn/brasero-session-cfg.c
+++ b/libbrasero-burn/brasero-session-cfg.c
@@ -92,23 +92,20 @@ G_DEFINE_TYPE (BraseroSessionCfg, brasero_session_cfg, BRASERO_TYPE_SESSION_SPAN
static gchar *
brasero_session_cfg_get_gconf_key (BraseroSessionCfg *self,
+ BraseroMedium *medium,
const gchar *property)
{
BraseroTrackType *type;
- BraseroMedium *medium;
BraseroDrive *drive;
gchar *display_name;
gchar *key = NULL;
gchar *disc_type;
- drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (self));
- if (!drive)
- return NULL;
-
- medium = brasero_drive_get_medium (drive);
if (brasero_medium_get_status (medium) == BRASERO_MEDIUM_NONE)
return NULL;
-
+
+ drive = brasero_medium_get_drive (medium);
+
/* make sure display_name doesn't contain any forbidden characters */
if (!brasero_drive_is_fake (drive)) {
gchar *tmp;
@@ -191,39 +188,54 @@ brasero_session_cfg_disable (BraseroSessionCfg *self)
}
static void
-brasero_session_cfg_save_drive_properties (BraseroSessionCfg *self)
+brasero_session_cfg_save_drive_flags (BraseroSessionCfg *self,
+ BraseroMedium *medium)
{
BraseroSessionCfgPrivate *priv;
BraseroBurnFlag flags;
GConfClient *client;
- const gchar *path;
- guint64 rate;
gchar *key;
priv = BRASERO_SESSION_CFG_PRIVATE (self);
client = gconf_client_get_default ();
-
- rate = brasero_burn_session_get_rate (BRASERO_BURN_SESSION (self));
- key = brasero_session_cfg_get_gconf_key (self, "speed");
+ key = brasero_session_cfg_get_gconf_key (self, medium, "flags");
if (!key) {
g_object_unref (client);
return;
}
- gconf_client_set_int (client, key, rate / 1000, NULL);
+ flags = gconf_client_get_int (client, key, NULL);
+ flags &= ~BRASERO_DEST_SAVED_FLAGS;
+ flags |= (brasero_burn_session_get_flags (BRASERO_BURN_SESSION (self)) & BRASERO_DEST_SAVED_FLAGS);
+ gconf_client_set_int (client, key, flags, NULL);
g_free (key);
+}
- key = brasero_session_cfg_get_gconf_key (self, "flags");
+static void
+brasero_session_cfg_save_drive_properties (BraseroSessionCfg *self,
+ BraseroMedium *medium)
+{
+ BraseroSessionCfgPrivate *priv;
+ GConfClient *client;
+ const gchar *path;
+ guint64 rate;
+ gchar *key;
+
+ priv = BRASERO_SESSION_CFG_PRIVATE (self);
+
+ brasero_session_cfg_save_drive_flags (self, medium);
+
+ client = gconf_client_get_default ();
+
+ rate = brasero_burn_session_get_rate (BRASERO_BURN_SESSION (self));
+ key = brasero_session_cfg_get_gconf_key (self, medium, "speed");
if (!key) {
g_object_unref (client);
return;
}
- flags = gconf_client_get_int (client, key, NULL);
- flags &= ~BRASERO_DEST_SAVED_FLAGS;
- flags |= (brasero_burn_session_get_flags (BRASERO_BURN_SESSION (self)) & BRASERO_DEST_SAVED_FLAGS);
- gconf_client_set_int (client, key, flags, NULL);
+ gconf_client_set_int (client, key, rate / 1000, NULL);
g_free (key);
/* temporary directory */
@@ -241,12 +253,22 @@ brasero_session_cfg_add_drive_properties_flags (BraseroSessionCfg *self,
{
BraseroMedia media;
BraseroBurnFlag flag;
+ BraseroDrive *drive;
+ BraseroMedium *medium;
BraseroBurnResult result;
BraseroSessionCfgPrivate *priv;
priv = BRASERO_SESSION_CFG_PRIVATE (self);
- media = brasero_burn_session_get_dest_media (BRASERO_BURN_SESSION (self));
+ drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (self));
+ if (!drive)
+ return;
+
+ medium = brasero_drive_get_medium (drive);
+ if (!medium)
+ return;
+
+ media = brasero_medium_get_status (medium);
/* add flags then wipe out flags from session to check them one by one */
flags |= brasero_burn_session_get_flags (BRASERO_BURN_SESSION (self));
@@ -350,7 +372,7 @@ brasero_session_cfg_add_drive_properties_flags (BraseroSessionCfg *self,
}
/* Always save flags */
- brasero_session_cfg_save_drive_properties (self);
+ brasero_session_cfg_save_drive_flags (self, medium);
}
static void
@@ -381,7 +403,7 @@ brasero_session_cfg_set_drive_properties (BraseroSessionCfg *self)
/* Update/set the rate */
client = gconf_client_get_default ();
- key = brasero_session_cfg_get_gconf_key (self, "speed");
+ key = brasero_session_cfg_get_gconf_key (self, medium, "speed");
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
@@ -405,7 +427,7 @@ brasero_session_cfg_set_drive_properties (BraseroSessionCfg *self)
/* Do the same with the flags.
* NOTE: we only save/load PROPERTIES_FLAGS */
- key = brasero_session_cfg_get_gconf_key (self, "flags");
+ key = brasero_session_cfg_get_gconf_key (self, medium, "flags");
if (!key) {
g_object_unref (client);
return;
@@ -846,7 +868,8 @@ brasero_session_cfg_input_changed (BraseroBurnSession *session)
}
static void
-brasero_session_cfg_output_changed (BraseroBurnSession *session)
+brasero_session_cfg_output_changed (BraseroBurnSession *session,
+ BraseroMedium *former)
{
BraseroSessionCfgPrivate *priv;
@@ -854,6 +877,9 @@ brasero_session_cfg_output_changed (BraseroBurnSession *session)
if (priv->disabled)
return;
+ brasero_session_cfg_save_drive_properties (BRASERO_SESSION_CFG (session),
+ former);
+
/* In this case need to :
* - load flags
* - check if all flags are thereafter supported
@@ -888,6 +914,7 @@ brasero_session_cfg_add_flags (BraseroSessionCfg *self,
BraseroBurnFlag flags)
{
BraseroSessionCfgPrivate *priv;
+ BraseroDrive *drive;
priv = BRASERO_SESSION_CFG_PRIVATE (self);
@@ -905,7 +932,9 @@ brasero_session_cfg_add_flags (BraseroSessionCfg *self,
&priv->compulsory);
/* Always save flags */
- brasero_session_cfg_save_drive_properties (self);
+ drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (self));
+ if (drive && brasero_drive_get_medium (drive))
+ brasero_session_cfg_save_drive_flags (self, brasero_drive_get_medium (drive));
brasero_session_cfg_update (self,
FALSE,
@@ -917,6 +946,7 @@ brasero_session_cfg_remove_flags (BraseroSessionCfg *self,
BraseroBurnFlag flags)
{
BraseroSessionCfgPrivate *priv;
+ BraseroDrive *drive;
priv = BRASERO_SESSION_CFG_PRIVATE (self);
@@ -928,7 +958,9 @@ brasero_session_cfg_remove_flags (BraseroSessionCfg *self,
&priv->compulsory);
/* Always save flags */
- brasero_session_cfg_save_drive_properties (self);
+ drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (self));
+ if (drive && brasero_drive_get_medium (drive))
+ brasero_session_cfg_save_drive_flags (self, brasero_drive_get_medium (drive));
brasero_session_cfg_update (self,
FALSE,
@@ -974,9 +1006,15 @@ static void
brasero_session_cfg_finalize (GObject *object)
{
BraseroSessionCfgPrivate *priv;
+ BraseroDrive *drive;
priv = BRASERO_SESSION_CFG_PRIVATE (object);
+ drive = brasero_burn_session_get_burner (BRASERO_BURN_SESSION (object));
+ if (drive && brasero_drive_get_medium (drive))
+ brasero_session_cfg_save_drive_properties (BRASERO_SESSION_CFG (object),
+ brasero_drive_get_medium (drive));
+
if (priv->caps_sig) {
BraseroPluginManager *manager;
diff --git a/libbrasero-burn/brasero-session.c b/libbrasero-burn/brasero-session.c
index 8958ee6..f5876e7 100644
--- a/libbrasero-burn/brasero-session.c
+++ b/libbrasero-burn/brasero-session.c
@@ -420,9 +420,11 @@ brasero_burn_session_dest_media_added (BraseroDrive *drive,
BraseroMedium *medium,
BraseroBurnSession *self)
{
+ /* No medium before */
g_signal_emit (self,
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
- 0);
+ 0,
+ NULL);
}
static void
@@ -432,7 +434,8 @@ brasero_burn_session_dest_media_removed (BraseroDrive *drive,
{
g_signal_emit (self,
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
- 0);
+ 0,
+ medium);
}
void
@@ -440,6 +443,7 @@ brasero_burn_session_set_burner (BraseroBurnSession *self,
BraseroDrive *drive)
{
BraseroBurnSessionPrivate *priv;
+ BraseroMedium *former;
g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
@@ -448,6 +452,11 @@ brasero_burn_session_set_burner (BraseroBurnSession *self,
if (drive == priv->settings->burner)
return;
+ former = brasero_drive_get_medium (priv->settings->burner);
+ if (former)
+ former = g_object_ref (former);
+
+ /* If there was no drive before no need for a changing signal */
if (priv->settings->burner) {
if (priv->dest_added_sig) {
g_signal_handler_disconnect (priv->settings->burner,
@@ -480,7 +489,10 @@ brasero_burn_session_set_burner (BraseroBurnSession *self,
g_signal_emit (self,
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
- 0);
+ 0,
+ former);
+ if (former)
+ g_object_unref (former);
}
BraseroDrive *
@@ -628,6 +640,35 @@ brasero_burn_session_get_output_format (BraseroBurnSession *self)
* the type of image it can be a toc (cue) or the path of the image (all others)
*/
+static void
+brasero_burn_session_set_image_output_real (BraseroBurnSession *self,
+ BraseroImageFormat format,
+ const gchar *image,
+ const gchar *toc)
+{
+ BraseroBurnSessionPrivate *priv;
+
+ priv = BRASERO_BURN_SESSION_PRIVATE (self);
+
+ if (priv->settings->image)
+ g_free (priv->settings->image);
+
+ if (image)
+ priv->settings->image = g_strdup (image);
+ else
+ priv->settings->image = NULL;
+
+ if (priv->settings->toc)
+ g_free (priv->settings->toc);
+
+ if (toc)
+ priv->settings->toc = g_strdup (toc);
+ else
+ priv->settings->toc = NULL;
+
+ priv->settings->format = format;
+}
+
BraseroBurnResult
brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
BraseroImageFormat format,
@@ -648,6 +689,8 @@ brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
BraseroDrive *drive;
GSList *list;
+ /* NOTE: changing/changed signals are handled in
+ * set_burner (). */
monitor = brasero_medium_monitor_get_default ();
list = brasero_medium_monitor_get_media (monitor, BRASERO_MEDIA_TYPE_FILE);
drive = brasero_medium_get_drive (list->data);
@@ -659,29 +702,13 @@ brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
return BRASERO_BURN_OK;
}
- if (priv->settings->image)
- g_free (priv->settings->image);
-
- if (image)
- priv->settings->image = g_strdup (image);
- else
- priv->settings->image = NULL;
-
- if (priv->settings->toc)
- g_free (priv->settings->toc);
-
- if (toc)
- priv->settings->toc = g_strdup (toc);
- else
- priv->settings->toc = NULL;
-
- priv->settings->format = format;
-
if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
BraseroMediumMonitor *monitor;
BraseroDrive *drive;
GSList *list;
+ brasero_burn_session_set_image_output_real (self, format, image, toc);
+
monitor = brasero_medium_monitor_get_default ();
list = brasero_medium_monitor_get_media (monitor,BRASERO_MEDIA_TYPE_FILE);
drive = brasero_medium_get_drive (list->data);
@@ -689,10 +716,13 @@ brasero_burn_session_set_image_output_full (BraseroBurnSession *self,
g_object_unref (monitor);
g_slist_free (list);
}
- else
+ else {
+ brasero_burn_session_set_image_output_real (self, format, image, toc);
g_signal_emit (self,
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
- 0);
+ 0,
+ brasero_drive_get_medium (priv->settings->burner));
+ }
return BRASERO_BURN_OK;
}
@@ -711,6 +741,10 @@ brasero_burn_session_set_tmpdir (BraseroBurnSession *self,
priv = BRASERO_BURN_SESSION_PRIVATE (self);
+ if (priv->settings->tmpdir && path
+ && !strcmp (priv->settings->tmpdir, path))
+ return BRASERO_BURN_OK;
+
if (priv->settings->tmpdir)
g_free (priv->settings->tmpdir);
@@ -1128,11 +1162,15 @@ brasero_burn_session_pop_settings (BraseroBurnSession *self)
{
BraseroSessionSetting *settings;
BraseroBurnSessionPrivate *priv;
+ BraseroMedium *former;
g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
priv = BRASERO_BURN_SESSION_PRIVATE (self);
+ if (!priv->pile_settings)
+ return;
+
if (priv->dest_added_sig) {
g_signal_handler_disconnect (priv->settings->burner,
priv->dest_added_sig);
@@ -1145,10 +1183,11 @@ brasero_burn_session_pop_settings (BraseroBurnSession *self)
priv->dest_removed_sig = 0;
}
- brasero_session_settings_clean (priv->settings);
+ former = brasero_drive_get_medium (priv->settings->burner);
+ if (former)
+ former = g_object_ref (former);
- if (!priv->pile_settings)
- return;
+ brasero_session_settings_clean (priv->settings);
settings = priv->pile_settings->data;
priv->pile_settings = g_slist_remove (priv->pile_settings, settings);
@@ -1169,7 +1208,10 @@ brasero_burn_session_pop_settings (BraseroBurnSession *self)
g_signal_emit (self,
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
- 0);
+ 0,
+ former);
+ if (former)
+ g_object_unref (former);
}
void
@@ -1691,9 +1733,10 @@ brasero_burn_session_class_init (BraseroBurnSessionClass *klass)
G_STRUCT_OFFSET (BraseroBurnSessionClass, output_changed),
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
- 0);
+ 1,
+ BRASERO_TYPE_MEDIUM);
brasero_burn_session_signals [INPUT_CHANGED_SIGNAL] =
g_signal_new ("input_changed",
diff --git a/libbrasero-burn/brasero-session.h b/libbrasero-burn/brasero-session.h
index 5cb143d..05eef0d 100644
--- a/libbrasero-burn/brasero-session.h
+++ b/libbrasero-burn/brasero-session.h
@@ -67,7 +67,8 @@ struct _BraseroBurnSessionClass {
* the session properties they are interested in.
*/
void (*input_changed) (BraseroBurnSession *session);
- void (*output_changed) (BraseroBurnSession *session);
+ void (*output_changed) (BraseroBurnSession *session,
+ BraseroMedium *medium);
};
GType brasero_burn_session_get_type ();
diff --git a/libbrasero-burn/brasero-src-image.c b/libbrasero-burn/brasero-src-image.c
index e9f9287..14ee2ad 100644
--- a/libbrasero-burn/brasero-src-image.c
+++ b/libbrasero-burn/brasero-src-image.c
@@ -572,7 +572,8 @@ brasero_src_image_init (BraseroSrcImage *object)
g_object_unref (file);
}
g_free (uri);
-
+
+ /* Translators: this is a disc image */
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]