olaf neophyte and de.po updates, valgrind tweaks, delete green lady, inkscape dpi=96
[goodguy/history.git] / cinelerra-5.1 / guicast / bcfilebox.C
index ae6e15f6f196b3d35ef48320e2198ac2f0c7a126..fa2f8b24401483dc332e28db2a8cd5ace6419d20 100644 (file)
@@ -222,8 +222,21 @@ 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() - 50, 1, filebox->get_resources()->filebox_filter)
+ : BC_TextBox(x, y, filebox->get_w() - x - 50, 1, filebox->get_resources()->filebox_filter)
 {
        this->filebox = filebox;
 }
@@ -466,6 +479,7 @@ BC_FileBox::BC_FileBox(int x, int y, const char *init_path,
        column_type = new int[columns];
        column_width = new int[columns];
 
+       filter_title = 0;
        filter_text = 0;
        filter_popup = 0;
        usethis_button = 0;
@@ -552,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,
@@ -571,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)
@@ -617,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;
@@ -646,9 +669,11 @@ void BC_FileBox::create_objects()
        y += textbox->get_h() + 10;
 
        if(!want_directory) {
-               add_subwindow(filter_text = new BC_FileBoxFilterText(x, y, this));
+               add_subwindow(filter_title = new BC_Title(x, y, _("Specify filter:")));
+               int x1 = x + filter_title->get_w() + 10;
+               add_subwindow(filter_text = new BC_FileBoxFilterText(x1, y, this));
                add_subwindow(filter_popup =
-                       new BC_FileBoxFilterMenu(x + filter_text->get_w(), y, this));;
+                       new BC_FileBoxFilterMenu(x1 + filter_text->get_w(), y, this));
        }
 
 // listbox has to be active because refresh might be called from newfolder_thread
@@ -659,6 +684,7 @@ void BC_FileBox::create_objects()
 
        refresh();
        show_window();
+       unlock_window();
 }
 
 int BC_FileBox::get_listbox_w()
@@ -708,7 +734,8 @@ int BC_FileBox::resize_event(int w, int h)
                w - 30,
                0);
 
-
+       if(filter_title) filter_title->reposition_window(filter_title->get_x(),
+               h - (get_h() - filter_title->get_y()));
        if(filter_text) filter_text->reposition_window(filter_text->get_x(),
                h - (get_h() - filter_text->get_y()),
                w - (get_w() - filter_text->get_w()),
@@ -723,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()),
@@ -750,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;
 }
@@ -793,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;
@@ -805,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);
 
@@ -820,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) ) {
@@ -890,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;
@@ -938,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]);
@@ -946,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(),