📄 bookmarks.m
字号:
/***************************************************************************** * bookmarks.m: MacOS X Bookmarks window ***************************************************************************** * Copyright (C) 2005, 2006 the VideoLAN team * $Id: bookmarks.m 15136 2006-04-07 18:38:30Z fkuehne $ * * Authors: Felix Kühne <fkuehne@users.sf.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Note: * the code used to bind with VLC's modules is heavily based upon * ../wxwidgets/bookmarks.cpp, written by Gildas Bazin. * (he is a member of the VideoLAN team) *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#import "bookmarks.h"#import "intf.h"#import "wizard.h"#import <vlc/intf.h>/***************************************************************************** * VLCExtended implementation * * implements the GUI functions for the window, the data source and the * delegate for o_tbl_dataTable *****************************************************************************/@implementation VLCBookmarksstatic VLCBookmarks *_o_sharedInstance = nil;+ (VLCBookmarks *)sharedInstance{ return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];}- (id)init{ if (_o_sharedInstance) { [self dealloc]; } else { _o_sharedInstance = [super init]; } return _o_sharedInstance;}/***************************************************************************** * GUI methods *****************************************************************************/- (void)awakeFromNib{ [self initStrings];}- (void)dealloc{ if( p_old_input ) { vlc_object_release( p_old_input ); } [super dealloc];}- (void)initStrings{ /* localise the items */ /* main window */ [o_bookmarks_window setTitle: _NS("Bookmarks")]; [o_btn_add setTitle: _NS("Add")]; [o_btn_clear setTitle: _NS("Clear")]; [o_btn_edit setTitle: _NS("Edit")]; [o_btn_extract setTitle: _NS("Extract")]; [o_btn_rm setTitle: _NS("Remove")]; [[[o_tbl_dataTable tableColumnWithIdentifier:@"description"] headerCell] setStringValue: _NS("Description")]; [[[o_tbl_dataTable tableColumnWithIdentifier:@"size_offset"] headerCell] setStringValue: _NS("Position")]; [[[o_tbl_dataTable tableColumnWithIdentifier:@"time_offset"] headerCell] setStringValue: _NS("Time")]; /* edit window */ [o_edit_btn_ok setTitle: _NS("OK")]; [o_edit_btn_cancel setTitle: _NS("Cancel")]; [o_edit_lbl_name setStringValue: _NS("Name")]; [o_edit_lbl_time setStringValue: _NS("Time")]; [o_edit_lbl_bytes setStringValue: _NS("Position")];}- (void)showBookmarks{ /* show the window, called from intf.m */ [o_bookmarks_window displayIfNeeded]; [o_bookmarks_window makeKeyAndOrderFront: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; seekpoint_t bookmark; vlc_value_t pos; bookmark.psz_name = NULL; bookmark.i_byte_offset = 0; bookmark.i_time_offset = 0; var_Get(p_intf, "position", &pos); bookmark.psz_name = _("Untitled"); input_Control( p_input, INPUT_GET_BYTE_POSITION, &bookmark.i_byte_offset ); var_Get( p_input, "time", &pos ); bookmark.i_time_offset = pos.i_time; input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark ); vlc_object_release( p_input ); [o_tbl_dataTable reloadData];}- (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 ); if( !p_input ) return; input_Control( p_input, INPUT_CLEAR_BOOKMARKS ); vlc_object_release( p_input ); [o_tbl_dataTable reloadData];}- (IBAction)edit:(id)sender{ /* 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 ); seekpoint_t **pp_bookmarks; int i_bookmarks; char * toBeReturned; toBeReturned = ""; int i_toBeReturned; i_toBeReturned = 0; int row; row = [o_tbl_dataTable selectedRow]; 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; } else if(row < 0) { vlc_object_release( p_input ); return; } else { [o_edit_fld_name setStringValue: [NSString stringWithUTF8String: pp_bookmarks[row]->psz_name]]; [o_edit_fld_time setStringValue: [[NSNumber numberWithInt: (pp_bookmarks[row]->i_time_offset / 1000000)] stringValue]]; [o_edit_fld_bytes setStringValue: [[NSNumber numberWithInt: pp_bookmarks[row]->i_byte_offset] stringValue]]; } p_old_input = p_input; vlc_object_release( p_input ); [NSApp beginSheet: o_edit_window modalForWindow: o_bookmarks_window modalDelegate: o_edit_window didEndSelector: nil contextInfo: nil];}- (IBAction)edit_cancel:(id)sender{ /* close sheet */ [NSApp endSheet:o_edit_window]; [o_edit_window close];}- (IBAction)edit_ok:(id)sender{ /* save field contents and close sheet */ intf_thread_t * p_intf = VLCIntf; 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 ); if( !p_input ) { NSBeginCriticalAlertSheet(_NS("No input"), _NS("OK"), @"", @"", o_bookmarks_window, nil, nil, nil, nil, _NS("No " "input found. A stream must be playing or paused for " "bookmarks to work.")); return; } if( p_old_input != p_input ) { NSBeginCriticalAlertSheet(_NS("Input has changed"), _NS("OK"), @"", @"", o_bookmarks_window, nil, nil, nil, nil, _NS("Input " "has changed, unable to save bookmark. Suspending playback with " "\"Pause\" while editing bookmarks to ensure to keep the same " "input.")); vlc_object_release( p_input ); return; } if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, &i_bookmarks ) != VLC_SUCCESS ) { vlc_object_release( p_input ); return; } i = [o_tbl_dataTable selectedRow];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -