brasero r1284 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1284 - in trunk: . src
- Date: Sun, 14 Sep 2008 17:52:27 +0000 (UTC)
Author: philippr
Date: Sun Sep 14 17:52:27 2008
New Revision: 1284
URL: http://svn.gnome.org/viewvc/brasero?rev=1284&view=rev
Log:
Ask the user if he wants to burn an image when one is added to a data project
Fix #547731 â warn idiot users ...
* src/brasero-data-disc.c (brasero_data_disc_switch_to_image),
(brasero_data_disc_image_uri_cb), (brasero_data_disc_init):
* src/brasero-data-vfs.c (brasero_data_vfs_emit_image_signal),
(brasero_data_vfs_loading_node_result),
(brasero_data_vfs_class_init):
* src/brasero-marshal.list:
Modified:
trunk/ChangeLog
trunk/src/brasero-data-disc.c
trunk/src/brasero-data-vfs.c
trunk/src/brasero-marshal.list
Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c (original)
+++ trunk/src/brasero-data-disc.c Sun Sep 14 17:52:27 2008
@@ -62,6 +62,9 @@
#include "brasero-rename.h"
#include "brasero-notify.h"
+#include "brasero-app.h"
+#include "brasero-project-manager.h"
+
#include "burn-debug.h"
#include "burn-basics.h"
#include "burn-track.h"
@@ -671,6 +674,97 @@
brasero_file_filtered_remove (BRASERO_FILE_FILTERED (priv->filter), uri);
}
+struct _BraseroDataDiscProjectSwitch {
+ gchar *uri;
+ BraseroDataDisc *disc;
+};
+typedef struct _BraseroDataDiscProjectSwitch BraseroDataDiscProjectSwitch;
+
+static gboolean
+brasero_data_disc_switch_to_image (gpointer data)
+{
+ GtkWidget *manager;
+ GtkWidget *toplevel;
+ BraseroDataDiscPrivate *priv;
+ BraseroDataDiscProjectSwitch *callback_data = data;
+
+ priv = BRASERO_DATA_DISC_PRIVATE (callback_data->disc);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (callback_data->disc));
+ if (!BRASERO_IS_APP (toplevel))
+ return BRASERO_BURN_OK;
+
+ /* Clean up everything to avoid warning dialog */
+ brasero_data_project_reset (priv->project);
+
+ /* Tell project manager to switch */
+ manager = brasero_app_get_project_manager (BRASERO_APP (toplevel));
+ brasero_project_manager_iso (BRASERO_PROJECT_MANAGER (manager), callback_data->uri);
+
+ return FALSE;
+}
+
+static BraseroBurnResult
+brasero_data_disc_image_uri_cb (BraseroDataVFS *vfs,
+ const gchar *uri,
+ BraseroDataDisc *self)
+{
+ gint answer;
+ gchar *name;
+ GtkWidget *button;
+ GtkWidget *dialog;
+ GtkWidget *toplevel;
+ BraseroDataDiscPrivate *priv;
+ BraseroDataDiscProjectSwitch *callback_data;
+
+ priv = BRASERO_DATA_DISC_PRIVATE (self);
+
+ if (priv->loading)
+ return BRASERO_BURN_OK;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ if (!BRASERO_IS_APP (toplevel))
+ return BRASERO_BURN_OK;
+
+ name = brasero_file_node_get_uri_name (uri);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("Do you want to burn \"%s\" to a disc or add it in to the data project?"),
+ name);
+ g_free (name);
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("This file is the image of a disc and can therefore be burnt to disc without having to add it to a data project first."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Add to project"), GTK_RESPONSE_NO);
+
+ button = brasero_utils_make_button (_("_Burn..."),
+ NULL,
+ "media-optical-burn",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (button);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
+ button,
+ GTK_RESPONSE_YES);
+
+ gtk_widget_show_all (dialog);
+ answer = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (answer != GTK_RESPONSE_YES)
+ return BRASERO_BURN_OK;
+
+ callback_data = g_new (BraseroDataDiscProjectSwitch, 1);
+ callback_data->disc = self;
+ callback_data->uri = g_strdup (uri);
+ g_idle_add (brasero_data_disc_switch_to_image, callback_data);
+
+ return BRASERO_BURN_CANCEL;
+}
+
static void
brasero_data_disc_filter_expanded_cb (GtkExpander *expander,
BraseroDataDisc *self)
@@ -2049,6 +2143,10 @@
G_CALLBACK (brasero_data_disc_filtered_uri_cb),
object);
g_signal_connect (priv->project,
+ "image-uri",
+ G_CALLBACK (brasero_data_disc_image_uri_cb),
+ object);
+ g_signal_connect (priv->project,
"unreadable-uri",
G_CALLBACK (brasero_data_disc_unreadable_uri_cb),
object);
Modified: trunk/src/brasero-data-vfs.c
==============================================================================
--- trunk/src/brasero-data-vfs.c (original)
+++ trunk/src/brasero-data-vfs.c Sun Sep 14 17:52:27 2008
@@ -68,6 +68,7 @@
enum {
UNREADABLE_SIGNAL,
RECURSIVE_SIGNAL,
+ IMAGE_SIGNAL,
FILTERED_SIGNAL,
ACTIVITY_SIGNAL,
UNKNOWN_SIGNAL,
@@ -603,6 +604,41 @@
g_hash_table_size (priv->directories));
}
+static BraseroBurnResult
+brasero_data_vfs_emit_image_signal (BraseroDataVFS *self,
+ const gchar *uri)
+{
+ GValue instance_and_params [2];
+ GValue return_value;
+ GValue *params;
+
+ /* object which signalled */
+ instance_and_params->g_type = 0;
+ g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (self));
+ g_value_set_instance (instance_and_params, self);
+
+ /* arguments of signal (name) */
+ params = instance_and_params + 1;
+ params->g_type = 0;
+ g_value_init (params, G_TYPE_STRING);
+ g_value_set_string (params, uri);
+
+ /* default to FALSE */
+ return_value.g_type = 0;
+ g_value_init (&return_value, G_TYPE_INT);
+ g_value_set_int (&return_value, BRASERO_BURN_CANCEL);
+
+ g_signal_emitv (instance_and_params,
+ brasero_data_vfs_signals [IMAGE_SIGNAL],
+ 0,
+ &return_value);
+
+ g_value_unset (instance_and_params);
+ g_value_unset (params);
+
+ return g_value_get_int (&return_value);
+}
+
static void
brasero_data_vfs_loading_node_result (GObject *owner,
GError *error,
@@ -612,6 +648,8 @@
{
GSList *iter;
GSList *nodes;
+ BraseroFileNode *root;
+ BraseroFileTreeStats *stats;
gchar *registered = callback_data;
BraseroDataVFS *self = BRASERO_DATA_VFS (owner);
BraseroDataVFSPrivate *priv = BRASERO_DATA_VFS_PRIVATE (self);
@@ -636,6 +674,38 @@
return;
}
+ /* It can happen that the user made a mistake out of ignorance or for
+ * whatever other reason and dropped an image he wanted to burn.
+ * So if our file is the only one in the project and if that's an image
+ * check it is an image. If so, ask him if that's he really want to do. */
+ root = brasero_data_project_get_root (BRASERO_DATA_PROJECT (self));
+ stats = BRASERO_FILE_NODE_STATS (root);
+
+ if (stats && !stats->children
+ && (!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")
+ || !strcmp (g_file_info_get_content_type (info), "application/x-cd-image"))) {
+ BraseroBurnResult result;
+
+ result = brasero_data_vfs_emit_image_signal (self, uri);
+ if (result == BRASERO_BURN_CANCEL) {
+ for (iter = nodes; iter; iter = iter->next) {
+ BraseroFileNode *node;
+ guint reference;
+
+ reference = GPOINTER_TO_INT (iter->data);
+ node = brasero_data_project_reference_get (BRASERO_DATA_PROJECT (self), reference);
+
+ /* the node could have been removed in the mean time */
+ if (node)
+ brasero_data_project_remove_node (BRASERO_DATA_PROJECT (self), node);
+ }
+
+ return;
+ }
+ }
+
/* NOTE: we don't check for a broken symlink here since the user chose
* to add it. So even if it were we would have to add it. The same for
* hidden files. */
@@ -1216,6 +1286,17 @@
1,
G_TYPE_BOOLEAN);
+ brasero_data_vfs_signals [IMAGE_SIGNAL] =
+ g_signal_new ("image_uri",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE,
+ 0,
+ NULL, NULL,
+ brasero_marshal_INT__STRING,
+ G_TYPE_INT,
+ 1,
+ G_TYPE_STRING);
+
brasero_data_vfs_signals [FILTERED_SIGNAL] =
g_signal_new ("filtered_uri",
G_TYPE_FROM_CLASS (klass),
Modified: trunk/src/brasero-marshal.list
==============================================================================
--- trunk/src/brasero-marshal.list (original)
+++ trunk/src/brasero-marshal.list Sun Sep 14 17:52:27 2008
@@ -3,6 +3,7 @@
INT:VOID
INT:INT
INT:INT,INT
+INT:STRING
INT:BOOLEAN,BOOLEAN,BOOLEAN
VOID:DOUBLE,STRING
VOID:INT64
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]