brasero r719 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r719 - in trunk: . src
- Date: Tue, 15 Apr 2008 17:12:01 +0100 (BST)
Author: philippr
Date: Tue Apr 15 17:12:01 2008
New Revision: 719
URL: http://svn.gnome.org/viewvc/brasero?rev=719&view=rev
Log:
Added the possibility to save an audio project to plain text file as a list of songs
Some cleaning
Plugged two memleaks specific to trunk branch
* src/brasero-audio-disc.c
(brasero_audio_disc_set_row_from_metadata),
(brasero_audio_disc_get_track):
* src/brasero-disc.c (brasero_track_clear_song):
* src/brasero-disc.h:
* src/brasero-project.c
(brasero_project_save_audio_project_plain_text),
(brasero_project_save_project_real),
(brasero_project_save_project_ask_for_path),
(brasero_project_save_project), (brasero_project_save_project_as),
(brasero_project_save_session):
* src/brasero-session.c (brasero_session_get_path):
* src/scsi-get-configuration.h:
* src/scsi-spc1.h:
Modified:
trunk/ChangeLog
trunk/src/brasero-audio-disc.c
trunk/src/brasero-disc.c
trunk/src/brasero-disc.h
trunk/src/brasero-project.c
trunk/src/brasero-session.c
trunk/src/scsi-get-configuration.h
trunk/src/scsi-spc1.h
Modified: trunk/src/brasero-audio-disc.c
==============================================================================
--- trunk/src/brasero-audio-disc.c (original)
+++ trunk/src/brasero-audio-disc.c Tue Apr 15 17:12:01 2008
@@ -1248,6 +1248,9 @@
g_free (name);
}
+ if (icon)
+ g_object_unref (icon);
+
return TRUE;
}
@@ -1837,11 +1840,15 @@
do {
gint64 end;
gint64 start;
+ gchar *title;
+ gchar *artist;
gtk_tree_model_get (model, &iter,
URI_COL, &uri,
START_COL, &start,
END_COL, &end,
+ NAME_COL, &title,
+ ARTIST_COL, &artist,
-1);
if (!uri) {
@@ -1855,11 +1862,18 @@
song->gap += BRASERO_DURATION_TO_SECTORS (length);
}
else {
+ BraseroSongInfo *info;
+
song = g_new0 (BraseroDiscSong, 1);
song->uri = uri;
song->start = start > 0 ? start:0;
song->end = end > 0 ? end:0;
+ info = g_new0 (BraseroSongInfo, 1);
+ info->title = title;
+ info->artist = artist;
+ song->info = info;
+
track->contents.tracks = g_slist_append (track->contents.tracks, song);
}
Modified: trunk/src/brasero-disc.c
==============================================================================
--- trunk/src/brasero-disc.c (original)
+++ trunk/src/brasero-disc.c Tue Apr 15 17:12:01 2008
@@ -679,6 +679,10 @@
BraseroDiscSong *song;
song = data;
+
+ if (song->info)
+ brasero_song_info_free (song->info);
+
g_free (song->uri);
g_free (song);
}
Modified: trunk/src/brasero-disc.h
==============================================================================
--- trunk/src/brasero-disc.h (original)
+++ trunk/src/brasero-disc.h Tue Apr 15 17:12:01 2008
@@ -73,6 +73,8 @@
gint64 gap;
gint64 start;
gint64 end;
+
+ BraseroSongInfo *info;
};
typedef struct _BraseroDiscSong BraseroDiscSong;
Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c (original)
+++ trunk/src/brasero-project.c Tue Apr 15 17:12:01 2008
@@ -129,6 +129,11 @@
gint *center,
gint *footer);
+typedef enum {
+ BRASERO_PROJECT_SAVE_XML = 0,
+ BRASERO_PROJECT_SAVE_PLAIN = 1
+} BraseroProjectSave;
+
struct BraseroProjectPrivate {
GtkWidget *size_display;
GtkWidget *discs;
@@ -144,6 +149,7 @@
guint merge_id;
gchar *project;
+
gint64 sectors;
BraseroDisc *current;
@@ -2385,8 +2391,104 @@
}
static gboolean
+brasero_project_save_audio_project_plain_text (BraseroProject *proj,
+ const gchar *uri,
+ BraseroDiscTrack *track,
+ gboolean use_dialog)
+{
+ GSList *iter;
+ gchar *path;
+ FILE *file;
+
+ path = g_filename_from_uri (uri, NULL, NULL);
+ if (!path)
+ return FALSE;
+
+ file = fopen (path, "w+");
+ g_free (path);
+ if (!file) {
+ if (use_dialog)
+ brasero_project_not_saved_dialog (proj);
+
+ return FALSE;
+ }
+
+ for (iter = track->contents.tracks; iter; iter = iter->next) {
+ BraseroDiscSong *song;
+ BraseroSongInfo *info;
+ guint written;
+ gchar *time;
+
+ song = iter->data;
+ info = song->info;
+
+ written = fwrite (info->title, 1, strlen (info->title), file);
+ if (written != strlen (info->title))
+ goto error;
+
+ time = brasero_utils_get_time_string (song->end - song->start, TRUE, FALSE);
+ if (time) {
+ written = fwrite ("\t", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ written = fwrite (time, 1, strlen (time), file);
+ if (written != strlen (time)) {
+ g_free (time);
+ goto error;
+ }
+ g_free (time);
+ }
+
+ if (info->artist) {
+ gchar *string;
+
+ written = fwrite ("\t", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ string = g_strdup_printf (_(" by %s"), info->artist);
+ written = fwrite (string, 1, strlen (string), file);
+ if (written != strlen (string)) {
+ g_free (string);
+ goto error;
+ }
+ g_free (string);
+ }
+
+ written = fwrite ("\n(", 1, 2, file);
+ if (written != 2)
+ goto error;
+
+ written = fwrite (song->uri, 1, strlen (song->uri), file);
+ if (written != strlen (song->uri))
+ goto error;
+
+ written = fwrite (")", 1, 1, file);
+ if (written != 1)
+ goto error;
+
+ written = fwrite ("\n\n", 1, 2, file);
+ if (written != 2)
+ goto error;
+ }
+
+ fclose (file);
+ return TRUE;
+
+error:
+ fclose (file);
+
+ if (use_dialog)
+ brasero_project_not_saved_dialog (proj);
+
+ return FALSE;
+}
+
+static gboolean
brasero_project_save_project_real (BraseroProject *project,
- const gchar *uri)
+ const gchar *uri,
+ BraseroProjectSave save_type)
{
BraseroDiscResult result;
BraseroDiscTrack track;
@@ -2412,21 +2514,34 @@
return FALSE;
}
- brasero_project_set_uri (project, uri, track.type);
- if (!brasero_project_save_project_xml (project,
- uri ? uri : project->priv->project,
- &track,
- TRUE))
- return FALSE;
+ if (save_type == BRASERO_PROJECT_SAVE_XML) {
+ brasero_project_set_uri (project, uri, track.type);
+ if (!brasero_project_save_project_xml (project,
+ uri ? uri : project->priv->project,
+ &track,
+ TRUE))
+ return FALSE;
+
+ project->priv->modified = 0;
+ }
+ else if (save_type == BRASERO_PROJECT_SAVE_PLAIN) {
+ brasero_project_set_uri (project, uri, track.type);
+ if (!brasero_project_save_audio_project_plain_text (project,
+ uri,
+ &track,
+ TRUE))
+ return FALSE;
+ }
- project->priv->modified = 0;
brasero_track_clear (&track);
return TRUE;
}
static gchar *
-brasero_project_save_project_ask_for_path (BraseroProject *project)
+brasero_project_save_project_ask_for_path (BraseroProject *project,
+ BraseroProjectSave *type)
{
+ GtkWidget *combo = NULL;
GtkWidget *toplevel;
GtkWidget *chooser;
gchar *uri = NULL;
@@ -2444,9 +2559,26 @@
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
g_get_home_dir ());
+ /* if the file chooser is an audio project offer the possibility to save
+ * in plain text a list of the current displayed songs (only in save as
+ * mode) */
+ if (type && BRASERO_IS_AUDIO_DISC (project->priv->current)) {
+ combo = gtk_combo_box_new_text ();
+ gtk_widget_show (combo);
+
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Save project as brasero audio project"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Save project as a plain text list"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (chooser), combo);
+ }
+
gtk_widget_show (chooser);
answer = gtk_dialog_run (GTK_DIALOG (chooser));
if (answer == GTK_RESPONSE_OK) {
+ if (combo)
+ *type = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
if (*uri == '\0') {
g_free (uri);
@@ -2464,11 +2596,10 @@
gchar *uri = NULL;
gboolean result;
- if (!project->priv->project
- && !(uri = brasero_project_save_project_ask_for_path (project)))
+ if (!project->priv->project && !(uri = brasero_project_save_project_ask_for_path (project, NULL)))
return FALSE;
- result = brasero_project_save_project_real (project, uri);
+ result = brasero_project_save_project_real (project, uri, BRASERO_PROJECT_SAVE_XML);
g_free (uri);
return result;
@@ -2477,14 +2608,15 @@
gboolean
brasero_project_save_project_as (BraseroProject *project)
{
+ BraseroProjectSave type;
gboolean result;
gchar *uri;
- uri = brasero_project_save_project_ask_for_path (project);
+ uri = brasero_project_save_project_ask_for_path (project, &type);
if (!uri)
return FALSE;
- result = brasero_project_save_project_real (project, uri);
+ result = brasero_project_save_project_real (project, uri, type);
g_free (uri);
return result;
@@ -2520,7 +2652,7 @@
if (answer != GTK_RESPONSE_YES)
return FALSE;
- brasero_project_save_project_real (project, NULL);
+ brasero_project_save_project_real (project, NULL, BRASERO_PROJECT_SAVE_XML);
/* return FALSE since this is not a tmp project */
return FALSE;
Modified: trunk/src/brasero-session.c
==============================================================================
--- trunk/src/brasero-session.c (original)
+++ trunk/src/brasero-session.c Tue Apr 15 17:12:01 2008
@@ -47,6 +47,7 @@
brasero_session_get_path (const gchar *name)
{
gchar *directory;
+ gchar *retval;
directory = g_build_filename (g_get_user_config_dir (),
"brasero",
@@ -54,7 +55,9 @@
if (!g_file_test (directory, G_FILE_TEST_EXISTS))
g_mkdir_with_parents (directory, S_IRWXU);
- return g_build_filename (directory, name, NULL);
+ retval = g_build_filename (directory, name, NULL);
+ g_free (directory);
+ return retval;
}
gboolean
Modified: trunk/src/scsi-get-configuration.h
==============================================================================
--- trunk/src/scsi-get-configuration.h (original)
+++ trunk/src/scsi-get-configuration.h Tue Apr 15 17:12:01 2008
@@ -22,15 +22,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
+#include <glib.h>
+
#include "scsi-base.h"
#ifndef _SCSI_GET_CONFIGURATION_H
#define _SCSI_GET_CONFIGURATION_H
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
typedef enum {
BRASERO_SCSI_PROF_NON_REMOVABLE = 0x0001,
@@ -1610,9 +1609,7 @@
};
typedef struct _BraseroScsiGetConfigHdr BraseroScsiGetConfigHdr;
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
#endif /* _SCSI_GET_CONFIGURATION_H */
Modified: trunk/src/scsi-spc1.h
==============================================================================
--- trunk/src/scsi-spc1.h (original)
+++ trunk/src/scsi-spc1.h Tue Apr 15 17:12:01 2008
@@ -32,10 +32,7 @@
#ifndef _BURN_SPC1_H
#define _BURN_SPC1_H
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
BraseroScsiResult
brasero_spc1_mode_sense_get_page (BraseroDeviceHandle *handle,
@@ -44,9 +41,7 @@
int *data_size,
BraseroScsiErrCode *error);
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
#endif /* _BURN_SPC1_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]