#include "file.h"
#include "filexml.h"
#include "language.h"
+#include "loadfile.h"
#include "localsession.h"
#include "mainerror.h"
#include "mainindexes.h"
+#include "mainmenu.h"
#include "mainsession.h"
#include "mwindow.h"
#include "mwindowgui.h"
void AssetListMenu::create_objects()
{
+ add_item(load_file = new AssetPopupLoadFile(mwindow, gui));
add_item(format = new AWindowListFormat(mwindow, gui));
add_item(new AWindowListSort(mwindow, gui));
add_item(new AssetListCopy(mwindow, gui));
update_titles(shots_displayed = 1);
}
+AssetPopupLoadFile::AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui)
+ : BC_MenuItem(_("Load files..."), "o", 'o')
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+}
+
+AssetPopupLoadFile::~AssetPopupLoadFile()
+{
+}
+
+int AssetPopupLoadFile::handle_event()
+{
+ mwindow->gui->mainmenu->load_file->thread->start();
+ return 1;
+}
+
void AssetListMenu::update_titles(int shots)
{
format->update();
MWindow *mwindow;
AWindowGUI *gui;
+ AssetPopupLoadFile *load_file;
AWindowListFormat *format;
AssetSnapshot *asset_snapshot;
AssetGrabshot *asset_grabshot;
int shots_displayed;
};
+class AssetPopupLoadFile : public BC_MenuItem
+{
+public:
+ AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui);
+ ~AssetPopupLoadFile();
+
+ int handle_event();
+
+ MWindow *mwindow;
+ AWindowGUI *gui;
+};
+
class AssetListCopy : public BC_MenuItem
{
public:
class AssetPopupBuildIndex;
class AssetPopupView;
class AssetPopupViewWindow;
+class AssetPopupLoadFile;
class AssetPopupMixer;
class AssetPopupPaste;
class AssetMatchSize;
return 1;
}
break;
+ case 'o':
+ if( !ctrl_down() && !shift_down() ) {
+ assetlist_menu->load_file->handle_event();
+ return 1;
+ }
+ break;
case DELETE:
if( shift_down() ) {
PluginServer* plugin = selected_plugin();
int KeyframePopupDelete::handle_event()
{
mwindow->undo->update_undo_before(_("delete keyframe"), 0);
+ mwindow->speed_before();
delete popup->keyframe_auto;
+ mwindow->speed_after(1);
mwindow->undo->update_undo_after(_("delete keyframe"), LOAD_ALL);
mwindow->save_backup();
save_backup();
char string[BCSTRLEN];
sprintf(string,"set %s", FloatAuto::curve_name(mode));
- undo->update_undo_after(string, LOAD_AUTOMATION);
+ undo->update_undo_after(string,
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
update_gui(changed_edl);
}
edl->local_session->get_selectionend());
int changed_edl = speed_after(1);
save_backup();
- undo->update_undo_after(_("clear keyframes"), LOAD_AUTOMATION);
+ undo->update_undo_after(_("clear keyframes"),
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
update_gui(changed_edl);
}
edl->tracks->clear_default_keyframe();
int changed_edl = speed_after(1);
save_backup();
- undo->update_undo_after(_("clear default keyframe"), LOAD_AUTOMATION);
+ undo->update_undo_after(_("clear default keyframe"),
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
update_gui(changed_edl);
return 0;
}
edl->local_session->get_selectionend());
int changed_edl = speed_after(1);
save_backup();
- undo->update_undo_after(_("cut keyframes"), LOAD_AUTOMATION);
+ undo->update_undo_after(_("cut keyframes"),
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
update_gui(changed_edl);
return 0;
}
edl->tracks->clear_default_keyframe();
int changed_edl = speed_after(1);
save_backup();
- undo->update_undo_after(_("cut default keyframe"), LOAD_AUTOMATION);
+ undo->update_undo_after(_("cut default keyframe"),
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
update_gui(changed_edl);
return 0;
}
gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
FileXML file;
file.read_from_string(string);
-
+ delete [] string;
double start = edl->local_session->get_selectionstart();
double end = edl->local_session->get_selectionend();
edl->tracks->clear_automation(start, end);
edl->session->typeless_keyframes);
int changed_edl = speed_after(1);
save_backup();
- undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
- delete [] string;
+ undo->update_undo_after(_("paste keyframes"),
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
update_gui(changed_edl);
}
gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
FileXML file;
file.read_from_string(string);
+ delete [] string;
double start = edl->local_session->get_selectionstart();
edl->tracks->paste_automation(start, &file, 1, 0,
edl->session->typeless_keyframes);
// edl->tracks->paste_default_keyframe(&file);
- undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
int changed_edl = speed_after(1);
+ undo->update_undo_after(_("paste default keyframe"),
+ !changed_edl ? LOAD_AUTOMATION :
+ LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
save_backup();
- delete [] string;
update_gui(changed_edl);
}
void MWindow::set_edit_length(double length)
{
- gui->lock_window("MWindow::detach_transitions 1");
+ gui->lock_window("MWindow::set_edit_length 1");
undo->update_undo_before();
double start = edl->local_session->get_selectionstart();
void MWindow::set_transition_length(Transition *transition, double length)
{
- gui->lock_window("MWindow::detach_transitions 1");
+ gui->lock_window("MWindow::set_transition_length 1");
undo->update_undo_before();
//double start = edl->local_session->get_selectionstart();
void MWindow::set_transition_length(double length)
{
- gui->lock_window("MWindow::detach_transitions 1");
+ gui->lock_window("MWindow::set_transition_length 2");
undo->update_undo_before();
double start = edl->local_session->get_selectionstart();
n = snprintf(cp, sz, "%s", txt);
cp += n; sz -= n;
}
- n = snprintf(cp, sz,
+ n = snprintf(cp, sz,
"%02d/%02d/%02d %02d:%02d:%02d, +%s\n",
- dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
+ dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
dtm.tm_hour, dtm.tm_min, dtm.tm_sec, duration);
cp += n; sz -= n;
if( path && *path ) {
#include "clip.h"
#include "filexml.h"
#include "language.h"
+#include "mainerror.h"
#include "svg.h"
#include "svgwin.h"
#include "overlayframe.inc"
#include <string.h>
#include <errno.h>
#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/wait.h>
REGISTER_PLUGIN(SvgMain)
EQUIV(out_w, that.out_w) &&
EQUIV(out_h, that.out_h) &&
!strcmp(svg_file, that.svg_file) &&
+ ms_time != 0 && that.ms_time != 0 &&
ms_time == that.ms_time;
}
}
}
+static int exec_command(char* const*argv)
+{
+ pid_t pid = vfork();
+ if( pid < 0 ) return -1;
+ if( pid > 0 ) {
+ int stat = 0;
+ waitpid(pid, &stat, 0);
+ if( stat ) {
+ char msg[BCTEXTLEN];
+ sprintf(msg, "%s: error exit status %d", argv[0], stat);
+ MainError::show_error(msg);
+ }
+ return 0;
+ }
+ execvp(argv[0], &argv[0]);
+ return -1;
+}
+
int SvgMain::process_realtime(VFrame *input, VFrame *output)
{
char last_svg_file[BCTEXTLEN];
strcpy(last_svg_file, config.svg_file);
int64_t last_ms_time = config.ms_time;
- load_configuration();
+ need_reconfigure = load_configuration();
if( last_dpi != config.dpi )
need_export = 1;
if( strcmp(last_svg_file, config.svg_file) ||
st_png.st_mtim.tv_sec*1000 + st_png.st_mtim.tv_nsec/1000000;
int fd = ms_time < config.ms_time ? -1 : open(filename_png, O_RDWR);
if( fd < 0 ) { // file does not exist, export it
- char command[BCTEXTLEN];
+ char command[BCTEXTLEN], dpi[BCSTRLEN];
snprintf(command, sizeof(command),
"inkscape --without-gui --export-background=0x000000 "
"--export-background-opacity=0 -d %f %s --export-png=%s",
config.dpi, config.svg_file, filename_png);
printf(_("Running command %s\n"), command);
- system(command);
+ snprintf(dpi, sizeof(dpi), "%f", config.dpi);
+ snprintf(command, sizeof(command), "--export-png=%s",filename_png);
+ char *const argv[] = {
+ (char*)"inkscape",
+ (char*)"--without-gui",
+ (char*)"--export-background=0x000000",
+ (char*)"--export-background-opacity=0",
+ (char*)"-d", dpi, config.svg_file, command,
+ 0, };
+ exec_command(argv);
// in order for lockf to work it has to be open for writing
fd = open(filename_png, O_RDWR);
if( fd < 0 )
#include "svgwin.h"
#include "filexml.h"
#include "language.h"
+#include "mainerror.h"
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
#include <errno.h>
#include "empty_svg.h"
int SvgWin::close_event()
{
+ new_svg_button->stop();
edit_svg_button->stop();
set_done(1);
return 1;
int SvgWin::hide_window(int flush)
{
+ new_svg_button->stop();
edit_svg_button->stop();
return BC_WindowBase::hide_window(flush);
}
{
this->client = client;
this->window = window;
+ new_window = 0;
+}
+NewSvgButton::~NewSvgButton()
+{
+ stop();
}
+
int NewSvgButton::handle_event()
{
window->editing_lock.lock();
char *cp = getenv("HOME");
if( cp ) strncpy(directory, cp, sizeof(directory));
}
- NewSvgWindow *new_window = new NewSvgWindow(client, window, directory);
+ new_window = new NewSvgWindow(client, window, directory);
new_window->create_objects();
new_window->update_filter("*.svg");
result = new_window->run_window();
const char *filepath = new_window->get_path(0);
strcpy(filename, filepath);
- delete new_window;
+ delete new_window; new_window = 0;
if( result || !filepath || !*filepath ) {
window->editing_lock.lock();
window->editing = 0;
} while(result); // file doesn't exist so repeat
strcpy(client->config.svg_file, filename);
- struct stat st;
- client->config.ms_time = stat(filename, &st) ? 0 :
- st.st_mtim.tv_sec*1000 + st.st_mtim.tv_nsec/1000000;
+ client->config.ms_time = 0;
window->update_gui(client->config);
client->send_configure_change();
return;
}
+void NewSvgButton::stop()
+{
+ if( new_window ) {
+ new_window->set_done(1);
+ }
+ join();
+}
+
EditSvgButton::EditSvgButton(SvgMain *client, SvgWin *window, int x, int y)
: BC_GenericButton(x, y, _("Edit")), Thread(1)
{
join();
}
+static int exec_command(char* const*argv)
+{
+ pid_t pid = vfork();
+ if( pid < 0 ) return -1;
+ if( pid > 0 ) {
+ int stat = 0;
+ waitpid(pid, &stat, 0);
+ if( stat ) {
+ char msg[BCTEXTLEN];
+ sprintf(msg, "%s: error exit status %d", argv[0], stat);
+ MainError::show_error(msg);
+ }
+ return 0;
+ }
+ execvp(argv[0], &argv[0]);
+ return -1;
+}
+
void SvgInkscapeThread::run()
{
// Runs the inkscape
snprintf(command, sizeof(command),
"inkscape --with-gui %s", edit->client->config.svg_file);
printf(_("Running external SVG editor: %s\n"), command);
+ char *const argv[] = {
+ (char*) "incscape",
+ (char*)"--with-gui",
+ edit->client->config.svg_file,
+ 0,
+ };
enable_cancel();
- system(command);
+ exec_command(argv);
printf(_("External SVG editor finished\n"));
struct fifo_struct fifo_buf;
fifo_buf.pid = getpid();
}
-
NewSvgWindow::NewSvgWindow(SvgMain *client, SvgWin *window, char *init_directory)
: BC_FileBox(0,
BC_WindowBase::get_resources()->filebox_h / 2,
{
public:
NewSvgButton(SvgMain *client, SvgWin *window, int x, int y);
+ ~NewSvgButton();
int handle_event();
void run();
+ void stop();
SvgMain *client;
SvgWin *window;
+ NewSvgWindow *new_window;
};
class EditSvgButton : public BC_GenericButton, public Thread