From: Derk-Jan Hartman Date: Thu, 23 Dec 2004 00:33:05 +0000 (+0000) Subject: * src/libvlc.h: Added a "snapshot-format" option to be able to select png or jpg... X-Git-Tag: 0.8.2~1409 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=89885149e814b2d287dd7166a92eb69f3221f0af;p=vlc * src/libvlc.h: Added a "snapshot-format" option to be able to select png or jpg (png default) * src/video_output/vout_intf.c: use above option and set the default destination for snapshots on OS X to the Desktop. * REST: Add the Snapshot command to the menu's etc. --- diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib index 1e0c4b19fb..49d8917042 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib @@ -197,6 +197,7 @@ "o_mi_services" = id; "o_mi_show_all" = id; "o_mi_slower" = id; + "o_mi_snapshot" = id; "o_mi_stop" = id; "o_mi_subtitle" = id; "o_mi_title" = id; diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib index ee2c196459..bf4d14e970 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib @@ -3,7 +3,7 @@ IBDocumentLocation - 47 61 505 517 0 0 800 578 + 25 92 505 517 0 0 1280 938 IBEditorPositions 1617 @@ -11,7 +11,7 @@ 2197 237 313 596 367 0 0 1024 746 29 - 421 486 419 44 0 0 800 578 + 326 879 419 44 0 0 1280 938 915 731 416 165 180 0 0 1024 746 @@ -27,6 +27,7 @@ IBOpenObjects 21 + 29 IBSystem Version 7S215 diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib index 77d6dd901b..2616b76788 100644 Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m index 01e5dd7f6c..1a5ecac3e9 100644 --- a/modules/gui/macosx/controls.m +++ b/modules/gui/macosx/controls.m @@ -292,6 +292,10 @@ if( ![o_window isZoomed] ) [o_window performZoom:self]; } + else if( [o_title isEqualToString: _NS("Snapshot") ] ) + { + [o_window snapshot]; + } else { vlc_value_t val; @@ -634,6 +638,7 @@ [[o_mi title] isEqualToString: _NS("Normal Size")] || [[o_mi title] isEqualToString: _NS("Double Size")] || [[o_mi title] isEqualToString: _NS("Fit to Screen")] || + [[o_mi title] isEqualToString: _NS("Snapshot")] || [[o_mi title] isEqualToString: _NS("Float on Top")] ) { id o_window; diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index d39aeecbb0..fe350ad0e0 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -195,6 +195,7 @@ struct intf_sys_t IBOutlet id o_mi_fittoscreen; IBOutlet id o_mi_fullscreen; IBOutlet id o_mi_floatontop; + IBOutlet id o_mi_snapshot; IBOutlet id o_mi_videotrack; IBOutlet id o_mu_videotrack; IBOutlet id o_mi_screen; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index ce7710ee22..5a45a806b0 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -366,6 +366,9 @@ static VLCMain *_o_sharedMainInstance = nil; i_key = config_GetInt( p_intf, "key-fullscreen" ); [o_mi_fullscreen setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_fullscreen setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; + i_key = config_GetInt( p_intf, "key-snapshot" ); + [o_mi_snapshot setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; + [o_mi_snapshot setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; var_Create( p_intf, "intf-change", VLC_VAR_BOOL ); @@ -477,6 +480,7 @@ static VLCMain *_o_sharedMainInstance = nil; [o_mi_fittoscreen setTitle: _NS("Fit to Screen")]; [o_mi_fullscreen setTitle: _NS("Fullscreen")]; [o_mi_floatontop setTitle: _NS("Float on Top")]; + [o_mi_snapshot setTitle: _NS("Snapshot")]; [o_mi_videotrack setTitle: _NS("Video Track")]; [o_mu_videotrack setTitle: _NS("Video Track")]; [o_mi_screen setTitle: _NS("Video Device")]; diff --git a/modules/gui/macosx/vout.h b/modules/gui/macosx/vout.h index 33432d75d0..418bf73ac0 100644 --- a/modules/gui/macosx/vout.h +++ b/modules/gui/macosx/vout.h @@ -48,6 +48,7 @@ - (void)toggleFloatOnTop; - (void)toggleFullscreen; - (BOOL)isFullscreen; +- (void)snapshot; - (void)updateTitle; - (BOOL)windowShouldClose:(id)sender; diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 386149ea0b..e809402f1f 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -333,6 +333,11 @@ return( p_vout->b_fullscreen ); } +- (void)snapshot +{ + vout_Control( p_vout, VOUT_SNAPSHOT ); +} + - (BOOL)canBecomeKeyWindow { return YES; diff --git a/src/libvlc.h b/src/libvlc.h index 45b4a0d134..64138ec401 100644 --- a/src/libvlc.h +++ b/src/libvlc.h @@ -36,6 +36,9 @@ static char *ppsz_language_text[] = N_("Norwegian"), N_("Polish"), N_("Brazilian"), N_("Russian"), N_("Swedish") }; +static char *ppsz_snap_formats[] = +{ "png", "jpg" }; + /***************************************************************************** * Configuration options for the main program. Each module will also separatly * define its own configuration options. @@ -257,6 +260,11 @@ static char *ppsz_align_descriptions[] = "Allows you to specify the directory where the video snapshots will " \ "be stored.") +#define SNAP_FORMAT_TEXT N_("Video snapshot format") +#define SNAP_FORMAT_LONGTEXT N_( \ + "Allows you to specify the image format in which the video snapshots will " \ + "be stored.") + #define ASPECT_RATIO_TEXT N_("Source aspect ratio") #define ASPECT_RATIO_LONGTEXT N_( \ "This will force the source aspect ratio. For instance, some DVDs claim " \ @@ -898,6 +906,9 @@ vlc_module_begin(); ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, VLC_TRUE ); add_directory( "snapshot-path", NULL, NULL, SNAP_PATH_TEXT, SNAP_PATH_LONGTEXT, VLC_FALSE ); + add_string( "snapshot-format", "png", NULL, SNAP_FORMAT_TEXT, + SNAP_FORMAT_LONGTEXT, VLC_FALSE ); + change_string_list( ppsz_snap_formats, NULL, 0 ); set_subcategory( SUBCAT_VIDEO_VOUT ); add_module( "vout", "video output", NULL, NULL, VOUT_TEXT, VOUT_LONGTEXT, @@ -1195,14 +1206,14 @@ vlc_module_begin(); # define KEY_VOL_UP KEY_MODIFIER_COMMAND|KEY_UP # define KEY_VOL_DOWN KEY_MODIFIER_COMMAND|KEY_DOWN # define KEY_VOL_MUTE KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'m' -# define KEY_SUBDELAY_UP KEY_MODIFIER_COMMAND|'k' -# define KEY_SUBDELAY_DOWN KEY_MODIFIER_COMMAND|'j' -# define KEY_AUDIODELAY_UP KEY_MODIFIER_COMMAND|'h' -# define KEY_AUDIODELAY_DOWN KEY_MODIFIER_COMMAND|'g' +# define KEY_SUBDELAY_UP KEY_MODIFIER_COMMAND|'j' +# define KEY_SUBDELAY_DOWN KEY_MODIFIER_COMMAND|'h' +# define KEY_AUDIODELAY_UP KEY_MODIFIER_COMMAND|'l' +# define KEY_AUDIODELAY_DOWN KEY_MODIFIER_COMMAND|'k' # define KEY_AUDIO_TRACK 'l' # define KEY_SUBTITLE_TRACK 's' # define KEY_INTF_SHOW 'i' -# define KEY_SNAPSHOT KEY_MODIFIER_CTRL|'s' +# define KEY_SNAPSHOT KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'s' # define KEY_SET_BOOKMARK1 KEY_MODIFIER_COMMAND|KEY_F1 # define KEY_SET_BOOKMARK2 KEY_MODIFIER_COMMAND|KEY_F2 diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index 8830b9d653..465be82c4a 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -175,6 +175,7 @@ void vout_IntfInit( vout_thread_t *p_vout ) /* Create a few object variables we'll need later on */ var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); + var_Create( p_vout, "snapshot-format", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); @@ -259,7 +260,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) char *psz_filename; subpicture_t *p_subpic; picture_t *p_pif; - vlc_value_t val; + vlc_value_t val, format; int i_ret; var_Get( p_vout, "snapshot-path", &val ); @@ -268,20 +269,35 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) free( val.psz_string ); val.psz_string = 0; } +#ifdef SYS_DARWIN + if( !val.psz_string && p_vout->p_vlc->psz_homedir ) + { + asprintf( &val.psz_string, "%s/Desktop", + p_vout->p_vlc->psz_homedir ); + } +#else if( !val.psz_string && p_vout->p_vlc->psz_homedir ) { asprintf( &val.psz_string, "%s/" CONFIG_DIR, p_vout->p_vlc->psz_homedir ); } +#endif if( !val.psz_string ) { msg_Err( p_vout, "no directory specified for snapshots" ); return VLC_EGENERIC; } + var_Get( p_vout, "snapshot-format", &format ); + if( format.psz_string && !*format.psz_string ) + { + free( format.psz_string ); + format.psz_string = strdup( "png" ); + } - asprintf( &psz_filename, "%s/vlcsnap-%u.png", val.psz_string, - (unsigned int)(p_pic->date / 100000) & 0xFFFFFF ); + asprintf( &psz_filename, "%s/vlcsnap-%u.%s", val.psz_string, + (unsigned int)(p_pic->date / 100000) & 0xFFFFFF, format.psz_string ); free( val.psz_string ); + free( format.psz_string ); /* Save the snapshot */ fmt_in.i_chroma = p_vout->render.i_chroma;