edl plugin names eng, fix segv for opengl brender, renderfarm rework strategy, perf...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / awindowgui.C
index a984e20cdf66c45455fc08607471f5ed8bd0292b..ae74854b19e0517640e164b042943dc5a9c97b42 100644 (file)
@@ -29,6 +29,7 @@
 #include "bcsignals.h"
 #include "bchash.h"
 #include "cache.h"
+#include "cstrdup.h"
 #include "clip.h"
 #include "clippopup.h"
 #include "cursors.h"
@@ -105,14 +106,14 @@ VFrame *AssetVIcon::frame()
                        delete temp;  temp = 0;
                }
                if( !temp )
-                       temp = new VFrame(asset->width, asset->height, BC_RGB888);
+                       temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
                int ww = picon->gui->vicon_thread->view_w;
                int hh = picon->gui->vicon_thread->view_h;
                while( seq_no >= images.size() ) {
                        file->set_layer(0);
                        int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
                        file->set_video_position(pos,0);
-                       file->read_frame(temp);
+                       if( file->read_frame(temp) ) temp->clear_frame();
                        add_image(temp, ww, hh, BC_RGB8);
                }
                mwindow->video_cache->check_in(asset);
@@ -221,6 +222,7 @@ void AssetPicon::reset()
        icon_vframe = 0;
        vicon = 0;
        in_use = 1;
+       mtime = 0;
        id = 0;
        persistent = 0;
 }
@@ -297,35 +299,36 @@ void AssetPicon::create_objects()
                                else {
                                        gui->lock_window("AssetPicon::create_objects 2");
                                        icon = gui->video_icon;
-                                       icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
+                                       icon_vframe = gui->video_vframe;
                                }
                        }
                        else {
                                icon = gui->video_icon;
-                               icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
+                               icon_vframe = gui->video_vframe;
                        }
                }
                else
                if( asset->audio_data ) {
                        icon = gui->audio_icon;
-                       icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
+                       icon_vframe = gui->audio_vframe;
                }
-
+               struct stat st;
+               mtime = !stat(asset->path, &st) ? st.st_mtime : 0;
        }
        else
        if( indexable && !indexable->is_asset ) {
                icon = gui->video_icon;
-               icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
+               icon_vframe = gui->video_vframe;
        }
        else
        if( edl ) {
                set_text(strcpy(name, edl->local_session->clip_title));
                icon = gui->clip_icon;
-               icon_vframe = mwindow->theme->get_image("clip_icon");
+               icon_vframe = gui->clip_vframe;
        }
        else
        if( plugin ) {
-               strcpy(name,  plugin->title);
+               strcpy(name, _(plugin->title));
                set_text(name);
                icon_vframe = plugin->get_picon();
                if( icon_vframe )
@@ -373,9 +376,7 @@ void AssetPicon::create_objects()
                              mwindow->edl->session->frames_per_foot);
                set_text(name);
                icon = gui->label_icon;
-               icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_LABEL];
-               set_icon(icon);
-               set_icon_vframe(icon_vframe);
+               icon_vframe = gui->label_vframe;
        }
        if( !icon ) {
                icon = gui->file_icon;
@@ -616,9 +617,9 @@ void AWindowGUI::create_objects()
        mwindow->theme->get_awindow_sizes(this);
        load_defaults(mwindow->defaults);
 
-       int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y + 5;
+       int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
        int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
-       search_text = new AWindowSearchText(mwindow, this, x1, y1);
+       search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
        search_text->create_objects();
        int dy = search_text->get_h() + 10;
        y1 += dy;  h1 -= dy;
@@ -720,9 +721,9 @@ int AWindowGUI::translation_event()
 
 void AWindowGUI::reposition_objects()
 {
-       int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y + 5;
+       int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
        int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
-       search_text->reposition_window(x1, y1, w1);
+       search_text->reposition_window(x1, y1+5, w1);
        int dy = search_text->get_h() + 10;
        y1 += dy;  h1 -= dy;
        asset_list->reposition_window(x1, y1, w1, h1);
@@ -837,6 +838,7 @@ void AWindowRemovePlugin::handle_close_event(int result)
 {
        if( !result ) {
                printf(_("remove %s\n"), plugin->path);
+               awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
                ArrayList<BC_ListBoxItem*> *folder =
                        plugin->audio ? plugin->transition ?
                                &awindow->gui->atransitions :
@@ -846,14 +848,14 @@ void AWindowRemovePlugin::handle_close_event(int result)
                                &awindow->gui->veffects :
                        0;
                if( folder ) remove_plugin(plugin, *folder);
+               MWindow *mwindow = awindow->mwindow;
+               awindow->gui->unlock_window();
                char plugin_path[BCTEXTLEN];
                strcpy(plugin_path, plugin->path);
-               MWindow *mwindow = awindow->mwindow;
                mwindow->plugindb->remove(plugin);
                remove(plugin_path);
                char index_path[BCTEXTLEN];
-               snprintf(index_path, sizeof(index_path), "%s/%s",
-                       mwindow->preferences->plugin_dir, PLUGIN_FILE);
+               mwindow->create_defaults_path(index_path, PLUGIN_FILE);
                remove(index_path);
                char picon_path[BCTEXTLEN];
                FileSystem fs;
@@ -1108,7 +1110,11 @@ void AWindowGUI::update_asset_list()
                if( !picon->in_use ) {
                        delete picon;
                        assets.remove_number(i);
+                       continue;
                }
+               if( !picon->indexable || !picon->indexable->is_asset ) continue;
+               struct stat st;
+               picon->mtime = !stat(picon->indexable->path, &st) ? st.st_mtime : 0;
        }
 }
 
@@ -1135,7 +1141,7 @@ void AWindowGUI::update_picon(Indexable *indexable)
        }
 }
 
-void AWindowGUI::sort_assets()
+void AWindowGUI::sort_assets(int use_mtime)
 {
        switch( mwindow->edl->session->awindow_folder ) {
        case AW_AEFFECT_FOLDER:
@@ -1154,7 +1160,7 @@ void AWindowGUI::sort_assets()
                sort_picons(&labellist);
                break;
        default:
-               sort_picons(&assets);
+               sort_picons(&assets, use_mtime);
        }
 // reset xyposition
        asset_list->update_format(asset_list->get_format(), 0);
@@ -1197,7 +1203,7 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
                    (picon->indexable && picon->indexable->awindow_folder == folder) ||
                    (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
                        const char *text = search_text->get_text();
-                       int hidden = text && text[0] && !strcasestr(picon->get_text(), text);
+                       int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
                        if( picon->vicon ) picon->vicon->hidden = hidden;
                        if( hidden ) continue;
                        BC_ListBoxItem *item2, *item1;
@@ -1207,6 +1213,14 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
                        else
                        if( picon->label && picon->label->textstr )
                                dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
+                       else if( picon->mtime ) {
+                               char date_time[BCSTRLEN];
+                               struct tm stm;  localtime_r(&picon->mtime, &stm);
+                               sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
+                                        stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
+                                        stm.tm_hour, stm.tm_min, stm.tm_sec);
+                               dst[1].append(item2 = new BC_ListBoxItem(date_time));
+                       }
                        else
                                dst[1].append(item2 = new BC_ListBoxItem(""));
                        item1->set_autoplace_text(1);  item1->set_autoplace_icon(1);
@@ -1215,26 +1229,29 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
        }
 }
 
-void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
+void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime)
 {
-       int done = 0;
-       while(!done)
-       {
+       int done = 0, changed = 0;
+       while( !done ) {
                done = 1;
-               for( int i = 0; i < src->total - 1; i++ ) {
-                       BC_ListBoxItem *item1 = src->values[i];
-                       BC_ListBoxItem *item2 = src->values[i + 1];
-                       item1->set_autoplace_icon(1);
-                       item2->set_autoplace_icon(1);
-                       item1->set_autoplace_text(1);
-                       item2->set_autoplace_text(1);
-                       if( strcmp(item1->get_text(), item2->get_text()) > 0 ) {
+               for( int i=0; i<src->total-1; ++i ) {
+                       AssetPicon *item1 = (AssetPicon *)src->values[i];
+                       AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
+                       if( use_mtime ? item1->mtime > item2->mtime :
+                           strcmp(item1->get_text(), item2->get_text()) > 0 ) {
                                src->values[i + 1] = item1;
                                src->values[i] = item2;
-                               done = 0;
+                               done = 0;  changed = 1;
                        }
                }
        }
+       if( changed ) {
+               for( int i=0; i<src->total; ++i ) {
+                       AssetPicon *item = (AssetPicon *)src->values[i];
+                       item->set_autoplace_icon(1);
+                       item->set_autoplace_text(1);
+               }
+       }
 }
 
 
@@ -1543,7 +1560,7 @@ int AWindowAssets::button_press_event()
                        break;
                case AW_MEDIA_FOLDER:
                case AW_PROXY_FOLDER:
-                       gui->assetlist_menu->update_titles();
+                       gui->assetlist_menu->update_titles(folder==AW_MEDIA_FOLDER);
                        gui->assetlist_menu->activate_menu();
                        break;
                }
@@ -2122,7 +2139,7 @@ AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
 
 int AWindowListSort::handle_event()
 {
-       gui->sort_assets();
+       gui->sort_assets(0);
        return 1;
 }