olaf neophyte and de.po updates, valgrind tweaks, delete green lady, inkscape dpi=96
[goodguy/history.git] / cinelerra-5.1 / guicast / bcfilebox.C
index 5d755977c183bfbaa9c424d7234e1021213945f2..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,
@@ -572,7 +586,7 @@ void BC_FileBox::create_objects()
        }
 
        create_icons();
-       create_tables();
+       create_tables(0);
 
        add_subwindow(ok_button = new BC_FileBoxOK(this));
        if(want_directory)
@@ -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()),
@@ -754,12 +782,19 @@ int BC_FileBox::resize_event(int w, int h)
 
 int BC_FileBox::keypress_event()
 {
-       switch(get_keypress())
-       {
-               case 'w':
-                       if(ctrl_down()) set_done(1);
-                       return 1;
-                       break;
+       switch(get_keypress()) {
+       case 'a':
+               if( !ctrl_down() ) break;
+               refresh(0, 1);
+               return 1;
+       case 'z':
+               if( !ctrl_down() ) break;
+               refresh(0, 0);
+               return 1;
+       case 'w':
+               if( !ctrl_down() ) break;
+               set_done(1);
+               return 1;
        }
        return 0;
 }
@@ -797,8 +832,9 @@ static inline int ilen(int64_t v)
         return len;
 }
 
-int BC_FileBox::create_tables()
+int BC_FileBox::create_tables(int select_all)
 {
+       int preload_textbox = select_all;
        delete_tables();
        char string[BCTEXTLEN];
        BC_ListBoxItem *new_item;
@@ -809,6 +845,9 @@ int BC_FileBox::create_tables()
        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);
 
@@ -824,6 +863,10 @@ int BC_FileBox::create_tables()
 //             {
                        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) ) {
@@ -894,6 +937,12 @@ int BC_FileBox::create_tables()
                        }
                        list_column[column_of_type(FILEBOX_EXTENSION)].append(new_item);
 //             }
+
+               if( !is_dir && select_all ) {
+                       int k = list_column[0].size()-1;
+                       for( int j=0; j<columns; ++j )
+                               list_column[j][k]->set_selected(1);
+               }
        }
 
        return 0;
@@ -942,7 +991,7 @@ int BC_FileBox::column_of_type(int type)
 
 
 
-int BC_FileBox::refresh(int reset)
+int BC_FileBox::refresh(int reset, int select_all)
 {
        fs->set_sort_order(sort_order);
        fs->set_sort_field(column_type[sort_column]);
@@ -950,7 +999,7 @@ int BC_FileBox::refresh(int reset)
                fs->update(0);
        else
                fs->update_sort();
-       create_tables();
+       create_tables(select_all);
        listbox->set_master_column(column_of_type(FILEBOX_NAME), 0);
        listbox->update(list_column, column_titles, column_width, columns,
                reset>0 ? 0 : listbox->get_xposition(),