macosx: deploy string conversation function in more cases
authorFelix Paul Kühne <fkuehne@videolan.org>
Tue, 21 Jul 2015 17:46:28 +0000 (19:46 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Tue, 21 Jul 2015 17:47:12 +0000 (19:47 +0200)
16 files changed:
modules/gui/macosx/AudioEffects.m
modules/gui/macosx/ConvertAndSave.m
modules/gui/macosx/CoreInteraction.m
modules/gui/macosx/ExtensionsDialogProvider.m
modules/gui/macosx/MainMenu.m
modules/gui/macosx/MainWindow.m
modules/gui/macosx/StringUtility.m
modules/gui/macosx/VideoEffects.m
modules/gui/macosx/about.m
modules/gui/macosx/coredialogs.m
modules/gui/macosx/fspanel.m
modules/gui/macosx/intf.m
modules/gui/macosx/open.m
modules/gui/macosx/playlistinfo.m
modules/gui/macosx/prefs_widgets.m
modules/gui/macosx/simple_prefs.m

index a786723..7e0c57b 100644 (file)
@@ -86,8 +86,8 @@
                       eqz_preset_10b[i].f_amp[9]];
         [workValues addObject:workString];
         [workPreamp addObject:[NSString stringWithFormat:@"%1.f", eqz_preset_10b[i].f_preamp]];
-        [workTitles addObject:[NSString stringWithUTF8String:preset_list_text[i]]];
-        [workNames addObject:[NSString stringWithUTF8String:preset_list[i]]];
+        [workTitles addObject:toNSStr(preset_list_text[i])];
+        [workNames addObject:toNSStr(preset_list[i])];
     }
 
     NSString *defaultProfile = [NSString stringWithFormat:@"ZmxhdA==;;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%i",
index 1156521..efc78da 100644 (file)
     [openPanel beginSheetModalForWindow:_window completionHandler:^(NSInteger returnCode) {
         if (returnCode == NSOKButton)
         {
-            [self setMRL: [NSString stringWithUTF8String:vlc_path2uri([[[openPanel URL] path] UTF8String], NULL)]];
+            [self setMRL: toNSStr(vlc_path2uri([[[openPanel URL] path] UTF8String], NULL))];
             [self updateOKButton];
             [self updateDropView];
         }
             NSArray *values = [[paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
 
             if ([values count] > 0) {
-                [self setMRL: [NSString stringWithUTF8String:vlc_path2uri([[values firstObject] UTF8String], NULL)]];
+                [self setMRL: toNSStr(vlc_path2uri([[values firstObject] UTF8String], NULL))];
                 [self updateOKButton];
                 [self updateDropView];
                 return YES;
index 09fa7e3..face01d 100644 (file)
@@ -278,7 +278,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
     }
 
     NSURL *o_url;
-    o_url = [NSURL URLWithString:[NSString stringWithUTF8String:psz_uri]];
+    o_url = [NSURL URLWithString:toNSStr(psz_uri)];
     vlc_object_release(p_input);
 
     return o_url;
@@ -315,7 +315,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
         free(formated);
     }
 
-    NSURL * o_url = [NSURL URLWithString:[NSString stringWithUTF8String:psz_uri]];
+    NSURL * o_url = [NSURL URLWithString:toNSStr(psz_uri)];
     free(psz_uri);
 
     if ([o_name isEqualToString:@""]) {
@@ -659,7 +659,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
                 if (!psz_uri)
                     continue;
 
-                o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+                o_dic = [NSDictionary dictionaryWithObject:toNSStr(psz_uri) forKey:@"ITEM_URL"];
                 free(psz_uri);
 
                 o_array = [o_array arrayByAddingObject: o_dic];
@@ -1309,7 +1309,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
             && !strncmp(p_item->psz_name , "key-", 4)
             && !EMPTY_STR(p_item->psz_text)) {
             if (p_item->value.psz)
-                [mutArray addObject: [NSString stringWithUTF8String:p_item->value.psz]];
+                [mutArray addObject:toNSStr(p_item->value.psz)];
         }
     }
     module_config_free (p_config);
index 7185a4b..5d10372 100644 (file)
@@ -209,7 +209,7 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget,
                 {
                     NSDictionary *entry = [NSDictionary dictionaryWithObjectsAndKeys:
                                            [NSNumber numberWithInt:value->i_id], @"id",
-                                           [NSString stringWithUTF8String:value->psz_text], @"text",
+                                           toNSStr(value->psz_text), @"text",
                                            nil];
                     [contentArray addObject:entry];
                 }
@@ -221,7 +221,7 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget,
             {
                 assert([control isKindOfClass:[NSImageView class]]);
                 NSImageView *imageView = (NSImageView *)control;
-                NSString *string = widget->psz_text ? [NSString stringWithUTF8String:widget->psz_text] : nil;
+                NSString *string = widget->psz_text ? toNSStr(widget->psz_text) : nil;
                 NSImage *image = nil;
                 if (string)
                     image = [[NSImage alloc] initWithContentsOfURL:[NSURL fileURLWithPath:string]];
@@ -303,7 +303,7 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl
 
 - (void)performEventWithObject:(NSValue *)objectValue ofType:(const char*)type
 {
-    NSString *typeString = [NSString stringWithUTF8String:type];
+    NSString *typeString = toNSStr(type);
 
     if ([typeString isEqualToString: @"dialog-extension"]) {
         [self performSelectorOnMainThread:@selector(updateExtensionDialog:)
index 28bf382..1583842 100644 (file)
         [mi setTarget:self];
         [mi setAction:selector];
         [mi setTag:p_item->list.i[i]];
-        [mi setRepresentedObject:[NSString stringWithUTF8String:psz_name]];
+        [mi setRepresentedObject:toNSStr(psz_name)];
         [menu addItem:mi];
         if (p_item->value.i == p_item->list.i[i])
             [mi setState:NSOnState];
 
     [openPanel setAllowedFileTypes: [NSArray arrayWithObjects:@"cdg",@"idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil",nil]];
 
-    NSURL *url = [NSURL URLWithString:[[NSString stringWithUTF8String:path] stringByExpandingTildeInPath]];
+    NSURL *url = [NSURL URLWithString:[toNSStr(path) stringByExpandingTildeInPath]];
     url = [url URLByDeletingLastPathComponent];
     [openPanel setDirectoryURL: url];
     free(path);
index b0c75aa..9bc82cf 100644 (file)
@@ -344,25 +344,25 @@ static VLCMainWindow *sharedInstance = nil;
     NSMutableArray *mycompItems = [[NSMutableArray alloc] init];
     NSString *o_identifier;
     for (; ppsz_name && *ppsz_name; ppsz_name++, ppsz_longname++, p_category++) {
-        o_identifier = [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding];
+        o_identifier = toNSStr(*ppsz_name);
         switch (*p_category) {
             case SD_CAT_INTERNET:
                 [internetItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
                 [[internetItems lastObject] setIcon: imageFromRes(@"sidebar-podcast")];
                 [[internetItems lastObject] setSdtype: SD_CAT_INTERNET];
-                [[internetItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String:*ppsz_longname]];
+                [[internetItems lastObject] setUntranslatedTitle: toNSStr(*ppsz_longname)];
                 break;
             case SD_CAT_DEVICES:
                 [devicesItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
                 [[devicesItems lastObject] setIcon: imageFromRes(@"sidebar-local")];
                 [[devicesItems lastObject] setSdtype: SD_CAT_DEVICES];
-                [[devicesItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String:*ppsz_longname]];
+                [[devicesItems lastObject] setUntranslatedTitle: toNSStr(*ppsz_longname)];
                 break;
             case SD_CAT_LAN:
                 [lanItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
                 [[lanItems lastObject] setIcon: imageFromRes(@"sidebar-local")];
                 [[lanItems lastObject] setSdtype: SD_CAT_LAN];
-                [[lanItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String:*ppsz_longname]];
+                [[lanItems lastObject] setUntranslatedTitle: toNSStr(*ppsz_longname)];
                 break;
             case SD_CAT_MYCOMPUTER:
                 [mycompItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
@@ -374,7 +374,7 @@ static VLCMainWindow *sharedInstance = nil;
                     [[mycompItems lastObject] setIcon: imageFromRes(@"sidebar-pictures")];
                 else
                     [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
-                [[mycompItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String:*ppsz_longname]];
+                [[mycompItems lastObject] setUntranslatedTitle: toNSStr(*ppsz_longname)];
                 [[mycompItems lastObject] setSdtype: SD_CAT_MYCOMPUTER];
                 break;
             default:
@@ -694,11 +694,11 @@ static VLCMainWindow *sharedInstance = nil;
                 free(formated);
             }
         } else
-            aString = [NSString stringWithUTF8String:config_GetPsz(VLCIntf, "video-title")];
+            aString = toNSStr(config_GetPsz(VLCIntf, "video-title"));
 
         char *uri = input_item_GetURI(input_GetItem(p_input));
 
-        NSURL * o_url = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
+        NSURL * o_url = [NSURL URLWithString:toNSStr(uri)];
         if ([o_url isFileURL]) {
             [self setRepresentedURL: o_url];
             [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
@@ -1198,7 +1198,7 @@ static VLCMainWindow *sharedInstance = nil;
             if (!psz_uri)
                 continue;
 
-            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+            o_dic = [NSDictionary dictionaryWithObject:toNSStr(psz_uri) forKey:@"ITEM_URL"];
 
             free(psz_uri);
 
@@ -1294,7 +1294,7 @@ static VLCMainWindow *sharedInstance = nil;
         playlist_t * p_playlist = pl_Get(VLCIntf);
         char *psz_urls = var_InheritString(p_playlist, "podcast-urls");
 
-        NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
+        NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[toNSStr(config_GetPsz(VLCIntf, "podcast-urls")) componentsSeparatedByString:@"|"]];
         [urls removeObjectAtIndex: [o_podcast_unsubscribe_pop indexOfSelectedItem]];
         const char *psz_new_urls = [[urls componentsJoinedByString:@"|"] UTF8String];
         var_SetString(pl_Get(VLCIntf), "podcast-urls", psz_new_urls);
index 5227792..112b1ab 100644 (file)
@@ -68,7 +68,7 @@ NSString *const kVLCMediaUnknown = @"Unknown";
     NSString * stringObject = nil;
 
     if (psz != NULL) {
-        stringObject = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding];
+        stringObject = toNSStr(_(psz));
 
         if (stringObject == NULL) {
             msg_Err(VLCIntf, "could not translate: %s", psz);
@@ -133,7 +133,7 @@ NSString *const kVLCMediaUnknown = @"Unknown";
             remaining = dur - t;
         return [NSString stringWithFormat: @"-%s", secstotimestr(psz_time, (remaining / 1000000))];
     } else
-        return [NSString stringWithUTF8String:secstotimestr(psz_time, t / CLOCK_FREQ )];
+        return toNSStr(secstotimestr(psz_time, t / CLOCK_FREQ ));
 }
 
 - (NSString *)stringForTime:(long long int)time
index 8e51ece..4d8d07c 100644 (file)
     [_adjustHueSlider setToolTip: [NSString stringWithFormat:@"%.0f", config_GetFloat(p_intf, "hue")]];
     [_adjustSaturationSlider setToolTip: [NSString stringWithFormat:@"%0.3f", config_GetFloat(p_intf, "saturation")]];
     b_state = [_adjustCheckbox state];
-#if 0
+
     [_adjustBrightnessSlider setEnabled: b_state];
     [_adjustBrightnessCheckbox setEnabled: b_state];
     [_adjustContrastSlider setEnabled: b_state];
     [_cropSyncLeftRightCheckbox setState: NSOffState];
 
     tmpChar = config_GetPsz(p_intf, "transform-type");
-    tmpString = [NSString stringWithUTF8String:tmpChar];
+    tmpString = toNSStr(tmpChar);
     if ([tmpString isEqualToString:@"hflip"])
         [_transformPopup selectItemWithTag: 1];
     else if ([tmpString isEqualToString:@"vflip"])
     [_puzzleColumnsTextField setEnabled: b_state];
     [_puzzleColumnsStepper setEnabled: b_state];
     [_puzzleColumnsLabel setEnabled: b_state];
-#endif
 
-#if 0
     [self setCloneValue: config_GetInt(p_intf, "clone-count")];
     b_state = [_cloneCheckbox state];
     [_cloneNumberLabel setEnabled: b_state];
     [_sepiaLabel setEnabled: b_state];
 
     tmpChar = config_GetPsz(p_intf, "gradient-mode");
-    tmpString = [NSString stringWithUTF8String:tmpChar];
+    tmpString = toNSStr(tmpChar);
     if ([tmpString isEqualToString:@"hough"])
         [_gradientModePopup selectItemWithTag: 3];
     else if ([tmpString isEqualToString:@"edge"])
     [_gradientModeLabel setEnabled: b_state];
     [_gradientCartoonCheckbox setEnabled: b_state];
     [_gradientColorCheckbox setEnabled: b_state];
-#endif
-#if 0
+
     [_extractTextField setStringValue: [[NSString stringWithFormat:@"%llx", config_GetInt(p_intf, "extract-component")] uppercaseString]];
     [_extractTextField setEnabled: [_extractCheckbox state]];
     [_extractLabel setEnabled: [_extractCheckbox state]];
     [_blurLabel setEnabled: [_blurCheckbox state]];
 
     tmpChar = config_GetPsz(p_intf, "marq-marquee");
-    if (tmpChar) {
-        [_addTextTextTextField setStringValue: [NSString stringWithUTF8String:tmpChar]];
+    [_addTextTextTextField setStringValue:toNSStr(tmpChar)];
+    if (tmpChar)
         FREENULL(tmpChar);
-    } else
-        [_addTextTextTextField setStringValue: @""];
     [_addTextPositionPopup selectItemWithTag: config_GetInt(p_intf, "marq-position")];
     b_state = [_addTextCheckbox state];
     [_addTextPositionPopup setEnabled: b_state];
     [_addTextTextTextField setEnabled: b_state];
 
     tmpChar = config_GetPsz(p_intf, "logo-file");
-    if (tmpChar) {
-        [_addLogoLogoTextField setStringValue: [NSString stringWithUTF8String:tmpChar]];
+    [_addLogoLogoTextField setStringValue: toNSStr(tmpChar)];
+    if (tmpChar)
         FREENULL(tmpChar);
-    } else
-        [_addLogoLogoTextField setStringValue: @""];
     [_addLogoPositionPopup selectItemWithTag: config_GetInt(p_intf, "logo-position")];
     [_addLogoTransparencySlider setIntValue: config_GetInt(p_intf, "logo-opacity")];
     [_addLogoTransparencySlider setToolTip: [NSString stringWithFormat:@"%lli", config_GetInt(p_intf, "logo-opacity")]];
     [_addLogoLogoLabel setEnabled: b_state];
     [_addLogoTransparencySlider setEnabled: b_state];
     [_addLogoTransparencyLabel setEnabled: b_state];
-#endif
 }
 
 - (NSString *)generateProfileString
index 8ca3638..bc224a3 100644 (file)
     /* Setup the nameversion field */
     [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]];
 
-    NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [[NSString stringWithUTF8String:psz_authors] componentsSeparatedByString:@"\n\n"]];
+    NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [toNSStr(psz_authors) componentsSeparatedByString:@"\n\n"]];
     NSUInteger count = [tmpArray count];
     for (NSUInteger i = 0; i < count; i++) {
         [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]];
     o_authors = [tmpArray componentsJoinedByString:@"\n\n"];
 
     /* setup join us! */
-    NSString *joinus = [NSString stringWithUTF8String:_(""
-                                                        "<p>VLC media player is a free and open source media player, encoder, and "
-                                                        "streamer made by the volunteers of the <a href=\"http://www.videolan.org/"
-                                                        "\"><span style=\" text-decoration: underline; color:#0057ae;\">VideoLAN</"
-                                                        "span></a> community.</p><p>VLC uses its internal codecs, works on "
-                                                        "essentially every popular platform, and can read almost all files, CDs, "
-                                                        "DVDs, network streams, capture cards and other media formats!</p><p><a href="
-                                                        "\"http://www.videolan.org/contribute/\"><span style=\" text-decoration: "
-                                                        "underline; color:#0057ae;\">Help and join us!</span></a>")];
+    NSString *joinus = toNSStr(_(""
+                                 "<p>VLC media player is a free and open source media player, encoder, and "
+                                 "streamer made by the volunteers of the <a href=\"http://www.videolan.org/"
+                                 "\"><span style=\" text-decoration: underline; color:#0057ae;\">VideoLAN</"
+                                 "span></a> community.</p><p>VLC uses its internal codecs, works on "
+                                 "essentially every popular platform, and can read almost all files, CDs, "
+                                 "DVDs, network streams, capture cards and other media formats!</p><p><a href="
+                                 "\"http://www.videolan.org/contribute/\"><span style=\" text-decoration: "
+                                 "underline; color:#0057ae;\">Help and join us!</span></a>"));
     NSString *fontfamily;
     if (OSX_YOSEMITE)
         fontfamily = @"Helvetica Neue";
     if (sender == o_authors_btn)
         [o_credits_textview setString:o_authors];
     else if (sender == o_credits_btn)
-        [o_credits_textview setString:[[NSString stringWithUTF8String:psz_thanks] stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:0 range:NSRangeFromString(@"680 2")]];
+        [o_credits_textview setString:[toNSStr(psz_thanks) stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:0 range:NSRangeFromString(@"680 2")]];
     else
-        [o_credits_textview setString:[NSString stringWithUTF8String:psz_license]];
+        [o_credits_textview setString:toNSStr(psz_license)];
 
     [o_credits_textview scrollPoint:NSMakePoint(0, 0)];
     b_restart = YES;
index fec3665..10ec08f 100644 (file)
@@ -36,7 +36,7 @@ static void destroyProgressPanel (void *);
 static int DialogCallback(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
 {
     @autoreleasepool {
-        if ([[NSString stringWithUTF8String:type] isEqualToString: @"dialog-progress-bar"]) {
+        if ([toNSStr(type) isEqualToString: @"dialog-progress-bar"]) {
             /* the progress panel needs to update itself and therefore wants special treatment within this context */
             dialog_progress_bar_t *p_dialog = (dialog_progress_bar_t *)value.p_address;
 
@@ -145,7 +145,7 @@ bool checkProgressPanel (void *priv)
 
 -(void)performEventWithObject: (NSValue *)o_value ofType: (const char*)type
 {
-    NSString *o_type = [NSString stringWithUTF8String:type];
+    NSString *o_type = toNSStr(type);
 
     if ([o_type isEqualToString: @"dialog-error"])
         [self performSelectorOnMainThread:@selector(showFatalDialog:) withObject:o_value waitUntilDone:YES];
@@ -241,7 +241,7 @@ bool checkProgressPanel (void *priv)
     [o_prog_title_txt setStringValue: toNSStr(p_dialog->title)];
 
     if (p_dialog->cancel != NULL)
-        [o_prog_cancel_btn setTitle: [NSString stringWithUTF8String:p_dialog->cancel]];
+        [o_prog_cancel_btn setTitle: toNSStr(p_dialog->cancel)];
     else
         [o_prog_cancel_btn setTitle: _NS("Cancel")];
 
index b568dfc..d0594e7 100644 (file)
                     remaining = dur - t;
                 o_total_time = [NSString stringWithFormat: @"-%s", secstotimestr(psz_time, (remaining / 1000000))];
             } else
-                o_total_time = [NSString stringWithUTF8String:secstotimestr(psz_time, (dur / 1000000))];
+                o_total_time = toNSStr(secstotimestr(psz_time, (dur / 1000000)));
 
             [o_streamLength_txt setStringValue: o_total_time];
         }
 
         // update current position (left field)
-        NSString *o_playback_pos = [NSString stringWithUTF8String:secstotimestr(psz_time, t / CLOCK_FREQ)];
-               
+        NSString *o_playback_pos = toNSStr(secstotimestr(psz_time, t / CLOCK_FREQ));
+
         [o_streamPosition_txt setStringValue: o_playback_pos];
         vlc_object_release(p_input);
     } else {
index 1425eeb..6182fc8 100644 (file)
@@ -469,7 +469,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
         if (!psz_uri)
             continue;
 
-        NSDictionary *o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+        NSDictionary *o_dic = [NSDictionary dictionaryWithObject:toNSStr(psz_uri) forKey:@"ITEM_URL"];
         free(psz_uri);
         [o_result addObject: o_dic];
     }
index 0031679..cc26c19 100644 (file)
@@ -647,7 +647,7 @@ struct display_info_t
             char *psz_uri = vlc_path2uri([values[i] UTF8String], "file");
             if (!psz_uri)
                 continue;
-            dictionary = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+            dictionary = [NSDictionary dictionaryWithObject:toNSStr(psz_uri) forKey:@"ITEM_URL"];
             NSLog(@"dict: %@", dictionary);
             free(psz_uri);
             [array addObject: dictionary];
@@ -689,7 +689,7 @@ struct display_info_t
         char *psz_uri = vlc_path2uri([_filePath UTF8String], "file");
         if (!psz_uri) return;
 
-        NSMutableString *mrlString = [NSMutableString stringWithUTF8String: psz_uri ];
+        NSMutableString *mrlString = [NSMutableString stringWithUTF8String:psz_uri];
         NSRange offile = [mrlString rangeOfString:@"file"];
         free(psz_uri);
 
index 657f06a..bb4e6cd 100644 (file)
 
             /* fill uri info */
             char *psz_url = decode_URI(input_item_GetURI(p_item));
-            [_uriTextField setStringValue: [NSString stringWithUTF8String:psz_url ? psz_url : ""]];
+            [_uriTextField setStringValue:toNSStr(psz_url)];
             free(psz_url);
 
             /* fill title info */
             char *psz_title = input_item_GetTitle(p_item);
             if (!psz_title)
                 psz_title = input_item_GetName(p_item);
-            [_titleTextField setStringValue: [NSString stringWithUTF8String:psz_title ? : ""]];
+            [_titleTextField setStringValue:toNSStr(psz_title)];
             free(psz_title);
 
         #define SET( foo, bar ) \
 
             /* FIXME Can also be attachment:// */
             if (psz_meta && strncmp(psz_meta, "attachment://", 13))
-                image = [[NSImage alloc] initWithContentsOfURL: [NSURL URLWithString:[NSString stringWithUTF8String:psz_meta]]];
+                image = [[NSImage alloc] initWithContentsOfURL: [NSURL URLWithString:toNSStr(psz_meta)]];
             else
                 image = [NSImage imageNamed: @"noart.png"];
             [_imageWell setImage: image];
 - (void)setMeta: (char *)psz_meta forLabel: (id)theItem
 {
     if (psz_meta != NULL && *psz_meta)
-        [theItem setStringValue: [NSString stringWithUTF8String:psz_meta]];
+        [theItem setStringValue: toNSStr(psz_meta)];
     else
         [theItem setStringValue: @""];
 }
@@ -472,11 +472,7 @@ error:
     if (i_object_id == -1) {
         vlc_mutex_lock(&p_item->lock);
         for (int i = 0 ; i < p_item->i_categories ; i++) {
-            NSString *name;
-            if (p_item->pp_categories[i]->psz_name)
-                name = [NSString stringWithUTF8String:p_item->pp_categories[i]->psz_name];
-            else
-                name = @"";
+            NSString *name = toNSStr(p_item->pp_categories[i]->psz_name);
             VLCInfoTreeItem *item = [[VLCInfoTreeItem alloc]
                                       initWithName:name
                                       value:@""
@@ -491,16 +487,8 @@ error:
         vlc_mutex_lock(&p_item->lock);
         info_category_t *cat = p_item->pp_categories[i_object_id];
         for (int i = 0 ; i < cat->i_infos ; i++) {
-            NSString *name;
-            NSString *value;
-            if (cat->pp_infos[i]->psz_name != NULL)
-                name = [NSString stringWithUTF8String:cat->pp_infos[i]->psz_name];
-            else
-                name = @"";
-            if (cat->pp_infos[i]->psz_value != NULL)
-                value = [NSString stringWithUTF8String:cat->pp_infos[i]->psz_value];
-            else
-                value = @"";
+            NSString *name = toNSStr(cat->pp_infos[i]->psz_name);
+            NSString *value  = toNSStr(cat->pp_infos[i]->psz_value);
             VLCInfoTreeItem *item = [[VLCInfoTreeItem alloc]
                                      initWithName:name
                                      value:value
index 6e4a890..2edc1e8 100644 (file)
@@ -68,7 +68,7 @@
     [o_menu addItem: o_mi];                                                 \
 /*  Ctrl */                                                                 \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD]                       \
+        [toNSStr(UP_ARROWHEAD)                                              \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
@@ -79,7 +79,7 @@
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Alt */                                                              \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD OPTION_KEY]            \
+        [toNSStr(UP_ARROWHEAD OPTION_KEY)                                   \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
@@ -90,7 +90,7 @@
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Shift */                                                            \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD UPWARDS_WHITE_ARROW]   \
+        [toNSStr(UP_ARROWHEAD UPWARDS_WHITE_ARROW)                          \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Apple */                                                            \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD PLACE_OF_INTEREST_SIGN]\
+        [toNSStr(UP_ARROWHEAD PLACE_OF_INTEREST_SIGN)                       \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Alt+Shift */                                                        \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW] \
+        [toNSStr(UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW)               \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Alt+Apple */                                                        \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN] \
+        [toNSStr(UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN)            \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Shift+Apple */                                                      \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN] \
+        [toNSStr(UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN)   \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Ctrl+Alt+Shift+Apple */                                                  \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN] \
-         stringByAppendingString: string]                                  \
+        [toNSStr(UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN) \
+         stringByAppendingString: string]                                   \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
         NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask |            \
     [o_menu addItem: o_mi];                                                 \
 /* Alt */                                                                   \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:OPTION_KEY] stringByAppendingString: string] \
+        [toNSStr(OPTION_KEY) stringByAppendingString: string]               \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
         NSAlternateKeyMask];                                                \
     [o_menu addItem: o_mi];                                                 \
 /* Alt+Shift */                                                             \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:OPTION_KEY UPWARDS_WHITE_ARROW] stringByAppendingString: string] \
+        [toNSStr(OPTION_KEY UPWARDS_WHITE_ARROW) stringByAppendingString: string] \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
         NSAlternateKeyMask | NSShiftKeyMask];                               \
     [o_menu addItem: o_mi];                                                 \
 /* Alt+Apple */                                                             \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:OPTION_KEY PLACE_OF_INTEREST_SIGN]  \
+        [toNSStr(OPTION_KEY PLACE_OF_INTEREST_SIGN)                         \
          stringByAppendingString: string] action:nil keyEquivalent:@""];    \
     [o_mi setKeyEquivalentModifierMask:                                     \
         NSAlternateKeyMask | NSCommandKeyMask];                             \
     [o_menu addItem: o_mi];                                                 \
 /* Alt+Shift+Apple */                                                       \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN] \
+        [toNSStr(OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN)     \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Shift */                                                                 \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UPWARDS_WHITE_ARROW]                \
+        [toNSStr(UPWARDS_WHITE_ARROW)                                       \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Shift+Apple */                                                           \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN] \
+        [toNSStr(UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN)                \
          stringByAppendingString: string]                                   \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
     [o_menu addItem: o_mi];                                                 \
 /* Apple */                                                                 \
     o_mi = [[NSMenuItem alloc] initWithTitle:                               \
-        [[NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN]             \
+        [toNSStr(PLACE_OF_INTEREST_SIGN)                                    \
           stringByAppendingString: string]                                  \
         action:nil keyEquivalent:@""];                                      \
     [o_mi setKeyEquivalentModifierMask:                                     \
@@ -947,7 +947,7 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
 
         /* build the textfield */
         if (p_item->value.psz)
-            o_textfieldString = [NSString stringWithCString:p_item->value.psz encoding:NSUTF8StringEncoding];
+            o_textfieldString = toNSStr(p_item->value.psz);
         else
             o_textfieldString = @"";
         if (p_item->i_type == CONFIG_ITEM_PASSWORD) {
@@ -1934,8 +1934,7 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
 #if 0
             for (i = 0; i < sizeof(vlc_key) / sizeof(key_descriptor_t); i++)
                 if (vlc_key[i].psz_key_string)
-                    POPULATE_A_KEY(o_keys_menu,
-                                   [NSString stringWithUTF8String:vlc_key[i].psz_key_string],
+                    POPULATE_A_KEY(o_keys_menu,toNSStr(vlc_key[i].psz_key_string),
                                    vlc_key[i].i_key_code)
 #endif
                     }
@@ -2018,8 +2017,8 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
                 if (p_config->i_type == CONFIG_SUBCATEGORY &&
                     p_config->value.i == p_item->min.i) {
 
-                    o_modulelongname = [NSString stringWithUTF8String:module_get_name(p_parser, TRUE)];
-                    o_modulename = [NSString stringWithUTF8String:module_get_object(p_parser)];
+                    o_modulelongname = toNSStr(module_get_name(p_parser, TRUE));
+                    o_modulename = toNSStr(module_get_object(p_parser));
 
                     if (p_item->value.psz &&
                         strstr(p_item->value.psz, module_get_object(p_parser)))
index dc8deee..8543e7a 100644 (file)
@@ -539,7 +539,7 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam
 - (void)setupField:(NSTextField *)object forOption:(const char *)psz_option
 {
     char *psz_tmp = config_GetPsz(p_intf, psz_option);
-    [object setStringValue: [NSString stringWithUTF8String:psz_tmp ?: ""]];
+    [object setStringValue: toNSStr(psz_tmp)];
     [object setToolTip: _NS(config_GetLabel(p_intf, psz_option))];
     free(psz_tmp);
 }
@@ -557,7 +557,7 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam
     const char *pref = NULL;
     pref = [[[NSUserDefaults standardUserDefaults] objectForKey:@"language"] UTF8String];
     for (int x = 0; ppsz_language[x] != NULL; x++) {
-        [_intf_languagePopup addItemWithTitle:[NSString stringWithUTF8String:ppsz_language_text[x]]];
+        [_intf_languagePopup addItemWithTitle:toNSStr(ppsz_language_text[x])];
         if (pref) {
             if (!strcmp(ppsz_language[x], pref))
                 sel = x;
@@ -777,9 +777,9 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam
            && !strncmp(p_item->psz_name , "key-", 4)
            && !EMPTY_STR(p_item->psz_text)) {
             [tempArray_desc addObject: _NS(p_item->psz_text)];
-            [tempArray_names addObject: [NSString stringWithUTF8String:p_item->psz_name]];
+            [tempArray_names addObject: toNSStr(p_item->psz_name)];
             if (p_item->value.psz)
-                [_hotkeySettings addObject: [NSString stringWithUTF8String:p_item->value.psz]];
+                [_hotkeySettings addObject: toNSStr(p_item->value.psz)];
             else
                 [_hotkeySettings addObject: [NSString string]];
         }
@@ -907,7 +907,7 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
     if (_intfSettingChanged) {
         NSUInteger index = [_intf_languagePopup indexOfSelectedItem];
         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-        [defaults setObject:[NSString stringWithUTF8String:ppsz_language[index]] forKey:@"language"];
+        [defaults setObject:toNSStr(ppsz_language[index]) forKey:@"language"];
         [defaults synchronize];
 
         config_PutInt(p_intf, "metadata-network-access", [_intf_artCheckbox state]);
@@ -1252,7 +1252,7 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
 - (IBAction)showFontPicker:(id)sender
 {
     char * font = config_GetPsz(p_intf, "freetype-font");
-    NSString * fontName = font ? [NSString stringWithUTF8String:font] : nil;
+    NSString * fontName = font ? toNSStr(font) : nil;
     free(font);
     if (fontName) {
         NSFont * font = [NSFont fontWithName:fontName size:0.0];