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

278 lines
5.3 KiB
C
Raw Normal View History

#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)
{
ecore_list_destroy(em->drives);
}
if (em->dnd_candidates)
{
ecore_list_destroy(em->dnd_candidates);
}
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;
}
2008-09-15 13:31:30 +00:00
void
ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname)
{
2008-12-09 05:47:59 +00:00
Evas_Object *icon;
Evas_Coord x, y, w, h;
icon = edje_object_add(e);
edje_object_file_set(icon, em->theme_path, iname);
edje_object_part_geometry_get(b, "icon", &x, &y, &w, &h);
evas_object_move(icon, x, y);
evas_object_resize(icon, w, h);
edje_object_part_swallow(b, "icon", icon);
evas_object_show(icon);
2008-09-15 13:31:30 +00:00
}
int
ecdb_dnd_position(void *data, int type, void *event)
{
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);
ecore_list_first_goto(em->dnd_candidates);
while ((o = ecore_list_next(em->dnd_candidates)))
{
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]);
edje_object_part_text_set(o, "label", uri->path);
efreet_uri_free(uri);
}