]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/MainMenu.m
macosx: add custom numberformatter to goto time field to only allow digits and :
[vlc] / modules / gui / macosx / MainMenu.m
index 0a6412d18ef3dae199021c562a65f391086632f3..c0b3d5b69260bccdb162e9624bf9712fcd88f8df 100644 (file)
@@ -77,8 +77,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
                       _NS("URI"),           URI_COLUMN,
                       nil];
         // this array also assigns tags (index) to type of menu item
-        o_ptc_menuorder = [NSArray arrayWithObjects:TRACKNUM_COLUMN, TITLE_COLUMN, ARTIST_COLUMN, DURATION_COLUMN,
-                       GENRE_COLUMN, ALBUM_COLUMN, DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN, nil];
+        o_ptc_menuorder = @[TRACKNUM_COLUMN, TITLE_COLUMN, ARTIST_COLUMN, DURATION_COLUMN,
+                            GENRE_COLUMN, ALBUM_COLUMN, DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN];
     }
 
     return _o_sharedInstance;
@@ -122,7 +122,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
     /* check whether the user runs OSX with a RTL language */
     NSArray* languages = [NSLocale preferredLanguages];
-    NSString* preferredLanguage = [languages objectAtIndex:0];
+    NSString* preferredLanguage = languages[0];
 
     if ([NSLocale characterDirectionForLanguage:preferredLanguage] == NSLocaleLanguageDirectionRightToLeft) {
         msg_Dbg(VLCIntf, "adapting interface since '%s' is a RTL language", [preferredLanguage UTF8String]);
@@ -289,7 +289,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
         [mi setTarget:self];
         [mi setAction:selector];
         [mi setTag:p_item->list.i[i]];
-        [mi setRepresentedObject:[NSString stringWithUTF8String:psz_name]];
+        [mi setRepresentedObject:@(psz_name)];
         [menu addItem: [mi autorelease]];
         if (p_item->value.i == p_item->list.i[i])
             [mi setState:NSOnState];
@@ -392,8 +392,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_mi_snapshot setTitle: _NS("Snapshot")];
     [o_mi_videotrack setTitle: _NS("Video Track")];
     [o_mu_videotrack setTitle: _NS("Video Track")];
-    [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")];
-    [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")];
+    [o_mi_aspect_ratio setTitle: _NS("Aspect ratio")];
+    [o_mu_aspect_ratio setTitle: _NS("Aspect ratio")];
     [o_mi_crop setTitle: _NS("Crop")];
     [o_mu_crop setTitle: _NS("Crop")];
     [o_mi_screen setTitle: _NS("Fullscreen Video Device")];
@@ -406,10 +406,16 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_mu_ffmpeg_pp setTitle: _NS("Post processing")];
 
     [o_mu_subtitles setTitle:_NS("Subtitles")];
+    [o_mi_openSubtitleFile setTitle: _NS("Add Subtitle File...")];
     [o_mi_subtitle_track setTitle: _NS("Subtitles Track")];
     [o_mu_subtitle_tracks setTitle: _NS("Subtitles Track")];
-    [o_mi_openSubtitleFile setTitle: _NS("Open File...")];
+    [o_mi_subtitle_size setTitle: _NS("Text Size")];
+    [o_mi_subtitle_textcolor setTitle: _NS("Text Color")];
+    [o_mi_subtitle_outlinethickness setTitle: _NS("Outline Thickness")];
     [o_mi_subtitle_bgopacity setView: o_mi_subtitle_bgopacity_view];
+    [o_mi_subtitle_bgopacity_lbl setStringValue: _NS("Background Opacity")];
+    [o_mi_subtitle_bgopacity_lbl_gray setStringValue: _NS("Background Opacity")];
+    [o_mi_subtitle_bgcolor setTitle: _NS("Background Color")];
     [o_mi_teletext setTitle: _NS("Teletext")];
     [o_mi_teletext_transparent setTitle: _NS("Transparent")];
     [o_mi_teletext_index setTitle: _NS("Index")];
@@ -468,12 +474,12 @@ static VLCMainMenu *_o_sharedInstance = nil;
     NSMenuItem *o_mi_tmp;
     NSUInteger count = [o_ptc_menuorder count];
     for (NSUInteger i = 0; i < count; i++) {
-        NSString *o_title = [o_ptc_translation_dict objectForKey:[o_ptc_menuorder objectAtIndex:i]];
+        NSString *o_title = [o_ptc_translation_dict objectForKey:o_ptc_menuorder[i]];
         o_mi_tmp = [o_mu_playlistTableColumns addItemWithTitle:o_title
                                                         action:@selector(togglePlaylistColumnTable:)
                                                  keyEquivalent:@""];
         /* don't set a valid target for the title column selector, since we want it to be disabled */
-        if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN])
+        if (![o_ptc_menuorder[i] isEqualToString: TITLE_COLUMN])
             [o_mi_tmp setTarget:self];
         [o_mi_tmp setTag:i];
 
@@ -481,7 +487,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
                                              action:@selector(togglePlaylistColumnTable:)
                                       keyEquivalent:@""];
         /* don't set a valid target for the title column selector, since we want it to be disabled */
-        if (![[o_ptc_menuorder objectAtIndex:i] isEqualToString: TITLE_COLUMN])
+        if (![o_ptc_menuorder[i] isEqualToString: TITLE_COLUMN])
             [o_mi_tmp setTarget:self];
         [o_mi_tmp setTag:i];
     }
@@ -500,7 +506,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
     NSArray *menuitems_array = [the_menu itemArray];
     NSUInteger menuItemCount = [menuitems_array count];
     for (NSUInteger i=0; i < menuItemCount; i++) {
-        NSMenuItem *one_item = [menuitems_array objectAtIndex: i];
+        NSMenuItem *one_item = menuitems_array[i];
         if ([one_item hasSubmenu])
             [self releaseRepresentedObjects: [one_item submenu]];
 
@@ -594,11 +600,11 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_mitem setTarget: self];
     NSRect s_rect;
     for (NSUInteger i = 0; i < count; i++) {
-        s_rect = [[o_screens objectAtIndex: i] frame];
+        s_rect = [o_screens[i] frame];
         [o_submenu addItemWithTitle: [NSString stringWithFormat: @"%@ %li (%ix%i)", _NS("Screen"), i+1,
                                       (int)s_rect.size.width, (int)s_rect.size.height] action:@selector(toggleFullscreenDevice:) keyEquivalent:@""];
         o_mitem = [o_submenu itemAtIndex:i+1];
-        [o_mitem setTag: (int)[[o_screens objectAtIndex: i] displayID]];
+        [o_mitem setTag: (int)[o_screens[i] displayID]];
         [o_mitem setEnabled: YES];
         [o_mitem setTarget: self];
     }
@@ -708,10 +714,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
 - (IBAction)toggleSidebar:(id)sender
 {
-    BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-sidebar");
-    config_PutInt(VLCIntf, "macosx-show-sidebar", b_value);
     [[[VLCMain sharedInstance] mainWindow] toggleLeftSubSplitView];
-    [o_mi_toggleSidebar setState: b_value];
 }
 
 - (void)updateSidebarMenuItem
@@ -726,7 +729,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [[o_mu_playlistTableColumns            itemWithTag: i_tag] setState: i_new_state];
     [[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_new_state];
 
-    NSString *o_column = [o_ptc_menuorder objectAtIndex: i_tag];
+    NSString *o_column = o_ptc_menuorder[i_tag];
     [[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_new_state translationDict: o_ptc_translation_dict];
 }
 
@@ -922,8 +925,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [openPanel setCanChooseFiles: YES];
     [openPanel setCanChooseDirectories: NO];
     [openPanel setAllowsMultipleSelection: YES];
-    [openPanel setAllowedFileTypes: [NSArray arrayWithObjects: @"cdg",@"@idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil", nil]];
-    [openPanel setDirectoryURL:[NSURL fileURLWithPath:[[NSString stringWithUTF8String:path] stringByExpandingTildeInPath]]];
+    [openPanel setAllowedFileTypes: @[@"cdg",@"@idx",@"srt",@"sub",@"utf",@"ass",@"ssa",@"aqt",@"jss",@"psb",@"rt",@"smi",@"txt",@"smil"]];
+    [openPanel setDirectoryURL:[NSURL fileURLWithPath:[@(path) stringByExpandingTildeInPath]]];
     i_returnValue = [openPanel runModal];
     free(path);
 
@@ -935,10 +938,10 @@ static VLCMainMenu *_o_sharedInstance = nil;
         c = [[openPanel URLs] count];
 
         for (int i = 0; i < c ; i++) {
-            msg_Dbg(VLCIntf, "loading subs from %s", [[[[openPanel URLs] objectAtIndex: i] path] UTF8String]);
-            if (input_AddSubtitle(p_input, [[[[openPanel URLs] objectAtIndex: i] path] UTF8String], TRUE))
+            msg_Dbg(VLCIntf, "loading subs from %s", [[[openPanel URLs][i] path] UTF8String]);
+            if (input_AddSubtitle(p_input, [[[openPanel URLs][i] path] UTF8String], TRUE))
                 msg_Warn(VLCIntf, "unable to load subtitles from '%s'",
-                         [[[[openPanel URLs] objectAtIndex: i] path] UTF8String]);
+                         [[[openPanel URLs][i] path] UTF8String]);
         }
     }
     vlc_object_release(p_input);
@@ -1304,7 +1307,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_parent setEnabled:NO];
 
     /* Aspect Ratio */
-    if ([[o_parent title] isEqualToString: _NS("Aspect-ratio")] == YES) {
+    if ([[o_parent title] isEqualToString: _NS("Aspect ratio")] == YES) {
         NSMenuItem *o_lmi_tmp2;
         o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
         [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]];