#include "guicast.h"
#include "indexable.h"
#include "language.h"
+#include "localsession.h"
#include "mainerror.h"
#include "mainsession.h"
#include "mutex.h"
}
-BinFolder::BinFolder(int awindow_folder, const char *title)
+BinFolder::BinFolder(int awindow_folder, int is_clips, const char *title)
{
this->awindow_folder = awindow_folder;
+ this->is_clips = is_clips;
char *bp = this->title;
int len = sizeof(this->title);
while( --len>0 && *title ) *bp++ = *title++;
{
strcpy(title, that->title);
awindow_folder = that->awindow_folder;
+ is_clips = that->is_clips;
filters.copy_from(&that->filters);
}
file->tag.set_title("FOLDER");
file->tag.set_property("TITLE", title);
file->tag.set_property("AWINDOW_FOLDER", awindow_folder);
+ file->tag.set_property("IS_CLIPS", is_clips);
file->append_tag();
file->append_newline();
for( int i=0; i<filters.size(); ++i )
title[0] = 0;
file->tag.get_property("TITLE", title);
awindow_folder = file->tag.get_property("AWINDOW_FOLDER", -1);
+ is_clips = file->tag.get_property("IS_CLIPS", 0);
filters.remove_all_objects();
int ret = 0;
return ret;
}
-void BinFolder::add_patterns(ArrayList<Indexable*> *drag_assets)
+int BinFolder::add_patterns(ArrayList<Indexable*> *drag_idxbls)
{
- int n = drag_assets->size();
- if( n > 0 ) {
- int len = 1;
- for( int i=0; i<n; ++i )
- len += strlen(drag_assets->get(i)->path) + 1;
- char *pats = new char[len], *bp = pats;
- const char *cp = drag_assets->get(0)->path;
+ int n = drag_idxbls->size();
+ if( !n ) return 1;
+ Indexable *idxbl;
+ int len = 0;
+ for( int i=0; i<n; ++i ) {
+ idxbl = drag_idxbls->get(i);
+ if( !idxbl->is_asset &&
+ idxbl->awindow_folder == AW_PROXY_FOLDER )
+ continue;
+ len += strlen(idxbl->get_title()) + 1;
+ }
+ if( !len ) return 1;
+ char *pats = new char[len+1], *bp = pats;
+ for( int i=0; i<n; ++i ) {
+ idxbl = drag_idxbls->get(i);
+ if( !idxbl->is_asset &&
+ idxbl->awindow_folder == AW_PROXY_FOLDER )
+ continue;
+ if( i > 0 ) *bp++ = '\n';
+ const char *cp = idxbl->get_title();
while( *cp ) *bp++ = *cp++;
- for( int i=1; i<n; ++i ) {
- *bp++ = '\n';
- cp = drag_assets->get(i)->path;
- while( *cp ) *bp++ = *cp++;
- }
- *bp = 0;
-// new pattern filter
- BinFolderFilter *filter = new BinFolderFilter();
- filter->update_enabled(FOLDER_ENABLED_OR);
- filter->update_target(FOLDER_TARGET_PATTERNS);
- filter->update_op(FOLDER_OP_MATCHES);
- BinFolderTargetPatterns *patterns = (BinFolderTargetPatterns *)(filter->target);
- patterns->update(pats);
- filters.append(filter);
}
+ *bp = 0;
+// new pattern filter
+ BinFolderFilter *filter = new BinFolderFilter();
+ filter->update_enabled(FOLDER_ENABLED_OR);
+ filter->update_target(FOLDER_TARGET_PATTERNS);
+ filter->update_op(FOLDER_OP_MATCHES);
+ BinFolderTargetPatterns *patterns = (BinFolderTargetPatterns *)(filter->target);
+ patterns->update(pats);
+ filters.append(filter);
+ return 0;
}
double BinFolders::matches_indexable(int folder, Indexable *idxbl)
{
int k = size();
- while( --k>=0 && get(k)->awindow_folder!=folder );
- return k < 0 ? 0 : get(k)->matches_indexable(idxbl);
+ BinFolder *bin_folder = 0;
+ while( --k>=0 && (bin_folder=get(k)) && bin_folder->awindow_folder!=folder );
+ if( k < 0 ) return -1;
+ if( bin_folder->is_clips && idxbl->is_asset ) return -1;
+ if( !bin_folder->is_clips && !idxbl->is_asset ) return -1;
+ return bin_folder->matches_indexable(idxbl);
}
void BinFolders::save_xml(FileXML *file)
while( !(ret=file->read_tag()) ) {
if( file->tag.title_is("/FOLDERS") ) break;
if( file->tag.title_is("FOLDER") ) {
- BinFolder *folder = new BinFolder(-1, "folder");
+ BinFolder *folder = new BinFolder(-1, -1, "folder");
folder->load_xml(file);
append(folder);
}
char pattern[BCTEXTLEN], *bp = pattern, ch;
while( *cp && (ch=*cp++)!='\n' ) *bp++ = ch;
*bp = 0;
- if( bp > pattern &&
- !FileSystem::test_filter(idxbl->path, pattern) )
+ if( !pattern[0] ) continue;
+ const char *title = idxbl->get_title();
+ if( !FileSystem::test_filter(title, pattern) )
v = 1;
}
break; }
lock_window("NewFolderGUI::create_objects");
int x = 10, y = 10;
BC_Title *title;
- add_subwindow(title = new BC_Title(x, y, _("Enter the name of the folder:")));
+ add_subwindow(title = new BC_Title(x, y, _("Folder name:")));
y += title->get_h() + 5;
- add_subwindow(text_box = new BC_TextBox(x, y, 300, 1, _("Untitled")));
+ const char *text = !thread->is_clips ? _("media bin") : _("clip bin");
+ add_subwindow(text_box = new BC_TextBox(x, y, 300, 1, text));
add_subwindow(new BC_OKButton(this));
add_subwindow(new BC_CancelButton(this));
show_window();
: BC_DialogThread()
{
this->agui = agui;
+ is_clips = -1;
}
NewFolderThread::~NewFolderThread()
close_window();
}
-void NewFolderThread::start(int x, int y, int w, int h)
+void NewFolderThread::start(int x, int y, int w, int h, int is_clips)
{
close_window();
- wx = x; wy = y;
- ww = w; wh = h;
+ this->is_clips = is_clips;
+ this->wx = x; this->wy = y;
+ this->ww = w; this->wh = h;
Thread::start();
}
{
if( !result ) {
const char *text = window->get_text();
- agui->mwindow->new_folder(text);
+ agui->mwindow->new_folder(text, is_clips);
}
}
void NewFolderThread::handle_close_event(int result)
{
+ is_clips = -1;
}
ModifyFolderGUI::ModifyFolderGUI(ModifyFolderThread *thread, int x, int y, int w, int h)
lock_window("ModifyFolderGUI::create_objects");
modify_folder_xatom = create_xatom("CWINDOWGUI_UPDATE_FILTERS");
int x = 10, y = 10;
- add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
- y += 20;
+ BC_Title *title;
+ add_subwindow(title = new BC_Title(x, y, _("Enter the name of the folder:")));
+ const char *text = !thread->folder->is_clips ? _("Media") : _("Clips");
+ int tw = BC_Title::calculate_w(this, text, LARGEFONT);
+ int x0 = get_w() - 50 - tw;
+ add_subwindow(text_title = new BC_Title(x0, y, text, LARGEFONT, YELLOW));
+ y += title->get_h() + 10;
add_subwindow(text_box = new BC_TextBox(x, y, 300, 1, thread->folder->title));
- y += 30;
+ y += text_box->get_h() + 10;
int lh = get_h() - y - BC_OKButton::calculate_h() - 30;
int lw = get_w() - x - 120;
add_subwindow(folder_list =
MWindow *mwindow = thread->agui->mwindow;
mwindow->session->bwindow_w = w;
mwindow->session->bwindow_h = h;
+ int tx = text_title->get_x() + w - get_w();
+ int ty = text_title->get_y();
+ text_title->reposition_window(tx, ty);
int lx = folder_list->get_x();
int ly = folder_list->get_y();
int lh = h - ly - BC_OKButton::calculate_h() - 30;
this->original = folder;
agui->mwindow->edl->add_user();
this->folder = new BinFolder(*folder);
- wx = x; wy = y;
- ww = w; wh = h;
+ this->wx = x; this->wy = y;
+ this->ww = w; this->wh = h;
Thread::start();
}