macosx: split StringUtility from VLCMain and move it to a separate class where it...
authorFelix Paul Kühne <fkuehne@videolan.org>
Fri, 24 Aug 2012 11:12:10 +0000 (13:12 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Fri, 24 Aug 2012 11:12:20 +0000 (13:12 +0200)
extras/package/macosx/vlc.xcodeproj/project.pbxproj
modules/gui/macosx/MainMenu.m
modules/gui/macosx/MainWindow.m
modules/gui/macosx/Modules.am
modules/gui/macosx/StringUtility.h [new file with mode: 0644]
modules/gui/macosx/StringUtility.m [new file with mode: 0644]
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m
modules/gui/macosx/prefs_widgets.m

index deeb2b4..112065f 100644 (file)
                CC206B6B14AD0A5D007935C6 /* window-fullscreen-on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "window-fullscreen-on.png"; path = "Resources/mainwindow_dark/window-fullscreen-on.png"; sourceTree = "<group>"; };
                CC206B6C14AD0A5D007935C6 /* window-fullscreen-over.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "window-fullscreen-over.png"; path = "Resources/mainwindow_dark/window-fullscreen-over.png"; sourceTree = "<group>"; };
                CC206B6D14AD0A5D007935C6 /* window-fullscreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "window-fullscreen.png"; path = "Resources/mainwindow_dark/window-fullscreen.png"; sourceTree = "<group>"; };
+               CC269A4615E7947F00F2FDC9 /* StringUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringUtility.h; path = ../../../modules/gui/macosx/StringUtility.h; sourceTree = "<group>"; };
+               CC269A4715E7947F00F2FDC9 /* StringUtility.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = StringUtility.m; path = ../../../modules/gui/macosx/StringUtility.m; sourceTree = "<group>"; };
                CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
                CC3F9F851350B2A000B0E885 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = ../../../contrib/Growl.framework; sourceTree = "<absolute>"; };
                CC402F4B0E00ABBB006A4BA4 /* VLC.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VLC.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
                                CCCE366E13817E4500694F2A /* VideoEffects.m */,
                                CC0663341566C34C003A411C /* ConvertAndSave.h */,
                                CC0663351566C34C003A411C /* ConvertAndSave.m */,
+                               CC269A4615E7947F00F2FDC9 /* StringUtility.h */,
+                               CC269A4715E7947F00F2FDC9 /* StringUtility.m */,
                                CC017A0E14A4C8B600C09A4F /* custom UI code */,
                                CC0CD0E513DE0FC600B0D90D /* Imported Code */,
                        );
index bbb9855..a417102 100644 (file)
@@ -128,7 +128,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
     NSString* o_key;
     playlist_t *p_playlist;
     vlc_value_t val;
-    id o_vlcmain = [VLCMain sharedInstance];
+    id o_vlcstringutility = [VLCStringUtility sharedInstance];
     char * key;
 
     /* Check if we already did this once. Opening the other nibs calls it too,
@@ -143,98 +143,98 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
     key = config_GetPsz( p_intf, "key-quit" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_quit setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_quit setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_quit setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_quit setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-play-pause" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_play setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_play setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_play setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_play setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-stop" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_stop setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_stop setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_stop setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_stop setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-prev" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_previous setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_previous setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_previous setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_previous setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-next" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_next setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_next setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_next setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_next setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-jump+short" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_fwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_fwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_fwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-jump-short" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_bwd setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_bwd setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_bwd setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-vol-up" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_vol_up setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_vol_up setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_vol_up setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-vol-down" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_vol_down setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_vol_down setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_vol_down setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-vol-mute" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_mute setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_mute setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_mute setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_mute setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-toggle-fullscreen" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_fullscreen setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_fullscreen setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_fullscreen setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-snapshot" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_snapshot setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_snapshot setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_snapshot setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-random" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_random setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_random setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_random setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_random setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-zoom-half" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_half_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_half_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_half_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-zoom-original" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_normal_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_normal_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_normal_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     key = config_GetPsz( p_intf, "key-zoom-double" );
     o_key = [NSString stringWithFormat:@"%s", key];
-    [o_mi_double_window setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
-    [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
+    [o_mi_double_window setKeyEquivalent: [o_vlcstringutility VLCKeyToString: o_key]];
+    [o_mi_double_window setKeyEquivalentModifierMask: [o_vlcstringutility VLCModifiersToCocoa:o_key]];
     FREENULL( key );
 
     [self setSubmenusEnabled: FALSE];
index 48ad18e..a88623f 100644 (file)
@@ -131,11 +131,11 @@ static VLCMainWindow *_o_sharedInstance = nil;
     o_key = [NSString stringWithFormat:@"%s", key];
     FREENULL( key );
 
-    unsigned int i_keyModifiers = [[VLCMain sharedInstance] VLCModifiersToCocoa:o_key];
+    unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa:o_key];
 
     NSString * characters = [o_event charactersIgnoringModifiers];
     if ([characters length] > 0) {
-        return [[characters lowercaseString] isEqualToString: [[VLCMain sharedInstance] VLCKeyToString: o_key]] &&
+        return [[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: o_key]] &&
                 (i_keyModifiers & NSShiftKeyMask)     == ([o_event modifierFlags] & NSShiftKeyMask) &&
                 (i_keyModifiers & NSControlKeyMask)   == ([o_event modifierFlags] & NSControlKeyMask) &&
                 (i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) &&
index f5841c0..b75d94b 100644 (file)
@@ -5,6 +5,8 @@ LIBTOOL=@LIBTOOL@ --tag=CC
 
 SOURCES_macosx = \
        CompatibilityFixes.h \
+       StringUtility.h \
+       StringUtility.m \
        AppleRemote.h \
        AppleRemote.m \
        SPInvocationGrabbing.h \
diff --git a/modules/gui/macosx/StringUtility.h b/modules/gui/macosx/StringUtility.h
new file mode 100644 (file)
index 0000000..2dfdd5a
--- /dev/null
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * StringUtility.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
+ *          Christophe Massiot <massiot@via.ecp.fr>
+ *          Derk-Jan Hartman <hartman at videolan dot org>
+ *          Felix Paul Kühne <fkuehne at videolan dot org>
+ *
+ * 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.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#define _NS(s) [[VLCStringUtility sharedInstance] localizedString: s]
+/* Get an alternate version of the string.
+ * This string is stored as '1:string' but when displayed it only displays
+ * the translated string. the translation should be '1:translatedstring' though */
+#define _ANS(s) [[[VLCStringUtility sharedInstance] localizedString: _(s)] substringFromIndex:2]
+
+@interface VLCStringUtility : NSObject
+
++ (VLCStringUtility *)sharedInstance;
+
+- (NSString *)localizedString:(const char *)psz;
+- (char *)delocalizeString:(NSString *)psz;
+- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
+
+- (NSString *)VLCKeyToString:(NSString *)theString;
+- (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
+
+@end
diff --git a/modules/gui/macosx/StringUtility.m b/modules/gui/macosx/StringUtility.m
new file mode 100644 (file)
index 0000000..5b4352c
--- /dev/null
@@ -0,0 +1,299 @@
+/*****************************************************************************
+ * StringUtility.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
+ *          Christophe Massiot <massiot@via.ecp.fr>
+ *          Derk-Jan Hartman <hartman at videolan dot org>
+ *          Felix Paul Kühne <fkuehne at videolan dot org>
+ *
+ * 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.
+ *****************************************************************************/
+
+#import "StringUtility.h"
+#import "intf.h"
+#import <vlc_keys.h>
+
+@implementation VLCStringUtility
+
+static VLCStringUtility *_o_sharedInstance = nil;
+
++ (VLCStringUtility *)sharedInstance
+{
+    return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
+}
+
+- (id)init
+{
+    if (_o_sharedInstance) {
+        [self dealloc];
+    } else {
+        _o_sharedInstance = [super init];
+    }
+
+    return _o_sharedInstance;
+}
+
+#pragma mark -
+#pragma mark String utility
+
+- (NSString *)localizedString:(const char *)psz
+{
+    NSString * o_str = nil;
+
+    if( psz != NULL )
+    {
+        o_str = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding];
+
+        if( o_str == NULL )
+        {
+            msg_Err( VLCIntf, "could not translate: %s", psz );
+            return( @"" );
+        }
+    }
+    else
+    {
+        msg_Warn( VLCIntf, "can't translate empty strings" );
+        return( @"" );
+    }
+
+    return( o_str );
+}
+
+
+
+- (char *)delocalizeString:(NSString *)id
+{
+    NSData * o_data = [id dataUsingEncoding: NSUTF8StringEncoding
+                       allowLossyConversion: NO];
+    char * psz_string;
+
+    if( o_data == nil )
+    {
+        o_data = [id dataUsingEncoding: NSUTF8StringEncoding
+                  allowLossyConversion: YES];
+        psz_string = malloc( [o_data length] + 1 );
+        [o_data getBytes: psz_string];
+        psz_string[ [o_data length] ] = '\0';
+        msg_Err( VLCIntf, "cannot convert to the requested encoding: %s",
+                psz_string );
+    }
+    else
+    {
+        psz_string = malloc( [o_data length] + 1 );
+        [o_data getBytes: psz_string];
+        psz_string[ [o_data length] ] = '\0';
+    }
+
+    return psz_string;
+}
+
+/* i_width is in pixels */
+- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width
+{
+    NSMutableString *o_wrapped;
+    NSString *o_out_string;
+    NSRange glyphRange, effectiveRange, charRange;
+    NSRect lineFragmentRect;
+    unsigned glyphIndex, breaksInserted = 0;
+
+    NSTextStorage *o_storage = [[NSTextStorage alloc] initWithString: o_in_string
+                                                          attributes: [NSDictionary dictionaryWithObjectsAndKeys:
+                                                                       [NSFont labelFontOfSize: 0.0], NSFontAttributeName, nil]];
+    NSLayoutManager *o_layout_manager = [[NSLayoutManager alloc] init];
+    NSTextContainer *o_container = [[NSTextContainer alloc]
+                                    initWithContainerSize: NSMakeSize(i_width, 2000)];
+
+    [o_layout_manager addTextContainer: o_container];
+    [o_container release];
+    [o_storage addLayoutManager: o_layout_manager];
+    [o_layout_manager release];
+
+    o_wrapped = [o_in_string mutableCopy];
+    glyphRange = [o_layout_manager glyphRangeForTextContainer: o_container];
+
+    for( glyphIndex = glyphRange.location ; glyphIndex < NSMaxRange(glyphRange) ;
+        glyphIndex += effectiveRange.length) {
+        lineFragmentRect = [o_layout_manager lineFragmentRectForGlyphAtIndex: glyphIndex
+                                                              effectiveRange: &effectiveRange];
+        charRange = [o_layout_manager characterRangeForGlyphRange: effectiveRange
+                                                 actualGlyphRange: &effectiveRange];
+        if([o_wrapped lineRangeForRange:
+            NSMakeRange(charRange.location + breaksInserted, charRange.length)].length > charRange.length) {
+            [o_wrapped insertString: @"\n" atIndex: NSMaxRange(charRange) + breaksInserted];
+            breaksInserted++;
+        }
+    }
+    o_out_string = [NSString stringWithString: o_wrapped];
+    [o_wrapped release];
+    [o_storage release];
+
+    return o_out_string;
+}
+
+
+#pragma mark -
+#pragma mark Key Shortcuts
+
+static struct
+{
+    unichar i_nskey;
+    unsigned int i_vlckey;
+} nskeys_to_vlckeys[] =
+{
+    { NSUpArrowFunctionKey, KEY_UP },
+    { NSDownArrowFunctionKey, KEY_DOWN },
+    { NSLeftArrowFunctionKey, KEY_LEFT },
+    { NSRightArrowFunctionKey, KEY_RIGHT },
+    { NSF1FunctionKey, KEY_F1 },
+    { NSF2FunctionKey, KEY_F2 },
+    { NSF3FunctionKey, KEY_F3 },
+    { NSF4FunctionKey, KEY_F4 },
+    { NSF5FunctionKey, KEY_F5 },
+    { NSF6FunctionKey, KEY_F6 },
+    { NSF7FunctionKey, KEY_F7 },
+    { NSF8FunctionKey, KEY_F8 },
+    { NSF9FunctionKey, KEY_F9 },
+    { NSF10FunctionKey, KEY_F10 },
+    { NSF11FunctionKey, KEY_F11 },
+    { NSF12FunctionKey, KEY_F12 },
+    { NSInsertFunctionKey, KEY_INSERT },
+    { NSHomeFunctionKey, KEY_HOME },
+    { NSEndFunctionKey, KEY_END },
+    { NSPageUpFunctionKey, KEY_PAGEUP },
+    { NSPageDownFunctionKey, KEY_PAGEDOWN },
+    { NSMenuFunctionKey, KEY_MENU },
+    { NSTabCharacter, KEY_TAB },
+    { NSCarriageReturnCharacter, KEY_ENTER },
+    { NSEnterCharacter, KEY_ENTER },
+    { NSBackspaceCharacter, KEY_BACKSPACE },
+    { NSDeleteCharacter, KEY_DELETE },
+    {0,0}
+};
+
+unsigned int CocoaKeyToVLC( unichar i_key )
+{
+    unsigned int i;
+
+    for( i = 0; nskeys_to_vlckeys[i].i_nskey != 0; i++ )
+    {
+        if( nskeys_to_vlckeys[i].i_nskey == i_key )
+        {
+            return nskeys_to_vlckeys[i].i_vlckey;
+        }
+    }
+    return (unsigned int)i_key;
+}
+
+- (unsigned int)VLCModifiersToCocoa:(NSString *)theString
+{
+    unsigned int new = 0;
+
+    if([theString rangeOfString:@"Command"].location != NSNotFound)
+        new |= NSCommandKeyMask;
+    if([theString rangeOfString:@"Alt"].location != NSNotFound)
+        new |= NSAlternateKeyMask;
+    if([theString rangeOfString:@"Shift"].location != NSNotFound)
+        new |= NSShiftKeyMask;
+    if([theString rangeOfString:@"Ctrl"].location != NSNotFound)
+        new |= NSControlKeyMask;
+    return new;
+}
+
+- (NSString *)VLCKeyToString:(NSString *)theString
+{
+    if (![theString isEqualToString:@""]) {
+        if ([theString characterAtIndex:([theString length] - 1)] != 0x2b)
+            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
+        else
+        {
+            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
+            theString = [NSString stringWithFormat:@"%@+", theString];
+        }
+        if ([theString characterAtIndex:([theString length] - 1)] != 0x2d)
+            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+        else
+        {
+            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+            theString = [NSString stringWithFormat:@"%@-", theString];
+        }
+        theString = [theString stringByReplacingOccurrencesOfString:@"Command" withString:@""];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Alt" withString:@""];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Shift" withString:@""];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString:@""];
+    }
+    if ([theString length] > 1)
+    {
+        if([theString rangeOfString:@"Up"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSUpArrowFunctionKey];
+        else if([theString rangeOfString:@"Down"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSDownArrowFunctionKey];
+        else if([theString rangeOfString:@"Right"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSRightArrowFunctionKey];
+        else if([theString rangeOfString:@"Left"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSLeftArrowFunctionKey];
+        else if([theString rangeOfString:@"Enter"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSEnterCharacter]; // we treat NSCarriageReturnCharacter as aquivalent
+        else if([theString rangeOfString:@"Insert"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSInsertFunctionKey];
+        else if([theString rangeOfString:@"Home"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSHomeFunctionKey];
+        else if([theString rangeOfString:@"End"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSEndFunctionKey];
+        else if([theString rangeOfString:@"Pageup"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSPageUpFunctionKey];
+        else if([theString rangeOfString:@"Pagedown"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSPageDownFunctionKey];
+        else if([theString rangeOfString:@"Menu"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSMenuFunctionKey];
+        else if([theString rangeOfString:@"Tab"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSTabCharacter];
+        else if([theString rangeOfString:@"Backspace"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSBackspaceCharacter];
+        else if([theString rangeOfString:@"Delete"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSDeleteCharacter];
+        else if([theString rangeOfString:@"F12"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF12FunctionKey];
+        else if([theString rangeOfString:@"F11"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF11FunctionKey];
+        else if([theString rangeOfString:@"F10"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF10FunctionKey];
+        else if([theString rangeOfString:@"F9"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF9FunctionKey];
+        else if([theString rangeOfString:@"F8"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF8FunctionKey];
+        else if([theString rangeOfString:@"F7"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF7FunctionKey];
+        else if([theString rangeOfString:@"F6"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF6FunctionKey];
+        else if([theString rangeOfString:@"F5"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF5FunctionKey];
+        else if([theString rangeOfString:@"F4"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF4FunctionKey];
+        else if([theString rangeOfString:@"F3"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF3FunctionKey];
+        else if([theString rangeOfString:@"F2"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF2FunctionKey];
+        else if([theString rangeOfString:@"F1"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSF1FunctionKey];
+        /* note that we don't support esc here, since it is reserved for leaving fullscreen */
+    }
+
+    return theString;
+}
+
+@end
index 7064b91..bb52d88 100644 (file)
@@ -40,6 +40,7 @@
 #import "SPMediaKeyTap.h"                   /* for the media key support */
 #import "misc.h"
 #import "MainWindow.h"
+#import "StringUtility.h"
 
 #import <IOKit/pwr_mgt/IOPMLib.h>           /* for sleep prevention */
 
@@ -50,13 +51,6 @@ unsigned int CocoaKeyToVLC( unichar i_key );
 
 #define VLCIntf [[VLCMain sharedInstance] intf]
 
-#define _NS(s) [[VLCMain sharedInstance] localizedString: s]
-/* Get an alternate version of the string.
- * This string is stored as '1:string' but when displayed it only displays
- * the translated string. the translation should be '1:translatedstring' though */
-#define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
-
-
 // You need to release those objects after use
 input_thread_t *getInput(void);
 vout_thread_t *getVout(void);
@@ -175,14 +169,9 @@ struct intf_sys_t
 - (void)setActiveVideoPlayback:(BOOL)b_value;
 - (BOOL)activeVideoPlayback;
 - (void)applicationWillTerminate:(NSNotification *)notification;
-- (NSString *)localizedString:(const char *)psz;
-- (char *)delocalizeString:(NSString *)psz;
-- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
-- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
-- (NSString *)VLCKeyToString:(NSString *)theString;
-- (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
 - (void)updateCurrentlyUsedHotkeys;
 - (void)fullscreenChanged;
+- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event force:(BOOL)b_force;
 - (void)checkFullscreenChange:(NSNumber *)o_full;
 - (void)PlaylistItemChanged;
 - (void)playbackStatusUpdated;
index d12af90..e1fdf0e 100644 (file)
@@ -47,6 +47,7 @@
 
 #import "CompatibilityFixes.h"
 #import "intf.h"
+#import "StringUtility.h"
 #import "MainMenu.h"
 #import "VideoView.h"
 #import "prefs.h"
@@ -1081,256 +1082,9 @@ static VLCMain *_o_sharedMainInstance = nil;
     }
 }
 
-#pragma mark -
-#pragma mark String utility
-// FIXME: this has nothing to do here
-
-- (NSString *)localizedString:(const char *)psz
-{
-    NSString * o_str = nil;
-
-    if( psz != NULL )
-    {
-        o_str = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding];
-
-        if( o_str == NULL )
-        {
-            msg_Err( VLCIntf, "could not translate: %s", psz );
-            return( @"" );
-        }
-    }
-    else
-    {
-        msg_Warn( VLCIntf, "can't translate empty strings" );
-        return( @"" );
-    }
-
-    return( o_str );
-}
-
-
-
-- (char *)delocalizeString:(NSString *)id
-{
-    NSData * o_data = [id dataUsingEncoding: NSUTF8StringEncoding
-                          allowLossyConversion: NO];
-    char * psz_string;
-
-    if( o_data == nil )
-    {
-        o_data = [id dataUsingEncoding: NSUTF8StringEncoding
-                     allowLossyConversion: YES];
-        psz_string = malloc( [o_data length] + 1 );
-        [o_data getBytes: psz_string];
-        psz_string[ [o_data length] ] = '\0';
-        msg_Err( VLCIntf, "cannot convert to the requested encoding: %s",
-                 psz_string );
-    }
-    else
-    {
-        psz_string = malloc( [o_data length] + 1 );
-        [o_data getBytes: psz_string];
-        psz_string[ [o_data length] ] = '\0';
-    }
-
-    return psz_string;
-}
-
-/* i_width is in pixels */
-- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width
-{
-    NSMutableString *o_wrapped;
-    NSString *o_out_string;
-    NSRange glyphRange, effectiveRange, charRange;
-    NSRect lineFragmentRect;
-    unsigned glyphIndex, breaksInserted = 0;
-
-    NSTextStorage *o_storage = [[NSTextStorage alloc] initWithString: o_in_string
-        attributes: [NSDictionary dictionaryWithObjectsAndKeys:
-        [NSFont labelFontOfSize: 0.0], NSFontAttributeName, nil]];
-    NSLayoutManager *o_layout_manager = [[NSLayoutManager alloc] init];
-    NSTextContainer *o_container = [[NSTextContainer alloc]
-        initWithContainerSize: NSMakeSize(i_width, 2000)];
-
-    [o_layout_manager addTextContainer: o_container];
-    [o_container release];
-    [o_storage addLayoutManager: o_layout_manager];
-    [o_layout_manager release];
-
-    o_wrapped = [o_in_string mutableCopy];
-    glyphRange = [o_layout_manager glyphRangeForTextContainer: o_container];
-
-    for( glyphIndex = glyphRange.location ; glyphIndex < NSMaxRange(glyphRange) ;
-            glyphIndex += effectiveRange.length) {
-        lineFragmentRect = [o_layout_manager lineFragmentRectForGlyphAtIndex: glyphIndex
-                                            effectiveRange: &effectiveRange];
-        charRange = [o_layout_manager characterRangeForGlyphRange: effectiveRange
-                                    actualGlyphRange: &effectiveRange];
-        if([o_wrapped lineRangeForRange:
-                NSMakeRange(charRange.location + breaksInserted, charRange.length)].length > charRange.length) {
-            [o_wrapped insertString: @"\n" atIndex: NSMaxRange(charRange) + breaksInserted];
-            breaksInserted++;
-        }
-    }
-    o_out_string = [NSString stringWithString: o_wrapped];
-    [o_wrapped release];
-    [o_storage release];
-
-    return o_out_string;
-}
-
-
 #pragma mark -
 #pragma mark Key Shortcuts
 
-static struct
-{
-    unichar i_nskey;
-    unsigned int i_vlckey;
-} nskeys_to_vlckeys[] =
-{
-    { NSUpArrowFunctionKey, KEY_UP },
-    { NSDownArrowFunctionKey, KEY_DOWN },
-    { NSLeftArrowFunctionKey, KEY_LEFT },
-    { NSRightArrowFunctionKey, KEY_RIGHT },
-    { NSF1FunctionKey, KEY_F1 },
-    { NSF2FunctionKey, KEY_F2 },
-    { NSF3FunctionKey, KEY_F3 },
-    { NSF4FunctionKey, KEY_F4 },
-    { NSF5FunctionKey, KEY_F5 },
-    { NSF6FunctionKey, KEY_F6 },
-    { NSF7FunctionKey, KEY_F7 },
-    { NSF8FunctionKey, KEY_F8 },
-    { NSF9FunctionKey, KEY_F9 },
-    { NSF10FunctionKey, KEY_F10 },
-    { NSF11FunctionKey, KEY_F11 },
-    { NSF12FunctionKey, KEY_F12 },
-    { NSInsertFunctionKey, KEY_INSERT },
-    { NSHomeFunctionKey, KEY_HOME },
-    { NSEndFunctionKey, KEY_END },
-    { NSPageUpFunctionKey, KEY_PAGEUP },
-    { NSPageDownFunctionKey, KEY_PAGEDOWN },
-    { NSMenuFunctionKey, KEY_MENU },
-    { NSTabCharacter, KEY_TAB },
-    { NSCarriageReturnCharacter, KEY_ENTER },
-    { NSEnterCharacter, KEY_ENTER },
-    { NSBackspaceCharacter, KEY_BACKSPACE },
-    { NSDeleteCharacter, KEY_DELETE },
-    {0,0}
-};
-
-unsigned int CocoaKeyToVLC( unichar i_key )
-{
-    unsigned int i;
-
-    for( i = 0; nskeys_to_vlckeys[i].i_nskey != 0; i++ )
-    {
-        if( nskeys_to_vlckeys[i].i_nskey == i_key )
-        {
-            return nskeys_to_vlckeys[i].i_vlckey;
-        }
-    }
-    return (unsigned int)i_key;
-}
-
-- (unsigned int)VLCModifiersToCocoa:(NSString *)theString
-{
-    unsigned int new = 0;
-
-    if([theString rangeOfString:@"Command"].location != NSNotFound)
-        new |= NSCommandKeyMask;
-    if([theString rangeOfString:@"Alt"].location != NSNotFound)
-        new |= NSAlternateKeyMask;
-    if([theString rangeOfString:@"Shift"].location != NSNotFound)
-        new |= NSShiftKeyMask;
-    if([theString rangeOfString:@"Ctrl"].location != NSNotFound)
-        new |= NSControlKeyMask;
-    return new;
-}
-
-- (NSString *)VLCKeyToString:(NSString *)theString
-{
-    if (![theString isEqualToString:@""]) {
-        if ([theString characterAtIndex:([theString length] - 1)] != 0x2b)
-            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
-        else
-        {
-            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
-            theString = [NSString stringWithFormat:@"%@+", theString];
-        }
-        if ([theString characterAtIndex:([theString length] - 1)] != 0x2d)
-            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
-        else
-        {
-            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
-            theString = [NSString stringWithFormat:@"%@-", theString];
-        }
-        theString = [theString stringByReplacingOccurrencesOfString:@"Command" withString:@""];
-        theString = [theString stringByReplacingOccurrencesOfString:@"Alt" withString:@""];
-        theString = [theString stringByReplacingOccurrencesOfString:@"Shift" withString:@""];
-        theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString:@""];
-    }
-    if ([theString length] > 1)
-    {
-        if([theString rangeOfString:@"Up"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSUpArrowFunctionKey];
-        else if([theString rangeOfString:@"Down"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSDownArrowFunctionKey];
-        else if([theString rangeOfString:@"Right"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSRightArrowFunctionKey];
-        else if([theString rangeOfString:@"Left"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSLeftArrowFunctionKey];
-        else if([theString rangeOfString:@"Enter"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSEnterCharacter]; // we treat NSCarriageReturnCharacter as aquivalent
-        else if([theString rangeOfString:@"Insert"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSInsertFunctionKey];
-        else if([theString rangeOfString:@"Home"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSHomeFunctionKey];
-        else if([theString rangeOfString:@"End"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSEndFunctionKey];
-        else if([theString rangeOfString:@"Pageup"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSPageUpFunctionKey];
-        else if([theString rangeOfString:@"Pagedown"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSPageDownFunctionKey];
-        else if([theString rangeOfString:@"Menu"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSMenuFunctionKey];
-        else if([theString rangeOfString:@"Tab"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSTabCharacter];
-        else if([theString rangeOfString:@"Backspace"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSBackspaceCharacter];
-        else if([theString rangeOfString:@"Delete"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSDeleteCharacter];
-        else if([theString rangeOfString:@"F12"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF12FunctionKey];
-        else if([theString rangeOfString:@"F11"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF11FunctionKey];
-        else if([theString rangeOfString:@"F10"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF10FunctionKey];
-        else if([theString rangeOfString:@"F9"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF9FunctionKey];
-        else if([theString rangeOfString:@"F8"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF8FunctionKey];
-        else if([theString rangeOfString:@"F7"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF7FunctionKey];
-        else if([theString rangeOfString:@"F6"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF6FunctionKey];
-        else if([theString rangeOfString:@"F5"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF5FunctionKey];
-        else if([theString rangeOfString:@"F4"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF4FunctionKey];
-        else if([theString rangeOfString:@"F3"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF3FunctionKey];
-        else if([theString rangeOfString:@"F2"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF2FunctionKey];
-        else if([theString rangeOfString:@"F1"].location != NSNotFound)
-            return [NSString stringWithFormat:@"%C", NSF1FunctionKey];
-        /* note that we don't support esc here, since it is reserved for leaving fullscreen */
-    }
-
-    return theString;
-}
-
-
 /*****************************************************************************
  * hasDefinedShortcutKey: Check to see if the key press is a defined VLC
  * shortcut key.  If it is, pass it off to VLC for handling and return YES,
@@ -1400,9 +1154,9 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         for( int i = 0; i < [o_usedHotkeys count]; i++ )
         {
             NSString *str = [o_usedHotkeys objectAtIndex: i];
-            unsigned int i_keyModifiers = [self VLCModifiersToCocoa: str];
+            unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa: str];
 
-            if( [[characters lowercaseString] isEqualToString: [self VLCKeyToString: str]] &&
+            if( [[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: str]] &&
                (i_keyModifiers & NSShiftKeyMask)     == (i_pressed_modifiers & NSShiftKeyMask) &&
                (i_keyModifiers & NSControlKeyMask)   == (i_pressed_modifiers & NSControlKeyMask) &&
                (i_keyModifiers & NSAlternateKeyMask) == (i_pressed_modifiers & NSAlternateKeyMask) &&
index a7d129f..6d923d2 100644 (file)
@@ -977,7 +977,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
         else
             i_view_type = CONFIG_ITEM_STRING;
 
-        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1034,7 +1034,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
 
 - (char *)stringValue
 {
-    return [[VLCMain sharedInstance] delocalizeString:
+    return [[VLCStringUtility sharedInstance] delocalizeString:
                         [o_textfield stringValue]];
 }
 
@@ -1067,7 +1067,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
         int i_index;
         i_view_type = CONFIG_ITEM_STRING_LIST;
 
-        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1121,8 +1121,8 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
         if( p_item->list.psz[[o_combo indexOfSelectedItem]] != NULL )
             return strdup( p_item->list.psz[[o_combo indexOfSelectedItem]] );
     } else {
-        if( [[VLCMain sharedInstance] delocalizeString: [o_combo stringValue]] != NULL )
-            return strdup( [[VLCMain sharedInstance] delocalizeString: [o_combo stringValue]] );
+        if( [[VLCStringUtility sharedInstance] delocalizeString: [o_combo stringValue]] != NULL )
+            return strdup( [[VLCStringUtility sharedInstance] delocalizeString: [o_combo stringValue]] );
     }
     return NULL;
 }
@@ -1178,8 +1178,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_LOADFILE;
 
-        o_itemTooltip = [[VLCMain sharedInstance]
-                           wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_itemTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* is it a directory */
         b_directory = ( [self type] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
@@ -1281,7 +1280,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_MODULE;
 
-        o_popupTooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_popupTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1451,7 +1450,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_INTEGER;
 
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1546,7 +1545,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
         int i_index;
         i_view_type = CONFIG_ITEM_STRING_LIST;
 
-        o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1646,7 +1645,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_RANGED_INTEGER;
 
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1762,7 +1761,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_INTEGER;
 
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1855,7 +1854,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_RANGED_INTEGER;
 
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -1972,7 +1971,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
         i_view_type = CONFIG_ITEM_BOOL;
 
         /* add the checkbox */
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
         ADD_CHECKBOX( o_checkbox, mainFrame, 0,
                         0, @"", o_tooltip, p_item->value.i, NSImageLeft)
         [o_checkbox setAutoresizingMask:NSViewNotSizable ];
@@ -2022,7 +2021,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_KEY;
 
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )
@@ -2159,7 +2158,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];       \
     {
         i_view_type = CONFIG_ITEM_MODULE_LIST;
 
-        o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+        o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
 
         /* add the label */
         if( p_item->psz_text )