📄 interaction.m
字号:
contextInfo:(void *)o_context{ vlc_object_lock( p_dialog->p_interaction ); if( i_return == NSAlertDefaultReturn ) { p_dialog->i_return = DIALOG_OK_YES; } else if( i_return == NSAlertAlternateReturn ) { p_dialog->i_return = DIALOG_NO; } else if( i_return == NSAlertOtherReturn ) { p_dialog->i_return = DIALOG_CANCELLED; } p_dialog->i_status = ANSWERED_DIALOG; vlc_object_unlock( p_dialog->p_interaction );}-(void)updateDialog{ if( p_dialog->i_flags & DIALOG_USER_PROGRESS ) { [o_prog_description setStringValue: [NSString stringWithUTF8String: p_dialog->psz_description]]; [o_prog_bar setDoubleValue: (double)p_dialog->val.f_float]; if( [o_prog_bar doubleValue] == 100.0 ) { /* we are done, let's hide */ [self hideDialog]; } if( p_dialog->i_timeToGo < 1 ) [o_prog_timeToGo setStringValue: @""]; else [o_prog_timeToGo setStringValue: [NSString stringWithFormat: _NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]]; return; } if( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) { [[VLCMain sharedInstance] setScrollField: [NSString stringWithUTF8String: p_dialog->psz_description] stopAfter: -1]; [o_mainIntfPgbar setDoubleValue: (double)p_dialog->val.f_float]; if( [o_mainIntfPgbar doubleValue] == 100.0 ) { /* we are done, let's hide */ [self hideDialog]; } return; }}-(void)hideDialog{ msg_Dbg( p_intf, "hide event %p", self ); if( p_dialog->i_flags & DIALOG_USER_PROGRESS ) { if([o_prog_win isVisible]) { [NSApp endSheet: o_prog_win]; [o_prog_win close]; } } if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) { if([o_auth_win isVisible]) { [NSApp endSheet: o_auth_win]; [o_auth_win close]; } } if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL ) { if([o_input_win isVisible]) { [NSApp endSheet: o_input_win]; [o_input_win close]; } } if( p_dialog->i_flags & DIALOG_INTF_PROGRESS ) { [o_mainIntfPgbar setIndeterminate: YES]; [o_mainIntfPgbar setHidden: YES]; [[VLCMain sharedInstance] resetScrollField]; }}-(void)destroyDialog{ msg_Dbg( p_intf, "destroy event" ); if( o_mainIntfPgbar ) [o_mainIntfPgbar release];}- (IBAction)cancelAndClose:(id)sender{ /* tell the core that the dialog was cancelled in a yes/no-style dialogue */ vlc_object_lock( p_dialog->p_interaction ); p_dialog->i_return = DIALOG_CANCELLED; p_dialog->i_status = ANSWERED_DIALOG; vlc_object_unlock( p_dialog->p_interaction ); msg_Dbg( p_intf, "dialog cancelled" );}- (IBAction)cancelDialog:(id)sender{ /* tell core that the user wishes to cancel the dialogue * Use this function if cancelling is optionally like in the progress-dialogue */ vlc_object_lock( p_dialog->p_interaction ); p_dialog->b_cancelled = true; vlc_object_unlock( p_dialog->p_interaction ); msg_Dbg( p_intf, "cancelling dialog, will close it later on" );}- (IBAction)okayAndClose:(id)sender{ msg_Dbg( p_intf, "running okayAndClose" ); vlc_object_lock( p_dialog->p_interaction ); if( p_dialog->i_flags == DIALOG_LOGIN_PW_OK_CANCEL ) { p_dialog->psz_returned[0] = strdup( [[o_auth_login_fld stringValue] UTF8String] ); p_dialog->psz_returned[1] = strdup( [[o_auth_pw_fld stringValue] UTF8String] ); } else if( p_dialog->i_flags == DIALOG_PSZ_INPUT_OK_CANCEL ) p_dialog->psz_returned[0] = strdup( [[o_input_fld stringValue] UTF8String] ); p_dialog->i_return = DIALOG_OK_YES; p_dialog->i_status = ANSWERED_DIALOG; vlc_object_unlock( p_dialog->p_interaction ); msg_Dbg( p_intf, "dialog acknowledged" );}@end/***************************************************************************** * VLCErrorInteractionPanel implementation *****************************************************************************/@implementation VLCErrorInteractionPanel-(id)init{ [super init]; /* load the nib */ nib_interact_errpanel_loaded = [NSBundle loadNibNamed:@"InteractionErrorPanel" owner:self]; /* init strings */ [o_window setTitle: _NS("Errors and Warnings")]; [o_cleanup_button setTitle: _NS("Clean up")]; [o_messages_btn setTitle: _NS("Show Details")]; /* init data sources */ o_errors = [[NSMutableArray alloc] init]; o_icons = [[NSMutableArray alloc] init]; return self;}-(void)dealloc{ [o_errors release]; [o_icons release]; [super dealloc];}-(void)showPanel{ [o_window makeKeyAndOrderFront: self];}-(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg{ /* format our string as desired */ NSMutableAttributedString * ourError; ourError = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"%@\n%@", o_error, o_msg] attributes: [NSDictionary dictionaryWithObject: [NSFont systemFontOfSize:11] forKey: NSFontAttributeName]]; [ourError addAttribute: NSFontAttributeName value: [NSFont boldSystemFontOfSize:11] range: NSMakeRange( 0, [o_error length])]; [o_errors addObject: ourError]; [ourError release]; [o_icons addObject: [NSImage imageWithErrorIcon]]; [o_error_table reloadData];}-(void)addWarning: (NSString *)o_warning withMsg:(NSString *)o_msg{ /* format our string as desired */ NSMutableAttributedString * ourWarning; ourWarning = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"%@\n%@", o_warning, o_msg] attributes: [NSDictionary dictionaryWithObject: [NSFont systemFontOfSize:11] forKey: NSFontAttributeName]]; [ourWarning addAttribute: NSFontAttributeName value: [NSFont boldSystemFontOfSize:11] range: NSMakeRange( 0, [o_warning length])]; [o_errors addObject: ourWarning]; [ourWarning release]; [o_icons addObject: [NSImage imageWithWarningIcon]]; [o_error_table reloadData];}-(IBAction)cleanupTable:(id)sender{ [o_errors removeAllObjects]; [o_icons removeAllObjects]; [o_error_table reloadData];}-(IBAction)showMessages:(id)sender{ [[VLCMain sharedInstance] showMessagesPanel: sender];}/*---------------------------------------------------------------------------- * data source methods *---------------------------------------------------------------------------*/- (int)numberOfRowsInTableView:(NSTableView *)theDataTable{ return [o_errors count];}- (id)tableView:(NSTableView *)theDataTable objectValueForTableColumn: (NSTableColumn *)theTableColumn row: (int)row{ if( [[theTableColumn identifier] isEqualToString: @"error_msg"] ) return [o_errors objectAtIndex: row]; if( [[theTableColumn identifier] isEqualToString: @"icon"] ) return [o_icons objectAtIndex: row]; return @"unknown identifier";}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -