]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/MainMenu.m
macosx: do not allow playlist item deletion for sd modules
[vlc] / modules / gui / macosx / MainMenu.m
index 032c263fa8b17b4e9854c70abecf992ec6e5bf7b..2fda43e98586e745e27d4e2f68ea1ef82e911ab6 100644 (file)
  *****************************************************************************/
 
 #import "MainMenu.h"
+#import "intf.h"
+
 #import <vlc_common.h>
 #import <vlc_playlist.h>
 #import <vlc_input.h>
 
-#import "intf.h"
 #import "open.h"
 #import "wizard.h"
 #import "about.h"
@@ -285,18 +286,18 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_mitem setTag: -1];
     [o_mitem setEnabled: YES];
     [o_mitem setTarget: self];
-    for (NSUInteger x = 0; x < 7; x++) {
+    for (NSUInteger x = 1; x < 7; x++) {
         [o_mu_ffmpeg_pp addItemWithTitle:[NSString stringWithFormat:_NS("Level %i"), x]
                                                action:@selector(togglePostProcessing:)
                                         keyEquivalent:@""];
-        o_mitem = [o_mu_ffmpeg_pp itemAtIndex:x+1];
-        [o_mitem setEnabled: YES];
+        o_mitem = [o_mu_ffmpeg_pp itemAtIndex:x];
+        [o_mitem setEnabled:YES];
         [o_mitem setTag:x];
-        [o_mitem setTarget: self];
+        [o_mitem setTarget:self];
     }
     char *psz_config = config_GetPsz(p_intf, "video-filter");
     if (psz_config) {
-        if (!strstr(psz_config, "postprocess"))
+        if (!strstr(psz_config, "postproc"))
             [[o_mu_ffmpeg_pp itemAtIndex:0] setState:NSOnState];
         else
             [[o_mu_ffmpeg_pp itemWithTag:config_GetInt(p_intf, "postproc-q")] setState:NSOnState];
@@ -940,65 +941,17 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
 - (void)_disablePostProcessing
 {
-    char *psz_name = "postprocess";
-    char *psz_string, *psz_parser;
-    psz_string = config_GetPsz(p_intf, "video-filter");
-
-    if (!psz_string)
-        return;
-
-    psz_parser = strstr(psz_string, psz_name);
-    if (psz_parser) {
-        if (*(psz_parser + strlen(psz_name)) == ':') {
-            memmove(psz_parser, psz_parser + strlen(psz_name) + 1,
-                    strlen(psz_parser + strlen(psz_name) + 1) + 1);
-        } else
-            *psz_parser = '\0';
-
-        /* Remove trailing : : */
-        if (strlen(psz_string) > 0 && *(psz_string + strlen(psz_string) -1) == ':')
-            *(psz_string + strlen(psz_string) -1) = '\0';
-    } else {
-        free(psz_string);
-        return;
-    }
-    config_PutPsz(p_intf, "video-filter", psz_string);
-
-    /* Try to set on the fly */
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        var_SetString(p_vout, "video-filter", psz_string);
-        vlc_object_release(p_vout);
-    }
+    [[VLCCoreInteraction sharedInstance] setVideoFilter:"postproc" on:false];
 }
 
 - (void)_enablePostProcessing
 {
-    char *psz_name = "postprocess";
-    char *psz_string, *psz_parser;
-    psz_string = config_GetPsz(p_intf, "video-filter");
-
-    if (psz_string == NULL)
-        psz_string = psz_name;
-    else if (strstr(psz_string, psz_name) == NULL) {
-        char *psz_tmp = strdup([[NSString stringWithFormat: @"%s:%s", psz_string, psz_name] UTF8String]);
-        free(psz_string);
-        psz_string = psz_tmp;
-    }
-
-    config_PutPsz(p_intf, "video-filter", psz_string);
-
-    /* Try to set on the fly */
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        var_SetString(p_vout, "video-filter", psz_string);
-        vlc_object_release(p_vout);
-    }
+    [[VLCCoreInteraction sharedInstance] setVideoFilter:"postproc" on:true];
 }
 
 - (IBAction)togglePostProcessing:(id)sender
 {
-    char *psz_name = "postprocess";
+    char *psz_name = "postproc";
     NSInteger count = [o_mu_ffmpeg_pp numberOfItems];
     for (NSUInteger x = 0; x < count; x++)
         [[o_mu_ffmpeg_pp itemAtIndex:x] setState:NSOffState];
@@ -1010,23 +963,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
         [self _enablePostProcessing];
         [sender setState:NSOnState];
 
-        vout_thread_t *p_vout = getVout();
-        vlc_object_t *p_filter;
-
-        config_PutInt(p_intf, "postproc-q", [sender tag]);
-
-        if (p_vout) {
-            p_filter = vlc_object_find_name(pl_Get(p_intf), psz_name);
-
-            if (!p_filter) {
-                msg_Warn(p_intf, "filter '%s' isn't enabled", psz_name);
-                vlc_object_release(p_vout);
-                return;
-            }
-            var_SetInteger(p_filter, "postproc-q", [sender tag]);
-            vlc_object_release(p_vout);
-            vlc_object_release(p_filter);
-        }
+        [[VLCCoreInteraction sharedInstance] setVideoFilterProperty:"postproc-q" forFilter:"postproc" integer:[sender tag]];
     }
 }
 
@@ -1223,7 +1160,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
 - (IBAction)viewPreferences:(id)sender
 {
-    NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentWindowLevel];
+    NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel];
     [[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
 }
 
@@ -1493,7 +1430,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
         return;
     }
 
-    if (var_Change(p_object, psz_variable, VLC_VAR_GETLIST,
+    if (var_Change(p_object, psz_variable, VLC_VAR_GETCHOICES,
                    &val_list, &text_list) < 0) {
         if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
         return;