Commit 46ab781e authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* If the "show advanced" option has been changed and you press the Apply

  button, the preferences window is destroyed and created.
parent 22342e60
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* prefs.h: MacOS X plugin for vlc * prefs.h: MacOS X plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: prefs.h,v 1.2 2003/02/08 22:20:28 massiot Exp $ * $Id: prefs.h,v 1.3 2003/02/21 02:45:21 hartman Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* *
...@@ -48,8 +48,7 @@ ...@@ -48,8 +48,7 @@
- (void)configChanged:(id)o_unknown; - (void)configChanged:(id)o_unknown;
- (void)clickedApply:(id)sender; - (void)clickedApplyCancelOK:(id)sender;
- (void)clickedCancelOK:(id)sender;
@end @end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* prefs.m: MacOS X plugin for vlc * prefs.m: MacOS X plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: prefs.m,v 1.14 2003/02/20 18:10:16 hartman Exp $ * $Id: prefs.m,v 1.15 2003/02/21 02:45:21 hartman Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* *
...@@ -576,15 +576,15 @@ ...@@ -576,15 +576,15 @@
s_rc.origin.y = s_panel_rc.origin.y + 14; s_rc.origin.y = s_panel_rc.origin.y + 14;
s_rc.size.height = 25; s_rc.size.width = 105; s_rc.size.height = 25; s_rc.size.width = 105;
s_rc.origin.x = s_panel_rc.size.width - s_rc.size.width - 14; s_rc.origin.x = s_panel_rc.size.width - s_rc.size.width - 14;
DEF_PANEL_BUTTON( 0, _NS("OK"), clickedCancelOK: ); DEF_PANEL_BUTTON( 0, _NS("OK"), clickedApplyCancelOK: );
[o_panel setDefaultButtonCell: [o_button cell]]; [o_panel setDefaultButtonCell: [o_button cell]];
s_rc.origin.x -= s_rc.size.width; s_rc.origin.x -= s_rc.size.width;
DEF_PANEL_BUTTON( 1, _NS("Cancel"), clickedCancelOK: ); DEF_PANEL_BUTTON( 1, _NS("Cancel"), clickedApplyCancelOK: );
[o_button setKeyEquivalent: @"\E"]; [o_button setKeyEquivalent: @"\E"];
s_rc.origin.x -= s_rc.size.width; s_rc.origin.x -= s_rc.size.width;
DEF_PANEL_BUTTON( 2, _NS("Apply"), clickedApply: ); DEF_PANEL_BUTTON( 2, _NS("Apply"), clickedApplyCancelOK: );
[o_button setEnabled: NO]; [o_button setEnabled: NO];
#undef DEF_PANEL_BUTTON #undef DEF_PANEL_BUTTON
...@@ -724,92 +724,102 @@ ...@@ -724,92 +724,102 @@
} }
} }
- (void)clickedApply:(id)sender - (void)clickedApplyCancelOK:(id)sender
{ {
id o_vlc_control; id o_vlc_control;
NSEnumerator *o_enum; NSEnumerator *o_enum;
BOOL b_advanced_change = FALSE;
NSWindow *o_pref_panel = [[sender superview] window];
NSString *o_module_name = [[o_pref_panel toolbar] identifier];
NSView *o_config_view = [sender superview]; if ( ![[sender title] isEqualToString: _NS("Cancel")] )
NSWindow *o_config_panel = [o_config_view window];
NSButton *o_btn_apply = [o_config_view viewWithTag: 2];
NSString *o_module_name = [[o_config_panel toolbar] identifier];
NSMutableArray *o_prefs = [o_save_prefs objectForKey: o_module_name];
o_enum = [o_prefs objectEnumerator];
while( ( o_vlc_control = [o_enum nextObject] ) )
{ {
int i_type = [o_vlc_control configType]; NSView *o_config_view = [sender superview];
NSString *o_name = [o_vlc_control configName]; NSWindow *o_config_panel = [o_config_view window];
char *psz_name = (char *)[o_name lossyCString]; NSButton *o_btn_apply = [o_config_view viewWithTag: 2];
NSString *o_module_name = [[o_config_panel toolbar] identifier];
switch( i_type ) NSMutableArray *o_prefs = [o_save_prefs objectForKey: o_module_name];
o_enum = [o_prefs objectEnumerator];
while( ( o_vlc_control = [o_enum nextObject] ) )
{ {
int i_type = [o_vlc_control configType];
case CONFIG_ITEM_MODULE: NSString *o_name = [o_vlc_control configName];
case CONFIG_ITEM_STRING: char *psz_name = (char *)[o_name lossyCString];
case CONFIG_ITEM_FILE:
switch( i_type )
{ {
char *psz_value;
NSString *o_value; case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_STRING:
o_value = [o_vlc_control stringValue]; case CONFIG_ITEM_FILE:
psz_value = (char *)[o_value lossyCString]; {
char *psz_value;
config_PutPsz( p_intf, psz_name, NSString *o_value;
*psz_value ? psz_value : NULL );
} o_value = [o_vlc_control stringValue];
break; psz_value = (char *)[o_value lossyCString];
case CONFIG_ITEM_INTEGER: config_PutPsz( p_intf, psz_name,
case CONFIG_ITEM_BOOL: *psz_value ? psz_value : NULL );
{ }
int i_value = [o_vlc_control intValue]; break;
config_PutInt( p_intf, psz_name, i_value ); case CONFIG_ITEM_INTEGER:
} case CONFIG_ITEM_BOOL:
break; {
int i_value = [o_vlc_control intValue];
case CONFIG_ITEM_FLOAT: if ( !strcmp( psz_name, "advanced" ) && ( config_GetInt( p_intf, "advanced" ) != i_value ) )
{ {
float f_value = [o_vlc_control floatValue]; b_advanced_change = TRUE;
}
config_PutFloat( p_intf, psz_name, f_value ); config_PutInt( p_intf, psz_name, i_value );
}
break;
case CONFIG_ITEM_FLOAT:
{
float f_value = [o_vlc_control floatValue];
config_PutFloat( p_intf, psz_name, f_value );
}
break;
} }
break;
} }
[o_btn_apply setEnabled: NO];
[o_prefs removeAllObjects];
config_SaveConfigFile( p_intf, NULL );
} }
[o_btn_apply setEnabled: NO]; if ( [[sender title] isEqualToString: _NS("Apply")] && !b_advanced_change )
[o_prefs removeAllObjects];
config_SaveConfigFile( p_intf, NULL );
}
- (void)clickedCancelOK:(id)sender
{
NSWindow *o_pref_panel = [[sender superview] window];
NSString *o_module_name = [[o_pref_panel toolbar] identifier];
if( [[sender title] isEqualToString: _NS("OK")] )
{ {
[self clickedApply: sender]; ;
}
[o_pref_panel close];
if( [self respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] )
{
[self performSelectorOnMainThread: @selector(destroyPrefPanel:)
withObject: o_module_name
waitUntilDone: NO];
} }
else else
{ {
[NSTimer scheduledTimerWithTimeInterval: 0.1 [o_pref_panel close];
target: self selector: @selector(destroyPrefPanel:)
userInfo: o_module_name repeats: NO]; if( [self respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] )
{
[self performSelectorOnMainThread: @selector(destroyPrefPanel:)
withObject: o_module_name
waitUntilDone: YES];
if ( [[sender title] isEqualToString: _NS("Apply")] && b_advanced_change )
{
[self createPrefPanel:@"main"];
}
}
else
{
[NSTimer scheduledTimerWithTimeInterval: 0.1
target: self selector: @selector(destroyPrefPanel:)
userInfo: o_module_name repeats: NO];
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment