olaf neophyte and de.po updates, valgrind tweaks, delete green lady, inkscape dpi=96
[goodguy/history.git] / cinelerra-5.1 / guicast / bcfilebox.C
index ea9c58f5bf04e40177247b91e604196aca8b832a..fa2f8b24401483dc332e28db2a8cd5ace6419d20 100644 (file)
@@ -222,6 +222,19 @@ int BC_FileBoxDirectoryText::handle_event()
 }
 
 
+BC_FileBoxSearchText::BC_FileBoxSearchText(int x, int y, BC_FileBox *filebox)
+ : BC_TextBox(x, y, filebox->get_w() - x - 40, 1, "")
+{
+       this->filebox = filebox;
+}
+
+int BC_FileBoxSearchText::handle_event()
+{
+       filebox->refresh();
+       return 1;
+}
+
+
 BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox)
  : BC_TextBox(x, y, filebox->get_w() - x - 50, 1, filebox->get_resources()->filebox_filter)
 {
@@ -553,6 +566,7 @@ BC_FileBox::~BC_FileBox()
 
 void BC_FileBox::create_objects()
 {
+       lock_window("BC_FileBox::create_objects");
        int x = 10, y = 10;
        BC_Resources *resources = BC_WindowBase::get_resources();
        int directory_title_margin = MAX(20,
@@ -618,6 +632,14 @@ void BC_FileBox::create_objects()
        x = 10;
        y += directory_title->get_h() + 5;
 
+       BC_Title *search_title;
+       add_subwindow(search_title = new BC_Title(x, y, _("Search:")));
+       x += search_title->get_w() + 10;
+       add_subwindow(search_text = new BC_FileBoxSearchText(x, y, this));
+
+       x = 10;
+       y += search_text->get_h() + 5;
+
        int newest_id = 0, newest = -1;
        for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++) {
                if( !resources->filebox_history[i].path[0] ) continue;
@@ -662,6 +684,7 @@ void BC_FileBox::create_objects()
 
        refresh();
        show_window();
+       unlock_window();
 }
 
 int BC_FileBox::get_listbox_w()
@@ -727,6 +750,11 @@ int BC_FileBox::resize_event(int w, int h)
                directory_title->get_y(),
                directory_title->get_w() + recent_popup->get_w(),
                recent_popup->get_h());
+       search_text->reposition_window(
+               search_text->get_x(),
+               search_text->get_y(),
+               get_w() - search_text->get_x() -  40,
+               1);
        textbox->reposition_window(textbox->get_x(),
                h - (get_h() - textbox->get_y()),
                w - (get_w() - textbox->get_w()),
@@ -806,6 +834,7 @@ static inline int ilen(int64_t v)
 
 int BC_FileBox::create_tables(int select_all)
 {
+       int preload_textbox = select_all;
        delete_tables();
        char string[BCTEXTLEN];
        BC_ListBoxItem *new_item;
@@ -816,6 +845,9 @@ int BC_FileBox::create_tables(int select_all)
        for(int i = 0; i < fs->total_files(); i++)
        {
                FileItem *file_item = fs->get_entry(i);
+               const char *text = search_text->get_text();
+               if( text && text[0] && !bstrcasestr(file_item->name, text) )
+                       continue;
                int is_dir = file_item->is_dir;
                BC_Pixmap* icon = get_icon(file_item->name, is_dir);
 
@@ -831,6 +863,10 @@ int BC_FileBox::create_tables(int select_all)
 //             {
                        if(!is_dir)
                        {
+                               if( preload_textbox ) {
+                                       preload_textbox = 0;
+                                       textbox->update(new_item->get_text());
+                               }
                                int64_t size = file_item->size;
                                if( (size_format == FILEBOX_SIZE_1000 && size >= 1000) ||
                                    (size_format == FILEBOX_SIZE_1024 && size >= 1024) ) {