sams latest icons, rework proxy settings
[goodguy/history.git] / cinelerra-5.1 / cinelerra / awindowgui.C
index ba047200dc5e3115375624660dc1a63916f9d964..8b9a3ff4d2b55376048421541bdbd466c75c1f42 100644 (file)
 #include "assetpopup.h"
 #include "assets.h"
 #include "awindowgui.h"
-#include "awindowgui.inc"
 #include "awindow.h"
-#include "awindowmenu.h"
 #include "bcsignals.h"
 #include "bchash.h"
 #include "cache.h"
 #include "bccmodels.h"
+#include "clippopup.h"
 #include "cursors.h"
 #include "cwindowgui.h"
 #include "cwindow.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "effectlist.h"
 #include "file.h"
 #include "filesystem.h"
+#include "folderlistmenu.h"
 #include "indexable.h"
 #include "keys.h"
 #include "language.h"
 #include "labels.h"
-#include "labeledit.h"
+#include "labelpopup.h"
 #include "localsession.h"
 #include "mainmenu.h"
 #include "mainsession.h"
 #include<fcntl.h>
 
 
+const char *AWindowGUI::folder_names[] =
+{
+       N_("Audio Effects"),
+       N_("Video Effects"),
+       N_("Audio Transitions"),
+       N_("Video Transitions"),
+       N_("Labels"),
+       N_("Clips"),
+       N_("Media"),
+       N_("Proxy"),
+       N_("User"),
+};
+
 
 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
  : VIcon(w, h, framerate)
@@ -150,11 +164,22 @@ AssetPicon::AssetPicon(MWindow *mwindow,
 }
 
 AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui,
-       const char *folder)
- : BC_ListBoxItem(folder, gui->folder_icon)
+       AWindowGUI *gui, int folder, int persist)
+ : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]), gui->folder_icon)
+{
+       reset();
+       foldernum = folder;
+       this->mwindow = mwindow;
+       this->gui = gui;
+       persistent = persist;
+}
+
+AssetPicon::AssetPicon(MWindow *mwindow,
+       AWindowGUI *gui, const char *folder_name, int folder_num)
+ : BC_ListBoxItem(folder_name, gui->folder_icon)
 {
        reset();
+       foldernum = folder_num;
        this->mwindow = mwindow;
        this->gui = gui;
 }
@@ -189,8 +214,8 @@ AssetPicon::~AssetPicon()
 {
        if( vicon )
                gui->vicon_thread->del_vicon(vicon);
-       if(indexable) indexable->remove_user();
-       if(edl) edl->remove_user();
+       if( indexable ) indexable->remove_user();
+       if( edl ) edl->remove_user();
        if( icon && !gui->protected_pixmap(icon) ) {
                delete icon;
                if( !plugin ) delete icon_vframe;
@@ -220,53 +245,50 @@ void AssetPicon::create_objects()
 
        pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
 
-       if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
-       if(indexable)
-       {
+       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
+       if( indexable ) {
                fs.extract_name(name, indexable->path);
                set_text(name);
        }
 
-       if(indexable && indexable->is_asset)
-       {
-               if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+       if( indexable && indexable->is_asset ) {
+               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
                Asset *asset = (Asset*)indexable;
-               if(asset->video_data)
-               {
-                       if(mwindow->preferences->use_thumbnails)
-                       {
+               if( asset->video_data ) {
+                       if( mwindow->preferences->use_thumbnails ) {
                                gui->unlock_window();
-                               if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+                               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
                                File *file = mwindow->video_cache->check_out(asset,
                                        mwindow->edl,
                                        1);
-                               if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+                               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
 
-                               if(file)
-                               {
+                               if( file ) {
                                        int height = asset->height > 0 ? asset->height : 1;
                                        pixmap_w = pixmap_h * asset->width / height;
 
                                        file->set_layer(0);
                                        file->set_video_position(0, 0);
 
-                                       if(gui->temp_picon &&
+                                       if( gui->temp_picon &&
                                                (gui->temp_picon->get_w() != asset->width ||
-                                               gui->temp_picon->get_h() != asset->height))
-                                       {
+                                               gui->temp_picon->get_h() != asset->height) ) {
                                                delete gui->temp_picon;
                                                gui->temp_picon = 0;
                                        }
 
-                                       if(!gui->temp_picon)
-                                       {
+                                       if( !gui->temp_picon ) {
                                                gui->temp_picon = new VFrame(0, -1,
                                                        asset->width, asset->height,
                                                        BC_RGB888, -1);
                                        }
-
+                                       { char string[BCTEXTLEN];
+                                       sprintf(string, _("Reading %s"), name);
+                                       mwindow->gui->lock_window("AssetPicon::create_objects");
+                                       mwindow->gui->show_message(string);
+                                       mwindow->gui->unlock_window(); }
                                        file->read_frame(gui->temp_picon);
-                                       if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+                                       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
                                        mwindow->video_cache->check_in(asset);
 
                                        gui->lock_window("AssetPicon::create_objects 1");
@@ -286,50 +308,44 @@ void AssetPicon::create_objects()
                                        int64_t length = secs * gui->vicon_thread->refresh_rate;
                                        vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
                                        gui->vicon_thread->add_vicon(vicon);
-                                       if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+                                       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
 
                                }
-                               else
-                               {
+                               else {
                                        gui->lock_window("AssetPicon::create_objects 2");
                                        icon = gui->video_icon;
                                        icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
                                }
                        }
-                       else
-                       {
+                       else {
                                icon = gui->video_icon;
                                icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
                        }
                }
                else
-               if(asset->audio_data)
-               {
+               if( asset->audio_data ) {
                        icon = gui->audio_icon;
                        icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
                }
 //printf("AssetPicon::create_objects 2\n");
 
-               if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
        }
        else
-       if(indexable && !indexable->is_asset)
-       {
+       if( indexable && !indexable->is_asset ) {
                icon = gui->video_icon;
                icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
        }
        else
-       if(edl)
-       {
+       if( edl ) {
 //printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title);
                set_text(strcpy(name, edl->local_session->clip_title));
                icon = gui->clip_icon;
                icon_vframe = mwindow->theme->get_image("clip_icon");
        }
        else
-       if(plugin)
-       {
-               strcpy(name, _(plugin->title));
+       if( plugin ) {
+               strcpy(name,  plugin->title);
                set_text(name);
                icon_vframe = plugin->get_picon();
                if( icon_vframe )
@@ -368,7 +384,7 @@ void AssetPicon::create_objects()
                }
        }
        else
-       if(label) {
+       if( label ) {
                Units::totext(name,
                              label->position,
                              mwindow->edl->session->time_format,
@@ -376,8 +392,8 @@ void AssetPicon::create_objects()
                              mwindow->edl->session->frame_rate,
                              mwindow->edl->session->frames_per_foot);
                set_text(name);
-               icon = gui->file_icon;
-               icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
+               icon = gui->label_icon;
+               icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_LABEL];
                set_icon(icon);
                set_icon_vframe(icon_vframe);
        }
@@ -388,7 +404,7 @@ void AssetPicon::create_objects()
        set_icon(icon);
        set_icon_vframe(icon_vframe);
 
-       if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
+       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
 }
 
 
@@ -414,6 +430,7 @@ AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
        video_icon = 0;
        folder_icon = 0;
        clip_icon = 0;
+       label_icon = 0;
        atransition_icon = 0;  atransition_vframe = 0;
        vtransition_icon = 0;  vtransition_vframe = 0;
        aeffect_icon = 0;      aeffect_vframe = 0;
@@ -424,13 +441,17 @@ AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
        plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
        newfolder_thread = 0;
        asset_menu = 0;
+       effectlist_menu = 0;
        assetlist_menu = 0;
+       cliplist_menu = 0;
+       labellist_menu = 0;
        folderlist_menu = 0;
        temp_picon = 0;
        allow_iconlisting = 1;
        remove_plugin = 0;
        vicon_thread = 0;
        vicon_drawing = 1;
+       displayed_folder = AW_NO_FOLDER;
 }
 
 AWindowGUI::~AWindowGUI()
@@ -445,27 +466,29 @@ AWindowGUI::~AWindowGUI()
        displayed_assets[1].remove_all_objects();
 
        delete vicon_thread;
-       delete file_icon;
-       delete audio_icon;
-       delete video_icon;
-       delete folder_icon;
-       delete clip_icon;
-       delete atransition_icon;
-       delete vtransition_icon;
-       delete aeffect_icon;
-       delete ladspa_icon;
-       delete ladspa_vframe;
-       delete ff_aud_icon;
-       delete ff_aud_vframe;
-       delete ff_vid_icon;
-       delete ff_vid_vframe;
-       delete veffect_icon;
+       delete file_icon;         delete file_res;
+       delete audio_icon;        delete audio_res;
+       delete video_icon;        delete video_res;
+       delete folder_icon;       delete folder_res;
+       delete clip_icon;         delete clip_res;
+       delete label_icon;        delete label_res;
+       delete atransition_icon;  delete atrans_res;
+       delete vtransition_icon;  delete vtrans_res;
+       delete aeffect_icon;      delete aeffect_res;
+       delete veffect_icon;      delete veffect_res;
+       delete ladspa_icon;       delete ladspa_res;
+       delete ff_aud_icon;       delete ff_aud_res;
+       delete ff_vid_icon;       delete ff_vid_res;
        delete newfolder_thread;
        delete asset_menu;
+       delete clip_menu;
        delete label_menu;
+       delete effectlist_menu;
        delete assetlist_menu;
+       delete cliplist_menu;
+       delete labellist_menu;
        delete folderlist_menu;
-       if(temp_picon) delete temp_picon;
+       delete temp_picon;
        delete remove_plugin;
 }
 
@@ -476,6 +499,7 @@ bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
                icon == audio_icon ||
                icon == video_icon ||
                icon == clip_icon ||
+               icon == label_icon ||
                icon == vtransition_icon ||
                icon == atransition_icon ||
                icon == veffect_icon ||
@@ -485,10 +509,46 @@ bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
                icon == ff_vid_icon;
 }
 
-void AWindowGUI::create_objects()
+VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
+{
+       char png_path[BCTEXTLEN];
+       char *pp = png_path, *ep = pp + sizeof(png_path)-1;
+       snprintf(pp, ep-pp, "%s/picon_%s/%s.png",
+               File::get_plugin_path(), plugin_icons, name);
+       return VFramePng::vframe_png(png_path,0,0);
+}
+
+VFrame *AWindowGUI::get_picon(const char *name)
+{
+       VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
+       if( !vframe ) vframe = get_picon(name, DEFAULT_PICON);
+       return vframe;
+}
+
+VFrame *AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
+{
+       VFrame *ret = vfrm = get_picon(fn);
+       if( !ret ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
+       icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
+       return ret;
+}
+VFrame *AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
 {
-       AssetPicon *picon;
+       VFrame *ret = vfrm = get_picon(fn);
+       if( !ret ) vfrm = mwindow->theme->get_image(fn);
+       icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
+       return ret;
+}
+VFrame *AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
+{
+       VFrame *ret = vfrm = get_picon(fn);
+       if( !ret ) vfrm = new VFramePng(png);
+       icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
+       return vfrm;
+}
 
+void AWindowGUI::create_objects()
+{
        lock_window("AWindowGUI::create_objects");
 SET_TRACE
 //printf("AWindowGUI::create_objects 1\n");
@@ -496,60 +556,35 @@ SET_TRACE
        asset_titles[1] = _("Comments");
 
 SET_TRACE
-
        set_icon(mwindow->theme->get_image("awindow_icon"));
-       file_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
-               PIXMAP_ALPHA);
-
-       folder_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
-               PIXMAP_ALPHA);
 
-       audio_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
-               PIXMAP_ALPHA);
+       file_res    = resource_icon(file_vframe,   file_icon,   "film_icon",   ICON_UNKNOWN);
+       folder_res  = resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
+       audio_res   = resource_icon(audio_vframe,  audio_icon,  "audio_icon",  ICON_SOUND);
+       video_res   = resource_icon(video_vframe,  video_icon,  "video_icon",  ICON_FILM);
+       label_res   = resource_icon(label_vframe,  label_icon,  "label_icon",  ICON_LABEL);
 
-       video_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
-               PIXMAP_ALPHA);
+       clip_res    = theme_icon(clip_vframe,        clip_icon,        "clip_icon");
+       atrans_res  = theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
+       vtrans_res  = theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
+       aeffect_res = theme_icon(aeffect_vframe,     aeffect_icon,     "aeffect_icon");
+       veffect_res = theme_icon(veffect_vframe,     veffect_icon,     "veffect_icon");
 
-SET_TRACE
-
-       clip_vframe = mwindow->theme->get_image("clip_icon");
-       clip_icon = new BC_Pixmap(this, clip_vframe, PIXMAP_ALPHA);
-       atransition_vframe = mwindow->theme->get_image("atransition_icon");
-       atransition_icon = new BC_Pixmap(this, atransition_vframe, PIXMAP_ALPHA);
-       vtransition_vframe = mwindow->theme->get_image("vtransition_icon");
-       vtransition_icon = new BC_Pixmap(this, vtransition_vframe, PIXMAP_ALPHA);
-       aeffect_vframe = mwindow->theme->get_image("aeffect_icon");
-       aeffect_icon = new BC_Pixmap(this, aeffect_vframe, PIXMAP_ALPHA);
-       ladspa_vframe = new VFramePng(lad_picon_png);
-       ladspa_icon = new BC_Pixmap(this, ladspa_vframe, PIXMAP_ALPHA);
-       ff_aud_vframe = new VFramePng(ff_audio_png);
-       ff_aud_icon = new BC_Pixmap(this, ff_aud_vframe, PIXMAP_ALPHA);
-       ff_vid_vframe = new VFramePng(ff_video_png);
-       ff_vid_icon = new BC_Pixmap(this, ff_vid_vframe, PIXMAP_ALPHA);
-       veffect_vframe = mwindow->theme->get_image("veffect_icon");
-       veffect_icon = new BC_Pixmap(this, veffect_vframe, PIXMAP_ALPHA);
+       ladspa_res  = plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
+       ff_aud_res  = plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio",  ff_audio_png);
+       ff_vid_res  = plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video",  ff_video_png);
 
 SET_TRACE
 
 // Mandatory folders
-       folders.append(picon = new AssetPicon(mwindow, this, AEFFECT_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, VEFFECT_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, ATRANSITION_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, VTRANSITION_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, LABEL_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, CLIP_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, MEDIA_FOLDER));
-       picon->persistent = 1;
+       folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
 
        create_label_folder();
 SET_TRACE
@@ -604,24 +639,26 @@ SET_TRACE
 
        add_subwindow(asset_menu = new AssetPopup(mwindow, this));
        asset_menu->create_objects();
-
+       add_subwindow(clip_menu = new ClipPopup(mwindow, this));
+       clip_menu->create_objects();
        add_subwindow(label_menu = new LabelPopup(mwindow, this));
        label_menu->create_objects();
 
-SET_TRACE
-
+       add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
+       effectlist_menu->create_objects();
        add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
-
-SET_TRACE
        assetlist_menu->create_objects();
-
+       add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
+       cliplist_menu->create_objects();
+       add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
+       labellist_menu->create_objects();
 SET_TRACE
 
        add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
        folderlist_menu->create_objects();
+SET_TRACE
 //printf("AWindowGUI::create_objects 2\n");
 
-SET_TRACE
        create_custom_xatoms();
        unlock_window();
 }
@@ -719,7 +756,7 @@ int AWindowGUI::close_event()
 void AWindowGUI::start_vicon_drawing()
 {
        if( !vicon_drawing ) return;
-       if( strcmp(mwindow->edl->session->current_folder, MEDIA_FOLDER) ) return;
+       if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
        if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
        vicon_thread->start_drawing();
 }
@@ -801,13 +838,21 @@ void AWindowRemovePlugin::handle_close_event(int result)
                mwindow->plugindb->remove(plugin);
                remove(plugin_path);
                char index_path[BCTEXTLEN];
-               sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE);
+               snprintf(index_path, sizeof(index_path), "%s/%s",
+                       mwindow->preferences->plugin_dir, PLUGIN_FILE);
                remove(index_path);
-               char png_path[BCTEXTLEN];
-               if( plugin->get_theme_png_path(png_path, mwindow->preferences->theme) )
-                       remove(png_path);
-               if( plugin->get_theme_png_path(png_path, "picon") )
-                       remove(png_path);
+               FileSystem fs;
+               fs.update(File::get_plugin_path());
+               for( int i=0; i<fs.dir_list.total; ++i ) {
+                       char *fs_path = fs.dir_list[i]->path;
+                       if( !fs.is_dir(fs_path) ) continue;
+                       char *cp = strrchr(fs_path,'/');
+                       cp = !cp ? fs_path : cp+1;
+                       if( strncmp("picon_", cp, 6) ) continue;
+                       char png_path[BCTEXTLEN];
+                       if( !plugin->get_plugin_png_path(png_path, cp+6) )
+                               remove(png_path);
+               }
                delete plugin;  plugin = 0;
                awindow->gui->async_update_assets();
        }
@@ -838,15 +883,15 @@ BC_Window* AWindowRemovePlugin::new_gui()
 
 int AWindowGUI::keypress_event()
 {
-       switch(get_keypress()) {
+       switch( get_keypress() ) {
        case 'w': case 'W':
-               if(ctrl_down()) {
+               if( ctrl_down() ) {
                        close_event();
                        return 1;
                }
                break;
        case DELETE:
-               if(shift_down()) {
+               if( shift_down() ) {
                        PluginServer* plugin = selected_plugin();
                        if( !plugin ) break;
                        remove_plugin = new AWindowRemovePlugin(awindow, plugin);
@@ -891,54 +936,50 @@ void AWindowGUI::update_folder_list()
 {
        stop_vicon_drawing();
 //printf("AWindowGUI::update_folder_list 1\n");
-       for(int i = 0; i < folders.total; i++)
-       {
+       for( int i = 0; i < folders.total; i++ ) {
                AssetPicon *picon = (AssetPicon*)folders.values[i];
                picon->in_use--;
        }
 //printf("AWindowGUI::update_folder_list 1\n");
 
 // Search assets for folders
-       for(int i = 0; i < mwindow->edl->folders.total; i++)
-       {
-               char *folder = mwindow->edl->folders.values[i];
+       for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
+               const char *folder = mwindow->edl->folders.values[i];
                int exists = 0;
 //printf("AWindowGUI::update_folder_list 1.1\n");
 
-               for(int j = 0; j < folders.total; j++)
-               {
+               for( int j = 0; j < folders.total; j++ ) {
                        AssetPicon *picon = (AssetPicon*)folders.values[j];
-                       if(!strcasecmp(picon->get_text(), folder))
-                       {
+                       if( !strcasecmp(picon->get_text(), folder) ) {
                                exists = 1;
                                picon->in_use = 1;
                                break;
                        }
                }
 
-               if(!exists)
-               {
-                       AssetPicon *picon = new AssetPicon(mwindow, this, folder);
+               if( !exists ) {
+                       int aw_folder = folder_number(folder);
+                       AssetPicon *picon = aw_folder >= 0 ?
+                               new AssetPicon(mwindow, this, aw_folder, 0) :
+                               new AssetPicon(mwindow, this, folder, AW_USER_FOLDER);
                        picon->create_objects();
                        folders.append(picon);
                }
 //printf("AWindowGUI::update_folder_list 1.3\n");
        }
 //printf("AWindowGUI::update_folder_list 1\n");
-//for(int i = 0; i < folders.total; i++)
+//for( int i = 0; i < folders.total; i++ )
 //     printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
 
 // Delete excess
-       for(int i = folders.total - 1; i >= 0; i--)
-       {
+       for( int i=folders.total; --i>=0; ) {
                AssetPicon *picon = (AssetPicon*)folders.values[i];
-               if(!picon->in_use && !picon->persistent)
-               {
+               if( !picon->in_use && !picon->persistent ) {
                        delete picon;
                        folders.remove_number(i);
                }
        }
-//for(int i = 0; i < folders.total; i++)
+//for( int i = 0; i < folders.total; i++ )
 //     printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
 //printf("AWindowGUI::update_folder_list 2\n");
        start_vicon_drawing();
@@ -952,10 +993,10 @@ void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
        mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
                        0, plugin_list);
 
-       for(int i = 0; i < plugin_list.total; i++) {
+       for( int i = 0; i < plugin_list.total; i++ ) {
                PluginServer *server = plugin_list.values[i];
                int visible = plugin_visibility & (1<<server->dir_idx);
-               if(!visible) continue;
+               if( !visible ) continue;
 // Create new listitem
                AssetPicon *picon = new AssetPicon(mwindow, this, server);
                picon->create_objects();
@@ -966,7 +1007,7 @@ void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
 void AWindowGUI::create_label_folder()
 {
        Label *current;
-       for(current = mwindow->edl->labels->first; current; current = NEXT) {
+       for( current = mwindow->edl->labels->first; current; current = NEXT ) {
                AssetPicon *picon = new AssetPicon(mwindow, this, current);
                picon->create_objects();
                labellist.append(picon);
@@ -977,8 +1018,7 @@ void AWindowGUI::create_label_folder()
 void AWindowGUI::update_asset_list()
 {
 //printf("AWindowGUI::update_asset_list 1\n");
-       for(int i = 0; i < assets.total; i++)
-       {
+       for( int i = 0; i < assets.total; i++ ) {
                AssetPicon *picon = (AssetPicon*)assets.values[i];
                picon->in_use--;
        }
@@ -991,17 +1031,14 @@ void AWindowGUI::update_asset_list()
 
 
 // Synchronize EDL clips
-       for(int i = 0; i < mwindow->edl->clips.total; i++)
-       {
+       for( int i = 0; i < mwindow->edl->clips.total; i++ ) {
                int exists = 0;
 
 // Look for clip in existing listitems
-               for(int j = 0; j < assets.total && !exists; j++)
-               {
+               for( int j = 0; j < assets.total && !exists; j++ ) {
                        AssetPicon *picon = (AssetPicon*)assets.values[j];
 
-                       if(picon->id == mwindow->edl->clips.values[i]->id)
-                       {
+                       if( picon->id == mwindow->edl->clips.values[i]->id ) {
                                picon->edl = mwindow->edl->clips.values[i];
                                picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
                                exists = 1;
@@ -1010,8 +1047,7 @@ void AWindowGUI::update_asset_list()
                }
 
 // Create new listitem
-               if(!exists)
-               {
+               if( !exists ) {
                        AssetPicon *picon = new AssetPicon(mwindow,
                                this,
                                mwindow->edl->clips.values[i]);
@@ -1028,19 +1064,16 @@ void AWindowGUI::update_asset_list()
 
 
 // Synchronize EDL assets
-       for(Asset *current = mwindow->edl->assets->first;
+       for( Asset *current = mwindow->edl->assets->first;
                current;
-               current = NEXT)
-       {
+               current = NEXT ) {
                int exists = 0;
 
 // Look for asset in existing listitems
-               for(int j = 0; j < assets.total && !exists; j++)
-               {
+               for( int j = 0; j < assets.total && !exists; j++ ) {
                        AssetPicon *picon = (AssetPicon*)assets.values[j];
 
-                       if(picon->id == current->id)
-                       {
+                       if( picon->id == current->id ) {
                                picon->indexable = current;
                                exists = 1;
                                picon->in_use = 1;
@@ -1049,8 +1082,7 @@ void AWindowGUI::update_asset_list()
                }
 
 // Create new listitem
-               if(!exists)
-               {
+               if( !exists ) {
 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
                        AssetPicon *picon = new AssetPicon(mwindow, this, current);
 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
@@ -1060,24 +1092,23 @@ void AWindowGUI::update_asset_list()
                }
        }
 
-
+       mwindow->gui->lock_window("AWindowGUI::update_asset_list");
+       mwindow->gui->default_message();
+       mwindow->gui->unlock_window();
 
 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
 
 
 // Synchronize nested EDLs
-       for(int i = 0; i < mwindow->edl->nested_edls->size(); i++)
-       {
+       for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) {
                int exists = 0;
                Indexable *indexable = mwindow->edl->nested_edls->get(i);
 
 // Look for asset in existing listitems
-               for(int j = 0; j < assets.total && !exists; j++)
-               {
+               for( int j = 0; j < assets.total && !exists; j++ ) {
                        AssetPicon *picon = (AssetPicon*)assets.values[j];
 
-                       if(picon->id == indexable->id)
-                       {
+                       if( picon->id == indexable->id ) {
                                picon->indexable = indexable;
                                exists = 1;
                                picon->in_use = 1;
@@ -1086,8 +1117,7 @@ void AWindowGUI::update_asset_list()
                }
 
 // Create new listitem
-               if(!exists)
-               {
+               if( !exists ) {
                        AssetPicon *picon = new AssetPicon(mwindow,
                                this,
                                indexable);
@@ -1105,12 +1135,10 @@ void AWindowGUI::update_asset_list()
 
 
 //printf("AWindowGUI::update_asset_list %d\n", __LINE__);
-       for(int i = assets.size() - 1; i >= 0; i--)
-       {
+       for( int i = assets.size() - 1; i >= 0; i-- ) {
                AssetPicon *picon = (AssetPicon*)assets.get(i);
 //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
-               if(!picon->in_use)
-               {
+               if( !picon->in_use ) {
                        delete picon;
                        assets.remove_number(i);
                }
@@ -1118,48 +1146,56 @@ void AWindowGUI::update_asset_list()
 //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
 }
 
-
-
-
+void AWindowGUI::update_picon(Indexable *indexable)
+{
+//printf("AWindowGUI::update_asset_list 1\n");
+       VIcon *vicon = 0;
+       for( int i = 0; i < assets.total; i++ ) {
+               AssetPicon *picon = (AssetPicon*)assets.values[i];
+               if( picon->indexable == indexable ||
+                   picon->edl == (EDL *)indexable ) {
+                       char name[BCTEXTLEN];
+                       FileSystem fs;
+                       fs.extract_name(name, indexable->path);
+                       picon->set_text(name);
+                       vicon = picon->vicon;
+                       break;
+               }
+       }
+       if( vicon ) {
+               stop_vicon_drawing();
+               vicon->clear_images();
+               vicon->reset(indexable->get_frame_rate());
+               start_vicon_drawing();
+       }
+}
 
 void AWindowGUI::sort_assets()
 {
 //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
-       if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
-               sort_picons(&aeffects,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
-               sort_picons(&veffects,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
-               sort_picons(&atransitions,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
-               sort_picons(&vtransitions,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
-               ;// Labels should ALWAYS be sorted by time.
-       else
-               sort_picons(&assets,
-                       mwindow->edl->session->current_folder);
+       switch( mwindow->edl->session->awindow_folder ) {
+       case AW_AEFFECT_FOLDER:
+               sort_picons(&aeffects);
+               break;
+       case AW_VEFFECT_FOLDER:
+               sort_picons(&veffects);
+               break;
+       case AW_ATRANSITION_FOLDER:
+               sort_picons(&atransitions);
+               break;
+       case AW_VTRANSITION_FOLDER:
+               sort_picons(&vtransitions);
+               break;
+       case AW_LABEL_FOLDER:
+               sort_picons(&labellist);
+               break;
+       default:
+               sort_picons(&assets);
+       }
 
        update_assets();
 }
 
-
-
-
-
-
-
-
-
-
-
 void AWindowGUI::collect_assets()
 {
        int i = 0;
@@ -1168,37 +1204,34 @@ void AWindowGUI::collect_assets()
        while(1)
        {
                AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
-               if(!result) break;
+               if( !result ) break;
 
-               if(result->indexable) mwindow->session->drag_assets->append(result->indexable);
-               if(result->edl) mwindow->session->drag_clips->append(result->edl);
+               if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
+               if( result->edl ) mwindow->session->drag_clips->append(result->edl);
        }
 }
 
 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
-       ArrayList<BC_ListBoxItem*> *src,
-       char *folder)
+       ArrayList<BC_ListBoxItem*> *src, int folder)
 {
 // Remove current pointers
        dst[0].remove_all();
        dst[1].remove_all_objects();
 
 // Create new pointers
-//if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder);
-       for(int i = 0; i < src->total; i++)
-       {
+//if( folder ) printf("AWindowGUI::copy_picons 1 %s\n", folder);
+       for( int i = 0; i < src->total; i++ ) {
                AssetPicon *picon = (AssetPicon*)src->values[i];
 //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
-               if(!folder ||
-                       (folder && picon->indexable && !strcasecmp(picon->indexable->folder, folder)) ||
-                       (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
-               {
+               if( folder < 0 ||
+                   (picon->indexable && picon->indexable->awindow_folder == folder) ||
+                   (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
                        BC_ListBoxItem *item2, *item1;
                        dst[0].append(item1 = picon);
-                       if(picon->edl)
+                       if( picon->edl )
                                dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
                        else
-                       if(picon->label && picon->label->textstr)
+                       if( picon->label && picon->label->textstr )
                                dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
                        else
                                dst[1].append(item2 = new BC_ListBoxItem(""));
@@ -1209,24 +1242,21 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
        }
 }
 
-void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src,
-               char *folder)
+void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
 {
 //printf("AWindowGUI::sort_picons 1\n")
        int done = 0;
        while(!done)
        {
                done = 1;
-               for(int i = 0; i < src->total - 1; i++)
-               {
+               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)
-                       {
+                       if( strcmp(item1->get_text(), item2->get_text()) > 0 ) {
                                src->values[i + 1] = item1;
                                src->values[i] = item2;
                                done = 0;
@@ -1238,48 +1268,40 @@ void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src,
 
 void AWindowGUI::filter_displayed_assets()
 {
-       allow_iconlisting = 1;
+       //allow_iconlisting = 1;
        asset_titles[0] = _("Title");
        asset_titles[1] = _("Comments");
-       if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
-               copy_picons(displayed_assets,
-                       &aeffects,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
-               copy_picons(displayed_assets,
-                       &veffects,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
-               copy_picons(displayed_assets,
-                       &atransitions,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
-               copy_picons(displayed_assets,
-                       &vtransitions,
-                       0);
-       else
-       if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER)) {
-               copy_picons(displayed_assets,
-                           &labellist,
-                           0);
+
+       switch( mwindow->edl->session->awindow_folder ) {
+       case AW_AEFFECT_FOLDER:
+               copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
+               break;
+       case AW_VEFFECT_FOLDER:
+               copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
+               break;
+       case AW_ATRANSITION_FOLDER:
+               copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
+               break;
+       case AW_VTRANSITION_FOLDER:
+               copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
+               break;
+       case AW_LABEL_FOLDER:
+               copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
                asset_titles[0] = _("Time Stamps");
                asset_titles[1] = _("Title");
-               allow_iconlisting = 0;
+               //allow_iconlisting = 0;
+               break;
+       default:
+               copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
+               break;
        }
-       else
-               copy_picons(displayed_assets,
-                       &assets,
-                       mwindow->edl->session->current_folder);
+
        // Ensure the current folder icon is highlighted
-       for(int i = 0; i < folders.total; i++)
-       {
-               if(!strcasecmp(mwindow->edl->session->current_folder, folders.values[i]->get_text()))
-                       folders.values[i]->set_selected(1);
-               else
-                       folders.values[i]->set_selected(0);
+       int selected_folder = mwindow->edl->session->awindow_folder;
+       for( int i = 0; i < folders.total; i++ ) {
+               AssetPicon *folder_item = (AssetPicon *)folders.values[i];
+               int selected = folder_item->foldernum == selected_folder ? 1 : 0;
+               folder_item->set_selected(selected);
        }
 }
 
@@ -1295,33 +1317,27 @@ void AWindowGUI::update_assets()
 //printf("AWindowGUI::update_assets 3\n");
        filter_displayed_assets();
 
-//for(int i = 0; i < folders.total; i++)
 //printf("AWindowGUI::update_assets 4\n");
-//     printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
-       if(mwindow->edl->session->folderlist_format != folder_list->get_format())
+       if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
                folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
-       folder_list->update(&folders,
-               0,
-               0,
-               1,
-               folder_list->get_xposition(),
-               folder_list->get_yposition(),
-               -1);
-//printf("AWindowGUI::update_assets 5\n");
+       }
+       int folder_xposition = folder_list->get_xposition();
+       int folder_yposition = folder_list->get_yposition();
+       folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
 
-       if(mwindow->edl->session->assetlist_format != asset_list->get_format())
+//printf("AWindowGUI::update_assets 5\n");
+       if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
                asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
-
-
-//printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
-       asset_list->update(displayed_assets,
-               asset_titles,
-               mwindow->edl->session->asset_columns,
-               ASSET_COLUMNS,
-               asset_list->get_xposition(),
-               asset_list->get_yposition(),
-               -1,
-               0);
+       }
+       int asset_xposition = asset_list->get_xposition();
+       int asset_yposition = asset_list->get_yposition();
+       if( displayed_folder != mwindow->edl->session->awindow_folder ) {
+               displayed_folder = mwindow->edl->session->awindow_folder;
+               asset_xposition = asset_yposition = 0;
+       }
+       asset_list->update(displayed_assets, asset_titles,
+               mwindow->edl->session->asset_columns, ASSET_COLUMNS,
+               asset_xposition, asset_yposition, -1, 0);
        asset_list->center_selection();
 //printf("AWindowGUI::update_assets 7\n");
 
@@ -1342,23 +1358,17 @@ void AWindowGUI::update_effects()
        create_persistent_folder(&vtransitions, 0, 1, 0, 1);
 }
 
-int AWindowGUI::current_folder_number()
+int AWindowGUI::folder_number(const char *name)
 {
-       int result = -1;
-       for(int i = 0; i < folders.total; i++)
-       {
-               if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
-               {
-                       result = i;
-                       break;
-               }
+       for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
+               if( !strcasecmp(name, folder_names[i]) ) return i;
        }
-       return result;
+       return AW_NO_FOLDER;
 }
 
 int AWindowGUI::drag_motion()
 {
-       if(get_hidden()) return 0;
+       if( get_hidden() ) return 0;
 
        int result = 0;
        return result;
@@ -1366,7 +1376,7 @@ int AWindowGUI::drag_motion()
 
 int AWindowGUI::drag_stop()
 {
-       if(get_hidden()) return 0;
+       if( get_hidden() ) return 0;
 
        return 0;
 }
@@ -1408,8 +1418,7 @@ AWindowDivider::~AWindowDivider()
 
 int AWindowDivider::button_press_event()
 {
-       if(is_event_win() && cursor_inside())
-       {
+       if( is_event_win() && cursor_inside() ) {
                mwindow->session->current_operation = DRAG_PARTITION;
                return 1;
        }
@@ -1418,8 +1427,7 @@ int AWindowDivider::button_press_event()
 
 int AWindowDivider::cursor_motion_event()
 {
-       if(mwindow->session->current_operation == DRAG_PARTITION)
-       {
+       if( mwindow->session->current_operation == DRAG_PARTITION ) {
                int wmin = 25;
                int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
                int fw = gui->get_relative_cursor_x();
@@ -1435,8 +1443,7 @@ int AWindowDivider::cursor_motion_event()
 
 int AWindowDivider::button_release_event()
 {
-       if(mwindow->session->current_operation == DRAG_PARTITION)
-       {
+       if( mwindow->session->current_operation == DRAG_PARTITION ) {
                mwindow->session->current_operation = NO_OPERATION;
                return 1;
        }
@@ -1449,21 +1456,18 @@ int AWindowDivider::button_release_event()
 
 
 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
- : BC_ListBox(x,
-               y,
-               w,
-               h,
+ : BC_ListBox(x, y, w, h,
                mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
                        LISTBOX_ICONS : LISTBOX_TEXT,
-               &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
-               0,             // Titles for columns.  Set to 0 for no titles
+               &gui->folders,    // Each column has an ArrayList of BC_ListBoxItems.
+               0,                // Titles for columns.  Set to 0 for no titles
                0,                // width of each column
-               1,                      // Total columns.
-               0,                    // Pixel of top of window.
-               0,                        // If this listbox is a popup window
-               LISTBOX_SINGLE,  // Select one item or multiple items
-               ICON_TOP,        // Position of icon relative to text of each item
-               1)               // Allow drags
+               1,                // Total columns.
+               0,                // Pixel of top of window.
+               0,                // If this listbox is a popup window
+               LISTBOX_SINGLE,   // Select one item or multiple items
+               ICON_TOP,         // Position of icon relative to text of each item
+               1)                // Allow drags
 {
        this->mwindow = mwindow;
        this->gui = gui;
@@ -1477,17 +1481,15 @@ AWindowFolders::~AWindowFolders()
 int AWindowFolders::selection_changed()
 {
        AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
-       if(picon)
-       {
+       if( picon ) {
                gui->stop_vicon_drawing();
 
-               if(get_button_down() && get_buttonpress() == 3)
-               {
+               if( get_button_down() && get_buttonpress() == 3 ) {
                        gui->folderlist_menu->update_titles();
                        gui->folderlist_menu->activate_menu();
                }
 
-               strcpy(mwindow->edl->session->current_folder, picon->get_text());
+               mwindow->edl->session->awindow_folder =  picon->foldernum;
 //printf("AWindowFolders::selection_changed 1\n");
                gui->asset_list->draw_background();
                gui->async_update_assets();
@@ -1503,10 +1505,8 @@ int AWindowFolders::button_press_event()
 
        result = BC_ListBox::button_press_event();
 
-       if(!result)
-       {
-               if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
-               {
+       if( !result ) {
+               if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
                        gui->folderlist_menu->update_titles();
                        gui->folderlist_menu->activate_menu();
                        result = 1;
@@ -1524,25 +1524,23 @@ int AWindowFolders::button_press_event()
 
 
 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
- : BC_ListBox(x,
-               y,
-               w,
-               h,
+ : BC_ListBox(x, y, w, h,
                (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
                        LISTBOX_ICONS : LISTBOX_TEXT,
                &gui->assets,     // Each column has an ArrayList of BC_ListBoxItems.
-               gui->asset_titles,             // Titles for columns.  Set to 0 for no titles
-               mwindow->edl->session->asset_columns,                // width of each column
-               1,                      // Total columns.
-               0,                    // Pixel of top of window.
-               0,                        // If this listbox is a popup window
-               LISTBOX_MULTIPLE,  // Select one item or multiple items
-               ICON_TOP,        // Position of icon relative to text of each item
-               1)               // Allow drag
+               gui->asset_titles,// Titles for columns.  Set to 0 for no titles
+               mwindow->edl->session->asset_columns, // width of each column
+               1,                // Total columns.
+               0,                // Pixel of top of window.
+               0,                // If this listbox is a popup window
+               LISTBOX_MULTIPLE, // Select one item or multiple items
+               ICON_TOP,         // Position of icon relative to text of each item
+               1)                // Allow drag
 {
        this->mwindow = mwindow;
        this->gui = gui;
        set_drag_scroll(0);
+       set_scroll_stretch(1, 1);
 }
 
 AWindowAssets::~AWindowAssets()
@@ -1555,15 +1553,34 @@ int AWindowAssets::button_press_event()
 
        result = BC_ListBox::button_press_event();
 
-       if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
-       {
+       if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
                BC_ListBox::deactivate_selection();
-               gui->assetlist_menu->update_titles();
-               gui->assetlist_menu->activate_menu();
+               int folder = mwindow->edl->session->awindow_folder;
+               switch( folder ) {
+               case AW_AEFFECT_FOLDER:
+               case AW_VEFFECT_FOLDER:
+               case AW_ATRANSITION_FOLDER:
+               case AW_VTRANSITION_FOLDER:
+                       gui->effectlist_menu->update();
+                       gui->effectlist_menu->activate_menu();
+                       break;
+               case AW_LABEL_FOLDER:
+                       gui->labellist_menu->update();
+                       gui->labellist_menu->activate_menu();
+                       break;
+               case AW_CLIP_FOLDER:
+                       gui->cliplist_menu->update();
+                       gui->cliplist_menu->activate_menu();
+                       break;
+               case AW_MEDIA_FOLDER:
+               case AW_PROXY_FOLDER:
+                       gui->assetlist_menu->update_titles();
+                       gui->assetlist_menu->activate_menu();
+                       break;
+               }
                result = 1;
        }
 
-
        return result;
 }
 
@@ -1573,11 +1590,12 @@ int AWindowAssets::handle_event()
 //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
        AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
        if( !asset_picon ) return 0;
-       const char *folder = mwindow->edl->session->current_folder;
-       if( !strcasecmp(folder, AEFFECT_FOLDER) ) return 1;
-       if( !strcasecmp(folder, VEFFECT_FOLDER) ) return 1;
-       if( !strcasecmp(folder, ATRANSITION_FOLDER) ) return 1;
-       if( !strcasecmp(folder, VTRANSITION_FOLDER) ) return 1;
+       switch( mwindow->edl->session->awindow_folder ) {
+       case AW_AEFFECT_FOLDER:
+       case AW_VEFFECT_FOLDER:
+       case AW_ATRANSITION_FOLDER:
+       case AW_VTRANSITION_FOLDER: return 1;
+       }
        VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
                mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
        if( !vwindow || !vwindow->is_running() ) return 1;
@@ -1595,43 +1613,42 @@ int AWindowAssets::handle_event()
 int AWindowAssets::selection_changed()
 {
 // Show popup window
-       if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
-       {
-               if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) ||
-                       !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
-                       !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
-                       !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
-               {
-                       gui->assetlist_menu->update_titles();
-                       gui->assetlist_menu->activate_menu();
-               }
-               else
-                if (!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
-               {
-                       if(((AssetPicon*)get_selection(0, 0))->label)
-                               gui->label_menu->activate_menu();
-               }
-               else
-               {
-                       if(((AssetPicon*)get_selection(0, 0))->indexable)
-                               gui->asset_menu->update();
-                       else
-                       if(((AssetPicon*)get_selection(0, 0))->edl)
-                               gui->asset_menu->update();
-
-
-
+       AssetPicon *item;
+       if( get_button_down() && get_buttonpress() == 3 &&
+           (item = (AssetPicon*)get_selection(0, 0)) ) {
+               int folder = mwindow->edl->session->awindow_folder;
+               switch( folder ) {
+               case AW_AEFFECT_FOLDER:
+               case AW_VEFFECT_FOLDER:
+               case AW_ATRANSITION_FOLDER:
+               case AW_VTRANSITION_FOLDER:
+                       gui->effectlist_menu->update();
+                       gui->effectlist_menu->activate_menu();
+                       break;
+               case AW_LABEL_FOLDER:
+                       if( !item->label ) break;
+                       gui->label_menu->activate_menu();
+                       break;
+               case AW_CLIP_FOLDER:
+                       if( !item->indexable && !item->edl ) break;
+                       gui->clip_menu->update();
+                       gui->clip_menu->activate_menu();
+                       break;
+               default:
+                       if( !item->indexable && !item->edl ) break;
+                       gui->asset_menu->update();
                        gui->asset_menu->activate_menu();
+                       break;
                }
 
                BC_ListBox::deactivate_selection();
                return 1;
        }
-       else if( get_button_down() && get_buttonpress() == 1 && get_selection(0, 0) ) {
+       else if( get_button_down() && get_buttonpress() == 1 &&
+                (item = (AssetPicon*)get_selection(0, 0)) ) {
                VIcon *vicon = 0;
                if( !gui->vicon_thread->viewing ) {
-                       AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
-                       vicon = picon->vicon;
+                       vicon = item->vicon;
                }
                gui->vicon_thread->set_view_popup(vicon);
 
@@ -1644,12 +1661,11 @@ void AWindowAssets::draw_background()
        clear_box(0,0,get_w(),get_h(),get_bg_surface());
        set_color(BC_WindowBase::get_resources()->audiovideo_color);
        set_font(LARGEFONT);
-       draw_text(get_w() -
-                       get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4,
-               30,
-               mwindow->edl->session->current_folder,
-               -1,
-               get_bg_surface());
+       int aw_folder = mwindow->edl->session->awindow_folder;
+       if( aw_folder < 0 ) return;
+       const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
+       draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
+               aw_name, -1, get_bg_surface());
 }
 
 int AWindowAssets::drag_start_event()
@@ -1657,58 +1673,46 @@ int AWindowAssets::drag_start_event()
        int collect_pluginservers = 0;
        int collect_assets = 0;
 
-       if(BC_ListBox::drag_start_event())
-       {
-               if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
-               {
+       if( BC_ListBox::drag_start_event() ) {
+               switch( mwindow->edl->session->awindow_folder ) {
+               case AW_AEFFECT_FOLDER:
                        mwindow->session->current_operation = DRAG_AEFFECT;
                        collect_pluginservers = 1;
-               }
-               else
-               if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
-               {
+                       break;
+               case AW_VEFFECT_FOLDER:
                        mwindow->session->current_operation = DRAG_VEFFECT;
                        collect_pluginservers = 1;
-               }
-               else
-               if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
-               {
+                       break;
+               case AW_ATRANSITION_FOLDER:
                        mwindow->session->current_operation = DRAG_ATRANSITION;
                        collect_pluginservers = 1;
-               }
-               else
-               if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
-               {
+                       break;
+               case AW_VTRANSITION_FOLDER:
                        mwindow->session->current_operation = DRAG_VTRANSITION;
                        collect_pluginservers = 1;
-               }
-               else
-               if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
-               {
+                       break;
+               case AW_LABEL_FOLDER:
                        // do nothing!
-               }
-               else
-               {
+                       break;
+               default:
                        mwindow->session->current_operation = DRAG_ASSET;
                        collect_assets = 1;
+                       break;
                }
 
-
-               if(collect_pluginservers)
-               {
+               if( collect_pluginservers ) {
                        int i = 0;
                        mwindow->session->drag_pluginservers->remove_all();
                        while(1)
                        {
                                AssetPicon *result = (AssetPicon*)get_selection(0, i++);
-                               if(!result) break;
+                               if( !result ) break;
 
                                mwindow->session->drag_pluginservers->append(result->plugin);
                        }
                }
 
-               if(collect_assets)
-               {
+               if( collect_assets ) {
                        gui->collect_assets();
                }
 
@@ -1726,8 +1730,7 @@ int AWindowAssets::drag_motion_event()
        mwindow->gui->drag_motion();
        mwindow->gui->unlock_window();
 
-       for(int i = 0; i < mwindow->vwindows.size(); i++)
-       {
+       for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
                VWindow *vwindow = mwindow->vwindows.get(i);
                if( !vwindow->is_running() ) continue;
                vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
@@ -1751,27 +1754,28 @@ int AWindowAssets::drag_stop_event()
 
        unlock_window();
 
-       if(!result)
-       {
+       if( !result ) {
                mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
                result = mwindow->gui->drag_stop();
                mwindow->gui->unlock_window();
        }
 
-       if(!result)
-       {
-               for(int i = 0; i < mwindow->vwindows.size(); i++)
-               {
+       if( !result ) {
+               for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
                        VWindow *vwindow = mwindow->vwindows.get(i);
+                       if( !vwindow ) continue;
                        if( !vwindow->is_running() ) continue;
+                       if( vwindow->gui->is_hidden() ) continue;
                        vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
-                       result = vwindow->gui->drag_stop();
+                       if( vwindow->gui->cursor_above() &&
+                           vwindow->gui->get_cursor_over_window() ) {
+                               result = vwindow->gui->drag_stop();
+                       }
                        vwindow->gui->unlock_window();
                }
        }
 
-       if(!result)
-       {
+       if( !result ) {
                mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
                result = mwindow->cwindow->gui->drag_stop();
                mwindow->cwindow->gui->unlock_window();
@@ -1779,7 +1783,7 @@ int AWindowAssets::drag_stop_event()
 
        lock_window("AWindowAssets::drag_stop_event");
 
-       if(result) get_drag_popup()->set_animation(0);
+       if( result ) get_drag_popup()->set_animation(0);
 
        BC_ListBox::drag_stop_event();
        mwindow->session->current_operation = ::NO_OPERATION; // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
@@ -1840,8 +1844,7 @@ AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int
 
 int AWindowDeleteFolder::handle_event()
 {
-       if(gui->folder_list->get_selection(0, 0))
-       {
+       if( gui->folder_list->get_selection(0, 0) ) {
                BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
                mwindow->delete_folder(folder->get_text());
        }
@@ -1897,7 +1900,9 @@ AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
 
 int AWindowInfo::handle_event()
 {
-       gui->awindow->asset_edit->edit_asset(gui->selected_asset());
+       int cur_x, cur_y;
+       gui->get_abs_cursor_xy(cur_x, cur_y, 0);
+       gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
        return 1;
 }
 
@@ -1953,63 +1958,6 @@ int AWindowView::handle_event()
        return 1;
 }
 
-
-LabelPopup::LabelPopup(MWindow *mwindow, AWindowGUI *gui)
- : BC_PopupMenu(0,
-               0,
-               0,
-               "",
-               0)
-{
-       this->mwindow = mwindow;
-       this->gui = gui;
-}
-
-LabelPopup::~LabelPopup()
-{
-}
-
-void LabelPopup::create_objects()
-{
-       add_item(editlabel = new LabelPopupEdit(mwindow, this));
-}
-
-int LabelPopup::update()
-{
-       gui->collect_assets();
-       return 0;
-}
-
-
-
-LabelPopupEdit::LabelPopupEdit(MWindow *mwindow, LabelPopup *popup)
- : BC_MenuItem(_("Edit..."))
-{
-       this->mwindow = mwindow;
-       this->popup = popup;
-}
-
-LabelPopupEdit::~LabelPopupEdit()
-{
-}
-
-int LabelPopupEdit::handle_event()
-{
-       int i = 0;
-       while(1)
-       {
-               AssetPicon *result = (AssetPicon*)mwindow->awindow->gui->asset_list->get_selection(0, i++);
-               if(!result) break;
-
-               if(result->label) {
-                       mwindow->awindow->gui->awindow->label_edit->edit_label(result->label);
-                       break;
-               }
-       }
-
-       return 1;
-}
-
 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
  : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
 {
@@ -2040,8 +1988,23 @@ void AddTools::create_objects()
        }
 }
 
+#if 0
+// plugin_dirs list from toplevel makefile include plugin_defs
+N_("ladspa")
+N_("ffmpeg")
+N_("audio_tools")
+N_("audio_transitions")
+N_("blending")
+N_("colors")
+N_("exotic")
+N_("transforms")
+N_("tv_effects")
+N_("video_tools")
+N_("video_transitions")
+#endif
+
 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
- : BC_MenuItem(text)
+ : BC_MenuItem(_(text))
 {
        this->menu = menu;
        this->idx = idx;
@@ -2092,3 +2055,54 @@ int AVIconDrawing::handle_event()
        return 1;
 }
 
+
+AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
+ : BC_MenuItem("")
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+}
+
+int AWindowListFormat::handle_event()
+{
+       gui->stop_vicon_drawing();
+
+       EDLSession *session = mwindow->edl->session;
+       switch( session->assetlist_format ) {
+       case ASSETS_TEXT:
+               session->assetlist_format = ASSETS_ICONS;
+               break;
+       case ASSETS_ICONS:
+               session->assetlist_format = ASSETS_TEXT;
+               break;
+       }
+
+       gui->asset_list->update_format(session->assetlist_format, 1);
+       if( !mwindow->awindow->gui->allow_iconlisting ) {
+               mwindow->edl->session->assetlist_format = ASSETS_TEXT;
+       }
+
+       gui->start_vicon_drawing();
+       return 1;
+}
+
+void AWindowListFormat::update()
+{
+        set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
+                (char*)_("Display icons") : (char*)_("Display text"));
+}
+
+AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
+ : BC_MenuItem(_("Sort items"))
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+}
+
+int AWindowListSort::handle_event()
+{
+       gui->sort_assets();
+       return 1;
+}
+
+