brasero r1471 - in trunk: . src



Author: philippr
Date: Wed Nov  5 12:57:24 2008
New Revision: 1471
URL: http://svn.gnome.org/viewvc/brasero?rev=1471&view=rev

Log:
	Allow blanking and checking from the command line specifying a drive path
	Once done close brasero

	* src/brasero-app.c (brasero_app_blank), (on_erase_cb),
	(brasero_app_check), (on_integrity_check_cb):
	* src/brasero-app.h:
	* src/main.c (brasero_app_parse_options), (main):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-app.c
   trunk/src/brasero-app.h
   trunk/src/main.c

Modified: trunk/src/brasero-app.c
==============================================================================
--- trunk/src/brasero-app.c	(original)
+++ trunk/src/brasero-app.c	Wed Nov  5 12:57:24 2008
@@ -237,7 +237,9 @@
 }
 
 void
-brasero_app_blank (BraseroApp *app)
+brasero_app_blank (BraseroApp *app,
+		   const gchar *device,
+		   gboolean wait_and_close)
 {
 	GtkWidget *dialog;
 	GtkWidget *toplevel;
@@ -245,17 +247,39 @@
 	dialog = brasero_blank_dialog_new ();
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (app));
 
-	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
-	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+	if (device) {
+		BraseroDrive *drive;
+		BraseroMedium *medium;
+		BraseroMediumMonitor *monitor;
+
+		monitor = brasero_medium_monitor_get_default ();
+		drive = brasero_medium_monitor_get_drive (monitor, device);
+		g_object_unref (monitor);
 
-	gtk_widget_show (dialog);
+		medium = brasero_drive_get_medium (drive);
+
+		brasero_tool_dialog_set_medium (BRASERO_TOOL_DIALOG (dialog), medium);
+		g_object_unref (drive);
+	}
+
+	if (wait_and_close) {
+		gtk_widget_show (dialog);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+	}
+	else {
+		gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+		gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+		gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+		
+		gtk_widget_show (dialog);
+	}
 }
 
 static void
 on_erase_cb (GtkAction *action, BraseroApp *app)
 {
-	brasero_app_blank (app);
+	brasero_app_blank (app, NULL, FALSE);
 }
 
 static void
@@ -274,8 +298,10 @@
 	gtk_widget_show (dialog);
 }
 
-static void
-on_integrity_check_cb (GtkAction *action, BraseroApp *app)
+void
+brasero_app_check (BraseroApp *app,
+		   const gchar *device,
+		   gboolean wait_and_close)
 {
 	GtkWidget *dialog;
 	GtkWidget *toplevel;
@@ -283,11 +309,39 @@
 	dialog = brasero_sum_dialog_new ();
 	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (app));
 
-	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
-	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+	if (device) {
+		BraseroDrive *drive;
+		BraseroMedium *medium;
+		BraseroMediumMonitor *monitor;
+
+		monitor = brasero_medium_monitor_get_default ();
+		drive = brasero_medium_monitor_get_drive (monitor, device);
+		g_object_unref (monitor);
 
-	gtk_widget_show (dialog);
+		medium = brasero_drive_get_medium (drive);
+
+		brasero_tool_dialog_set_medium (BRASERO_TOOL_DIALOG (dialog), medium);
+		g_object_unref (drive);
+	}
+
+	if (wait_and_close) {
+		gtk_widget_show (dialog);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+	}
+	else {
+		gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+		gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+		gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
+		
+		gtk_widget_show (dialog);
+	}
+}
+
+static void
+on_integrity_check_cb (GtkAction *action, BraseroApp *app)
+{
+	brasero_app_check (app, NULL, FALSE);
 }
 
 static void

Modified: trunk/src/brasero-app.h
==============================================================================
--- trunk/src/brasero-app.h	(original)
+++ trunk/src/brasero-app.h	Wed Nov  5 12:57:24 2008
@@ -52,7 +52,14 @@
 brasero_app_new (void);
 
 void
-brasero_app_blank (BraseroApp *app);
+brasero_app_blank (BraseroApp *app,
+		   const gchar *device,
+		   gboolean wait_and_close);
+
+void
+brasero_app_check (BraseroApp *app,
+		   const gchar *device,
+		   gboolean wait_and_close);
 
 void
 brasero_app_get_geometry (BraseroApp *app,

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Wed Nov  5 12:57:24 2008
@@ -65,6 +65,7 @@
 gint copy_project;
 gint empty_project;
 gint disc_blank;
+gint disc_check;
 gint open_ncb;
 gint debug;
 
@@ -110,6 +111,10 @@
 	  N_("Open the blank disc dialog"),
 	  NULL },
 
+	{ "check", 'k', 0, G_OPTION_ARG_NONE, &disc_check,
+	  N_("Open the check disc dialog"),
+	  NULL },
+
 	{ "ncb", 'n', 0, G_OPTION_ARG_NONE, &open_ncb,
 	  N_("Burn the contents of burn:// URI"),
 	  NULL },
@@ -154,7 +159,7 @@
 	g_slist_free (list);							\
 }
 
-static void
+static gboolean
 brasero_app_parse_options (BraseroApp *app)
 {
 	gint nb = 0;
@@ -166,7 +171,7 @@
     	if (empty_project) {
 		brasero_project_manager_empty (BRASERO_PROJECT_MANAGER (manager));
 	    	brasero_session_load (app, FALSE);
-		return;
+		return TRUE;
 	}
 
 	/* we first check that only one of the options was given
@@ -252,7 +257,32 @@
 	    	BRASERO_PROJECT_OPEN_LIST (manager, brasero_project_manager_video, files);
 	}
 	else if (disc_blank) {
-		brasero_app_blank (app);
+		gchar *device = NULL;
+
+		/* make sure there is only one file in the remaining list for
+		 * specifying the source device. It could be extended to let
+		 * the user specify the destination device as well */
+		if (files
+		&&  files [0] != NULL
+		&&  files [1] == NULL)
+			device = files [0];
+
+		brasero_app_blank (app, device, TRUE);
+		return FALSE;
+	}
+	else if (disc_check) {
+		gchar *device = NULL;
+
+		/* make sure there is only one file in the remaining list for
+		 * specifying the source device. It could be extended to let
+		 * the user specify the destination device as well */
+		if (files
+		&&  files [0] != NULL
+		&&  files [1] == NULL)
+			device = files [0];
+
+		brasero_app_check (app, device, TRUE);
+		return FALSE;
 	}
 	else if (open_ncb) {
 		GSList *list = NULL;
@@ -300,6 +330,7 @@
 	}
 
     	brasero_session_load (app, load_default_project);
+	return TRUE;
 }
 
 int
@@ -363,13 +394,11 @@
 	if (app == NULL)
 		return 1;
 
-	gtk_widget_realize (app);
-
-	brasero_app_parse_options (BRASERO_APP (app));
-
-	gtk_widget_show (app);
-
-	gtk_main ();
+	if (brasero_app_parse_options (BRASERO_APP (app))) {
+		gtk_widget_realize (app);
+		gtk_widget_show (app);
+		gtk_main ();
+	}
 
 	brasero_burn_library_shutdown ();
 



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