Commit fa1bf19a authored by Felix Paul Kühne's avatar Felix Paul Kühne

* implemented a non-blocking progress-bar in the main interface; needs testing (closes #475)

parent 3fbed7ad
......@@ -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;
......
......@@ -18,7 +18,7 @@
<string>777 479 187 249 0 0 1440 878 </string>
</dict>
<key>IBFramework Version</key>
<string>439.0</string>
<string>446.1</string>
<key>IBLockedObjects</key>
<array/>
<key>IBOpenObjects</key>
......@@ -26,6 +26,6 @@
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>8I127</string>
<string>8J135</string>
</dict>
</plist>
......@@ -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 ));
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment