legacy/experimental/ecdb/trunk/src/ecdb_misc.c

286 lines
5.3 KiB
C
Raw Normal View History

/* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h"
Ecdb_Project *
ecdb_project_new(void)
{
2008-12-09 05:47:59 +00:00
Ecdb_Project *proj;
proj = calloc(1, sizeof(Ecdb_Project));
if (!proj)
{
return NULL;
}
if (!ecdb_project_init(proj))
{
FREE(proj);
return NULL;
}
return proj;
}
2008-05-15 00:14:33 +00:00
int
ecdb_project_init(Ecdb_Project *proj)
{
2008-12-09 05:47:59 +00:00
return TRUE;
2008-05-15 00:14:33 +00:00
}
void
ecdb_project_destroy(Ecdb_Project *proj)
{
2008-12-09 05:47:59 +00:00
printf("Destroying base project\n");
}
2008-06-10 03:33:53 +00:00
void
ecdb_project_type_set(Ecdb_Project *proj, unsigned int t)
{
2008-12-09 05:47:59 +00:00
proj->type = t;
2008-06-10 03:33:53 +00:00
}
2008-04-07 01:04:15 +00:00
int
ecdb_shutdown(void *data, int type, void *event)
{
2008-12-09 05:47:59 +00:00
if (em->drives)
{
2008-12-18 18:54:50 +00:00
ecdb_drive_info_list_free(em->drives);
2008-12-09 05:47:59 +00:00
}
if (em->dnd_candidates)
{
2008-12-18 18:54:50 +00:00
eina_list_free(em->dnd_candidates);
2008-12-09 05:47:59 +00:00
}
FREE(em);
if (!ecore_file_recursive_rm("/tmp/ecdb"))
{
printf("Removal of temporary directory failed!\n");
}
ewl_main_quit();
return FALSE;
}
2008-08-04 22:18:34 +00:00
int
ecdb_burn_init(void)
{
2008-12-09 05:47:59 +00:00
if (!burn_initialize())
{
return 0;
}
2008-08-04 22:18:34 +00:00
2008-12-09 05:47:59 +00:00
burn_msgs_set_severities("NEVER", "SORRY", "ecdb: ");
burn_set_signal_handling("ecdb: ", NULL, 0);
2008-08-04 22:18:34 +00:00
2008-12-09 05:47:59 +00:00
return 1;
}
2008-08-04 22:18:34 +00:00
int
ecdb_image_init(void)
{
2008-12-09 05:47:59 +00:00
if (!iso_init())
{
return 0;
}
iso_set_msgs_severities("NEVER", "SORRY", "ecdb: ");
2008-08-04 22:18:34 +00:00
2008-12-09 05:47:59 +00:00
return 1;
}
int
ecdb_match_keyword(const char *chk, const char *key, int len)
{
2008-12-09 05:47:59 +00:00
int i;
2008-12-09 05:47:59 +00:00
for (i = 0; i < len; i++)
{
if (chk[i] != key[i])
{
return TRUE;
}
}
2008-12-09 05:47:59 +00:00
return FALSE;
}
char *
ecdb_strip_string(const char *strip)
{
2008-12-09 05:47:59 +00:00
char *t1 = (char *)strip;
do
{
if (*t1 == ' ')
{
t1++;
return strdup(t1);
}
} while ((t1) && (t1++));
return NULL;
}
char *
ecdb_strip_next_argument(const char *strip)
{
2008-12-09 05:47:59 +00:00
char *t1 = (char *)strip, *t2;
char *ret = NULL;
int len = 0, space = FALSE;
do
{
if (*t1 == ' ')
{
space = TRUE;
}
if ((*t1 != ' ') && (space == TRUE))
{
t2 = t1;
/* Find length of string to copy */
while ((*t2) && (*t2 != ' '))
{
len++;
t2++;
}
/* Given no more args */
if (!len)
{
return NULL;
}
else
{
len++;
}
/* Make a new string and copy everything over */
ret = malloc(sizeof(char) * len);
memcpy(ret, t1, len);
return ret;
}
} while (*(t1++));
return NULL;
}
int
ecdb_dnd_position(void *data, int type, void *event)
{
2008-12-18 18:54:50 +00:00
Eina_List *l;
2008-12-09 05:47:59 +00:00
Ecore_X_Event_Xdnd_Position *ev;
Evas_Object *o;
Ecore_X_Rectangle rect;
Evas_Coord window_x, window_y, window_w, window_h, x, y, w, h;
ev = event;
if (ev->win != ecore_evas_software_x11_window_get(em->main_win_ee))
{
return 1;
}
ecore_evas_geometry_get(em->main_win_ee, &window_x, &window_y, &window_w,
&window_h);
2008-12-18 18:54:50 +00:00
em->dnd_candidates = eina_list_nth_list(em->dnd_candidates, 0);
EINA_LIST_FOREACH(em->dnd_candidates, l, o)
2008-12-09 05:47:59 +00:00
{
if (evas_object_visible_get(o))
{
evas_object_geometry_get(o, &x, &y, &w, &h);
x += window_x;
y += window_y;
if ((ev->position.x >= x) && (ev->position.x <= (x+w))
&& (ev->position.y >= y) && (ev->position.y <= (y + h)))
{
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
em->drop_object = o;
ecore_x_dnd_send_status(1, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
return 1;
}
}
}
rect.x = window_x;
rect.y = window_y;
rect.width = window_w;
rect.height = window_h;
ecore_x_dnd_send_status(0, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
return 1;
}
int
ecdb_dnd_drop(void *data, int type, void *event)
{
2008-12-09 05:47:59 +00:00
if (em->drop_object)
{
ecore_x_selection_xdnd_request
(ecore_evas_software_x11_window_get(em->main_win_ee),
"text/uri-list");
}
return 1;
}
int
ecdb_dnd_selection(void *data, int type, void *event)
{
2008-12-09 05:47:59 +00:00
Ecore_X_Event_Selection_Notify *ev;
Ecore_X_Selection_Data_Files *files;
void (*call_func)(Evas_Object *, Ecore_X_Selection_Data_Files *) = NULL;
ev = event;
if ((!em->drop_object) || (ev->selection != ECORE_X_SELECTION_XDND)
|| (!(files = ev->data)) || (files->num_files <= 0))
{
ecore_x_dnd_send_finished();
return 1;
}
call_func = evas_object_data_get(em->drop_object, "dnd_call_func");
if (call_func != NULL)
{
call_func(em->drop_object, files);
}
em->drop_object = NULL;
ecore_x_dnd_send_finished();
return 1;
}
// For use with the entry group, where only one file is valid. We take the
// first one and ignore the rest (if any)
void
ecdb_dnd_entry_dnd_set(Evas_Object *o, Ecore_X_Selection_Data_Files *files)
{
2008-12-09 05:47:59 +00:00
Efreet_Uri *uri;
uri = efreet_uri_decode(files->files[0]);
ecdb_entry_text_set(o, uri->path);
2008-12-09 05:47:59 +00:00
efreet_uri_free(uri);
}
int
ecdb_speed_convert(Ecdb_Drive_Info *drive, int sel)
{
int count, num_speeds, i;
count = 1;
sel++;
num_speeds = drive->write_speeds[0];
for (i = 0; i < num_speeds; i++)
{
if (drive->write_speeds[i] <= 0)
continue;
if (count == sel)
return drive->write_speeds[count];
count++;
}
return -1;
}