brasero r1478 - in trunk: . src



Author: philippr
Date: Thu Nov  6 12:11:18 2008
New Revision: 1478
URL: http://svn.gnome.org/viewvc/brasero?rev=1478&view=rev

Log:
	Fix #559415 â consolidate error dialogue code
	Create a simple common error dialog function used throughout brasero

	* src/brasero-audio-disc.c (brasero_audio_disc_short_track_dialog),
	(brasero_audio_disc_file_type_error_dialog),
	(brasero_audio_disc_unreadable_dialog), (brasero_audio_disc_split),
	(brasero_audio_disc_inotify_removal_warning):
	* src/brasero-burn-dialog.c (brasero_burn_dialog_show_log):
	* src/brasero-data-disc.c
	(brasero_data_disc_import_failure_dialog),
	(brasero_data_disc_unreadable_uri_cb),
	(brasero_data_disc_recursive_uri_cb),
	(brasero_data_disc_unknown_uri_cb):
	* src/brasero-jacket-view.c (brasero_jacket_view_set_image):
	* src/brasero-playlist.c (brasero_playlist_dialog_error):
	* src/brasero-project-manager.c (brasero_project_manager_open_uri):
	* src/brasero-project.c (brasero_project_no_song_dialog),
	(brasero_project_no_file_dialog),
	(brasero_project_invalid_project_dialog),
	(brasero_project_not_saved_dialog):
	* src/brasero-search-beagle.c (brasero_search_beagle_error_dialog):
	* src/brasero-split-dialog.c
	(brasero_split_dialog_no_silence_message),
	(brasero_split_dialog_metadata_finished_cb):
	* src/brasero-src-image.c (brasero_src_image_error):
	* src/brasero-tool-dialog.c (brasero_tool_dialog_media_error),
	(brasero_tool_dialog_media_busy), (brasero_tool_dialog_no_media):
	* src/brasero-utils.c (brasero_utils_launch_app),
	(brasero_utils_message_dialog):
	* src/brasero-utils.h:
	* src/brasero-video-disc.c
	(brasero_video_disc_unreadable_uri_dialog),
	(brasero_video_disc_not_video_dialog):
	* src/main.c (brasero_app_parse_options):


Modified:
   trunk/ChangeLog
   trunk/src/brasero-audio-disc.c
   trunk/src/brasero-burn-dialog.c
   trunk/src/brasero-data-disc.c
   trunk/src/brasero-jacket-view.c
   trunk/src/brasero-playlist.c
   trunk/src/brasero-project-manager.c
   trunk/src/brasero-project.c
   trunk/src/brasero-search-beagle.c
   trunk/src/brasero-split-dialog.c
   trunk/src/brasero-src-image.c
   trunk/src/brasero-tool-dialog.c
   trunk/src/brasero-utils.c
   trunk/src/brasero-utils.h
   trunk/src/brasero-video-disc.c
   trunk/src/main.c

Modified: trunk/src/brasero-audio-disc.c
==============================================================================
--- trunk/src/brasero-audio-disc.c	(original)
+++ trunk/src/brasero-audio-disc.c	Thu Nov  6 12:11:18 2008
@@ -1144,23 +1144,10 @@
 static void
 brasero_audio_disc_short_track_dialog (BraseroAudioDisc *disc)
 {
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (disc));
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT |
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_WARNING,
-					 GTK_BUTTONS_CLOSE,
-					 _("The track will be padded at its end:"));
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Track Length"));
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("the track is shorter than 6 seconds."));
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (disc)),
+				      _("The track will be padded at its end:"),
+				      ("the track is shorter than 6 seconds."),
+				      GTK_MESSAGE_WARNING);
 }
 
 static gchar *
@@ -1327,7 +1314,8 @@
 brasero_audio_disc_file_type_error_dialog (BraseroAudioDisc *disc,
 					   const gchar *uri)
 {
-	GtkWidget *dialog, *toplevel;
+	GtkWidget *toplevel;
+	gchar *primary;
 	gchar *name;
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (disc));
@@ -1337,22 +1325,13 @@
 	}
 
     	BRASERO_GET_BASENAME_FOR_DISPLAY (uri, name);
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("\"%s\" can't be handled by gstreamer:"),
-					 name);
+	primary = g_strdup_printf (_("\"%s\" can't be handled by gstreamer:"), name);
+	brasero_utils_message_dialog (toplevel,
+				      primary,
+				      _("Make sure the appropriate codec is installed."),
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Unhandled Song"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("Make sure the appropriate codec is installed."));
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static gboolean
@@ -1573,7 +1552,8 @@
 				      const gchar *uri,
 				      GError *error)
 {
-	GtkWidget *dialog, *toplevel;
+	GtkWidget *toplevel;
+	gchar *primary;
 	gchar *name;
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (disc));
@@ -1585,23 +1565,13 @@
 		return;
 	}
 
-	name = g_filename_display_basename (uri);
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("File \"%s\" can't be opened."),
-					 name);
+	primary = g_strdup_printf (_("File \"%s\" can't be opened."), name);
+	brasero_utils_message_dialog (toplevel,
+				      primary,
+				      error->message,
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Unreadable File"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  error->message);
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static void
@@ -2780,22 +2750,10 @@
 
 	/* don't check g_slist_length == 0 since then the button is greyed */
 	if (g_list_length (selected) > 1) {
-		GtkWidget *message;
-
-		message = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-						  GTK_DIALOG_DESTROY_WITH_PARENT|
-						  GTK_DIALOG_MODAL,
-						  GTK_MESSAGE_ERROR,
-						  GTK_BUTTONS_CLOSE,
-						  _("Select one song only please."));
-
-		gtk_window_set_title (GTK_WINDOW (message), _("Error"));
-
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-							  _("Impossible to split more than one song at a time"));
-
-		gtk_dialog_run (GTK_DIALOG (message));
-		gtk_widget_destroy (message);
+		brasero_utils_message_dialog (toplevel,
+					      _("Select one song only please."),
+					      _("Impossible to split more than one song at a time"),
+					      GTK_MESSAGE_ERROR);
 
 		g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
 		g_list_free (selected);
@@ -3669,27 +3627,17 @@
 					    const gchar *uri)
 {
 	gchar *name;
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
+	gchar *primary;
 
 	BRASERO_GET_BASENAME_FOR_DISPLAY (uri, name);
 
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (disc));
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT |
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_WARNING,
-					 GTK_BUTTONS_CLOSE,
-					 _("File \"%s\" was removed from the file system:"),
-					 name);
+	primary = g_strdup_printf (_("File \"%s\" was removed from the file system:"), name);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (disc)),
+				      primary,
+				      _("it will be removed from the project."),
+				      GTK_MESSAGE_WARNING);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("File Deletion"));
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("it will be removed from the project."));
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static void

Modified: trunk/src/brasero-burn-dialog.c
==============================================================================
--- trunk/src/brasero-burn-dialog.c	(original)
+++ trunk/src/brasero-burn-dialog.c	Thu Nov  6 12:11:18 2008
@@ -1391,30 +1391,6 @@
 }
 
 static void
-brasero_burn_dialog_message (BraseroBurnDialog *dialog,
-			     const gchar *title,
-			     const gchar *primary_message,
-			     const gchar *secondary_message,
-			     GtkMessageType type)
-{
-	GtkWidget *message;
-
-	message = gtk_message_dialog_new (GTK_WINDOW (dialog),
-					  GTK_DIALOG_MODAL |
-					  GTK_DIALOG_DESTROY_WITH_PARENT,
-					  type,
-					  GTK_BUTTONS_CLOSE,
-					  primary_message);
-
-	gtk_window_set_title (GTK_WINDOW (message), title);
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-						  secondary_message);
-	gtk_dialog_run (GTK_DIALOG (message));
-	gtk_widget_destroy (message);
-}
-
-static void
 brasero_burn_dialog_show_log (BraseroBurnDialog *dialog)
 {
 	gint words_num;
@@ -1457,11 +1433,10 @@
 	 * bigger then only show the end which is the most relevant. */
 	logfile = brasero_burn_session_get_log_path (dialog->priv->session);
 	if (g_stat (logfile, &stats) == -1) {
-		brasero_burn_dialog_message (dialog,
-					     _("Session Log Error"),
-					     _("The session log cannot be displayed:"),
-					     _("the log file could not be found."),
-					     GTK_MESSAGE_ERROR);
+		brasero_utils_message_dialog (GTK_WIDGET (dialog),
+					      _("The session log cannot be displayed:"),
+					      _("the log file could not be found."),
+					      GTK_MESSAGE_ERROR);
 		gtk_widget_destroy (message);
 		return;
 	}
@@ -1480,21 +1455,19 @@
 
 		file = g_fopen (logfile, "r");
 		if (!file) {
-			brasero_burn_dialog_message (dialog,
-						     _("Session Log Error"),
-						     _("The session log cannot be displayed:"),
-						     strerror (errno),
-						     GTK_MESSAGE_ERROR);
+			brasero_utils_message_dialog (GTK_WIDGET (dialog),
+						      _("The session log cannot be displayed:"),
+						      strerror (errno),
+						      GTK_MESSAGE_ERROR);
 			gtk_widget_destroy (message);
 			return;
 		}
 
 		if (fread (contents, 1, sizeof (contents), file) != sizeof (contents)) {
-			brasero_burn_dialog_message (dialog,
-						     _("Session Log Error"),
-						     _("The session log cannot be displayed:"),
-						     strerror (errno),
-						     GTK_MESSAGE_ERROR);
+			brasero_utils_message_dialog (GTK_WIDGET (dialog),
+						      _("The session log cannot be displayed:"),
+						      strerror (errno),
+						      GTK_MESSAGE_ERROR);
 			gtk_widget_destroy (message);
 			return;
 		}

Modified: trunk/src/brasero-data-disc.c
==============================================================================
--- trunk/src/brasero-data-disc.c	(original)
+++ trunk/src/brasero-data-disc.c	Thu Nov  6 12:11:18 2008
@@ -214,24 +214,10 @@
 brasero_data_disc_import_failure_dialog (BraseroDataDisc *disc,
 					 GError *error)
 {
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (disc));
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT |
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_WARNING,
-					 GTK_BUTTONS_CLOSE,
-					 _("The session couldn't be imported:"));
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Session Import Error"));
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  error?error->message:_("unknown error"));
-
-	gtk_widget_show_all (dialog);
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (disc)),
+				      _("The session couldn't be imported:"),
+				      error?error->message:_("unknown error"),
+				      GTK_MESSAGE_WARNING);
 }
 
 static gboolean
@@ -897,8 +883,7 @@
 				     BraseroDataDisc *self)
 {
 	gchar *name;
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
+	gchar *primary;
 	BraseroDataDiscPrivate *priv;
 
 	priv = BRASERO_DATA_DISC_PRIVATE (self);
@@ -911,24 +896,13 @@
 		return;
 	}
 
- 	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_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("\"%s\" cannot be added to the selection:"),
-					 name);
+	primary = g_strdup_printf (_("\"%s\" cannot be added to the selection:"), name);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (self)),
+				      primary,
+				      error->message,
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Unreadable File"));
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  "%s.",
-						  error->message);
-
-	gtk_widget_show_all (dialog);
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static void
@@ -937,8 +911,7 @@
 				    BraseroDataDisc *self)
 {
 	gchar *name;
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
+	gchar *primary;
 	BraseroDataDiscPrivate *priv;
 
 	priv = BRASERO_DATA_DISC_PRIVATE (self);
@@ -954,24 +927,13 @@
 		return;
 	}
 
-	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_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("\"%s\" cannot be added to the selection:"),
-					 name);
+	primary = g_strdup_printf (_("\"%s\" cannot be added to the selection:"), name);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (self)),
+				      primary,
+				      _("it is a recursive symlink."),
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Recursive Symlink"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("it is a recursive symlink."));
-
-	gtk_widget_show_all (dialog);
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static void
@@ -980,8 +942,7 @@
 				  BraseroDataDisc *self)
 {
 	gchar *name;
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
+	gchar *primary;
 	BraseroDataDiscPrivate *priv;
 
 	priv = BRASERO_DATA_DISC_PRIVATE (self);
@@ -997,24 +958,13 @@
 		return;
 	}
 
-	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_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("\"%s\" cannot be added to the selection:"),
-					 name);
+	primary = g_strdup_printf (_("\"%s\" cannot be added to the selection:"), name);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (self)),
+				      primary,
+				      _("it doesn't exist at the specified location."),
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("File Not Found"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("it doesn't exist at the specified location."));
-
-	gtk_widget_show_all (dialog);
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static gboolean

Modified: trunk/src/brasero-jacket-view.c
==============================================================================
--- trunk/src/brasero-jacket-view.c	(original)
+++ trunk/src/brasero-jacket-view.c	Thu Nov  6 12:11:18 2008
@@ -33,6 +33,7 @@
 
 #include "brasero-jacket-view.h"
 #include "brasero-jacket-buffer.h"
+#include "brasero-utils.h"
 
 typedef struct _BraseroJacketViewPrivate BraseroJacketViewPrivate;
 struct _BraseroJacketViewPrivate
@@ -1090,17 +1091,11 @@
 
 	image = gdk_pixbuf_new_from_file (path, &error);
 	if (error) {
-		GtkWidget *message;
-
-		message = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
-						  GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
-						  GTK_MESSAGE_ERROR,
-						  GTK_BUTTONS_CLOSE,
-						  _("The image couldn't be loaded:"));
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-							  error->message);
-		gtk_dialog_run (GTK_DIALOG (message));
-		gtk_widget_destroy (message);
+		brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (self)),
+					      _("The image couldn't be loaded:"),
+					      error->message,
+					      GTK_MESSAGE_ERROR);
+		g_error_free (error);
 		return priv->image_path;
 	}
 

Modified: trunk/src/brasero-playlist.c
==============================================================================
--- trunk/src/brasero-playlist.c	(original)
+++ trunk/src/brasero-playlist.c	Thu Nov  6 12:11:18 2008
@@ -814,7 +814,7 @@
 brasero_playlist_dialog_error (BraseroPlaylist *playlist, const gchar *uri)
 {
 	gchar *name;
-	GtkWidget *dialog;
+	gchar *primary;
 	GtkWidget *toplevel;
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (playlist));
@@ -824,22 +824,14 @@
 	}
 
 	BRASERO_GET_BASENAME_FOR_DISPLAY (uri, name);
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("Error parsing playlist \"%s\":"),
-					 name);
-	g_free (name);
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("an unknown error occured."));
 
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Playlist Loading Error"));
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	primary = g_strdup_printf (_("Error parsing playlist \"%s\":"), name);
+	brasero_utils_message_dialog (GTK_WIDGET (toplevel),
+				      primary,
+				      _("an unknown error occured."),
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
+	g_free (name);
 }
 
 static void

Modified: trunk/src/brasero-project-manager.c
==============================================================================
--- trunk/src/brasero-project-manager.c	(original)
+++ trunk/src/brasero-project-manager.c	Thu Nov  6 12:11:18 2008
@@ -991,8 +991,6 @@
 	gchar *uri;
 	GFile *file;
 	GFileInfo *info;
-	GtkWidget *dialog;
-	GtkWidget *window;
 	BraseroProjectType type;
 
 	/* FIXME: make that asynchronous */
@@ -1057,18 +1055,14 @@
 	  	type = brasero_project_manager_open_by_mime (manager, uri, mime);
         } 
 	else {
-		/* FIXME: we may want to ask the user if he wants to remove it */
-		window = gtk_widget_get_toplevel (GTK_WIDGET (manager));
-	  	dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-					   	 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-					   	 GTK_MESSAGE_ERROR,
-					   	 GTK_BUTTONS_CLOSE,
-					   	 _("Error while loading the project:"));
-	  	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-							  _("The project '%s' does not exist."),
-							  uri);
-	  	gtk_dialog_run (GTK_DIALOG (dialog));
-	  	gtk_widget_destroy (dialog);
+		gchar *string;
+
+		string = g_strdup_printf (_("The project '%s' does not exist."), uri);
+		brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (manager)),
+					      _("Error while loading the project:"),
+					      string,
+					      GTK_MESSAGE_ERROR);
+		g_free (string);
 
 		type = BRASERO_PROJECT_TYPE_INVALID;
 	}

Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c	(original)
+++ trunk/src/brasero-project.c	Thu Nov  6 12:11:18 2008
@@ -813,47 +813,19 @@
 static void
 brasero_project_no_song_dialog (BraseroProject *project)
 {
-	GtkWidget *message;
-	GtkWidget *toplevel;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
-	message = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					  GTK_DIALOG_DESTROY_WITH_PARENT|
-					  GTK_DIALOG_MODAL,
-					  GTK_MESSAGE_WARNING,
-					  GTK_BUTTONS_CLOSE,
-					  _("Please add songs to the project."));
-
-	gtk_window_set_title (GTK_WINDOW (message), _("Empty Project"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-						  _("The project is empty."));
-
-	gtk_dialog_run (GTK_DIALOG (message));
-	gtk_widget_destroy (message);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (project)),
+				      _("Please add songs to the project."),
+				      _("The project is empty."),
+				      GTK_MESSAGE_WARNING);
 }
 
 static void
 brasero_project_no_file_dialog (BraseroProject *project)
 {
-	GtkWidget *message;
-	GtkWidget *toplevel;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
-	message = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					  GTK_DIALOG_DESTROY_WITH_PARENT|
-					  GTK_DIALOG_MODAL,
-					  GTK_MESSAGE_WARNING,
-					  GTK_BUTTONS_CLOSE,
-					  _("Please add files to the project."));
-
-	gtk_window_set_title (GTK_WINDOW (message), _("Empty Project"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-						  _("The project is empty."));
-
-	gtk_dialog_run (GTK_DIALOG (message));
-	gtk_widget_destroy (message);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (project)),
+				      _("Please add files to the project."),
+				      _("The project is empty."),
+				      GTK_MESSAGE_WARNING);
 }
 
 void
@@ -1642,24 +1614,10 @@
 brasero_project_invalid_project_dialog (BraseroProject *project,
 					const char *reason)
 {
-	GtkWidget *dialog;
-	GtkWidget *toplevel;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT |
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("Error while loading the project:"));
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Project Loading Error"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  reason);
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (project)),
+				      _("Error while loading the project:"),
+				      reason,
+				      GTK_MESSAGE_ERROR);
 }
 
 static gboolean
@@ -2219,31 +2177,14 @@
 static void
 brasero_project_not_saved_dialog (BraseroProject *project)
 {
-	GtkWidget *dialog;
-	xmlErrorPtr error;
-	GtkWidget *toplevel;
-
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_WARNING,
-					 GTK_BUTTONS_CLOSE,
-					 _("Your project has not been saved:"));
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Unsaved Project"));
+	xmlError *error;
 
 	error = xmlGetLastError ();
-	if (error)
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-							  error->message);
-	else
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-							  _("Unknown error."));	
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (project)),
+				      _("Your project has not been saved:"),
+				      error?error->message:_("Unknown error."),
+				      GTK_MESSAGE_ERROR);
 	xmlResetLastError ();
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static GtkResponseType

Modified: trunk/src/brasero-search-beagle.c
==============================================================================
--- trunk/src/brasero-search-beagle.c	(original)
+++ trunk/src/brasero-search-beagle.c	Thu Nov  6 12:11:18 2008
@@ -1044,7 +1044,6 @@
 static void
 brasero_search_beagle_error_dialog (BraseroSearch *search, GError *error)
 {
-	GtkWidget *dialog;
 	GtkWidget *toplevel;
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (search));
@@ -1053,20 +1052,10 @@
 		return;
 	}
 
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("Error querying beagle:"));
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Search Error"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  error->message);
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	brasero_utils_message_dialog (toplevel,
+				      _("Error querying beagle:"),
+				      error->message,
+				      GTK_MESSAGE_ERROR);
 }
 
 static void

Modified: trunk/src/brasero-split-dialog.c
==============================================================================
--- trunk/src/brasero-split-dialog.c	(original)
+++ trunk/src/brasero-split-dialog.c	Thu Nov  6 12:11:18 2008
@@ -607,22 +607,10 @@
 static void
 brasero_split_dialog_no_silence_message (BraseroSplitDialog *self)
 {
-	GtkWidget *message;
-
-	/* no silences found */
-	message = gtk_message_dialog_new (GTK_WINDOW (self),
-					  GTK_DIALOG_DESTROY_WITH_PARENT|
-					  GTK_DIALOG_MODAL,
-					  GTK_MESSAGE_WARNING,
-					  GTK_BUTTONS_CLOSE,
-					  _("The track wasn't split:"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-						  _("no silence could be retrieved."));
-
-	gtk_window_set_title (GTK_WINDOW (message), _("No Silence"));
-	gtk_dialog_run (GTK_DIALOG (message));
-	gtk_widget_destroy (message);
+	brasero_utils_message_dialog (GTK_WIDGET (self),
+				      _("The track wasn't split:"),
+				      _("no silence could be retrieved."),
+				      GTK_MESSAGE_WARNING);
 }
 
 static void
@@ -643,21 +631,10 @@
 	priv->metadata = NULL;
 
 	if (error) {
-		GtkWidget *message;
-
-		/* error while retrieve silences */
-		message = gtk_message_dialog_new (GTK_WINDOW (self),
-						  GTK_DIALOG_DESTROY_WITH_PARENT|
-						  GTK_DIALOG_MODAL,
-						  GTK_MESSAGE_ERROR,
-						  GTK_BUTTONS_CLOSE,
-						  _("An error occured while retrieving silences:"));
-		gtk_window_set_title (GTK_WINDOW (message), _("Error"));
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-							  error->message);
-
-		gtk_dialog_run (GTK_DIALOG (message));
-		gtk_widget_destroy (message);
+		brasero_utils_message_dialog (GTK_WIDGET (self),
+					      _("An error occured while retrieving silences:"),
+					      error->message,
+					      GTK_MESSAGE_ERROR);
 		return;
 	}
 

Modified: trunk/src/brasero-src-image.c
==============================================================================
--- trunk/src/brasero-src-image.c	(original)
+++ trunk/src/brasero-src-image.c	Thu Nov  6 12:11:18 2008
@@ -232,22 +232,10 @@
 brasero_src_image_error (BraseroSrcImage *self,
 			 GError *error)
 {
-	GtkWidget *toplevel;
-	GtkWidget *dialog;
-
-	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_CLOSE,
-					 _("Please, select another image."));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  error->message);
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
+	brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (self)),
+				      _("Please, select another image."),
+				      error->message,
+				      GTK_MESSAGE_ERROR);
 }
 
 static void

Modified: trunk/src/brasero-tool-dialog.c
==============================================================================
--- trunk/src/brasero-tool-dialog.c	(original)
+++ trunk/src/brasero-tool-dialog.c	Thu Nov  6 12:11:18 2008
@@ -71,34 +71,9 @@
 static GtkDialogClass *parent_class = NULL;
 
 static void
-brasero_tool_dialog_message (BraseroToolDialog *self,
-			     const gchar *title,
-			     const gchar *primary_message,
-			     const gchar *secondary_message,
-			     GtkMessageType type)
-{
-	GtkWidget *message;
-
-	message = gtk_message_dialog_new (GTK_WINDOW (self),
-					  GTK_DIALOG_MODAL |
-					  GTK_DIALOG_DESTROY_WITH_PARENT,
-					  type,
-					  GTK_BUTTONS_CLOSE,
-					  primary_message);
-
-	gtk_window_set_title (GTK_WINDOW (message), title);
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-						  secondary_message);
-	gtk_dialog_run (GTK_DIALOG (message));
-	gtk_widget_destroy (message);
-}
-
-static void
 brasero_tool_dialog_media_error (BraseroToolDialog *self)
 {
-	brasero_tool_dialog_message (self,
-				     _("Media Busy"),
+	brasero_utils_message_dialog (GTK_WIDGET (self),
 				     _("The operation cannot be performed:"),
 				     _("the inserted media is busy."),
 				     GTK_MESSAGE_ERROR);
@@ -107,8 +82,7 @@
 static void
 brasero_tool_dialog_media_busy (BraseroToolDialog *self)
 {
-	brasero_tool_dialog_message (self,
-				     _("Media Error"),
+	brasero_utils_message_dialog (GTK_WIDGET (self),
 				     _("The operation cannot be performed:"),
 				     _("the inserted media is not supported."),
 				     GTK_MESSAGE_ERROR);
@@ -117,8 +91,7 @@
 static void
 brasero_tool_dialog_no_media (BraseroToolDialog *self)
 {
-	brasero_tool_dialog_message (self,
-				     _("Media Error"),
+	brasero_utils_message_dialog (GTK_WIDGET (self),
 				     _("The operation cannot be performed:"),
 				     _("the drive is empty."),
 				     GTK_MESSAGE_ERROR);

Modified: trunk/src/brasero-utils.c
==============================================================================
--- trunk/src/brasero-utils.c	(original)
+++ trunk/src/brasero-utils.c	Thu Nov  6 12:11:18 2008
@@ -468,25 +468,10 @@
 		uri = item->data;
 
 		if (!g_app_info_launch_default_for_uri (uri, NULL, &error)) {
-			GtkWidget *dialog;
-			GtkWidget *toplevel;
-
-			toplevel = gtk_widget_get_toplevel (GTK_WIDGET (widget));
-			dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-							 GTK_DIALOG_DESTROY_WITH_PARENT|
-							 GTK_DIALOG_MODAL,
-							 GTK_MESSAGE_ERROR,
-							 GTK_BUTTONS_CLOSE,
-							 _("This file can't be opened:"));
-
-			gtk_window_set_title (GTK_WINDOW (dialog), _("File Error"));
-
-			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-								  error->message);
-
-			gtk_dialog_run (GTK_DIALOG (dialog));
-			gtk_widget_destroy (dialog);
-
+			brasero_utils_message_dialog (gtk_widget_get_toplevel (GTK_WIDGET (widget)),
+						      _("This file can't be opened:"),
+						      error->message,
+						      GTK_MESSAGE_ERROR);
 			g_error_free (error);
 			continue;
 		}
@@ -518,3 +503,29 @@
 
 	return retval;
 }
+
+void
+brasero_utils_message_dialog (GtkWidget *parent,
+			      const gchar *primary_message,
+			      const gchar *secondary_message,
+			      GtkMessageType type)
+{
+	GtkWidget *message;
+
+	message = gtk_message_dialog_new (GTK_WINDOW (parent),
+					  GTK_DIALOG_MODAL |
+					  GTK_DIALOG_DESTROY_WITH_PARENT,
+					  type,
+					  GTK_BUTTONS_CLOSE,
+					  primary_message);
+
+	gtk_window_set_title (GTK_WINDOW (message), "");
+
+	if (secondary_message)
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
+							  "%s",
+							  secondary_message);
+
+	gtk_dialog_run (GTK_DIALOG (message));
+	gtk_widget_destroy (message);
+}

Modified: trunk/src/brasero-utils.h
==============================================================================
--- trunk/src/brasero-utils.h	(original)
+++ trunk/src/brasero-utils.h	Thu Nov  6 12:11:18 2008
@@ -109,6 +109,12 @@
 gchar*
 brasero_utils_validate_utf8 (const gchar *name);
 
+void
+brasero_utils_message_dialog (GtkWidget *parent,
+			      const gchar *primary_message,
+			      const gchar *secondary_message,
+			      GtkMessageType type);
+
 G_END_DECLS
 
 #endif				/* _UTILS_H */

Modified: trunk/src/brasero-video-disc.c
==============================================================================
--- trunk/src/brasero-video-disc.c	(original)
+++ trunk/src/brasero-video-disc.c	Thu Nov  6 12:11:18 2008
@@ -270,7 +270,8 @@
 					  const gchar *uri,
 					  BraseroVideoDisc *self)
 {
-	GtkWidget *dialog, *toplevel;
+	GtkWidget *toplevel;
+	gchar *primary;
 	gchar *name;
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
@@ -282,22 +283,13 @@
 	}
 
 	name = g_filename_display_basename (uri);
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("File \"%s\" can't be opened."),
-					 name);
+	primary = g_strdup_printf (_("File \"%s\" can't be opened."), name);
+	brasero_utils_message_dialog (toplevel,
+				      primary,
+				      error->message,
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Unreadable file"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  error->message);
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static void
@@ -305,7 +297,8 @@
 				     const gchar *uri,
 				     BraseroVideoDisc *self)
 {
-	GtkWidget *dialog, *toplevel;
+	GtkWidget *toplevel;
+	gchar *primary;
 	gchar *name;
 
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
@@ -315,22 +308,13 @@
 	}
 
 	BRASERO_GET_BASENAME_FOR_DISPLAY (uri, name);
-	dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
-					 GTK_DIALOG_DESTROY_WITH_PARENT|
-					 GTK_DIALOG_MODAL,
-					 GTK_MESSAGE_ERROR,
-					 GTK_BUTTONS_CLOSE,
-					 _("\"%s\" does not have a suitable type for video projects."),
-					 name);
+	primary = g_strdup_printf (_("\"%s\" does not have a suitable type for video projects."), name);
+	brasero_utils_message_dialog (toplevel,
+				      primary,
+				      _("Please only add files with video contents."),
+				      GTK_MESSAGE_ERROR);
+	g_free (primary);
 	g_free (name);
-
-	gtk_window_set_title (GTK_WINDOW (dialog), _("Unhandled file"));
-
-	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-						  _("Please only add files with video contents."));
-
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
 }
 
 static BraseroDiscResult

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Thu Nov  6 12:11:18 2008
@@ -196,21 +196,10 @@
 		nb ++;
 
 	if (nb > 1) {
-		GtkWidget *message;
-
-		message = gtk_message_dialog_new (NULL,
-						  GTK_DIALOG_MODAL |
-						  GTK_DIALOG_DESTROY_WITH_PARENT,
-						  GTK_MESSAGE_INFO,
-						  GTK_BUTTONS_CLOSE,
-						  _("Incompatible command line options used:"));
-
-		gtk_window_set_title (GTK_WINDOW (message), _("Incompatible Options"));
-		
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
-							  _("only one option can be given at a time."));
-		gtk_dialog_run (GTK_DIALOG (message));
-		gtk_widget_destroy (message);
+		brasero_utils_message_dialog (NULL,
+					      _("Incompatible command line options used:"),
+					      _("only one option can be given at a time."),
+					      GTK_MESSAGE_ERROR);
 
 		brasero_project_manager_empty (BRASERO_PROJECT_MANAGER (manager));
 	}



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