Add a filter for the main filelist

This commit is contained in:
Jaime Thomas 2008-06-21 02:51:16 +00:00
parent 95537031b9
commit 2a42a8edaf
2 changed files with 48 additions and 1 deletions

View File

@ -308,7 +308,6 @@ static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev,
{ {
if ((child->dir) && (!strcmp(child->dst, file))) if ((child->dir) && (!strcmp(child->dst, file)))
{ {
printf("Setting directory\n");
ecdb_custom_filelist_directory_set(fl, child); ecdb_custom_filelist_directory_set(fl, child);
FREE(file); FREE(file);
return; return;

View File

@ -7,6 +7,7 @@ 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 _copy_disc_cb(Ewl_Widget *w, void *ev, void *data);
static void _audio_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 _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_start(void);
static Ewl_Widget *_page_data(void); static Ewl_Widget *_page_data(void);
@ -46,6 +47,7 @@ ecdb_create_main_gui(void)
{ {
Ewl_Widget *main_win, *vbox, *filelist, *note, *fn; Ewl_Widget *main_win, *vbox, *filelist, *note, *fn;
Ewl_Widget *cm, *menu; Ewl_Widget *cm, *menu;
Ewl_Widget *tb, *filter, *l, *s;
main_win = ewl_window_new(); main_win = ewl_window_new();
ewl_window_name_set(EWL_WINDOW(main_win), "ECDB"); ewl_window_name_set(EWL_WINDOW(main_win), "ECDB");
@ -69,6 +71,27 @@ ecdb_create_main_gui(void)
ewl_object_maximum_h_set(EWL_OBJECT(filelist), 300); ewl_object_maximum_h_set(EWL_OBJECT(filelist), 300);
ewl_widget_show(filelist); 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(); cm = ewl_context_menu_new();
ewl_context_menu_attach(EWL_CONTEXT_MENU(cm), filelist); ewl_context_menu_attach(EWL_CONTEXT_MENU(cm), filelist);
@ -206,3 +229,28 @@ _hidden_files_cb(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data)
hf = ewl_filelist_show_dot_files_get(filelist); hf = ewl_filelist_show_dot_files_get(filelist);
ewl_filelist_show_dot_files_set(filelist, !hf); 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 *f;
/* Fix this is ewl at some point */
f = ewl_filelist_filter_get(EWL_FILELIST(data));
if (f)
{
FREE(f->extension);
FREE(f);
}
filter = ewl_text_text_get(EWL_TEXT(w));
f = calloc(1, sizeof(Ewl_Filelist_Filter));
if (!f)
return;
f->mime_list = NULL;
f->extension = filter;
ewl_filelist_filter_set(EWL_FILELIST(data), f);
}