diff --git a/mixer/src/Mixer.C b/mixer/src/Mixer.C index ef12757..4d0d374 100644 --- a/mixer/src/Mixer.C +++ b/mixer/src/Mixer.C @@ -54,6 +54,7 @@ extern char *user_config_dir; extern char *instance_name; #include "debug.h" +#include "string_util.h" #include "NSM.H" @@ -269,6 +270,10 @@ void Mixer::cb_menu(Fl_Widget* o) { fl_alert( "%s", "Failed to import strip!" ); } } + else if ( !strcmp( picked, "&Mixer/Paste" ) ) + { + Fl::paste(*this); + } else if (! strcmp( picked, "&Project/Se&ttings/&Rows/One") ) { rows( 1 ); @@ -413,6 +418,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) : o->add( "&Mixer/&Add Strip", 'a', 0, 0 ); o->add( "&Mixer/Add &N Strips" ); o->add( "&Mixer/&Import Strip" ); + o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 ); o->add( "&View/&Theme", 0, 0, 0 ); o->add( "&Help/&Manual" ); o->add( "&Help/&About" ); @@ -746,6 +752,44 @@ Mixer::update_menu ( void ) +int +Mixer::handle ( int m ) +{ + + if ( Fl_Group::handle( m ) ) + return 1; + + switch ( m ) + { + case FL_PASTE: + { + if ( ! Fl::event_inside( this ) ) + return 0; + + const char *text = Fl::event_text(); + + char *file; + + if ( ! sscanf( text, "file://%a[^\r\n]\n", &file ) ) + { + WARNING( "invalid drop \"%s\"\n", text ); + return 0; + } + + unescape_url( file ); + + printf( "pasted file \"%s\"\n", file ); + + if (! Mixer_Strip::import_strip( file ) ) + fl_alert( "%s", "Failed to import strip!" ); + + return 1; + } + } + + return 0; +} + /************/ /* Commands */ /************/ diff --git a/mixer/src/Mixer.H b/mixer/src/Mixer.H index dedc2c4..3397f30 100644 --- a/mixer/src/Mixer.H +++ b/mixer/src/Mixer.H @@ -74,6 +74,8 @@ private: static int osc_non_hello ( const char *, const char *, lo_arg **, int , lo_message msg, void * ); public: + + virtual int handle ( int m ); char * get_unique_track_name ( const char *name ); diff --git a/mixer/src/Mixer_Strip.C b/mixer/src/Mixer_Strip.C index 3b90ed2..7c2c600 100644 --- a/mixer/src/Mixer_Strip.C +++ b/mixer/src/Mixer_Strip.C @@ -32,6 +32,7 @@ */ /* Each mixer strip comprises a fader and a panner */ +#include "Project.H" #include "Mixer_Strip.H" #include "Engine/Engine.H" #include @@ -597,6 +598,17 @@ Mixer_Strip::menu_cb ( const Fl_Menu_ *m ) { ((Fl_Sometimes_Input*)name_field)->take_focus(); } + else if ( ! strcmp( picked, "/Copy" ) ) + { + export_strip( "clipboard.strip" ); + + char *s; + asprintf( &s, "file://%s/%s\r\n", Project::path(), "clipboard.strip" ); + + Fl::copy( s, strlen(s), 0 ); + + free(s); + } else if ( ! strcmp( picked, "/Color" ) ) { unsigned char r, g, b; @@ -661,6 +673,7 @@ Mixer_Strip::menu ( void ) const { "Move Left", '[', 0, 0 }, { "Move Right", ']', 0, 0 }, { "Color", 0, 0, 0 }, + { "Copy", FL_CTRL + 'c', 0, 0 }, { "Export Strip", 0, 0, 0 }, { "Rename", FL_CTRL + 'n', 0, 0 }, { "Remove", FL_Delete, 0, 0 }, diff --git a/mixer/src/Project.H b/mixer/src/Project.H index 2eb4414..7de2efb 100644 --- a/mixer/src/Project.H +++ b/mixer/src/Project.H @@ -58,6 +58,7 @@ public: static int open ( const char *name ); static bool open ( void ) { return _is_open; } static bool create ( const char *name, const char *template_name ); - + + static const char *path ( void ) { return _path; } static const char *created_on ( void ) { return _created_on; } };