From: Felix Paul Kühne Date: Sun, 7 Aug 2005 17:54:45 +0000 (+0000) Subject: * ALL: ported the WX-bookmarks-window to Cocoa (closes #22) X-Git-Tag: 0.8.4~968 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=509ed543963645d4e73b1d4290ccd612477f8cca;p=vlc * ALL: ported the WX-bookmarks-window to Cocoa (closes #22) - complete functionality except "Extract" (I'm going to fix that next week) * MainMenu.nib: re-orded the window-menu a bit * wizard.*: added a method to launch it from the bookmarks --- diff --git a/Makefile.am b/Makefile.am index d8e4d64157..1998da5d1c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -164,6 +164,9 @@ EXTRA_DIST += \ extras/MacOSX/Resources/English.lproj/Wizard.nib/classes.nib \ extras/MacOSX/Resources/English.lproj/Wizard.nib/info.nib \ extras/MacOSX/Resources/English.lproj/Wizard.nib/keyedobjects.nib \ + extras/MacOSX/Resources/English.lproj/Bookmarks.nib/classes.nib \ + extras/MacOSX/Resources/English.lproj/Bookmarks.nib/info.nib \ + extras/MacOSX/Resources/English.lproj/Bookmarks.nib/keyedobjects.nib \ extras/MacOSX/Resources/English.lproj/InfoPlist.strings \ extras/MacOSX/Resources/a52.icns \ extras/MacOSX/Resources/aac.icns \ @@ -563,6 +566,8 @@ VLC-release.app: vlc wizard.m \ extended.h \ extended.m \ + bookmarks.h \ + bookmarks.m \ vout.m; do \ cp "$(srcdir)/modules/gui/macosx/$$i" \ $(top_builddir)/tmp/modules/gui/macosx; \ @@ -576,9 +581,9 @@ VLC-release.app: vlc cd ../../../; \ cp -r $(top_builddir)/tmp/extras/MacOSX/build/VLC.bundle \ $(top_builddir)/VLC-release.app;; \ - *darwin8*) cd $(top_builddir)/tmp/extras/MacOSX && xcodebuild -target vlc | grep -v '^\([ \t]\|$$\)'; \ + *darwin8*) cd $(top_builddir)/tmp/extras/Default/MacOSX && xcodebuild -target vlc | grep -v '^\([ \t]\|$$\)'; \ cd ../../../; \ - cp -r $(top_builddir)/tmp/extras/MacOSX/build/Default/VLC.bundle \ + cp -r $(top_builddir)/tmp/extras/MacOSX/build/VLC.bundle \ $(top_builddir)/VLC-release.app;; \ esac rm -Rf $(top_builddir)/tmp @@ -675,6 +680,8 @@ VLC.app: vlc wizard.m \ extended.h \ extended.m \ + bookmarks.h \ + bookmarks.m \ vout.m; do \ cp "$(srcdir)/modules/gui/macosx/$$i" \ $(top_builddir)/tmp/modules/gui/macosx; \ @@ -688,9 +695,9 @@ VLC.app: vlc cd ../../../; \ cp -r $(top_builddir)/tmp/extras/MacOSX/build/VLC.bundle \ $(top_builddir)/VLC.app;; \ - *darwin8*) cd $(top_builddir)/tmp/extras/MacOSX && xcodebuild -target vlc | grep -v '^\([ \t]\|$$\)'; \ + *darwin8*) cd $(top_builddir)/tmp/extras/Default/MacOSX && xcodebuild -target vlc | grep -v '^\([ \t]\|$$\)'; \ cd ../../../; \ - cp -r $(top_builddir)/tmp/extras/MacOSX/build/Default/VLC.bundle \ + cp -r $(top_builddir)/tmp/extras/MacOSX/build/VLC.bundle \ $(top_builddir)/VLC.app;; \ esac rm -Rf $(top_builddir)/tmp diff --git a/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/classes.nib new file mode 100644 index 0000000000..d0ee11f0bd --- /dev/null +++ b/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/classes.nib @@ -0,0 +1,40 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = { + add = id; + clear = id; + edit = id; + "edit_cancel" = id; + "edit_ok" = id; + extract = id; + goToBookmark = id; + myAction = id; + remove = id; + }; + CLASS = VLCBookmarks; + LANGUAGE = ObjC; + OUTLETS = { + "o_bookmarks_window" = id; + "o_btn_add" = id; + "o_btn_clear" = id; + "o_btn_edit" = id; + "o_btn_extract" = id; + "o_btn_rm" = id; + "o_edit_btn_cancel" = id; + "o_edit_btn_ok" = id; + "o_edit_fld_bytes" = id; + "o_edit_fld_name" = id; + "o_edit_fld_time" = id; + "o_edit_lbl_bytes" = id; + "o_edit_lbl_name" = id; + "o_edit_lbl_time" = id; + "o_edit_window" = id; + "o_tbl_dataTable" = id; + }; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/info.nib b/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/info.nib new file mode 100644 index 0000000000..9e1a52373c --- /dev/null +++ b/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/info.nib @@ -0,0 +1,17 @@ + + + + + IBDocumentLocation + 69 67 356 240 0 0 1440 878 + IBFramework Version + 437.0 + IBOpenObjects + + 38 + 5 + + IBSystem Version + 8C46 + + diff --git a/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/keyedobjects.nib new file mode 100644 index 0000000000..c1884e24e4 Binary files /dev/null and b/extras/MacOSX/Resources/English.lproj/Bookmarks.nib/keyedobjects.nib differ diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib index a0f25df9bc..4822a2a475 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib @@ -107,6 +107,7 @@ openRecentItem = id; openWebsite = id; reportABug = id; + showBookmarks = id; showExtended = id; showWizard = id; timesliderUpdate = id; @@ -143,6 +144,7 @@ "o_mi_about" = id; "o_mi_add_intf" = id; "o_mi_audiotrack" = id; + "o_mi_bookmarks" = id; "o_mi_bring_atf" = id; "o_mi_bwd" = id; "o_mi_channels" = id; diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib index 14a54fdcef..a1308029cd 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib @@ -21,8 +21,8 @@ IBOpenObjects - 29 2029 + 29 21 IBSystem Version diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib index 51df906651..52f20866b4 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/extras/MacOSX/vlc.pbproj/project.pbxproj b/extras/MacOSX/vlc.pbproj/project.pbxproj index 043671c66f..30777a619b 100644 --- a/extras/MacOSX/vlc.pbproj/project.pbxproj +++ b/extras/MacOSX/vlc.pbproj/project.pbxproj @@ -826,6 +826,7 @@ DCA693C30789DF8700139EC6, DCFCCDB9085CE18F001E36AF, DC7F46ED08A183FC0027DB24, + DCE7BD0508A56C8B007B10AE, ); isa = PBXResourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -910,6 +911,8 @@ DC769AB7085DF0DB001A838D, DC7F46F008A187F60027DB24, DC7F46F108A187F60027DB24, + DCE7BD0708A5724D007B10AE, + DCE7BD0608A5724D007B10AE, ); isa = PBXGroup; name = Classes; @@ -2291,6 +2294,48 @@ settings = { }; }; + DCE7BD0308A56C8B007B10AE = { + children = ( + DCE7BD0408A56C8B007B10AE, + ); + isa = PBXVariantGroup; + name = Bookmarks.nib; + path = ""; + refType = 4; + sourceTree = ""; + }; + DCE7BD0408A56C8B007B10AE = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = English; + path = Resources/English.lproj/Bookmarks.nib; + refType = 4; + sourceTree = ""; + }; + DCE7BD0508A56C8B007B10AE = { + fileRef = DCE7BD0308A56C8B007B10AE; + isa = PBXBuildFile; + settings = { + }; + }; + DCE7BD0608A5724D007B10AE = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + name = bookmarks.m; + path = ../../modules/gui/macosx/bookmarks.m; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + DCE7BD0708A5724D007B10AE = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = bookmarks.h; + path = ../../modules/gui/macosx/bookmarks.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; DCF358B9077F10BA007DB450 = { children = ( DCF358BA077F10BA007DB450, @@ -2323,6 +2368,7 @@ DCA693C10789DF8700139EC6, DCFCCDB7085CE18F001E36AF, DC7F46EB08A183FC0027DB24, + DCE7BD0308A56C8B007B10AE, ); isa = PBXGroup; name = nibs; diff --git a/modules/gui/macosx/Modules.am b/modules/gui/macosx/Modules.am index f6d98fb710..79c60f666a 100644 --- a/modules/gui/macosx/Modules.am +++ b/modules/gui/macosx/Modules.am @@ -32,5 +32,7 @@ SOURCES_macosx = \ wizard.m \ extended.h \ extended.m \ + bookmarks.h \ + bookmarks.m \ $(NULL) diff --git a/modules/gui/macosx/bookmarks.h b/modules/gui/macosx/bookmarks.h new file mode 100644 index 0000000000..74e66bdf98 --- /dev/null +++ b/modules/gui/macosx/bookmarks.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * bookmarks.h: MacOS X Bookmarks window + ***************************************************************************** + * Copyright (C) 2005 the VideoLAN team + * $Id$ + * + * Authors: Felix KŸhne + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#import +#import + +@interface VLCBookmarks : NSObject +{ + /* main window */ + IBOutlet id o_bookmarks_window; + IBOutlet id o_btn_add; + IBOutlet id o_btn_clear; + IBOutlet id o_btn_edit; + IBOutlet id o_btn_extract; + IBOutlet id o_btn_rm; + IBOutlet id o_tbl_dataTable; + + /* edit window */ + IBOutlet id o_edit_window; + IBOutlet id o_edit_btn_ok; + IBOutlet id o_edit_btn_cancel; + IBOutlet id o_edit_lbl_name; + IBOutlet id o_edit_lbl_time; + IBOutlet id o_edit_lbl_bytes; + IBOutlet id o_edit_fld_name; + IBOutlet id o_edit_fld_time; + IBOutlet id o_edit_fld_bytes; + + input_thread_t *p_old_input; +} + +- (IBAction)add:(id)sender; +- (IBAction)clear:(id)sender; +- (IBAction)edit:(id)sender; +- (IBAction)extract:(id)sender; +- (IBAction)remove:(id)sender; +- (IBAction)goToBookmark:(id)sender; + +- (IBAction)edit_cancel:(id)sender; +- (IBAction)edit_ok:(id)sender; + ++ (VLCBookmarks *)sharedInstance; + +- (void)initStrings; +- (void)showBookmarks; +- (id)getDataTable; +@end diff --git a/modules/gui/macosx/bookmarks.m b/modules/gui/macosx/bookmarks.m new file mode 100644 index 0000000000..4651c95397 --- /dev/null +++ b/modules/gui/macosx/bookmarks.m @@ -0,0 +1,504 @@ +/***************************************************************************** + * bookmarks.m: MacOS X Bookmarks window + ***************************************************************************** + * Copyright (C) 2005 the VideoLAN team + * $Id$ + * + * Authors: Felix KŸhne + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111, 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 + +/***************************************************************************** + * VLCExtended implementation + * + * implements the GUI functions for the window, the data source and the + * delegate for o_tbl_dataTable + *****************************************************************************/ + +@implementation VLCBookmarks + +static 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) + { + free(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("Size offset")]; + [[[o_tbl_dataTable tableColumnWithIdentifier:@"time_offset"] headerCell] \ + setStringValue: _NS("Time offset")]; + + /* 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("Bytes")]; +} + +- (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; + 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. The 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. Use \"pause\" while " \ + "editing bookmarks 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; + } + + int i; + i = [o_tbl_dataTable selectedRow]; + + if( pp_bookmarks[i]->psz_name ) + { + free( pp_bookmarks[i]->psz_name ); + } + /* FIXME: putting the name to core does not work!! -- FK*/ + pp_bookmarks[i]->psz_name = strdup([[o_edit_fld_name stringValue] UTF8String]); + pp_bookmarks[i]->i_byte_offset = [[o_edit_fld_bytes stringValue] intValue]; + pp_bookmarks[i]->i_time_offset = ([[o_edit_fld_time stringValue] intValue] * 1000000); + + if( input_Control( p_input, INPUT_CHANGE_BOOKMARK, pp_bookmarks[i], i ) \ + != VLC_SUCCESS ) + { + msg_Warn( p_intf, "VLCBookmarks: changing bookmark failed"); + vlc_object_release( p_input ); + return; + } + + [o_tbl_dataTable reloadData]; + vlc_object_release( p_input ); + + + [NSApp endSheet: o_edit_window]; + [o_edit_window close]; +} + +- (IBAction)extract:(id)sender +{ + /* extract */ + + intf_thread_t * p_intf = VLCIntf; + /* + if( [o_tbl_dataTable numberOfSelectedRows] < 2 ) + { + NSBeginAlertSheet(_NS("Invalid selection"), _NS("OK"), \ + @"", @"", o_bookmarks_window, nil, nil, nil, nil, _NS("" \ + "You must select two bookmarks")); + return; + } + 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 found"), _NS("OK"), \ + @"", @"", o_bookmarks_window, nil, nil, nil, nil, _NS("" \ + "The stream must be playing or paused for bookmarks to work")); + return; + } + + seekpoint_t **pp_bookmarks; + int i_bookmarks ; + int i_first = -1; + int i_second = -1; + int x = 0; + int c = 0; + while (c != 2) + { + if([o_tbl_dataTable isRowSelected:x]) + { + if (i_first == -1) + { + i_first = x; + c = 1; + return; + } + else if (i_second == -1) + { + i_second = x; + c = 2; + return; + } + } + x = (x + 1); + } + + if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, \ + &i_bookmarks ) != VLC_SUCCESS ) + { + vlc_object_release( p_input ); + msg_Err(p_intf, "bookmarks couldn't be retrieved from core"); + return; + } + msg_Dbg(p_intf, "calling for wizard"); + + [[[VLCMain sharedInstance] getWizard] initWithExtractValuesFrom: \ + [[NSNumber numberWithInt: \ + (pp_bookmarks[i_first]->i_time_offset/1000000)] stringValue] \ + to: [[NSNumber numberWithInt: \ + (pp_bookmarks[i_second]->i_time_offset/1000000)] stringValue] \ + ofItem: [NSString stringWithUTF8String: \ + p_input->input.p_item->psz_uri]]; + vlc_object_release( p_input ); + msg_Dbg(p_intf, "released input");*/ + msg_Err(p_intf, "not implemented yet, sorry"); +} + +- (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 ); + + if( !p_input ) + { + return; + } + + input_Control( p_input, INPUT_SET_BOOKMARK, [o_tbl_dataTable selectedRow] ); + + vlc_object_release( p_input ); +} + +- (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 ); + + if( !p_input ) return; + + int i_focused = [o_tbl_dataTable selectedRow]; + if( i_focused >= 0 ) + { + input_Control( p_input, INPUT_DEL_BOOKMARK, i_focused ); + } + + vlc_object_release( p_input ); + + [o_tbl_dataTable reloadData]; +} + +/***************************************************************************** + * callback stuff + *****************************************************************************/ + +-(id)getDataTable +{ + return o_tbl_dataTable; +} + +/***************************************************************************** + * data source methods + *****************************************************************************/ + +- (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 ); + seekpoint_t **pp_bookmarks; + int i_bookmarks; + + if(!p_input) + { + return 0; + } else if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, \ + &i_bookmarks ) != VLC_SUCCESS ) + { + vlc_object_release( p_input ); + return 0; + } else { + return i_bookmarks; + } +} + +- (id)tableView:(NSTableView *)theDataTable objectValueForTableColumn: \ + (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 ); + seekpoint_t **pp_bookmarks; + int i_bookmarks; + char * toBeReturned; + toBeReturned = ""; + int i_toBeReturned; + i_toBeReturned = 0; + + 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 ([[theTableColumn identifier] isEqualToString: @"description"]) + { + toBeReturned = pp_bookmarks[row]->psz_name; + vlc_object_release( p_input ); + return [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]; + } + 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)] \ + stringValue]; + } + else + { + /* may not happen, but just in case */ + vlc_object_release( p_input ); + msg_Err(p_intf, "VLCBookmarks: unknown table column identifier " \ + "(%s) while updating table", [[theTableColumn identifier] \ + UTF8String] ); + return @"unknown identifier"; + } + } + +} + +/***************************************************************************** + * delegate methods + *****************************************************************************/ + +- (void)tableViewSelectionDidChange:(NSNotification *)aNotification +{ + /* check whether a row is selected and en-/disable the edit/remove buttons */ + if ([o_tbl_dataTable selectedRow] == -1) + { + /* no row is selected */ + [o_btn_edit setEnabled: NO]; + [o_btn_rm setEnabled: NO]; + [o_btn_extract setEnabled: NO]; + } else { + /* a row is selected */ + [o_btn_edit setEnabled: YES]; + [o_btn_rm setEnabled: YES]; + if ([o_tbl_dataTable numberOfSelectedRows] == 2) + { + [o_btn_extract setEnabled: YES]; + } + } +} + +@end diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index 75237ca069..c51bc3579b 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -92,10 +92,12 @@ struct intf_sys_t id o_open; /* VLCOpen */ id o_wizard; /* VLCWizard */ id o_extended; /* VLCExtended */ + id o_bookmarks; /* VLCBookmarks */ BOOL nib_open_loaded; /* reference to the open-nib */ BOOL nib_about_loaded; /* reference to the about-nib */ BOOL nib_wizard_loaded; /* reference to the wizard-nib */ BOOL nib_extended_loaded; /* reference to the extended-nib */ + BOOL nib_bookmarks_loaded; /* reference to the bookmarks-nib */ IBOutlet id o_window; /* main window */ IBOutlet id o_playlist_view;/* playlist view */ @@ -229,6 +231,7 @@ struct intf_sys_t IBOutlet id o_mi_controller; IBOutlet id o_mi_equalizer; IBOutlet id o_mi_extended; + IBOutlet id o_mi_bookmarks; IBOutlet id o_mi_playlist; IBOutlet id o_mi_info; IBOutlet id o_mi_messages; @@ -266,6 +269,7 @@ struct intf_sys_t - (id)getPlaylist; - (id)getInfo; - (id)getWizard; +- (id)getBookmarks; - (void)terminate; - (NSString *)localizedString:(char *)psz; - (char *)delocalizeString:(NSString *)psz; @@ -296,6 +300,7 @@ struct intf_sys_t - (IBAction)showWizard:(id)sender; - (IBAction)showExtended:(id)sender; +- (IBAction)showBookmarks:(id)sender; - (IBAction)viewAbout:(id)sender; - (IBAction)viewPreferences:(id)sender; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 3195004387..f24de7e281 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -40,7 +40,7 @@ #include "open.h" #include "wizard.h" #include "extended.h" -//#include "bookmarks.h" +#include "bookmarks.h" /***************************************************************************** * Local prototypes. @@ -301,7 +301,7 @@ static VLCMain *_o_sharedMainInstance = nil; o_open = [[VLCOpen alloc] init]; o_wizard = [[VLCWizard alloc] init]; o_extended = [[VLCExtended alloc] init]; - //o_bookmarks = [[VLCBookmarks alloc] init]; + o_bookmarks = [[VLCBookmarks alloc] init]; i_lastShownVolume = -1; return _o_sharedMainInstance; @@ -432,7 +432,7 @@ static VLCMain *_o_sharedMainInstance = nil; [o_prefs release]; [o_open release]; [o_extended release]; - //[o_bookmarks release]; + [o_bookmarks release]; [super dealloc]; } @@ -543,7 +543,7 @@ static VLCMain *_o_sharedMainInstance = nil; [o_mi_controller setTitle: _NS("Controller")]; [o_mi_equalizer setTitle: _NS("Equalizer")]; [o_mi_extended setTitle: _NS("Extended controls")]; - //[o_mi_bookmarks setTitle: _NS("Bookmarks")]; + [o_mi_bookmarks setTitle: _NS("Bookmarks")]; [o_mi_playlist setTitle: _NS("Playlist")]; [o_mi_info setTitle: _NS("Info")]; [o_mi_messages setTitle: _NS("Messages")]; @@ -566,8 +566,10 @@ static VLCMain *_o_sharedMainInstance = nil; /* error panel */ [o_error setTitle: _NS("Error")]; - [o_err_lbl setStringValue: _NS("An error has occurred which probably prevented the execution of your request:")]; - [o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, please follow the instructions at:")]; + [o_err_lbl setStringValue: _NS("An error has occurred which probably " \ + "prevented the execution of your request:")]; + [o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, " \ + "please follow the instructions at:")]; [o_err_btn_msgs setTitle: _NS("Open Messages Window")]; [o_err_btn_dismiss setTitle: _NS("Dismiss")]; [o_err_ckbk_surpress setTitle: _NS("Suppress further errors")]; @@ -792,6 +794,15 @@ static VLCMain *_o_sharedMainInstance = nil; return nil; } +- (id)getBookmarks +{ + if ( o_bookmarks ) + { + return o_bookmarks; + } + return nil; +} + - (void)manage { NSDate * o_sleep_date; @@ -1463,14 +1474,22 @@ static VLCMain *_o_sharedMainInstance = nil; { nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner:self]; [o_wizard initStrings]; + [o_wizard resetWizard]; [o_wizard showWizard]; } else { + [o_wizard resetWizard]; [o_wizard showWizard]; } } - (IBAction)showExtended:(id)sender { + /* we need the wizard-nib for the bookmarks's extract functionality */ + if (!nib_wizard_loaded) + { + nib_wizard_loaded = [NSBundle loadNibNamed:@"Wizard" owner:self]; + } + if (!nib_extended_loaded) { nib_extended_loaded = [NSBundle loadNibNamed:@"Extended" owner:self]; @@ -1481,17 +1500,16 @@ static VLCMain *_o_sharedMainInstance = nil; } } -/*- (IBAction)showBookmarks:(id)sender +- (IBAction)showBookmarks:(id)sender { if (!nib_bookmarks_loaded) { nib_bookmarks_loaded = [NSBundle loadNibNamed:@"Bookmarks" owner:self]; - [o_bookmarks initStrings]; - [o_bookmarks showPanel]; + [o_bookmarks showBookmarks]; } else { - [o_bookmarks showPanel]; + [o_bookmarks showBookmarks]; } -}*/ +} - (IBAction)viewAbout:(id)sender { diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m index de39811e79..1b74cceb49 100644 --- a/modules/gui/macosx/playlist.m +++ b/modules/gui/macosx/playlist.m @@ -45,7 +45,8 @@ #include #include "intf.h" -#include "wizard.h" +#import "wizard.h" +#import "bookmarks.h" #include "playlist.h" #include "controls.h" #include "osd.h" @@ -524,6 +525,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ //[o_outline_dict removeAllObjects]; [o_outline_view reloadData]; [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView]; + [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData]; } - (void)playModeUpdated diff --git a/modules/gui/macosx/wizard.h b/modules/gui/macosx/wizard.h index e3a4855884..690f63524f 100644 --- a/modules/gui/macosx/wizard.h +++ b/modules/gui/macosx/wizard.h @@ -173,5 +173,7 @@ - (void)createOpts; - (void)rebuildCodecMenus; - (id)getPlaylistWizard; +- (void)initWithExtractValuesFrom: (NSString *)from to: (NSString *)to \ + ofItem: (NSString *)item; @end diff --git a/modules/gui/macosx/wizard.m b/modules/gui/macosx/wizard.m index 025781cbfa..bbc674a258 100644 --- a/modules/gui/macosx/wizard.m +++ b/modules/gui/macosx/wizard.m @@ -287,8 +287,6 @@ static VLCWizard *_o_sharedInstance = nil; /* just present the window to the user */ [o_tab_pageHolder selectFirstTabViewItem:self]; - [self resetWizard]; - [o_wizard_window center]; [o_wizard_window displayIfNeeded]; [o_wizard_window makeKeyAndOrderFront:nil]; @@ -459,6 +457,28 @@ static VLCWizard *_o_sharedInstance = nil; [o_wh_btn_okay setTitle: _NS("OK")]; } +- (void)initWithExtractValuesFrom: (NSString *)from to: (NSString *)to \ + ofItem: (NSString *)item +{ + [self resetWizard]; + msg_Dbg(VLCIntf, "wizard was resetted"); + [o_userSelections setObject:@"trnscd" forKey:@"trnscdOrStrmg"]; + [o_btn_backward setEnabled:YES]; + [o_tab_pageHolder selectTabViewItemAtIndex:1]; + [o_t2_fld_prtExtrctFrom setStringValue: from]; + [o_t2_fld_prtExtrctTo setStringValue: to]; + [o_t2_fld_pathToNewStrm setStringValue: item]; + [o_t1_matrix_strmgOrTrnscd selectCellAtRow:1 column:0]; + [[o_t1_matrix_strmgOrTrnscd cellAtRow:0 column:0] setState: NSOffState]; + [o_t2_ckb_enblPartExtrct setState: NSOnState]; + msg_Dbg(VLCIntf, "wizard interface is set"); + + [o_wizard_window center]; + [o_wizard_window display]; + [o_wizard_window makeKeyAndOrderFront:nil]; + msg_Dbg(VLCIntf, "wizard window displayed"); +} + - (IBAction)cancelRun:(id)sender { [o_wizard_window close];