experimental-legacy/ecdb/trunk/src/ecdb_gui.c

209 lines
5.7 KiB
C

#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 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);
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
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);
}
void
ecdb_create_main_gui(void)
{
Ewl_Widget *main_win, *vbox, *filelist, *note, *fn;
Ewl_Widget *cm, *menu;
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);
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);
}