From b919f4c125e89353af797a1371172da9383ce423 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Tue, 23 Dec 2008 02:26:24 +0000 Subject: [PATCH] Show the X writing speed, and sort the speeds returned. --- .../ecdb/trunk/src/ecdb_burn_data_gui.c | 19 +++++++++++++-- .../ecdb/trunk/src/ecdb_burn_image_gui.c | 19 +++++++++++++-- experimental/ecdb/trunk/src/ecdb_drives.c | 23 ++++++++++++++++--- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c b/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c index abb440cc..da2ac7d6 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c @@ -129,7 +129,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info) { Evas_Object *c1, *c2, *b; Ecdb_Drive_Info *drive; - int sel, i, num_speeds; + int sel, i, num_speeds, speed; char buf[1024]; c2 = data; @@ -148,7 +148,22 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info) continue; b = ecdb_button_add(c2, NULL); - snprintf(buf, sizeof(buf), "%d", drive->write_speeds[i]); + + if ((drive->profile_name) && (drive->profile_name[0] != '\0')) + { + if (drive->profile_name[0] == 'C') + speed = drive->write_speeds[i] / 150; + else if (drive->profile_name[0] == 'D') + speed = drive->write_speeds[i] / 1352; + else + speed = drive->write_speeds[i] / 4500; + } + else + { + speed = 0; + } + + snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]); ecdb_button_label_set(b, buf); ecdb_combo_append(c2, b); evas_object_show(b); diff --git a/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c b/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c index fb58982e..281060b1 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c @@ -129,7 +129,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info) { Evas_Object *c1, *c2, *b; Ecdb_Drive_Info *drive; - int sel, i, num_speeds; + int sel, i, num_speeds, speed; char buf[1024]; c2 = data; @@ -148,7 +148,22 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info) continue; b = ecdb_button_add(c2, NULL); - snprintf(buf, sizeof(buf), "%d", drive->write_speeds[i]); + + if ((drive->profile_name) && (drive->profile_name[0] != '\0')) + { + if (drive->profile_name[0] == 'C') + speed = drive->write_speeds[i] / 150; + else if (drive->profile_name[0] == 'D') + speed = drive->write_speeds[i] / 1352; + else + speed = drive->write_speeds[i] / 4500; + } + else + { + speed = 0; + } + + snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]); ecdb_button_label_set(b, buf); ecdb_combo_append(c2, b); evas_object_show(b); diff --git a/experimental/ecdb/trunk/src/ecdb_drives.c b/experimental/ecdb/trunk/src/ecdb_drives.c index dde6ba95..029af402 100644 --- a/experimental/ecdb/trunk/src/ecdb_drives.c +++ b/experimental/ecdb/trunk/src/ecdb_drives.c @@ -1,13 +1,20 @@ /* vim: set sw=3 ts=3 sts=3 expandtab: */ #include "ecdb.h" +int +_drive_speed_sort(int *s1, int *s2) +{ + return (*s1 > *s2) ? 0 : 1; +} + int ecdb_aquire_drive_info(void) { - int ret, i; + int ret, i, *s; unsigned int drive_num; struct burn_drive_info *drives_current; struct burn_speed_descriptor *speeds; + Ecore_List *sort; ret = 0; if (em->drives) @@ -61,14 +68,24 @@ ecdb_aquire_drive_info(void) drive->read_speeds[0] = i + 1; drive->write_speeds[0] = i + 1; + sort = ecore_list_new(); for (ret = 1; ret <= i; ret++) { - drive->write_speeds[ret] = speeds->write_speed; - drive->read_speeds[ret] = speeds->read_speed; + ecore_list_append(sort, &speeds->write_speed); speeds = speeds->prev; } + ecore_list_sort(sort, ECORE_COMPARE_CB(_drive_speed_sort), + ECORE_SORT_MIN); + ecore_list_first_goto(sort); + for (ret = 1; ret <= i; ret++) + { + s = ecore_list_next(sort); + drive->write_speeds[ret] = *s; + drive->read_speeds[ret] = *s; + } + ecore_list_destroy(sort); burn_drive_free_speedlist(&speeds); em->drives = eina_list_append(em->drives, drive); }