load files search box, avoid segv in get_prev_keyframe, fix titles only handles,...
[goodguy/history.git] / cinelerra-5.1 / guicast / bcfilebox.C
index 80cf3320191f37ec35b4096c7f418485292cb71e..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)
 {
@@ -619,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;
@@ -729,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()),
@@ -819,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);