[brasero] Detect when a project, playlist is passed on the command line and behave as if -p option had been pa



commit 04dc916b37277ea8bf288efe4b75dc9179b5bd86
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Wed Aug 26 15:25:11 2009 +0200

    Detect when a project, playlist is passed on the command line and behave as if -p option had been passed.

 src/brasero-app.c             |   42 ++++++++++++++++++++++++++++-
 src/brasero-app.h             |    7 +++++
 src/brasero-project-manager.c |   45 ++++++++++++-------------------
 src/brasero-project-manager.h |   14 +++------
 src/brasero-project.c         |   58 +++++++++-------------------------------
 src/brasero-project.h         |    9 +++---
 src/main.c                    |   30 ++-------------------
 7 files changed, 90 insertions(+), 115 deletions(-)
---
diff --git a/src/brasero-app.c b/src/brasero-app.c
index e7b3e99..aef3f6a 100644
--- a/src/brasero-app.c
+++ b/src/brasero-app.c
@@ -1127,6 +1127,44 @@ on_configure_event_cb (GtkWidget *widget,
 	return FALSE;
 }
 
+gboolean
+brasero_app_open_project (BraseroApp *app,
+                          const gchar *uri,
+                          gboolean is_playlist,
+                          gboolean warn_user,
+                          gboolean burn)
+{
+	BraseroSessionCfg *session;
+	BraseroAppPrivate *priv;
+
+	priv = BRASERO_APP_PRIVATE (app);
+
+	session = brasero_session_cfg_new ();
+
+#ifdef BUILD_PLAYLIST
+
+	if (is_playlist) {
+		if (!brasero_project_open_audio_playlist_project (uri, BRASERO_BURN_SESSION (session), warn_user))
+			return FALSE;
+	}
+	else
+
+#endif
+	
+	if (!brasero_project_open_project_xml (uri, BRASERO_BURN_SESSION (session), warn_user))
+		return FALSE;
+
+	if (!priv->projects) {
+		brasero_app_create_mainwin (app);
+		brasero_project_manager_open_session (BRASERO_PROJECT_MANAGER (priv->projects), session, burn);
+		brasero_app_run_mainwin (app);
+	}
+	else
+		brasero_project_manager_open_session (BRASERO_PROJECT_MANAGER (priv->projects), session, burn);
+
+	return TRUE;
+}
+
 static gboolean
 brasero_app_open_by_mime (BraseroApp *app,
                           const gchar *uri,
@@ -1145,7 +1183,7 @@ brasero_app_open_by_mime (BraseroApp *app,
 	 * installed, it's returned as application/xml, so check that too. */
 	if (!strcmp (mime, "application/x-brasero")
 	||  !strcmp (mime, "application/xml"))
-		return (brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (priv->projects), uri, FALSE, FALSE) != BRASERO_PROJECT_TYPE_INVALID);
+		return brasero_app_open_project (app, uri, FALSE, TRUE, FALSE);
 
 #ifdef BUILD_PLAYLIST
 
@@ -1153,7 +1191,7 @@ brasero_app_open_by_mime (BraseroApp *app,
 	     ||  !strcmp (mime, "audio/x-ms-asx")
 	     ||  !strcmp (mime, "audio/x-mp3-playlist")
 	     ||  !strcmp (mime, "audio/x-mpegurl"))
-		return (brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (priv->projects), uri, TRUE, FALSE) != BRASERO_PROJECT_TYPE_INVALID);
+		return brasero_app_open_project (app, uri, TRUE,  TRUE, FALSE);
 
 #endif
 
diff --git a/src/brasero-app.h b/src/brasero-app.h
index 4ff5125..49d3293 100644
--- a/src/brasero-app.h
+++ b/src/brasero-app.h
@@ -112,6 +112,13 @@ brasero_app_check (BraseroApp *app,
 		   const gchar *device);
 
 gboolean
+brasero_app_open_project (BraseroApp *app,
+                          const gchar *uri,
+                          gboolean is_playlist,
+                          gboolean warn_user,
+                          gboolean burn);
+
+gboolean
 brasero_app_open_uri (BraseroApp *app,
                       const gchar *uri_arg);
 
diff --git a/src/brasero-project-manager.c b/src/brasero-project-manager.c
index 0a04af8..bc575df 100644
--- a/src/brasero-project-manager.c
+++ b/src/brasero-project-manager.c
@@ -751,19 +751,18 @@ brasero_project_manager_iso (BraseroProjectManager *manager,
 					TRUE);
 }
 
-BraseroProjectType
-brasero_project_manager_open_project (BraseroProjectManager *manager,
-				      const gchar *uri,
-				      gboolean playlist,
-				      gboolean burn)
+gboolean
+brasero_project_manager_open_session (BraseroProjectManager *manager,
+                                      BraseroSessionCfg *session,
+                                      gboolean burn)
 {
 	GtkAction *action;
 	BraseroProjectType type;
 
-	type = brasero_project_open_project (BRASERO_PROJECT (manager->priv->project), uri, playlist);
+	type = brasero_project_open_session (BRASERO_PROJECT (manager->priv->project), session);
 	if (type == BRASERO_PROJECT_TYPE_INVALID) {
 		brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);
-		return type;
+		return FALSE;
 	}
 
 	brasero_project_manager_switch (manager,
@@ -774,12 +773,12 @@ brasero_project_manager_open_project (BraseroProjectManager *manager,
 
 	if (burn) {
 		brasero_project_burn (BRASERO_PROJECT (manager->priv->project));
-		return type;
+		return TRUE;
 	}
 
 	action = gtk_action_group_get_action (manager->priv->action_group, "NewChoose");
 	gtk_action_set_sensitive (action, TRUE);
-	return type;
+	return TRUE;
 }
 
 static void
@@ -829,30 +828,22 @@ brasero_project_manager_empty (BraseroProjectManager *manager)
 	brasero_project_manager_switch (manager, BRASERO_PROJECT_TYPE_INVALID, NULL, NULL, TRUE);
 }
 
-gboolean
-brasero_project_manager_load_session (BraseroProjectManager *manager,
-				      const gchar *path)
+static void
+brasero_project_manager_last_saved_clicked_cb (BraseroProjectTypeChooser *chooser,
+					       const gchar *path,
+					       BraseroProjectManager *manager)
 {
-    	if (path) {
+	if (path) {
 		gchar *uri;
-		BraseroProjectType type;
 
 		uri = g_filename_to_uri (path, NULL, NULL);
-    		type = brasero_project_load_session (BRASERO_PROJECT (manager->priv->project), uri);
+		brasero_app_open_project (brasero_app_get_default (),
+		                          uri,
+		                          FALSE, // not a playlist
+		                          FALSE, // should work so don't warn user
+		                          FALSE); // don't burn right away
 		g_free (uri);
-
-		brasero_project_manager_switch (manager, type, NULL, NULL, FALSE);
 	}
-
-    	return TRUE;
-}
-
-static void
-brasero_project_manager_last_saved_clicked_cb (BraseroProjectTypeChooser *chooser,
-					       const gchar *path,
-					       BraseroProjectManager *manager)
-{
-	brasero_project_manager_load_session (manager, path);
 }
 
 gboolean
diff --git a/src/brasero-project-manager.h b/src/brasero-project-manager.h
index 0ecd8df..c12bd3d 100644
--- a/src/brasero-project-manager.h
+++ b/src/brasero-project-manager.h
@@ -35,6 +35,7 @@
 #include "brasero-medium.h"
 #include "brasero-project-parse.h"
 #include "brasero-project-type-chooser.h"
+#include "brasero-session-cfg.h"
 
 G_BEGIN_DECLS
 
@@ -59,7 +60,6 @@ typedef struct {
 GType brasero_project_manager_get_type ();
 GtkWidget *brasero_project_manager_new ();
 
-
 void
 brasero_project_manager_audio (BraseroProjectManager *manager,
 			       GSList *uris,
@@ -80,11 +80,10 @@ void
 brasero_project_manager_iso (BraseroProjectManager *manager,
 			     const gchar *uri);
 
-BraseroProjectType
-brasero_project_manager_open_project (BraseroProjectManager *manager,
-				      const gchar *uri,
-				      gboolean playlist,
-				      gboolean burn);
+gboolean
+brasero_project_manager_open_session (BraseroProjectManager *manager,
+                                      BraseroSessionCfg *session,
+                                      gboolean burn);
 
 void
 brasero_project_manager_empty (BraseroProjectManager *manager);
@@ -98,9 +97,6 @@ brasero_project_manager_save_session (BraseroProjectManager *manager,
 				      const gchar *path,
 				      gchar **saved_uri,
 				      gboolean cancellable);
-gboolean
-brasero_project_manager_load_session (BraseroProjectManager *manager,
-				      const gchar *path);
 
 void
 brasero_project_manager_register_ui (BraseroProjectManager *manager,
diff --git a/src/brasero-project.c b/src/brasero-project.c
index 4228566..92b20eb 100644
--- a/src/brasero-project.c
+++ b/src/brasero-project.c
@@ -1606,12 +1606,16 @@ brasero_project_reset (BraseroProject *project)
 }
 
 static void
-brasero_project_new_session (BraseroProject *project)
+brasero_project_new_session (BraseroProject *project,
+                             BraseroSessionCfg *session)
 {
 	if (project->priv->session)
 		brasero_project_reset (project);
 
-	project->priv->session = brasero_session_cfg_new ();
+	if (session)
+		project->priv->session = g_object_ref (session);
+	else
+		project->priv->session = brasero_session_cfg_new ();
 
 	/* NOTE: "is-valid" is emitted whenever there is a change in the
 	 * contents of the session. So no need to connect to track-added, ... */
@@ -1695,7 +1699,7 @@ brasero_project_switch (BraseroProject *project, BraseroProjectType type)
 void
 brasero_project_set_audio (BraseroProject *project, GSList *uris)
 {
-	brasero_project_new_session (project);
+	brasero_project_new_session (project, NULL);
 	brasero_project_switch (project, BRASERO_PROJECT_TYPE_AUDIO);
 
 	for (; uris; uris = uris->next) {
@@ -1710,7 +1714,7 @@ void
 brasero_project_set_data (BraseroProject *project,
 			  GSList *uris)
 {
-	brasero_project_new_session (project);
+	brasero_project_new_session (project, NULL);
 	brasero_project_switch (project, BRASERO_PROJECT_TYPE_DATA);
 
 	for (; uris; uris = uris->next) {
@@ -1724,7 +1728,7 @@ brasero_project_set_data (BraseroProject *project,
 void
 brasero_project_set_video (BraseroProject *project, GSList *uris)
 {
-	brasero_project_new_session (project);
+	brasero_project_new_session (project, NULL);
 	brasero_project_switch (project, BRASERO_PROJECT_TYPE_VIDEO);
 
 	for (; uris; uris = uris->next) {
@@ -2281,30 +2285,15 @@ brasero_project_get_session_type (BraseroProject *project)
 
 /******************************* Projects **************************************/
 BraseroProjectType
-brasero_project_open_project_real (BraseroProject *project,
-				   const gchar *uri,	/* escaped */
-				   gboolean playlist,
-				   gboolean warn_user)
+brasero_project_open_session (BraseroProject *project,
+                              BraseroSessionCfg *session)
 {
 	GValue *value;
 	BraseroProjectType type;
 
-	brasero_project_new_session (project);
-
-#ifdef BUILD_PLAYLIST
-
-	if (playlist) {
-		if (!brasero_project_open_audio_playlist_project (uri, BRASERO_BURN_SESSION (project->priv->session), warn_user))
-			return BRASERO_PROJECT_TYPE_INVALID;
-	}
-	else
-
-#endif
-	
-	if (!brasero_project_open_project_xml (uri, BRASERO_BURN_SESSION (project->priv->session), warn_user))
-		return BRASERO_PROJECT_TYPE_INVALID;
+	brasero_project_new_session (project, session);
 
-        type = brasero_project_get_session_type (project);
+	type = brasero_project_get_session_type (project);
         if (type == BRASERO_PROJECT_TYPE_INVALID)
                 return type;
 
@@ -2337,27 +2326,6 @@ brasero_project_open_project_real (BraseroProject *project,
 	return type;
 }
 
-BraseroProjectType
-brasero_project_open_project (BraseroProject *project,
-			      const gchar *uri,
-			      gboolean playlist)	/* escaped */
-{
-	BraseroProjectType type;
-
-	type = brasero_project_open_project_real (project, uri, playlist, TRUE);
-	if (type != BRASERO_PROJECT_TYPE_INVALID && uri)
-		brasero_project_set_uri (project, uri, type);
-
-	return type;
-}
-
-BraseroProjectType
-brasero_project_load_session (BraseroProject *project,
-			      const gchar *uri)
-{
-	return brasero_project_open_project_real (project, uri, FALSE, FALSE);
-}
-
 /******************************** save project *********************************/
 static void
 brasero_project_not_saved_dialog (BraseroProject *project)
diff --git a/src/brasero-project.h b/src/brasero-project.h
index 501e16e..d2db172 100644
--- a/src/brasero-project.h
+++ b/src/brasero-project.h
@@ -32,6 +32,8 @@
 
 #include <gtk/gtk.h>
 
+#include "brasero-session-cfg.h"
+
 #include "brasero-disc.h"
 #include "brasero-uri-container.h"
 #include "brasero-project-type-chooser.h"
@@ -82,17 +84,14 @@ brasero_project_set_source (BraseroProject *project,
 			    BraseroURIContainer *source);
 
 BraseroProjectType
-brasero_project_open_project (BraseroProject *project,
-			      const gchar *uri,
-			      gboolean playlist);
+brasero_project_open_session (BraseroProject *project,
+			      BraseroSessionCfg *session);
 
 gboolean
 brasero_project_save_project (BraseroProject *project);
 gboolean
 brasero_project_save_project_as (BraseroProject *project);
 
-BraseroProjectType
-brasero_project_load_session (BraseroProject *project, const gchar *uri);
 gboolean
 brasero_project_save_session (BraseroProject *project,
 			      const gchar *uri,
diff --git a/src/main.c b/src/main.c
index c4f125c..ae1aa20 100644
--- a/src/main.c
+++ b/src/main.c
@@ -260,30 +260,6 @@ brasero_handle_burn_uri (BraseroApp *app,
 	return;
 }
 
-static gboolean
-brasero_app_open_project (BraseroApp *app,
-			  const gchar *path,
-			  gboolean playlist,
-			  gboolean burn)
-{
-	BraseroProjectType type;
-	GtkWidget *manager;
-	GFile *file;
-	gchar *uri;
-
-	brasero_app_create_mainwin (app);
-
-	file = g_file_new_for_commandline_arg (path);
-	uri = g_file_get_uri (file);
-	g_object_unref (file);
-
-	manager = brasero_app_get_project_manager (app);
-	type = brasero_project_manager_open_project (BRASERO_PROJECT_MANAGER (manager), uri, playlist, burn);
-	g_free (uri);
-
-	return (type != BRASERO_PROJECT_TYPE_INVALID);
-}
-
 static void
 brasero_app_parse_options (BraseroApp *app)
 {
@@ -334,10 +310,10 @@ brasero_app_parse_options (BraseroApp *app)
 		brasero_project_manager_empty (BRASERO_PROJECT_MANAGER (manager));
 	}
 	else if (project_uri) {
-		brasero_app_open_project (app, project_uri, FALSE, FALSE);
+		brasero_app_open_project (app, project_uri, FALSE, TRUE, FALSE);
 	}
 	else if (burn_project_uri) {
-		brasero_app_open_project (app, burn_project_uri, FALSE, TRUE);
+		brasero_app_open_project (app, burn_project_uri, FALSE, TRUE, TRUE);
 
 		if (g_remove (burn_project_uri) != 0) {
 			gchar *path;
@@ -352,7 +328,7 @@ brasero_app_parse_options (BraseroApp *app)
 #ifdef BUILD_PLAYLIST
 
 	else if (playlist_uri) {
-		brasero_app_open_project (app, playlist_uri, TRUE, FALSE);
+		brasero_app_open_project (app, playlist_uri, TRUE, TRUE, FALSE);
 	}
 
 #endif



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