From 51312b72b04bf65763526c9ecb64f0800ea6f0b3 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Mon, 4 Aug 2008 22:18:34 +0000 Subject: [PATCH] Moving over to mainly edje --- experimental/ecdb/trunk/src/Makefile.am | 1 - experimental/ecdb/trunk/src/ecdb.c | 32 ++- experimental/ecdb/trunk/src/ecdb.h | 9 +- experimental/ecdb/trunk/src/ecdb_common.h | 2 +- .../ecdb/trunk/src/ecdb_filelist_custom.c | 60 +++-- .../ecdb/trunk/src/ecdb_filelist_custom.h | 3 +- experimental/ecdb/trunk/src/ecdb_gui.c | 250 +----------------- experimental/ecdb/trunk/src/ecdb_image.c | 7 +- experimental/ecdb/trunk/src/ecdb_misc.c | 15 +- experimental/ecdb/trunk/src/ecdb_misc.h | 4 +- 10 files changed, 90 insertions(+), 293 deletions(-) diff --git a/experimental/ecdb/trunk/src/Makefile.am b/experimental/ecdb/trunk/src/Makefile.am index bc3e3d7f..0b335794 100644 --- a/experimental/ecdb/trunk/src/Makefile.am +++ b/experimental/ecdb/trunk/src/Makefile.am @@ -10,7 +10,6 @@ ecdb_SOURCES = \ ecdb_misc.c ecdb_misc.h \ ecdb_audio.c ecdb_audio.h \ ecdb_gui.c ecdb_gui.h \ - ecdb_filelist_custom.c ecdb_filelist_custom.h \ ecdb_common.h ecdb_CFLAGS = @ECDB_CFLAGS@ diff --git a/experimental/ecdb/trunk/src/ecdb.c b/experimental/ecdb/trunk/src/ecdb.c index 0cce3de6..aade371e 100644 --- a/experimental/ecdb/trunk/src/ecdb.c +++ b/experimental/ecdb/trunk/src/ecdb.c @@ -19,6 +19,15 @@ main(int argc, char **argv) ret = 1; return 1; } + + ecore_app_args_set(argc, (const char **)argv); + + if (!ecore_string_init()) + { + printf("Cannot initialize Ecore_String!\n"); + ret = 1; + goto SHUTDOWN; + } if (!ecore_file_init()) { @@ -27,9 +36,23 @@ main(int argc, char **argv) goto SHUTDOWN; } - if (!ewl_init(&argc, argv)) + if (!ecore_evas_init()) { - printf("Cannot initialize EWL!\n"); + printf("Cannot initialize Ecore_Evas!\n"); + ret = 1; + goto SHUTDOWN; + } + + if (!ecdb_image_init()) + { + printf("Cannot initialize libisofs!\n"); + ret = 1; + goto SHUTDOWN; + } + + if (!ecdb_burn_init()) + { + printf("Cannot initialize libburn!\n"); ret = 1; goto SHUTDOWN; } @@ -95,7 +118,10 @@ SHUTDOWN: burn_finish(); iso_finish(); ecore_file_shutdown(); + ecore_string_shutdown(); + ecore_evas_shutdown(); ecore_shutdown(); + printf("Program Done\n"); return ret; }; @@ -113,8 +139,6 @@ ecdb_setup(void) ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new(); ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new(); ECDB_DRIVE_ACTION_UPDATE = ecore_event_type_new(); - ecdb_image_init(); - ecdb_burn_init(); ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown, NULL); diff --git a/experimental/ecdb/trunk/src/ecdb.h b/experimental/ecdb/trunk/src/ecdb.h index 931ad6db..2852f21f 100644 --- a/experimental/ecdb/trunk/src/ecdb.h +++ b/experimental/ecdb/trunk/src/ecdb.h @@ -5,8 +5,12 @@ #include #include #include +#include #include -#include +#include +#include +#include + #include #include #include @@ -15,8 +19,6 @@ #include #include #include -#include -#include #include #undef FREE @@ -48,7 +50,6 @@ extern int ECDB_DRIVE_ACTION_UPDATE; #include "ecdb_burn.h" #include "ecdb_misc.h" #include "ecdb_audio.h" -#include "ecdb_filelist_custom.h" #include "ecdb_gui.h" #endif diff --git a/experimental/ecdb/trunk/src/ecdb_common.h b/experimental/ecdb/trunk/src/ecdb_common.h index 9fc480da..3e90428d 100644 --- a/experimental/ecdb/trunk/src/ecdb_common.h +++ b/experimental/ecdb/trunk/src/ecdb_common.h @@ -67,7 +67,7 @@ struct _Ecdb_Project_Info typedef struct _Ecdb_Source Ecdb_Source; struct _Ecdb_Source { - char *dst; + const char *dst; unsigned char dir:1; unsigned int num_children; Ecdb_Source **children; diff --git a/experimental/ecdb/trunk/src/ecdb_filelist_custom.c b/experimental/ecdb/trunk/src/ecdb_filelist_custom.c index d0f6b3ee..b811f0a5 100644 --- a/experimental/ecdb/trunk/src/ecdb_filelist_custom.c +++ b/experimental/ecdb/trunk/src/ecdb_filelist_custom.c @@ -1,16 +1,21 @@ #include "ecdb.h" static void free_file(Ewl_Filelist_File *file); -void ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir); -unsigned int ecdb_custom_filelist_model_data_unref(void *data); -void *ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, - unsigned int column); -Ewl_Filelist_Directory *ecdb_custom_filelist_directory_new(Ecdb_Source *src); -void ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, void *data); static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, - void *data); -char *ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl); -Ewl_Widget *ecdb_custom_filelist_view_widget_fetch(void *data, unsigned int row, unsigned int column); + void *data); + +static Ewl_Widget *ecdb_custom_filelist_view_widget_fetch(void *data, + unsigned int row, unsigned int column); +static void *ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, + unsigned int column); + + +static void ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir); +static unsigned int ecdb_custom_filelist_model_data_unref(void *data); +static Ewl_Filelist_Directory *ecdb_custom_filelist_directory_new + (Ecdb_Source *src); +static void ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, + void *data); Ewl_Widget * ecdb_custom_filelist_new(void) @@ -36,14 +41,15 @@ ecdb_custom_filelist_new(void) return ret; } -void +static void ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, void *data__UNUSED__) { int i; Ewl_Event_Dnd_Data_Received *dnd = ev; - char *path, **files = dnd->data; + char **files = dnd->data; Ecdb_Source *parent, *child; + Efreet_Uri *uri; /* Get the parent, find the path of the file(s) dropped * and add them as children to parent */ @@ -51,15 +57,16 @@ ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, for (i = 0; i < dnd->len; i++) { - /* Cheap and dirty hax */ - /* XXX FIXME XXX */ - path = strdup(&files[i][7]); - if (!ecore_file_exists(path)) - break; + uri = efreet_uri_decode(files[i]); + if (!ecore_file_exists(uri->path)) + { + efreet_uri_free(uri); + continue; + } child = ecdb_source_new(); - ecdb_source_data_set(child, path); + ecdb_source_data_set(child, uri->path); ecdb_source_child_append(parent, child); - free(path); + efreet_uri_free(uri); } ecdb_custom_filelist_directory_set(EWL_FILELIST(w), parent); @@ -93,7 +100,7 @@ ecdb_custom_filelist_directory_set(Ewl_Filelist *fl, Ecdb_Source *src) } } -Ewl_Filelist_Directory * +static Ewl_Filelist_Directory * ecdb_custom_filelist_directory_new(Ecdb_Source *parent) { Ecdb_Source *src; @@ -159,13 +166,14 @@ ecdb_custom_filelist_directory_new(Ecdb_Source *parent) return dir; } -static void free_file(Ewl_Filelist_File *file) +static void +free_file(Ewl_Filelist_File *file) { ecore_string_release(file->name); FREE(file); } -void +static void ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir) { Ewl_Filelist_File *file; @@ -216,7 +224,7 @@ ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir) dir->num_files = nf; } -unsigned int +static unsigned int ecdb_custom_filelist_model_data_unref(void *data) { Ewl_Filelist_Directory *dir; @@ -230,7 +238,7 @@ ecdb_custom_filelist_model_data_unref(void *data) return TRUE; } -void * +static void * ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, unsigned int column) { @@ -264,8 +272,8 @@ ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, return ret; } -static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, - void *data) +static void +ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, void *data) { Ewl_Event_Mouse_Down *md; char *file; @@ -341,7 +349,7 @@ ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl) return strdup(file->name); } -Ewl_Widget * +static Ewl_Widget * ecdb_custom_filelist_view_widget_fetch(void *data, unsigned int row __UNUSED__, unsigned int column) { diff --git a/experimental/ecdb/trunk/src/ecdb_filelist_custom.h b/experimental/ecdb/trunk/src/ecdb_filelist_custom.h index 459bbdd5..0f4e4b82 100644 --- a/experimental/ecdb/trunk/src/ecdb_filelist_custom.h +++ b/experimental/ecdb/trunk/src/ecdb_filelist_custom.h @@ -2,7 +2,8 @@ #define ECDB_FILELIST_CUSTOM_H void ecdb_custom_filelist_directory_set(Ewl_Filelist *fl, - Ecdb_Source *src); + Ecdb_Source *src); Ewl_Widget *ecdb_custom_filelist_new(void); +char * ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl); #endif diff --git a/experimental/ecdb/trunk/src/ecdb_gui.c b/experimental/ecdb/trunk/src/ecdb_gui.c index 32895dd5..1924b341 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_gui.c @@ -1,255 +1,13 @@ #include "ecdb.h" -static void _destroy_cb(Ewl_Widget *w, void *ev, void *data); -static void _destroy_data_page_cb(Ewl_Widget *w, void *ev, void *data); -static void _data_disc_cb(Ewl_Widget *w, void *ev, void *data); -static void _burn_image_cb(Ewl_Widget *w, void *ev, void *data); -static void _copy_disc_cb(Ewl_Widget *w, void *ev, void *data); -static void _audio_disc_cb(Ewl_Widget *w, void *ev, void *data); -static void _hidden_files_cb(Ewl_Widget *w, void *ev, void *data); -static void _filter_change_cb(Ewl_Widget *w, void *ev, void *data); - -static Ewl_Widget *_page_start(void); -static Ewl_Widget *_page_data(void); - -static void -_destroy_cb(Ewl_Widget *w, void *ev __UNUSED__, void *data __UNUSED__) +void +ecdb_create_main_gui(void) { - ewl_widget_destroy(w); - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL); -} - -static void -_destroy_data_page_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data) -{ - Ecdb_Burn_Project *proj = data; - printf("Destroy burn project data\n"); - ecdb_burn_project_destroy(proj); + printf("Creating main gui\n"); } void ecdb_create_data_tab(void) { - Ewl_Widget *note_page, *notebook; - - notebook = ewl_widget_name_find("main_notebook"); - - note_page = _page_data(); - ewl_container_child_append(EWL_CONTAINER(notebook), note_page); - ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(notebook), note_page, - "Data Disc"); - ewl_notebook_visible_page_set(EWL_NOTEBOOK(notebook), note_page); - ewl_widget_show(note_page); + printf("Creating data tab\n"); } - -void -ecdb_create_main_gui(void) -{ - Ewl_Widget *main_win, *vbox, *filelist, *note, *fn; - Ewl_Widget *cm, *menu; - Ewl_Widget *tb, *filter, *l, *s; - - main_win = ewl_window_new(); - ewl_window_name_set(EWL_WINDOW(main_win), "ECDB"); - ewl_window_title_set(EWL_WINDOW(main_win), "ECDB"); - ewl_callback_append(main_win, EWL_CALLBACK_DELETE_WINDOW, - _destroy_cb, NULL); - ewl_object_w_request(EWL_OBJECT(main_win), 640); - ewl_object_h_request(EWL_OBJECT(main_win), 480); - ewl_widget_name_set(main_win, "main_win"); - ewl_widget_show(main_win); - - vbox = ewl_vbox_new(); - ewl_container_child_append(EWL_CONTAINER(main_win), vbox); - ewl_widget_show(vbox); - - filelist = ewl_filelist_new(); - ewl_container_child_append(EWL_CONTAINER(vbox), filelist); - ewl_filelist_multiselect_set(EWL_FILELIST(filelist), TRUE); - ewl_filelist_directory_set(EWL_FILELIST(filelist), getenv("HOME")); - ewl_object_fill_policy_set(EWL_OBJECT(filelist), EWL_FLAG_FILL_ALL); - ewl_object_maximum_h_set(EWL_OBJECT(filelist), 300); - ewl_widget_show(filelist); - - tb = ewl_toolbar_new(); - ewl_container_child_append(EWL_CONTAINER(vbox), tb); - ewl_object_alignment_set(EWL_OBJECT(tb), EWL_FLAG_ALIGN_CENTER); - ewl_widget_show(tb); - - l = ewl_label_new(); - ewl_label_text_set(EWL_LABEL(l), "Filelist filter:"); - ewl_container_child_append(EWL_CONTAINER(tb), l); - ewl_widget_show(l); - - filter = ewl_entry_new(); - ewl_container_child_append(EWL_CONTAINER(tb), filter); - ewl_callback_append(filter, EWL_CALLBACK_VALUE_CHANGED, - _filter_change_cb, filelist); - ewl_object_maximum_w_set(EWL_OBJECT(filter), 300); - ewl_widget_show(filter); - - s = ewl_vseparator_new(); - ewl_container_child_append(EWL_CONTAINER(tb), s); - ewl_widget_show(s); - - cm = ewl_context_menu_new(); - ewl_context_menu_attach(EWL_CONTEXT_MENU(cm), filelist); - - menu = ewl_menu_item_new(); - ewl_button_label_set(EWL_BUTTON(menu), "Show/Hide Hidden Files"); - ewl_container_child_append(EWL_CONTAINER(cm), menu); - ewl_callback_append(menu, EWL_CALLBACK_CLICKED, _hidden_files_cb, - filelist); - ewl_widget_show(menu); - - note = ewl_notebook_new(); - ewl_object_fill_policy_set(EWL_OBJECT(note), EWL_FLAG_FILL_ALL); - ewl_container_child_append(EWL_CONTAINER(vbox), note); - ewl_notebook_tabbar_alignment_set(EWL_NOTEBOOK(note), - EWL_FLAG_ALIGN_LEFT); - ewl_widget_name_set(note, "main_notebook"); - ewl_widget_show(note); - - fn = _page_start(); - ewl_container_child_append(EWL_CONTAINER(note), fn); - ewl_notebook_page_tab_text_set(EWL_NOTEBOOK(note), fn, "Start"); - ewl_widget_show(fn); -} - -static Ewl_Widget -*_page_start(void) -{ - int i; - Ewl_Widget *box, *border[3], *buttons[3]; - char *bdr_titles[] = {"Create Data Disc", - "Burn Image", - "Copy Disc", - "Create Audio Disc"}; - - char *but_titles[] = {"Data Disc", - "Image", - "Copy", - "Audio Disc"}; - - char *images[] = {EWL_ICON_DRIVE_CDROM, - EWL_ICON_MEDIA_CDROM, - EWL_ICON_DRIVE_HARDDISK, - EWL_ICON_AUDIO_X_GENERIC}; - - static void (*funs[]) (Ewl_Widget *w, void *ev, void *data) = - {_data_disc_cb, - _burn_image_cb, - _copy_disc_cb, - _audio_disc_cb}; - - box = ewl_hbox_new(); - ewl_object_fill_policy_set(EWL_OBJECT(box), EWL_FLAG_FILL_NONE); - ewl_widget_show(box); - - for (i = 0; i < 4; i++) - { - border[i] = ewl_border_new(); - ewl_border_label_set(EWL_BORDER(border[i]), bdr_titles[i]); - ewl_container_child_append(EWL_CONTAINER(box), border[i]); - ewl_widget_show(border[i]); - - buttons[i] = ewl_button_new(); - ewl_container_child_append(EWL_CONTAINER(border[i]), - buttons[i]); - ewl_button_label_set(EWL_BUTTON(buttons[i]), but_titles[i]); - ewl_button_image_set(EWL_BUTTON(buttons[i]), - ewl_icon_theme_icon_path_get(images[i], 0), - NULL); - ewl_callback_append(buttons[i], EWL_CALLBACK_CLICKED, - funs[i], NULL); - ewl_widget_show(buttons[i]); - } - - return box; -} - -static Ewl_Widget -*_page_data(void) -{ - Ewl_Widget *box, *filelist; - Ecdb_Burn_Project *proj; - - proj = ecdb_burn_project_new(); - - box = ewl_vbox_new(); - ewl_widget_data_set(box, "proj_data", proj); - ewl_callback_prepend(box, EWL_CALLBACK_DESTROY, - _destroy_data_page_cb, proj); - ewl_widget_show(box); - - filelist = ecdb_custom_filelist_new(); - ewl_filelist_multiselect_set(EWL_FILELIST(filelist), TRUE); - ewl_container_child_append(EWL_CONTAINER(box), filelist); - ewl_widget_data_set(filelist, "source", proj->files); - ewl_widget_show(filelist); - - return box; -} - -static void -_data_disc_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) -{ - printf("Create Data Disc\n"); - ecdb_create_data_tab(); -} - -static void -_burn_image_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) -{ - printf("Burn Image to Disc\n"); -} - -static void -_copy_disc_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) -{ - printf("Copy Disc\n"); -} - -static void -_audio_disc_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) -{ - printf("Create Audio Disc\n"); -} - -static void -_hidden_files_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data) -{ - Ewl_Filelist *filelist = data; - unsigned int hf; - - hf = ewl_filelist_show_dot_files_get(filelist); - ewl_filelist_show_dot_files_set(filelist, !hf); -} - -static void -_filter_change_cb(Ewl_Widget *w, void *ev, void *data) -{ - char *filter; - Ewl_Filelist_Filter *old, *new; - - filter = ewl_text_text_get(EWL_TEXT(w)); - new = calloc(1, sizeof(Ewl_Filelist_Filter)); - if (!new) - return; - new->extension = filter; - - /* Fix this is ewl at some point */ - old = ewl_filelist_filter_get(EWL_FILELIST(data)); - if (old) - { - FREE(old->extension); - FREE(old); - } - - ewl_filelist_filter_set(EWL_FILELIST(data), new); -} - diff --git a/experimental/ecdb/trunk/src/ecdb_image.c b/experimental/ecdb/trunk/src/ecdb_image.c index 65c18f98..22d0de4e 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.c +++ b/experimental/ecdb/trunk/src/ecdb_image.c @@ -39,9 +39,8 @@ ecdb_source_destroy(Ecdb_Source *src) Ecdb_Source *child; /* free the non-recursive stuff */ - FREE(src->dst); - if (src->node) - iso_node_unref(src->node); + if (src->dst) ecore_string_release(src->dst); + if (src->node) iso_node_unref(src->node); for (i = 0; src->children[i]; i++) { @@ -58,7 +57,7 @@ ecdb_source_data_set(Ecdb_Source *src, const char *dst) if (!src) return; - src->dst = strdup(dst); + src->dst = ecore_string_instance(dst); /* Add the files recursively here */ if (ecore_file_is_dir(src->dst)) diff --git a/experimental/ecdb/trunk/src/ecdb_misc.c b/experimental/ecdb/trunk/src/ecdb_misc.c index 3db5d13d..47b928d2 100644 --- a/experimental/ecdb/trunk/src/ecdb_misc.c +++ b/experimental/ecdb/trunk/src/ecdb_misc.c @@ -48,18 +48,25 @@ ecdb_shutdown(void *data, int type, void *event) return FALSE; } -void +int ecdb_burn_init(void) { - burn_initialize(); + if (!burn_initialize()) + return 0; + burn_msgs_set_severities("NEVER", "SORRY", "ecdb: "); burn_set_signal_handling("ecdb: ", NULL, 0); + + return 1; } -void +int ecdb_image_init(void) { - iso_init(); + if (!iso_init()) + return 0; iso_set_msgs_severities("NEVER", "SORRY", "ecdb: "); + + return 1; } diff --git a/experimental/ecdb/trunk/src/ecdb_misc.h b/experimental/ecdb/trunk/src/ecdb_misc.h index eafa72c0..5fdd5dc5 100644 --- a/experimental/ecdb/trunk/src/ecdb_misc.h +++ b/experimental/ecdb/trunk/src/ecdb_misc.h @@ -7,7 +7,7 @@ void ecdb_project_destroy(Ecdb_Project *proj); void ecdb_project_type_set(Ecdb_Project *proj, unsigned int t); void ecdb_projects_free(void *data); int ecdb_shutdown(void *data, int type, void *event); -void ecdb_burn_init(void); -void ecdb_image_init(void); +int ecdb_burn_init(void); +int ecdb_image_init(void); #endif