brasero r1331 - in trunk: . src



Author: philippr
Date: Tue Sep 30 18:37:28 2008
New Revision: 1331
URL: http://svn.gnome.org/viewvc/brasero?rev=1331&view=rev

Log:
	New message to tell the user when there is no writable disc inserted

	* src/brasero-burn-options.c
	(brasero_burn_options_update_no_medium_warning),
	(brasero_burn_options_valid_media_cb),
	(brasero_burn_options_medium_num_changed),
	(brasero_burn_options_init):
	* src/brasero-medium-selection.c
	(brasero_medium_selection_show_type),
	(brasero_medium_selection_get_drive_num),
	(brasero_medium_selection_medium_added_cb),
	(brasero_medium_selection_medium_removed_cb),
	(brasero_medium_selection_class_init):
	* src/brasero-medium-selection.h:


Modified:
   trunk/ChangeLog
   trunk/src/brasero-burn-options.c
   trunk/src/brasero-medium-selection.c
   trunk/src/brasero-medium-selection.h

Modified: trunk/src/brasero-burn-options.c
==============================================================================
--- trunk/src/brasero-burn-options.c	(original)
+++ trunk/src/brasero-burn-options.c	Tue Sep 30 18:37:28 2008
@@ -56,6 +56,8 @@
 	GtkWidget *message_output;
 	GtkWidget *options;
 	GtkWidget *button;
+
+	guint is_valid:1;
 };
 
 #define BRASERO_BURN_OPTIONS_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_BURN_OPTIONS, BraseroBurnOptionsPrivate))
@@ -183,6 +185,42 @@
 	}
 }
 
+#define BRASERO_BURN_OPTIONS_NO_MEDIUM_WARNING	1000
+
+static void
+brasero_burn_options_update_no_medium_warning (BraseroBurnOptions *self)
+{
+	BraseroBurnOptionsPrivate *priv;
+
+	priv = BRASERO_BURN_OPTIONS_PRIVATE (self);
+
+	if (!priv->is_valid) {
+		brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_output),
+					       BRASERO_BURN_OPTIONS_NO_MEDIUM_WARNING);
+		return;
+	}
+
+	if (!brasero_burn_session_is_dest_file (BRASERO_BURN_SESSION (priv->session))) {
+		brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_output),
+					       BRASERO_BURN_OPTIONS_NO_MEDIUM_WARNING);
+		return;
+	}
+
+	if (brasero_medium_selection_get_drive_num (BRASERO_MEDIUM_SELECTION (priv->selection)) != 1) {
+		brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_output),
+					       BRASERO_BURN_OPTIONS_NO_MEDIUM_WARNING);
+		return;
+	}
+
+	/* The user may have forgotten to insert a disc so remind him of that if
+	 * there aren't any other possibility in the selection */
+	brasero_notify_message_add (BRASERO_NOTIFY (priv->message_output),
+				    _("Please, insert a recordable CD or DVD if you don't want to write to an image file."),
+				    NULL,
+				    -1,
+				    BRASERO_BURN_OPTIONS_NO_MEDIUM_WARNING);
+}
+
 static void
 brasero_burn_options_valid_media_cb (BraseroBurnSession *session,
 				     BraseroSessionError valid,
@@ -227,6 +265,7 @@
 	brasero_notify_message_remove (BRASERO_NOTIFY (priv->message_output),
 				       BRASERO_NOTIFY_CONTEXT_SIZE);
 
+	priv->is_valid = FALSE;
 	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."),
@@ -317,7 +356,18 @@
 				  G_CALLBACK (brasero_burn_options_message_response_cb),
 				  self);
 	}
+	else
+		priv->is_valid = TRUE;
 
+	brasero_burn_options_update_no_medium_warning (self);
+	gtk_window_resize (GTK_WINDOW (self), 10, 10);
+}
+
+static void
+brasero_burn_options_medium_num_changed (BraseroMediumSelection *selection,
+					 BraseroBurnOptions *self)
+{
+	brasero_burn_options_update_no_medium_warning (self);
 	gtk_window_resize (GTK_WINDOW (self), 10, 10);
 }
 
@@ -451,6 +501,15 @@
 					    "is-valid",
 					    G_CALLBACK (brasero_burn_options_valid_media_cb),
 					    object);
+
+	g_signal_connect (priv->selection,
+			  "medium-added",
+			  G_CALLBACK (brasero_burn_options_medium_num_changed),
+			  object);
+	g_signal_connect (priv->selection,
+			  "medium-removed",
+			  G_CALLBACK (brasero_burn_options_medium_num_changed),
+			  object);
 }
 
 static void

Modified: trunk/src/brasero-medium-selection.c
==============================================================================
--- trunk/src/brasero-medium-selection.c	(original)
+++ trunk/src/brasero-medium-selection.c	Tue Sep 30 18:37:28 2008
@@ -48,6 +48,14 @@
 
 #define BRASERO_MEDIUM_SELECTION_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_MEDIUM_SELECTION, BraseroMediumSelectionPrivate))
 
+typedef enum {
+	ADDED_SIGNAL,
+	REMOVED_SIGNAL,
+	LAST_SIGNAL
+} BraseroMediumSelectionSignalType;
+
+static guint brasero_medium_selection_signals [LAST_SIGNAL] = { 0 };
+
 enum {
 	MEDIUM_COL,
 	NAME_COL,
@@ -286,9 +294,16 @@
 			g_object_unref (medium);
 
 			if (!node) {
-				if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
+				if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter)) {
+					g_signal_emit (self,
+						       brasero_medium_selection_signals [ADDED_SIGNAL],
+						       0);
 					continue;
+				}
 
+				g_signal_emit (self,
+					       brasero_medium_selection_signals [ADDED_SIGNAL],
+					       0);
 				break;
 			}
 
@@ -316,6 +331,9 @@
 					    ICON_COL, medium_icon,
 					    -1);
 			g_free (medium_name);
+			g_signal_emit (self,
+				       brasero_medium_selection_signals [ADDED_SIGNAL],
+				       0);
 		}
 		g_slist_foreach (list, (GFunc) g_object_unref, NULL);
 		g_slist_free (list);
@@ -336,6 +354,18 @@
 		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
 }
 
+guint
+brasero_medium_selection_get_drive_num (BraseroMediumSelection *self)
+{
+	BraseroMediumSelectionPrivate *priv;
+	GtkTreeModel *model;
+
+	priv = BRASERO_MEDIUM_SELECTION_PRIVATE (self);
+
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
+	return gtk_tree_model_iter_n_children (model, NULL);
+}
+
 static void
 brasero_medium_selection_medium_added_cb (BraseroMediumMonitor *monitor,
 					  BraseroMedium *medium,
@@ -400,6 +430,10 @@
 
 	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,
+		       brasero_medium_selection_signals [ADDED_SIGNAL],
+		       0);
 }
 
 static void
@@ -424,6 +458,9 @@
 		if (medium == iter_medium) {
 			g_object_unref (iter_medium);
 			gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+			g_signal_emit (self,
+				       brasero_medium_selection_signals [REMOVED_SIGNAL],
+				       0);
 			break;
 		}
 
@@ -525,6 +562,27 @@
 	object_class->finalize = brasero_medium_selection_finalize;
 
 	combo_class->changed = brasero_medium_selection_changed;
+
+	brasero_medium_selection_signals [ADDED_SIGNAL] =
+	    g_signal_new ("medium_added",
+			  BRASERO_TYPE_MEDIUM_SELECTION,
+			  G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION|G_SIGNAL_NO_RECURSE,
+			  0,
+			  NULL,
+			  NULL,
+			  g_cclosure_marshal_VOID__VOID,
+			  G_TYPE_NONE,
+			  0);
+	brasero_medium_selection_signals [REMOVED_SIGNAL] =
+	    g_signal_new ("medium_removed",
+			  BRASERO_TYPE_MEDIUM_SELECTION,
+			  G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION|G_SIGNAL_NO_RECURSE,
+			  0,
+			  NULL,
+			  NULL,
+			  g_cclosure_marshal_VOID__VOID,
+			  G_TYPE_NONE,
+			  0);
 }
 
 GtkWidget *

Modified: trunk/src/brasero-medium-selection.h
==============================================================================
--- trunk/src/brasero-medium-selection.h	(original)
+++ trunk/src/brasero-medium-selection.h	Tue Sep 30 18:37:28 2008
@@ -75,6 +75,9 @@
 brasero_medium_selection_show_type (BraseroMediumSelection *selection,
 				    BraseroMediaType type);
 
+guint
+brasero_medium_selection_get_drive_num (BraseroMediumSelection *selection);
+
 void
 brasero_medium_selection_update_media_string (BraseroMediumSelection *selection);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]