X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fbookmarks.m;h=5c562b058101a0b8ef7939c8ab7fb2a56afd9a00;hb=fcc30d464b150e5d01a8028a9edc5af66b81b630;hp=69df666e437a4b93a6b30ee612ce6ae500cf6972;hpb=1c10df82d7f1f62c75510fa68e4683260336b9d2;p=vlc diff --git a/modules/gui/macosx/bookmarks.m b/modules/gui/macosx/bookmarks.m index 69df666e43..5c562b0581 100644 --- a/modules/gui/macosx/bookmarks.m +++ b/modules/gui/macosx/bookmarks.m @@ -117,11 +117,9 @@ static VLCBookmarks *_o_sharedInstance = nil; - (IBAction)add:(id)sender { /* add item to list */ - intf_thread_t * p_intf = VLCIntf; - input_thread_t * p_input = (input_thread_t *)vlc_object_find( p_intf, - VLC_OBJECT_INPUT, FIND_ANYWHERE ); - if( !p_input ) - return; + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); + + if( !p_input ) return; seekpoint_t bookmark; vlc_value_t pos; @@ -129,7 +127,7 @@ static VLCBookmarks *_o_sharedInstance = nil; bookmark.i_byte_offset = 0; bookmark.i_time_offset = 0; - var_Get(p_intf, "position", &pos); + var_Get( VLCIntf, "position", &pos); bookmark.psz_name = _("Untitled"); input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset ); var_Get( p_input, "time", &pos ); @@ -144,9 +142,7 @@ static VLCBookmarks *_o_sharedInstance = nil; - (IBAction)clear:(id)sender { /* clear table */ - intf_thread_t * p_intf = VLCIntf; - input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, - VLC_OBJECT_INPUT, FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); if( !p_input ) return; @@ -163,9 +159,7 @@ static VLCBookmarks *_o_sharedInstance = nil; /* put values to the sheet's fields and show sheet */ /* we take the values from the core and not the table, because we cannot * really trust it */ - intf_thread_t * p_intf = VLCIntf; - input_thread_t * p_input = (input_thread_t *)vlc_object_find( p_intf, - VLC_OBJECT_INPUT, FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); seekpoint_t **pp_bookmarks; int i_bookmarks; int row; @@ -214,12 +208,9 @@ static VLCBookmarks *_o_sharedInstance = nil; - (IBAction)edit_ok:(id)sender { /* save field contents and close sheet */ - - intf_thread_t * p_intf = VLCIntf; - seekpoint_t **pp_bookmarks; + seekpoint_t **pp_bookmarks; int i_bookmarks, i; - input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_intf, - VLC_OBJECT_INPUT, FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); if( !p_input ) { @@ -258,7 +249,7 @@ static VLCBookmarks *_o_sharedInstance = nil; if( input_Control( p_input, INPUT_CHANGE_BOOKMARK, pp_bookmarks[i], i ) != VLC_SUCCESS ) { - msg_Warn( p_intf, "Unable to change the bookmark"); + msg_Warn( VLCIntf, "Unable to change the bookmark"); vlc_object_release( p_input ); return; } @@ -274,9 +265,6 @@ static VLCBookmarks *_o_sharedInstance = nil; - (IBAction)extract:(id)sender { /* extract */ - - intf_thread_t * p_intf = VLCIntf; - if( [o_tbl_dataTable numberOfSelectedRows] < 2 ) { NSBeginAlertSheet(_NS("Invalid selection"), _NS("OK"), @@ -284,9 +272,7 @@ static VLCBookmarks *_o_sharedInstance = nil; _NS("Two bookmarks have to be selected.")); return; } - input_thread_t *p_input = - (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, - FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); if( !p_input ) { NSBeginCriticalAlertSheet(_NS("No input found"), _NS("OK"), @@ -319,16 +305,16 @@ static VLCBookmarks *_o_sharedInstance = nil; x = (x + 1); } - msg_Dbg(p_intf, "got the bookmark-indexes"); + msg_Dbg( VLCIntf, "got the bookmark-indexes"); if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks ) != VLC_SUCCESS ) { vlc_object_release( p_input ); - msg_Err(p_intf, "already defined bookmarks couldn't be retrieved"); + msg_Err( VLCIntf, "already defined bookmarks couldn't be retrieved"); return; } - msg_Dbg(p_intf, "calling wizard"); + msg_Dbg( VLCIntf, "calling wizard"); char *psz_uri = input_item_GetURI( input_GetItem( p_input ) ); [[[VLCMain sharedInstance] getWizard] initWithExtractValuesFrom: @@ -339,15 +325,12 @@ static VLCBookmarks *_o_sharedInstance = nil; ofItem: [NSString stringWithUTF8String: psz_uri]]; free( psz_uri ); vlc_object_release( p_input ); - msg_Dbg(p_intf, "released input"); + msg_Dbg( VLCIntf, "released input"); } - (IBAction)goToBookmark:(id)sender { - intf_thread_t * p_intf = VLCIntf; - input_thread_t *p_input = - (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, - FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); if( !p_input ) return; @@ -359,10 +342,7 @@ static VLCBookmarks *_o_sharedInstance = nil; - (IBAction)remove:(id)sender { /* remove selected item */ - intf_thread_t * p_intf = VLCIntf; - input_thread_t *p_input = - (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, - FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); if( !p_input ) return; @@ -392,9 +372,7 @@ static VLCBookmarks *_o_sharedInstance = nil; - (int)numberOfRowsInTableView:(NSTableView *)theDataTable { /* return the number of bookmarks */ - intf_thread_t * p_intf = VLCIntf; - input_thread_t * p_input = (input_thread_t *)vlc_object_find( p_intf, - VLC_OBJECT_INPUT, FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); seekpoint_t **pp_bookmarks; int i_bookmarks; @@ -415,53 +393,48 @@ static VLCBookmarks *_o_sharedInstance = nil; (NSTableColumn *)theTableColumn row: (int)row { /* return the corresponding data as NSString */ - intf_thread_t * p_intf = VLCIntf; - input_thread_t * p_input = (input_thread_t *)vlc_object_find( p_intf, - VLC_OBJECT_INPUT, FIND_ANYWHERE ); + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); seekpoint_t **pp_bookmarks; int i_bookmarks; char *toBeReturned; int i_toBeReturned = 0; - + id ret; + if( !p_input ) return @""; else if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks ) != VLC_SUCCESS ) { - vlc_object_release( p_input ); - return @""; + ret = @""; } else { if ([[theTableColumn identifier] isEqualToString: @"description"]) { toBeReturned = pp_bookmarks[row]->psz_name; - vlc_object_release( p_input ); - return [NSString stringWithUTF8String: toBeReturned]; + ret = [NSString stringWithUTF8String: toBeReturned]; } else if ([[theTableColumn identifier] isEqualToString: @"size_offset"]) { i_toBeReturned = pp_bookmarks[row]->i_byte_offset; - vlc_object_release( p_input ); - return [[NSNumber numberWithInt: i_toBeReturned] stringValue]; + ret = [[NSNumber numberWithInt: i_toBeReturned] stringValue]; } else if ([[theTableColumn identifier] isEqualToString: @"time_offset"]) { i_toBeReturned = pp_bookmarks[row]->i_time_offset; - vlc_object_release( p_input ); - return [[NSNumber numberWithInt: (i_toBeReturned / 1000000)] + ret = [[NSNumber numberWithInt: (i_toBeReturned / 1000000)] stringValue]; } else { /* may not happen, just in case */ - vlc_object_release( p_input ); - msg_Err(p_intf, "unknown table column identifier (%s) while " + msg_Err( VLCIntf, "unknown table column identifier (%s) while " "updating the bookmark table", [[theTableColumn identifier] UTF8String] ); - return @"unknown identifier"; + ret = @"unknown identifier"; } } - + vlc_object_release( p_input ); + return ret; } /*****************************************************************************