#include "guicast.h"
#include "indexable.h"
#include "language.h"
+#include "localsession.h"
#include "mainerror.h"
#include "mainsession.h"
#include "mutex.h"
struct tm ttm; memset(&ttm, 0, sizeof(ttm));
ttm.tm_year = year-1900; ttm.tm_mon = mon-1; ttm.tm_mday = day;
ttm.tm_hour = hour; ttm.tm_min = min; ttm.tm_sec = secs;
- ttm.tm_wday = ttm.tm_yday = 0; ttm.tm_isdst = daylight; /* tzset in main */
time_t t = mktime(&ttm);
return (int64_t)t;
}
}
-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 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;
- while( *cp ) *bp++ = *cp++;
- for( int i=1; i<n; ++i ) {
- *bp++ = '\n';
- cp = drag_assets->get(i)->path;
- while( *cp ) *bp++ = *cp++;
+int BinFolder::add_patterns(ArrayList<Indexable*> *drag_idxbls, int use_basename)
+{
+ 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->folder_no == AW_PROXY_FOLDER )
+ continue;
+
+ const char *tp = idxbl->get_title();
+ if( use_basename && idxbl->is_asset ) {
+ const char *cp = strrchr(tp, '/');
+ if( cp ) tp = cp + 1;
+ len += 1; // "*" + fn
}
- *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);
+ len += strlen(tp) + 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->folder_no == AW_PROXY_FOLDER )
+ continue;
+ if( i > 0 ) *bp++ = '\n';
+ const char *tp = idxbl->get_title();
+ if( use_basename && idxbl->is_asset ) {
+ const char *cp = strrchr(tp, '/');
+ if( cp ) tp = cp + 1;
+ *bp++ = '*';
+ }
+ while( *tp ) *bp++ = *tp++;
}
+ *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);
}
int enabled_type = file->tag.get_property("ENABLED", FOLDER_ENABLED_AND);
int op_type = file->tag.get_property("OP", FOLDER_OP_MATCHES);
int target_type = file->tag.get_property("TARGET", FOLDER_TARGET_PATTERNS);
- char data[0x40000];
- file->read_text_until("/FILTER", data, sizeof(data), 0);
+ XMLBuffer data;
+ file->read_text_until("/FILTER", &data, 0);
update_enabled(enabled_type);
update_target(target_type);
update_op(op_type);
target->load_xml(file);
if( target->type == FOLDER_TARGET_PATTERNS )
- ((BinFolderTargetPatterns *)target)->update(data);
+ ((BinFolderTargetPatterns *)target)->update(data.cstr());
return 0;
}
double BinFolderOp::around(double v, double a)
{
- if( type != FOLDER_OP_AROUND || a <= 0 ) return v;
- if( (v=fabs(v)) > a ) return -1;
- return v / a;
+ if( type != FOLDER_OP_AROUND ) return v;
+ v = fabs(v);
+ return a>0 ? v/a : v;
}
// string theory: Feynman, Einstein and Schrodinger string compare
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;
+ int lw = get_w() - x - 160;
add_subwindow(folder_list =
new BinFolderList(thread->folder, thread->agui->mwindow, this, x, y, lw, lh));
folder_list->create_objects();
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;
- int lw = w - lx - 120;
+ int lw = w - lx - 160;
folder_list->reposition_window(lx, ly, lw, lh);
int x1 = lx + lw + 15;
add_filter->reposition_window(x1, add_filter->get_y());
{
this->agui = agui;
original = 0;
+ modify_edl = 0;
folder = 0;
}
{
close_window();
this->original = folder;
- agui->mwindow->edl->add_user();
+ this->modify_edl = agui->mwindow->edl;
+ this->modify_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();
}
}
delete folder; folder = 0;
original = 0;
- agui->mwindow->edl->remove_user();
+ modify_edl->remove_user();
}
void ModifyFolderThread::handle_close_event(int result)