Show the X writing speed, and sort the speeds returned.

This commit is contained in:
Jaime Thomas 2008-12-23 02:26:24 +00:00
parent dcedfa0025
commit 8f7bd3e2d9
3 changed files with 54 additions and 7 deletions

View File

@ -129,7 +129,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
{ {
Evas_Object *c1, *c2, *b; Evas_Object *c1, *c2, *b;
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
int sel, i, num_speeds; int sel, i, num_speeds, speed;
char buf[1024]; char buf[1024];
c2 = data; c2 = data;
@ -148,7 +148,22 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
continue; continue;
b = ecdb_button_add(c2, NULL); 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_button_label_set(b, buf);
ecdb_combo_append(c2, b); ecdb_combo_append(c2, b);
evas_object_show(b); evas_object_show(b);

View File

@ -129,7 +129,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
{ {
Evas_Object *c1, *c2, *b; Evas_Object *c1, *c2, *b;
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
int sel, i, num_speeds; int sel, i, num_speeds, speed;
char buf[1024]; char buf[1024];
c2 = data; c2 = data;
@ -148,7 +148,22 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
continue; continue;
b = ecdb_button_add(c2, NULL); 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_button_label_set(b, buf);
ecdb_combo_append(c2, b); ecdb_combo_append(c2, b);
evas_object_show(b); evas_object_show(b);

View File

@ -1,13 +1,20 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */ /* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h" #include "ecdb.h"
int
_drive_speed_sort(int *s1, int *s2)
{
return (*s1 > *s2) ? 0 : 1;
}
int int
ecdb_aquire_drive_info(void) ecdb_aquire_drive_info(void)
{ {
int ret, i; int ret, i, *s;
unsigned int drive_num; unsigned int drive_num;
struct burn_drive_info *drives_current; struct burn_drive_info *drives_current;
struct burn_speed_descriptor *speeds; struct burn_speed_descriptor *speeds;
Ecore_List *sort;
ret = 0; ret = 0;
if (em->drives) if (em->drives)
@ -61,14 +68,24 @@ ecdb_aquire_drive_info(void)
drive->read_speeds[0] = i + 1; drive->read_speeds[0] = i + 1;
drive->write_speeds[0] = i + 1; drive->write_speeds[0] = i + 1;
sort = ecore_list_new();
for (ret = 1; ret <= i; ret++) for (ret = 1; ret <= i; ret++)
{ {
drive->write_speeds[ret] = speeds->write_speed; ecore_list_append(sort, &speeds->write_speed);
drive->read_speeds[ret] = speeds->read_speed;
speeds = speeds->prev; 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); burn_drive_free_speedlist(&speeds);
em->drives = eina_list_append(em->drives, drive); em->drives = eina_list_append(em->drives, drive);
} }