[Goodies-commits] r4504 - in xfburn/trunk: . xfburn
David Mohr
squisher at xfce.org
Thu Apr 3 19:56:15 CEST 2008
Author: squisher
Date: 2008-04-03 17:56:15 +0000 (Thu, 03 Apr 2008)
New Revision: 4504
Modified:
xfburn/trunk/xfburn-toolbars.ui
xfburn/trunk/xfburn.ui
xfburn/trunk/xfburn/xfburn-burn-image-dialog.c
xfburn/trunk/xfburn/xfburn-device-box.c
xfburn/trunk/xfburn/xfburn-device-list.c
xfburn/trunk/xfburn/xfburn-global.h
xfburn/trunk/xfburn/xfburn-main-window.c
Log:
Rewriting image burning functions to work for both CD and DVD:
* Changed function names to be media agnostic
* Calculate 'x' speed ratings on the fly, instead of list lookup
* Fixed dynamic speed calculation in the progress dialog to work for
the increased number of sectors that fit on a DVD
Modified: xfburn/trunk/xfburn/xfburn-burn-image-dialog.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-burn-image-dialog.c 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn/xfburn-burn-image-dialog.c 2008-04-03 17:56:15 UTC (rev 4504)
@@ -105,7 +105,7 @@
GtkWidget *button;
XfburnDevice *device;
- gtk_window_set_title (GTK_WINDOW (obj), _("Burn CD image"));
+ gtk_window_set_title (GTK_WINDOW (obj), _("Burn image"));
gtk_window_set_destroy_with_parent (GTK_WINDOW (obj), TRUE);
icon = gtk_widget_render_icon (GTK_WIDGET (obj), XFBURN_STOCK_BURN_CD, GTK_ICON_SIZE_DIALOG, NULL);
gtk_window_set_icon (GTK_WINDOW (obj), icon);
@@ -216,6 +216,9 @@
struct burn_progress progress;
gint ret;
time_t time_start;
+ char media_name[80];
+ int media_no;
+ int factor;
if (!burn_initialize ()) {
g_critical ("Unable to initialize libburn");
@@ -287,6 +290,20 @@
xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG (dialog_progress), _("Cannot recognize state of drive and media"));
goto cleanup;
}
+
+ /* retrieve media type, so we can convert from 'kb/s' into 'x' rating */
+ if (burn_disc_get_profile(drive_info->drive, &media_no, media_name) == 1) {
+ /* this will fail if newer disk types get supported */
+ if (media_no <= 0x0a)
+ factor = CDR_1X_SPEED;
+ else
+ /* assume DVD for now */
+ factor = DVD_1X_SPEED;
+ } else {
+ g_warning ("no profile could be retrieved to calculate current burn speed");
+ factor = 1;
+ }
+
burn_options = burn_write_opts_new (drive);
burn_write_opts_set_perform_opc (burn_options, 0);
@@ -334,6 +351,7 @@
xfburn_progress_dialog_set_status_with_text (XFBURN_PROGRESS_DIALOG (dialog_progress), XFBURN_PROGRESS_DIALOG_STATUS_RUNNING, _("Burning composition..."));
if (progress.sectors > 0 && progress.sector >= 0) {
gdouble percent = 0.0;
+ gdouble cur_speed = 0.0;
percent = (gdouble) (progress.buffer_capacity - progress.buffer_available) / (gdouble) progress.buffer_capacity;
xfburn_progress_dialog_set_buffer_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent);
@@ -341,8 +359,10 @@
percent = 1.0 + ((gdouble) progress.sector+1.0) / ((gdouble) progress.sectors) * 98.0;
xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent / 100.0);
+ cur_speed = ((gdouble) ((gdouble)(glong)progress.sector * 2048L) / (gdouble) (time_now - time_start)) / ((gdouble) (factor * 1000.0));
+ //DBG ("(%f / %f) / %f = %f\n", (gdouble) ((gdouble)(glong)progress.sector * 2048L), (gdouble) (time_now - time_start), ((gdouble) (factor * 1000.0)), cur_speed);
xfburn_progress_dialog_set_writing_speed (XFBURN_PROGRESS_DIALOG (dialog_progress),
- ((gdouble) (progress.sector * 2048) / (gdouble) (time_now - time_start)) / (150 * 1024));
+ cur_speed);
}
break;
case BURN_DRIVE_WRITING_LEADIN:
Modified: xfburn/trunk/xfburn/xfburn-device-box.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-box.c 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn/xfburn-device-box.c 2008-04-03 17:56:15 UTC (rev 4504)
@@ -326,6 +326,9 @@
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, "SAO", MODE_VALUE_COLUMN, WRITE_MODE_SAO, -1);
}
+ /*
+ * RAW modes are not supported by libburn yet
+ *
if (device->raw_block_types & BURN_BLOCK_RAW16) {
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, "RAW16", MODE_VALUE_COLUMN, WRITE_MODE_RAW16, -1);
@@ -342,6 +345,7 @@
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, "packet", MODE_VALUE_COLUMN, WRITE_MODE_PACKET, -1);
}
+ */
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combo_mode), 0);
}
Modified: xfburn/trunk/xfburn/xfburn-device-list.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-list.c 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn/xfburn-device-list.c 2008-04-03 17:56:15 UTC (rev 4504)
@@ -34,11 +34,8 @@
#include <libburn.h>
#include "xfburn-device-list.h"
+#include "xfburn-global.h"
-#define CDR_1X_SPEED 150
-
-/* private */
-static gint supported_cdr_speeds[] = {2, 4, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 52, -1};
static GList *devices = NULL;
/*************/
@@ -53,24 +50,6 @@
g_slist_free (device->supported_cdr_speeds);
}
-static gint
-get_closest_supported_cdr_speed (gint speed)
-{
- /* TODO: need some fixing */
- gint i = 0;
- gint previous = 0;
-
- while (supported_cdr_speeds[i] != -1) {
- if (speed < (supported_cdr_speeds[i] * CDR_1X_SPEED)) {
- return supported_cdr_speeds[previous];
- } else
- previous = i;
- i++;
- }
-
- return 0;
-}
-
static gboolean
no_speed_duplicate (GSList *speed_list, gint speed)
{
@@ -92,6 +71,9 @@
refresh_supported_speeds (XfburnDevice * device, struct burn_drive_info *drive_info)
{
struct burn_speed_descriptor *speed_list = NULL;
+ char media_name[80];
+ int media_no;
+ int factor;
gint ret;
/* empty previous list */
@@ -101,17 +83,32 @@
/* fill new list */
ret = burn_drive_get_speedlist (drive_info->drive, &speed_list);
+ /* retrieve media type, so we can convert from 'kb/s' into 'x' rating */
+ if (burn_disc_get_profile(drive_info->drive, &media_no, media_name) == 1) {
+ /* this will fail if newer disk types get supported */
+ if (media_no <= 0x0a)
+ factor = CDR_1X_SPEED;
+ else
+ /* assume DVD for now */
+ factor = DVD_1X_SPEED;
+ } else {
+ g_warning ("no profile could be retrieved to calculate speed");
+ factor = 1;
+ }
+
if (ret > 0) {
struct burn_speed_descriptor *el = speed_list;
while (el) {
gint speed = -1;
- speed = get_closest_supported_cdr_speed (el->write_speed);
+ DBG ("libburn speed in kb/s: %d\n", el->write_speed);
+ speed = el->write_speed / factor;
+ /* FIXME: why do we need no_speed_duplicate? */
if (speed > 0 && no_speed_duplicate (device->supported_cdr_speeds, speed)) {
device->supported_cdr_speeds = g_slist_prepend (device->supported_cdr_speeds, GINT_TO_POINTER (speed));
DBG ("added speed: %d\n", speed);
- }
+ }
el = el->next;
}
@@ -164,7 +161,7 @@
if (!burn_initialize ()) {
g_critical ("Unable to initialize libburn");
- return;
+ return -1;
}
if (devices) {
Modified: xfburn/trunk/xfburn/xfburn-global.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-global.h 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn/xfburn-global.h 2008-04-03 17:56:15 UTC (rev 4504)
@@ -54,4 +54,8 @@
#define MKISOFS_RUNNING " done, estimate"
#define MKISOFS_DONE "extents written"
+/* in reality CDR_1X_SPEED is 176.4 (see libburn.h:1577), but that shouldn't matter */
+#define CDR_1X_SPEED 176
+#define DVD_1X_SPEED 1385
+
#endif
Modified: xfburn/trunk/xfburn/xfburn-main-window.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-main-window.c 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn/xfburn-main-window.c 2008-04-03 17:56:15 UTC (rev 4504)
@@ -126,13 +126,13 @@
{"copy-data", "xfburn-data-copy", N_("Copy Data CD"), NULL, N_("Copy Data CD"),
G_CALLBACK (action_copy_cd),},
{"copy-audio", "xfburn-audio-copy", N_("Copy Audio CD"), NULL, N_("Copy Audio CD"),},
- {"burn-cd", "xfburn-burn-cd", N_("Burn CD Image"), NULL, N_("Burn CD Image"),
+ {"burn-image", "xfburn-burn-cd", N_("Burn Image"), NULL, N_("Burn Image"),
G_CALLBACK (action_burn_image),},
{"format-dvd", "xfburn-format-dvdrw", N_("Format DVD+RW"), NULL, N_("Format DVD+RW"),
G_CALLBACK (action_format_dvd),},
{"copy-dvd", "xfburn-data-copy", N_("Copy DVD"), NULL, N_("Copy DVD"),
G_CALLBACK (action_copy_dvd),},
- {"burn-dvd", "xfburn-burn-cd", N_("Burn DVD Image"), NULL, N_("Burn DVD Image"),
+ {"burn-dvd", "xfburn-burn-image", N_("Burn DVD Image"), NULL, N_("Burn DVD Image"),
G_CALLBACK (action_burn_dvd_image),},
};
@@ -151,7 +151,7 @@
"blank-cd",
"copy-data",
//"copy-audio",
- "burn-cd",
+ "burn-image",
"format-dvd",
"copy-dvd",
"burn-dvd",
@@ -645,7 +645,7 @@
gtk_action_set_sensitive (action, FALSE);
action = gtk_action_group_get_action (priv->action_group, "copy-audio");
gtk_action_set_sensitive (action, FALSE);
- action = gtk_action_group_get_action (priv->action_group, "burn-cd");
+ action = gtk_action_group_get_action (priv->action_group, "burn-image");
gtk_action_set_sensitive (action, FALSE);
}
if (!priv->support_cdrw) {
Modified: xfburn/trunk/xfburn-toolbars.ui
===================================================================
--- xfburn/trunk/xfburn-toolbars.ui 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn-toolbars.ui 2008-04-03 17:56:15 UTC (rev 4504)
@@ -16,7 +16,7 @@
<toolitem id="copy-data" />
<!-- <toolitem id="copy-audio" /> -->
- <toolitem id="burn-cd" />
+ <toolitem id="burn-image" />
<!--
<separator />
Modified: xfburn/trunk/xfburn.ui
===================================================================
--- xfburn/trunk/xfburn.ui 2008-04-03 17:33:37 UTC (rev 4503)
+++ xfburn/trunk/xfburn.ui 2008-04-03 17:56:15 UTC (rev 4504)
@@ -30,7 +30,7 @@
<menu action="action-menu">
<menuitem action="blank-cd"/>
<menuitem action="copy-data"/>
- <menuitem action="burn-cd"/>
+ <menuitem action="burn-image"/>
<placeholder name="placeholder-action-cd"/>
<!--
<separator />
More information about the Goodies-commits
mailing list