Moving over to mainly edje

This commit is contained in:
Jaime Thomas 2008-08-04 22:18:34 +00:00
parent 017e115411
commit 51312b72b0
10 changed files with 90 additions and 293 deletions

View File

@ -10,7 +10,6 @@ ecdb_SOURCES = \
ecdb_misc.c ecdb_misc.h \ ecdb_misc.c ecdb_misc.h \
ecdb_audio.c ecdb_audio.h \ ecdb_audio.c ecdb_audio.h \
ecdb_gui.c ecdb_gui.h \ ecdb_gui.c ecdb_gui.h \
ecdb_filelist_custom.c ecdb_filelist_custom.h \
ecdb_common.h ecdb_common.h
ecdb_CFLAGS = @ECDB_CFLAGS@ ecdb_CFLAGS = @ECDB_CFLAGS@

View File

@ -19,6 +19,15 @@ main(int argc, char **argv)
ret = 1; ret = 1;
return 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()) if (!ecore_file_init())
{ {
@ -27,9 +36,23 @@ main(int argc, char **argv)
goto SHUTDOWN; 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; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
@ -95,7 +118,10 @@ SHUTDOWN:
burn_finish(); burn_finish();
iso_finish(); iso_finish();
ecore_file_shutdown(); ecore_file_shutdown();
ecore_string_shutdown();
ecore_evas_shutdown();
ecore_shutdown(); ecore_shutdown();
printf("Program Done\n"); printf("Program Done\n");
return ret; return ret;
}; };
@ -113,8 +139,6 @@ ecdb_setup(void)
ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new(); ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new();
ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new(); ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new();
ECDB_DRIVE_ACTION_UPDATE = 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, ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown,
NULL); NULL);

View File

@ -5,8 +5,12 @@
#include <Ecore.h> #include <Ecore.h>
#include <Ecore_Data.h> #include <Ecore_Data.h>
#include <Ecore_File.h> #include <Ecore_File.h>
#include <Ecore_Evas.h>
#include <Efreet_Mime.h> #include <Efreet_Mime.h>
#include <Ewl.h> #include <Efreet.h>
#include <libburn/libburn.h>
#include <libisofs/libisofs.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -15,8 +19,6 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
#include <libburn/libburn.h>
#include <libisofs/libisofs.h>
#include <pthread.h> #include <pthread.h>
#undef FREE #undef FREE
@ -48,7 +50,6 @@ extern int ECDB_DRIVE_ACTION_UPDATE;
#include "ecdb_burn.h" #include "ecdb_burn.h"
#include "ecdb_misc.h" #include "ecdb_misc.h"
#include "ecdb_audio.h" #include "ecdb_audio.h"
#include "ecdb_filelist_custom.h"
#include "ecdb_gui.h" #include "ecdb_gui.h"
#endif #endif

View File

@ -67,7 +67,7 @@ struct _Ecdb_Project_Info
typedef struct _Ecdb_Source Ecdb_Source; typedef struct _Ecdb_Source Ecdb_Source;
struct _Ecdb_Source struct _Ecdb_Source
{ {
char *dst; const char *dst;
unsigned char dir:1; unsigned char dir:1;
unsigned int num_children; unsigned int num_children;
Ecdb_Source **children; Ecdb_Source **children;

View File

@ -1,16 +1,21 @@
#include "ecdb.h" #include "ecdb.h"
static void free_file(Ewl_Filelist_File *file); 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, static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev,
void *data); 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); 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 * Ewl_Widget *
ecdb_custom_filelist_new(void) ecdb_custom_filelist_new(void)
@ -36,14 +41,15 @@ ecdb_custom_filelist_new(void)
return ret; return ret;
} }
void static void
ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev,
void *data__UNUSED__) void *data__UNUSED__)
{ {
int i; int i;
Ewl_Event_Dnd_Data_Received *dnd = ev; Ewl_Event_Dnd_Data_Received *dnd = ev;
char *path, **files = dnd->data; char **files = dnd->data;
Ecdb_Source *parent, *child; Ecdb_Source *parent, *child;
Efreet_Uri *uri;
/* Get the parent, find the path of the file(s) dropped /* Get the parent, find the path of the file(s) dropped
* and add them as children to parent */ * 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++) for (i = 0; i < dnd->len; i++)
{ {
/* Cheap and dirty hax */ uri = efreet_uri_decode(files[i]);
/* XXX FIXME XXX */ if (!ecore_file_exists(uri->path))
path = strdup(&files[i][7]); {
if (!ecore_file_exists(path)) efreet_uri_free(uri);
break; continue;
}
child = ecdb_source_new(); child = ecdb_source_new();
ecdb_source_data_set(child, path); ecdb_source_data_set(child, uri->path);
ecdb_source_child_append(parent, child); ecdb_source_child_append(parent, child);
free(path); efreet_uri_free(uri);
} }
ecdb_custom_filelist_directory_set(EWL_FILELIST(w), parent); 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_custom_filelist_directory_new(Ecdb_Source *parent)
{ {
Ecdb_Source *src; Ecdb_Source *src;
@ -159,13 +166,14 @@ ecdb_custom_filelist_directory_new(Ecdb_Source *parent)
return dir; return dir;
} }
static void free_file(Ewl_Filelist_File *file) static void
free_file(Ewl_Filelist_File *file)
{ {
ecore_string_release(file->name); ecore_string_release(file->name);
FREE(file); FREE(file);
} }
void static void
ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir) ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir)
{ {
Ewl_Filelist_File *file; Ewl_Filelist_File *file;
@ -216,7 +224,7 @@ ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir)
dir->num_files = nf; dir->num_files = nf;
} }
unsigned int static unsigned int
ecdb_custom_filelist_model_data_unref(void *data) ecdb_custom_filelist_model_data_unref(void *data)
{ {
Ewl_Filelist_Directory *dir; Ewl_Filelist_Directory *dir;
@ -230,7 +238,7 @@ ecdb_custom_filelist_model_data_unref(void *data)
return TRUE; return TRUE;
} }
void * static void *
ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row,
unsigned int column) unsigned int column)
{ {
@ -264,8 +272,8 @@ ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row,
return ret; return ret;
} }
static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, static void
void *data) ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, void *data)
{ {
Ewl_Event_Mouse_Down *md; Ewl_Event_Mouse_Down *md;
char *file; char *file;
@ -341,7 +349,7 @@ ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl)
return strdup(file->name); return strdup(file->name);
} }
Ewl_Widget * static Ewl_Widget *
ecdb_custom_filelist_view_widget_fetch(void *data, unsigned int row __UNUSED__, ecdb_custom_filelist_view_widget_fetch(void *data, unsigned int row __UNUSED__,
unsigned int column) unsigned int column)
{ {

View File

@ -2,7 +2,8 @@
#define ECDB_FILELIST_CUSTOM_H #define ECDB_FILELIST_CUSTOM_H
void ecdb_custom_filelist_directory_set(Ewl_Filelist *fl, void ecdb_custom_filelist_directory_set(Ewl_Filelist *fl,
Ecdb_Source *src); Ecdb_Source *src);
Ewl_Widget *ecdb_custom_filelist_new(void); Ewl_Widget *ecdb_custom_filelist_new(void);
char * ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl);
#endif #endif

View File

@ -1,255 +1,13 @@
#include "ecdb.h" #include "ecdb.h"
static void _destroy_cb(Ewl_Widget *w, void *ev, void *data); void
static void _destroy_data_page_cb(Ewl_Widget *w, void *ev, void *data); ecdb_create_main_gui(void)
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__)
{ {
ewl_widget_destroy(w); printf("Creating main gui\n");
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);
} }
void void
ecdb_create_data_tab(void) ecdb_create_data_tab(void)
{ {
Ewl_Widget *note_page, *notebook; printf("Creating data tab\n");
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);
} }
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);
}

View File

@ -39,9 +39,8 @@ ecdb_source_destroy(Ecdb_Source *src)
Ecdb_Source *child; Ecdb_Source *child;
/* free the non-recursive stuff */ /* free the non-recursive stuff */
FREE(src->dst); if (src->dst) ecore_string_release(src->dst);
if (src->node) if (src->node) iso_node_unref(src->node);
iso_node_unref(src->node);
for (i = 0; src->children[i]; i++) for (i = 0; src->children[i]; i++)
{ {
@ -58,7 +57,7 @@ ecdb_source_data_set(Ecdb_Source *src, const char *dst)
if (!src) if (!src)
return; return;
src->dst = strdup(dst); src->dst = ecore_string_instance(dst);
/* Add the files recursively here */ /* Add the files recursively here */
if (ecore_file_is_dir(src->dst)) if (ecore_file_is_dir(src->dst))

View File

@ -48,18 +48,25 @@ ecdb_shutdown(void *data, int type, void *event)
return FALSE; return FALSE;
} }
void int
ecdb_burn_init(void) ecdb_burn_init(void)
{ {
burn_initialize(); if (!burn_initialize())
return 0;
burn_msgs_set_severities("NEVER", "SORRY", "ecdb: "); burn_msgs_set_severities("NEVER", "SORRY", "ecdb: ");
burn_set_signal_handling("ecdb: ", NULL, 0); burn_set_signal_handling("ecdb: ", NULL, 0);
return 1;
} }
void int
ecdb_image_init(void) ecdb_image_init(void)
{ {
iso_init(); if (!iso_init())
return 0;
iso_set_msgs_severities("NEVER", "SORRY", "ecdb: "); iso_set_msgs_severities("NEVER", "SORRY", "ecdb: ");
return 1;
} }

View File

@ -7,7 +7,7 @@ void ecdb_project_destroy(Ecdb_Project *proj);
void ecdb_project_type_set(Ecdb_Project *proj, unsigned int t); void ecdb_project_type_set(Ecdb_Project *proj, unsigned int t);
void ecdb_projects_free(void *data); void ecdb_projects_free(void *data);
int ecdb_shutdown(void *data, int type, void *event); int ecdb_shutdown(void *data, int type, void *event);
void ecdb_burn_init(void); int ecdb_burn_init(void);
void ecdb_image_init(void); int ecdb_image_init(void);
#endif #endif