{
BC_Menu *viewmenu, *windowmenu, *settingsmenu, *trackmenu;
PreferencesMenuitem *preferences;
- total_loads = 0;
add_menu(filemenu = new BC_Menu(_("File")));
filemenu->add_item(new_project = new NewProject(mwindow));
// file loaders
filemenu->add_item(load_file = new Load(mwindow, this));
load_file->create_objects();
+ filemenu->add_item(load_recent = new LoadRecent(mwindow, this));
+ load_recent->create_objects();
// new and load can be undone so no need to prompt save
Save *save; // affected by saveas
void MainMenu::init_loads(BC_Hash *defaults)
{
- total_loads = defaults->get((char*)"TOTAL_LOADS", 0);
- if( !total_loads ) return;
- filemenu->add_item(new BC_MenuItem("-"));
+// total_loads for legacy xml
+ int total_loads = defaults->get((char*)"TOTAL_LOADS", 0);
+ int loads_total = defaults->get((char*)"LOADS_TOTAL", 0);
+ if( loads_total < total_loads ) loads_total = total_loads;
- char string[BCTEXTLEN], path[BCTEXTLEN], filename[BCTEXTLEN];
+ char string[BCTEXTLEN], path[BCTEXTLEN];
FileSystem dir;
//printf("MainMenu::init_loads 2\n");
- for(int i = 0; i < total_loads; i++) {
+ for( int i=0; i<loads_total; ++i ) {
sprintf(string, "LOADPREVIOUS%d", i);
//printf("MainMenu::init_loads 3\n");
defaults->get(string, path);
- filemenu->add_item(load[i] = new LoadPrevious(mwindow, load_file));
- dir.extract_name(filename, path, 0);
- load[i]->set_text(filename);
- load[i]->set_path(path);
+ if( load.size() < TOTAL_LOADS )
+ load.append(new LoadRecentItem(path));
}
}
int MainMenu::save_loads(BC_Hash *defaults)
{
+// legacy to prevent segv, older code cant tolerate total_loads>10
+ int loads_total = load.size();
+ int total_loads = MIN(10, loads_total);
+ defaults->update((char*)"LOADS_TOTAL", loads_total);
defaults->update((char*)"TOTAL_LOADS", total_loads);
char string[BCTEXTLEN];
- for(int i = 0; i < total_loads; i++)
- {
+ for( int i=0; i<loads_total; ++i ) {
sprintf(string, "LOADPREVIOUS%d", i);
defaults->update(string, load[i]->path);
}
int MainMenu::add_load(char *path)
{
- if(total_loads == 0)
-{
- filemenu->add_item(new BC_MenuItem("-"));
- }
-
-// test for existing copy
- FileSystem fs;
- char text[BCTEXTLEN], new_path[BCTEXTLEN]; // get text and path
- fs.extract_name(text, path);
- strcpy(new_path, path);
-
- for(int i = 0; i < total_loads; i++)
- {
- if(!strcmp(load[i]->get_text(), text)) // already exists
- { // swap for top load
- for(int j = i; j > 0; j--) // move preceeding loads down
- {
- load[j]->set_text(load[j - 1]->get_text());
- load[j]->set_path(load[j - 1]->path);
- }
- load[0]->set_text(text);
- load[0]->set_path(new_path);
-
- return 1;
- }
- }
-
-// add another load
- if(total_loads < TOTAL_LOADS)
- {
- filemenu->add_item(load[total_loads] = new LoadPrevious(mwindow, load_file));
- total_loads++;
- }
-
-// cycle loads down
- for(int i = total_loads - 1; i > 0; i--)
- {
- // set menu item text
- load[i]->set_text(load[i - 1]->get_text());
- // set filename
- load[i]->set_path(load[i - 1]->path);
- }
-
-// set up the new load
- load[0]->set_text(text);
- load[0]->set_path(new_path);
- return 0;
+ return load.add_load(path);
}
-
-
-
-
-
// ================================== menu items
MainDumpsSubMenu::MainDumpsSubMenu(BC_MenuItem *menu_item)
unlock_window();
}
+
+LoadRecentItem::LoadRecentItem(const char *path)
+{
+ this->path = cstrdup(path);
+}
+
+LoadRecentItem::~LoadRecentItem()
+{
+ delete [] path;
+}
+
+int LoadRecentItems::add_load(char *path)
+{
+// test for existing copy
+ FileSystem fs;
+ char name[BCTEXTLEN], text[BCTEXTLEN];
+ fs.extract_name(name, path);
+ int loads_total = size();
+ int ret = 0, k = loads_total;
+ LoadRecentItem *load_item = 0;
+
+ for( int i=0; !ret && i<loads_total; ++i ) {
+ load_item = get(i);
+ fs.extract_name(text, load_item->path);
+ if( strcmp(name, text) ) continue;
+ k = i; ret = 1; // already exists, move to top
+ }
+ if( !ret ) { // adding a new one
+ while( loads_total >= TOTAL_LOADS )
+ remove_object_number(--loads_total);
+ insert(new LoadRecentItem(path), 0);
+ }
+ else if( k > 0 ) { // cycle loads
+ while( --k >= 0 ) set(k+1, get(k));
+ set(0, load_item);
+ }
+ return ret;
+}
+
+LoadRecentItems::LoadRecentItems()
+{
+}
+
+LoadRecentItems::~LoadRecentItems()
+{
+ remove_all_objects();
+}
+
+LoadRecent::LoadRecent(MWindow *mwindow, MainMenu *main_menu)
+ : BC_MenuItem(_("Load Recent..."))
+{
+ this->mwindow = mwindow;
+ this->main_menu = main_menu;
+ total_items = 0;
+}
+LoadRecent::~LoadRecent()
+{
+}
+
+void LoadRecent::create_objects()
+{
+ add_submenu(submenu = new LoadRecentSubMenu(this));
+}
+
+LoadPrevious *LoadRecent::get_next_item()
+{
+ int k = total_items++;
+ if( k < submenu->total_items() )
+ return (LoadPrevious *)submenu->get_item(k);
+ LoadPrevious *load_prev = new LoadPrevious(mwindow, main_menu->load_file);
+ submenu->add_item(load_prev);
+ return load_prev;
+}
+
+int LoadRecent::activate_submenu()
+{
+ total_items = 0;
+ scan_items(1);
+ if( total_items > 0 ) {
+ LoadPrevious *load_prev = get_next_item();
+ load_prev->set_text("-");
+ load_prev->set_path("");
+ }
+ scan_items(0);
+ while( total_items < submenu->total_items() )
+ submenu->del_item(0);
+ return BC_MenuItem::activate_submenu();
+}
+
+void LoadRecent::scan_items(int use_xml)
+{
+ FileSystem fs;
+ int loads_total = main_menu->load.size();
+ for( int i=0; i<loads_total; ++i ) {
+ LoadRecentItem *recent = main_menu->load[i];
+ char name[BCTEXTLEN];
+ fs.extract_name(name, recent->path);
+ const char *cp = strrchr(name, '.');
+ if( !cp || strcasecmp(cp+1,"xml") ? use_xml : !use_xml ) continue;
+ LoadPrevious *load_prev = get_next_item();
+ load_prev->set_text(name);
+ load_prev->set_path(recent->path);
+ }
+}
+
+LoadRecentSubMenu::LoadRecentSubMenu(LoadRecent *load_recent)
+ : BC_SubMenu()
+{
+ this->load_recent = load_recent;
+}
+
+LoadRecentSubMenu::~LoadRecentSubMenu()
+{
+}
+
#include "threadloader.inc"
#include "viewmenu.inc"
-#define TOTAL_LOADS 10 // number of files to cache
+#define TOTAL_LOADS 20 // number of files to cache
#define TOTAL_EFFECTS 10 // number of effects to cache
#define LAYOUT_LOAD 0
#define LAYOUT_SAVE 1
+class LoadRecentItem
+{
+public:
+ LoadRecentItem(const char *path);
+ ~LoadRecentItem();
+ char *path;
+};
+
+class LoadRecentItems : public ArrayList<LoadRecentItem *>
+{
+public:
+ LoadRecentItems();
+ ~LoadRecentItems();
+ int add_load(char *path);
+};
+
+class LoadRecentSubMenu : public BC_SubMenu
+{
+public:
+ LoadRecentSubMenu(LoadRecent *load_recent);
+ ~LoadRecentSubMenu();
+
+ LoadRecent *load_recent;
+};
+
+class LoadRecent : public BC_MenuItem
+{
+public:
+ LoadRecent(MWindow *mwindow, MainMenu *main_menu);
+ ~LoadRecent();
+ void create_objects();
+ LoadPrevious *get_next_item();
+ int activate_submenu();
+ void scan_items(int use_xml);
+
+ MWindow *mwindow;
+ MainMenu *main_menu;
+ LoadRecentSubMenu *submenu;
+ int total_items;
+};
+
+
class MainMenu : public BC_MenuBar
{
public:
MenuVEffects *veffects;
Load *load_file;
- LoadPrevious *load[TOTAL_LOADS];
- int total_loads;
+ LoadRecentItems load;
+ LoadRecent *load_recent;
RecordMenuItem *record_menu_item;
RenderItem *render;
EditClearMenu *clear_menu;
Undo *undo;
Redo *redo;
- int total_aeffects;
- int total_veffects;
- BC_Menu *filemenu, *audiomenu, *videomenu; // needed by most recents
+ BC_Menu *filemenu;
+ BC_Menu *audiomenu, *videomenu; // needed by most recents
+ int total_aeffects, total_veffects;
KeyframeCurveType *keyframe_curve_type;
LabelsFollowEdits *labels_follow_edits;
+++ /dev/null
-
-/*
- * CINELERRA
- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "timebomb.h"\r
-#include <stdio.h>\r
-#include <sys/stat.h>\r
-#include <stdlib.h>\r
-\r
-#define LASTYEAR 2001\r
-#define LASTDAY 1\r
-#define LASTMONTH 10\r
-#define EXCUSE \\r
-"To reduce support liability this release had an expiration date.\n" \\r
-"The expiration date of this release has expired.\n"\r
-\r
-static char *files[] = \r
-{\r
- "/usr/lib/libcinelerra.so",\r
- "/usr/bin/cinelerra"\r
-};\r
-\r
-TimeBomb::TimeBomb()\r
-{\r
- struct stat fileinfo;\r
- time_t system_time;\r
- int result;\r
-\r
- result = stat("/etc", &fileinfo);\r
- system_time = time(0);\r
-\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
-\r
- if(test_time(fileinfo.st_mtime) ||\r
- test_time(system_time))\r
- {\r
- printf(EXCUSE);\r
- disable_system();\r
- exit(1);\r
- }\r
-}\r
-\r
-\r
-int TimeBomb::test_time(time_t testtime)\r
-{\r
- struct tm *currenttime;\r
- currenttime = localtime(&testtime);\r
-\r
- if(currenttime->tm_year >= LASTYEAR - 1900 &&\r
- currenttime->tm_mday >= LASTDAY &&\r
- currenttime->tm_mon >= LASTMONTH - 1) return 1;\r
- else return 0;\r
-}\r
-\r
-void TimeBomb::disable_system()\r
-{\r
-//printf("TimeBomb::disable_system %d\n", sizeof(files));\r
- for(int i = 0; i < sizeof(files) / sizeof(char*); i++)\r
- {\r
- remove((const char*)files[i]);\r
- }\r
-}\r
-\r
-TimeBomb::~TimeBomb()\r
-{\r
-}\r
-\r