From: Felix Paul Kühne Date: Mon, 3 Jul 2006 10:38:09 +0000 (+0000) Subject: * implemented a non-blocking progress-bar in the main interface; needs testing (close... X-Git-Tag: 0.9.0-test0~10920 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=fa1bf19af0adba012589e25280b7ea1baf948a44;p=vlc * implemented a non-blocking progress-bar in the main interface; needs testing (closes #475) --- diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib index cd3dedb63f..866c8430ec 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib @@ -226,6 +226,7 @@ "o_err_msg" = id; "o_error" = id; "o_info" = id; + "o_main_pgbar" = id; "o_messages" = id; "o_mi_about" = id; "o_mi_add_intf" = id; diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib index bdb24bbde4..380fb947dc 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib @@ -18,7 +18,7 @@ 777 479 187 249 0 0 1440 878 IBFramework Version - 439.0 + 446.1 IBLockedObjects IBOpenObjects @@ -26,6 +26,6 @@ 21 IBSystem Version - 8I127 + 8J135 diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib index 01ab78dd2b..d9dea177e7 100644 Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/include/vlc_interaction.h b/include/vlc_interaction.h index 1873d9afa5..b0723ff17b 100644 --- a/include/vlc_interaction.h +++ b/include/vlc_interaction.h @@ -84,6 +84,7 @@ struct interaction_dialog_t #define DIALOG_LOGIN_PW_OK_CANCEL 0x20 #define DIALOG_USER_PROGRESS 0x40 #define DIALOG_PSZ_INPUT_OK_CANCEL 0x80 +#define DIALOG_INTF_PROGRESS 0x100 /** * Possible return codes @@ -175,13 +176,17 @@ VLC_EXPORT( int, __intf_UserOkayCancel,( vlc_object_t*, const char*, const char* #define intf_UserProgress( a, b, c, d ) __intf_UserProgress( VLC_OBJECT(a),b,c, d ) VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float) ); - #define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c, d ) VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) ); #define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d ) VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) ); +#define intf_IntfProgress( a, b, c, d ) __intf_IntfProgress( VLC_OBJECT(a),b,c, d ) +VLC_EXPORT( int, __intf_IntfProgress,( vlc_object_t*, const char*, float) ); +#define intf_IntfProgressUpdate( a, b, c, d ) __intf_IntfProgressUpdate( VLC_OBJECT(a),b,c, d ) +VLC_EXPORT( void, __intf_IntfProgressUpdate,( vlc_object_t*, int, const char*, float) ); + #define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b ) VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int )); diff --git a/modules/gui/macosx/interaction.m b/modules/gui/macosx/interaction.m index d1d5c206f7..aac169c021 100644 --- a/modules/gui/macosx/interaction.m +++ b/modules/gui/macosx/interaction.m @@ -160,7 +160,7 @@ { if( p_dialog->i_flags & DIALOG_OK_CANCEL ) { - msg_Dbg( p_intf, "requested flag: DIALOG_OK_CANCEL" ); + msg_Dbg( p_intf, "OK-Cancel-dialog requested" ); NSBeginInformationalAlertSheet( o_title, _NS("OK") , _NS("Cancel"), nil, o_window, self, @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil, @@ -168,7 +168,7 @@ } else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) { - msg_Dbg( p_intf, "requested flag: DIALOG_YES_NO_CANCEL" ); + msg_Dbg( p_intf, "yes-no-cancel-dialog requested" ); NSBeginInformationalAlertSheet( o_title, _NS("Yes"), _NS("No"), _NS("Cancel"), o_window, self, @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil, @@ -176,7 +176,7 @@ } else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) { - msg_Dbg( p_intf, "requested flag: DIALOG_LOGIN_PW_OK_CANCEL" ); + msg_Dbg( p_intf, "dialog for login and pw requested" ); [o_auth_title setStringValue: o_title]; [o_auth_description setStringValue: o_description]; [o_auth_login_fld setStringValue: @""]; @@ -187,17 +187,17 @@ } else if( p_dialog->i_flags & DIALOG_USER_PROGRESS ) { - msg_Dbg( p_intf, "requested flag: DIALOG_USER_PROGRESS" ); + msg_Dbg( p_intf, "user progress dialog requested" ); [o_prog_title setStringValue: o_title]; [o_prog_description setStringValue: o_description]; - [o_prog_bar setDoubleValue: 0]; + [o_prog_bar setFloatValue: p_dialog->val.f_float]; [NSApp beginSheet: o_prog_win modalForWindow: o_window modalDelegate: self didEndSelector: nil contextInfo: nil]; [o_prog_win makeKeyWindow]; } else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL ) { - msg_Dbg( p_intf, "requested flag: DIALOG_PSZ_INPUT_OK_CANCEL" ); + msg_Dbg( p_intf, "text input requested" ); [o_input_title setStringValue: o_title]; [o_input_description setStringValue: o_description]; [o_input_fld setStringValue: @""]; @@ -205,6 +205,16 @@ modalDelegate: self didEndSelector: nil contextInfo: nil]; [o_input_win makeKeyWindow]; } + else if( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) + { + msg_Dbg( p_intf, "progress-bar in main intf requested" ); + [[[VLCMain sharedInstance] getMainScrollField] + setStringValue: o_description]; + [[[VLCMain sharedInstance] getMainIntfPgbar] + setFloatValue: p_dialog->val.f_float]; + [[[VLCMain sharedInstance] getMainIntfPgbar] setHidden: NO]; + [[[VLCMain sharedInstance] getControllerWindow] makeKeyWindow]; + } else msg_Warn( p_intf, "requested dialog type unknown" ); } @@ -240,8 +250,7 @@ { [o_prog_description setStringValue: \ [NSString stringWithUTF8String: p_dialog->psz_description]]; - [o_prog_bar setDoubleValue: \ - (double)(p_dialog->val.f_float)]; + [o_prog_bar setFloatValue: p_dialog->val.f_float]; if( [o_prog_bar doubleValue] == 100.0 ) { @@ -250,6 +259,20 @@ return; } } + if( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) + { + [[[VLCMain sharedInstance] getMainScrollField] setStringValue: \ + [NSString stringWithUTF8String: p_dialog->psz_description]]; + [[[VLCMain sharedInstance] getMainIntfPgbar] setFloatValue: \ + p_dialog->val.f_float]; + + if( [[[VLCMain sharedInstance] getMainIntfPgbar] doubleValue] == 100.0 ) + { + /* we are done, let's hide */ + [self hideDialog]; + return; + } + } } -(void)hideDialog @@ -270,6 +293,12 @@ [NSApp endSheet: o_input_win]; [o_input_win close]; } + if( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) + { + [[[VLCMain sharedInstance] getMainIntfPgbar] setIndeterminate: YES]; + [[[VLCMain sharedInstance] getMainScrollField] setStringValue: @""]; + [[[VLCMain sharedInstance] getMainIntfPgbar] setHidden: YES]; + } } -(void)destroyDialog diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index 21d3131f8a..df19aeda93 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -119,6 +119,7 @@ struct intf_sys_t float f_slider_old; /* old slider val */ IBOutlet id o_volumeslider; /* volume slider */ + IBOutlet id o_main_pgbar; /* main interface progress bar */ IBOutlet id o_btn_prev; /* btn previous */ IBOutlet id o_btn_rewind; /* btn rewind */ IBOutlet id o_btn_play; /* btn play */ @@ -292,6 +293,9 @@ struct intf_sys_t - (id)getBookmarks; - (id)getEmbeddedList; - (id)getInteractionList; +- (id)getMainIntfPgbar; +- (id)getMainScrollField; +- (id)getControllerWindow; - (void)terminate; - (NSString *)localizedString:(char *)psz; - (char *)delocalizeString:(NSString *)psz; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 40de372a38..269442e676 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -913,6 +913,31 @@ static VLCMain *_o_sharedMainInstance = nil; return nil; } +- (id)getMainIntfPgbar +{ + if( o_main_pgbar ) + return o_main_pgbar; + + msg_Err( p_intf, "main interface progress bar item wasn't found" ); + return nil; +} + +- (id)getMainScrollField +{ + if( o_scrollfield ) + return o_scrollfield; + + msg_Err( p_intf, "main scroll field item wasn't found" ); + return nil; +} + +- (id)getControllerWindow +{ + if( o_window ) + return o_window; + return nil; +} + - (void)manage { playlist_t * p_playlist; diff --git a/src/interface/interaction.c b/src/interface/interaction.c index 111360a876..071a54c08a 100644 --- a/src/interface/interaction.c +++ b/src/interface/interaction.c @@ -457,6 +457,67 @@ int __intf_UserStringInput( vlc_object_t *p_this, return i_ret; } +/** Helper function to create a progress-bar in the main interface with a + * single-line description + * \param p_this Parent vlc_object + * \param psz_status Current status + * \param f_position Current position (0.0->100.0) + * \return Dialog id, to give to IntfProgressUpdate + */ +int __intf_IntfProgress( vlc_object_t *p_this, + const char *psz_status, + float f_pos ) +{ + int i_ret; + interaction_dialog_t *p_new = NULL; + + INTERACT_INIT( p_new ); + + p_new->i_type = INTERACT_DIALOG_ONEWAY; + p_new->psz_description = strdup( psz_status ); + p_new->val.f_float = f_pos; + + p_new->i_flags = DIALOG_INTF_PROGRESS; + + i_ret = intf_Interact( p_this, p_new ); + + return p_new->i_id; +} + +/** Update the progress bar in the main interface + * \param p_this Parent vlc_object + * \param i_id Identifier of the dialog + * \param psz_status New status + * \param f_position New position (0.0->100.0) + * \return nothing + */ +void __intf_IntfProgressUpdate( vlc_object_t *p_this, int i_id, + const char *psz_status, float f_pos ) +{ + interaction_t *p_interaction = intf_InteractionGet( p_this ); + interaction_dialog_t *p_dialog; + + if( !p_interaction ) return; + + vlc_mutex_lock( &p_interaction->object_lock ); + p_dialog = intf_InteractionGetById( p_this, i_id ); + + if( !p_dialog ) + { + vlc_mutex_unlock( &p_interaction->object_lock ) ; + return; + } + + if( p_dialog->psz_description ) + free( p_dialog->psz_description ); + p_dialog->psz_description = strdup( psz_status ); + + p_dialog->val.f_float = f_pos; + + p_dialog->i_status = UPDATED_DIALOG; + vlc_mutex_unlock( &p_interaction->object_lock) ; +} + /** Hide an interaction dialog * \param p_this the parent vlc object * \param i_id the id of the item to hide