Commit ade1ff28 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: GUI demo of Simple Preferences showing the Interface and Audio...

macosx: GUI demo of Simple Preferences showing the Interface and Audio categories. Feedback is welcome.
parent bcca390d
......@@ -304,6 +304,7 @@
"o_mi_show_all" = id;
"o_mi_slower" = id;
"o_mi_snapshot" = id;
"o_mi_sprefs" = id;
"o_mi_stop" = id;
"o_mi_subtitle" = id;
"o_mi_title" = id;
......
......@@ -25,13 +25,13 @@
<array/>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>2197</integer>
<integer>1789</integer>
<integer>2769</integer>
<integer>21</integer>
<integer>2730</integer>
<integer>29</integer>
<integer>2416</integer>
<integer>1789</integer>
<integer>29</integer>
<integer>2197</integer>
</array>
<key>IBSystem Version</key>
<string>8S2167</string>
......
......@@ -2,6 +2,7 @@
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = MPSlider; LANGUAGE = ObjC; SUPERCLASS = NSSlider; },
{CLASS = NSDatePicker; LANGUAGE = ObjC; SUPERCLASS = NSControl; },
{
ACTIONS = {showPanel = id; };
CLASS = VLAboutBox;
......@@ -441,6 +442,54 @@
"o_tree" = id;
};
SUPERCLASS = NSObject;
},
{
ACTIONS = {audioSettingChanged = id; buttonAction = id; interfaceSettingChanged = id; };
CLASS = VLCSimplePrefs;
LANGUAGE = ObjC;
OUTLETS = {
"o_audio_dolby_pop" = id;
"o_audio_dolby_txt" = id;
"o_audio_effects_box" = id;
"o_audio_enable_ckb" = id;
"o_audio_general_box" = id;
"o_audio_headphone_ckb" = id;
"o_audio_lang_fld" = id;
"o_audio_lang_txt" = id;
"o_audio_last_box" = id;
"o_audio_last_ckb" = id;
"o_audio_lastpwd_fld" = id;
"o_audio_lastpwd_txt" = id;
"o_audio_lastuser_fld" = id;
"o_audio_lastuser_txt" = id;
"o_audio_norm_ckb" = id;
"o_audio_norm_fld" = id;
"o_audio_spdif_ckb" = id;
"o_audio_view" = id;
"o_audio_visual_pop" = id;
"o_audio_visual_txt" = id;
"o_audio_vol_fld" = id;
"o_audio_vol_sld" = id;
"o_audio_vol_txt" = id;
"o_intf_art_pop" = id;
"o_intf_art_txt" = id;
"o_intf_black_ckb" = id;
"o_intf_embvout_ckb" = id;
"o_intf_fspanel_ckb" = id;
"o_intf_lang_pop" = id;
"o_intf_lang_txt" = id;
"o_intf_meta_ckb" = id;
"o_intf_network_box" = id;
"o_intf_view" = id;
"o_sprefs_basicFull_matrix" = id;
"o_sprefs_basic_box" = id;
"o_sprefs_cancel_btn" = id;
"o_sprefs_controls_box" = id;
"o_sprefs_reset_btn" = id;
"o_sprefs_save_btn" = id;
"o_sprefs_win" = id;
};
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
......
......@@ -3,9 +3,26 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>179 90 505 518 0 0 1280 1002 </string>
<string>398 124 505 518 0 0 1280 778 </string>
<key>IBEditorPositions</key>
<dict>
<key>2311</key>
<string>310 385 660 305 0 0 1280 778 </string>
<key>2330</key>
<string>190 210 660 502 0 0 1280 778 </string>
</dict>
<key>IBFramework Version</key>
<string>439.0</string>
<string>446.1</string>
<key>IBGroupedObjects</key>
<dict>
<key>1</key>
<array>
<string>2352</string>
<string>2353</string>
</array>
</dict>
<key>IBLastGroupID</key>
<string>2</string>
<key>IBLockedObjects</key>
<array>
<integer>2203</integer>
......@@ -15,9 +32,10 @@
</array>
<key>IBOpenObjects</key>
<array>
<integer>1530</integer>
<integer>2265</integer>
<integer>2330</integer>
</array>
<key>IBSystem Version</key>
<string>8C46</string>
<string>8S2167</string>
</dict>
</plist>
......@@ -68,6 +68,12 @@
C2F2A707095AE51700018C74 /* play_embedded_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F2A703095AE51600018C74 /* play_embedded_blue.png */; };
C2F2A708095AE51700018C74 /* skip_forward_embedded_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F2A704095AE51600018C74 /* skip_forward_embedded_blue.png */; };
C2F2A709095AE51700018C74 /* skip_previous_embedded_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F2A705095AE51600018C74 /* skip_previous_embedded_blue.png */; };
CC0B723D0D54F2B000448E00 /* spref_cone_Audio_64.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0B72370D54F2B000448E00 /* spref_cone_Audio_64.png */; };
CC0B723E0D54F2B000448E00 /* spref_cone_Hotkeys_64.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0B72380D54F2B000448E00 /* spref_cone_Hotkeys_64.png */; };
CC0B723F0D54F2B100448E00 /* spref_cone_Input_64.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0B72390D54F2B000448E00 /* spref_cone_Input_64.png */; };
CC0B72400D54F2B100448E00 /* spref_cone_Interface_64.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0B723A0D54F2B000448E00 /* spref_cone_Interface_64.png */; };
CC0B72410D54F2B100448E00 /* spref_cone_Subtitles_64.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0B723B0D54F2B000448E00 /* spref_cone_Subtitles_64.png */; };
CC0B72420D54F2B100448E00 /* spref_cone_Video_64.png in Resources */ = {isa = PBXBuildFile; fileRef = CC0B723C0D54F2B000448E00 /* spref_cone_Video_64.png */; };
CC1941250B9C1F8400635F6B /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1941240B9C1F8400635F6B /* QTKit.framework */; };
CC1AC1BC0A7BDA41002478C3 /* InteractionErrorPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = CC1AC1BA0A7BDA41002478C3 /* InteractionErrorPanel.nib */; };
CC1B4B4D09A8CF9E0078AD2E /* Interaction.nib in Resources */ = {isa = PBXBuildFile; fileRef = CC1B4B4B09A8CF9E0078AD2E /* Interaction.nib */; };
......@@ -1067,6 +1073,12 @@
C2F2A703095AE51600018C74 /* play_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = play_embedded_blue.png; path = Resources/play_embedded_blue.png; sourceTree = "<group>"; };
C2F2A704095AE51600018C74 /* skip_forward_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skip_forward_embedded_blue.png; path = Resources/skip_forward_embedded_blue.png; sourceTree = "<group>"; };
C2F2A705095AE51600018C74 /* skip_previous_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skip_previous_embedded_blue.png; path = Resources/skip_previous_embedded_blue.png; sourceTree = "<group>"; };
CC0B72370D54F2B000448E00 /* spref_cone_Audio_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Audio_64.png; path = Resources/spref_cone_Audio_64.png; sourceTree = "<group>"; };
CC0B72380D54F2B000448E00 /* spref_cone_Hotkeys_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Hotkeys_64.png; path = Resources/spref_cone_Hotkeys_64.png; sourceTree = "<group>"; };
CC0B72390D54F2B000448E00 /* spref_cone_Input_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Input_64.png; path = Resources/spref_cone_Input_64.png; sourceTree = "<group>"; };
CC0B723A0D54F2B000448E00 /* spref_cone_Interface_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Interface_64.png; path = Resources/spref_cone_Interface_64.png; sourceTree = "<group>"; };
CC0B723B0D54F2B000448E00 /* spref_cone_Subtitles_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Subtitles_64.png; path = Resources/spref_cone_Subtitles_64.png; sourceTree = "<group>"; };
CC0B723C0D54F2B000448E00 /* spref_cone_Video_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Video_64.png; path = Resources/spref_cone_Video_64.png; sourceTree = "<group>"; };
CC1941240B9C1F8400635F6B /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
CC1AC1BB0A7BDA41002478C3 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/InteractionErrorPanel.nib; sourceTree = "<group>"; };
CC1B4B4C09A8CF9E0078AD2E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/Interaction.nib; sourceTree = "<group>"; };
......@@ -1107,6 +1119,8 @@
CC6EDD4F0B9CA2140096068A /* eyetv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = eyetv.h; path = ../../modules/gui/macosx/eyetv.h; sourceTree = SOURCE_ROOT; };
CC6EDD500B9CA2140096068A /* eyetv.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = eyetv.m; path = ../../modules/gui/macosx/eyetv.m; sourceTree = SOURCE_ROOT; };
CC962E2C0CC7992800A56695 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = /System/Library/Frameworks/WebKit.framework; sourceTree = "<absolute>"; };
CCB24D5D0D54BBAE004D780C /* simple_prefs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = simple_prefs.m; path = ../../modules/gui/macosx/simple_prefs.m; sourceTree = SOURCE_ROOT; };
CCB24D5E0D54BBAE004D780C /* simple_prefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = simple_prefs.h; path = ../../modules/gui/macosx/simple_prefs.h; sourceTree = SOURCE_ROOT; };
CCC593780AB4A9FB0004FF52 /* embeddedwindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = embeddedwindow.h; path = ../../modules/gui/macosx/embeddedwindow.h; sourceTree = SOURCE_ROOT; };
CCC593790AB4A9FB0004FF52 /* embeddedwindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = embeddedwindow.m; path = ../../modules/gui/macosx/embeddedwindow.m; sourceTree = SOURCE_ROOT; };
CCCB86C00ACFDFB300CF1E10 /* fs_time_slider.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fs_time_slider.png; path = Resources/fs_time_slider.png; sourceTree = "<group>"; };
......@@ -1208,6 +1222,7 @@
8ECA7E520563CD9500DFC000 /* Controller */,
F69B0CA602E24F6401A80112 /* InfoPlist.strings */,
8EBF3FA303F13FFB0059A3A7 /* vlc.scriptSuite */,
CC0B71E00D54F0DD00448E00 /* simple prefs (taken from qt4) */,
8EBF3FA503F140960059A3A7 /* vlc.scriptTerminology */,
8EDAC3430440F72D0059A3A7 /* README.MacOSX.rtf */,
);
......@@ -1266,6 +1281,8 @@
2AEF857709A5FEC900130822 /* fspanel.m */,
CC6EDD4F0B9CA2140096068A /* eyetv.h */,
CC6EDD500B9CA2140096068A /* eyetv.m */,
CCB24D5D0D54BBAE004D780C /* simple_prefs.m */,
CCB24D5E0D54BBAE004D780C /* simple_prefs.h */,
);
name = Classes;
sourceTree = "<group>";
......@@ -1346,6 +1363,19 @@
name = Controller;
sourceTree = "<group>";
};
CC0B71E00D54F0DD00448E00 /* simple prefs (taken from qt4) */ = {
isa = PBXGroup;
children = (
CC0B72370D54F2B000448E00 /* spref_cone_Audio_64.png */,
CC0B72380D54F2B000448E00 /* spref_cone_Hotkeys_64.png */,
CC0B72390D54F2B000448E00 /* spref_cone_Input_64.png */,
CC0B723A0D54F2B000448E00 /* spref_cone_Interface_64.png */,
CC0B723B0D54F2B000448E00 /* spref_cone_Subtitles_64.png */,
CC0B723C0D54F2B000448E00 /* spref_cone_Video_64.png */,
);
name = "simple prefs (taken from qt4)";
sourceTree = "<group>";
};
CC33C26C0D257958008C4683 /* embedded */ = {
isa = PBXGroup;
children = (
......@@ -1642,6 +1672,12 @@
CC33C25F0D2578F5008C4683 /* stop_graphite.png in Resources */,
CC33C2600D2578F5008C4683 /* volumeslider_graphite.png in Resources */,
CC33C2610D2578F5008C4683 /* fullscreen_graphite.png in Resources */,
CC0B723D0D54F2B000448E00 /* spref_cone_Audio_64.png in Resources */,
CC0B723E0D54F2B000448E00 /* spref_cone_Hotkeys_64.png in Resources */,
CC0B723F0D54F2B100448E00 /* spref_cone_Input_64.png in Resources */,
CC0B72400D54F2B100448E00 /* spref_cone_Interface_64.png in Resources */,
CC0B72410D54F2B100448E00 /* spref_cone_Subtitles_64.png in Resources */,
CC0B72420D54F2B100448E00 /* spref_cone_Video_64.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -31,6 +31,8 @@ SOURCES_macosx = \
prefs.h \
prefs_widgets.h \
prefs_widgets.m \
simple_prefs.h \
simple_prefs.m \
output.h \
output.m \
vout.m \
......
......@@ -97,6 +97,7 @@ struct intf_sys_t
{
intf_thread_t *p_intf; /* The main intf object */
id o_prefs; /* VLCPrefs */
id o_sprefs; /* VLCSimplePrefs */
id o_about; /* VLAboutBox */
id o_open; /* VLCOpen */
id o_wizard; /* VLCWizard */
......@@ -161,6 +162,7 @@ struct intf_sys_t
IBOutlet id o_mi_about;
IBOutlet id o_mi_prefs;
IBOutlet id o_mi_sprefs;
IBOutlet id o_mi_checkForUpdate;
IBOutlet id o_mi_add_intf;
IBOutlet id o_mu_add_intf;
......@@ -309,6 +311,8 @@ struct intf_sys_t
- (void)controlTintChanged;
- (id)getControls;
- (id)getSimplePreferences;
- (id)getPreferences;
- (id)getPlaylist;
- (id)getInfo;
- (id)getWizard;
......
This diff is collapsed.
......@@ -271,52 +271,37 @@ static VLCTreeItem *o_root_item = nil;
if( [ o_children count] == 0 )
{
intf_thread_t *p_intf = VLCIntf;
vlc_list_t *p_list;
module_t *p_module = NULL;
module_t *p_parser;
int i_index = 0;
module_config_t *p_item,
*p_end;
int i_index = 0;
/* List the modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
if( !p_list ) return nil;
/* get parser */
p_parser = (module_t *)p_list->p_values[i_index].p_object;
if( [[self getName] isEqualToString: @"main"] )
{
/*
* Find the main module
*/
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object;
if( !strcmp( module_GetObjName( p_module ), "main" ) )
break;
}
if( p_module == NULL )
/* Build the tree for the main module */
const module_t *p_module = NULL;
vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
FIND_ANYWHERE );
if( !p_list ) return NULL;
for( unsigned i = 0; p_module == NULL; i++ )
{
msg_Err( p_intf,
"could not load the preferences" );
return nil;
assert (i < (unsigned)p_list->i_count);
const module_t *p_main = (module_t *)p_list->p_values[i].p_object;
if( strcmp( module_GetObjName( p_main ), "main" ) == 0 )
p_module = p_main;
}
if( i_index < p_list->i_count )
{
/* We found the main module */
/* Enumerate config categories and store a reference so we can
* generate their config panel them when it is asked by the user. */
VLCTreeItem *p_last_category = NULL;
unsigned int i_confsize;
p_item = module_GetConfig( p_parser, &i_confsize );
module_config_t *const p_config = module_GetConfig (p_module, &i_confsize);
p_end = p_item + i_confsize;
o_children = [[NSMutableArray alloc] initWithCapacity:10];
if( p_item ) do
for (size_t i = 0; i < i_confsize; i++)
{
p_item = p_config + i;
NSString *o_child_name;
NSString *o_child_title;
NSString *o_child_help;
switch( p_item->i_type )
{
case CONFIG_CATEGORY:
......@@ -341,6 +326,7 @@ static VLCTreeItem *o_root_item = nil;
case CONFIG_SUBCATEGORY:
if( p_item->value.i == -1 ) break;
/* Special cases: move the main subcategories to the parent cat*/
if( p_item->value.i != SUBCAT_PLAYLIST_GENERAL &&
p_item->value.i != SUBCAT_VIDEO_GENERAL &&
p_item->value.i != SUBCAT_INPUT_GENERAL &&
......@@ -364,16 +350,18 @@ static VLCTreeItem *o_root_item = nil;
parent:p_last_category
children:[[NSMutableArray alloc]
initWithCapacity:10]
whithCategory: p_item - module_GetConfig( p_parser, &i_confsize )]];
whithCategory: p_item - module_GetConfig( p_module, &i_confsize )]];
continue;
}
break;
default:
break;
}
} while( p_item < p_end && p_item++ );
}
module_PutConfig (p_config);
/* Build the tree of plugins */
/* Build a tree of the plugins */
/* Add the capabilities */
for( i_index = 0; i_index < p_list->i_count; i_index++ )
......@@ -387,9 +375,9 @@ static VLCTreeItem *o_root_item = nil;
/* Exclude empty plugins (submodules don't have config */
/* options, they are stored in the parent module) */
// Does not work
// if( modules_IsSubModule( p_module ) )
// continue;
// Does not work
// if( modules_IsSubModule( p_module ) )
// continue;
p_item = module_GetConfig( p_module, &confsize );
if( !p_item ) continue;
......@@ -454,9 +442,11 @@ static VLCTreeItem *o_root_item = nil;
children:IsALeafNode
whithCategory: -1]];
}
}
vlc_list_release( p_list );
}
return o_children;
}
......
/*****************************************************************************
* simple_prefs.h: Simple Preferences for Mac OS X
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id:$
*
* Authors: 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>
@interface VLCSimplePrefs : NSObject
{
IBOutlet id o_audio_dolby_pop;
IBOutlet id o_audio_dolby_txt;
IBOutlet id o_audio_effects_box;
IBOutlet id o_audio_enable_ckb;
IBOutlet id o_audio_general_box;
IBOutlet id o_audio_headphone_ckb;
IBOutlet id o_audio_lang_fld;
IBOutlet id o_audio_lang_txt;
IBOutlet id o_audio_last_box;
IBOutlet id o_audio_last_ckb;
IBOutlet id o_audio_lastpwd_fld;
IBOutlet id o_audio_lastpwd_txt;
IBOutlet id o_audio_lastuser_fld;
IBOutlet id o_audio_lastuser_txt;
IBOutlet id o_audio_norm_ckb;
IBOutlet id o_audio_norm_fld;
IBOutlet id o_audio_spdif_ckb;
IBOutlet id o_audio_view;
IBOutlet id o_audio_visual_pop;
IBOutlet id o_audio_visual_txt;
IBOutlet id o_audio_vol_fld;
IBOutlet id o_audio_vol_sld;
IBOutlet id o_audio_vol_txt;
IBOutlet id o_intf_art_pop;
IBOutlet id o_intf_art_txt;
IBOutlet id o_intf_black_ckb;
IBOutlet id o_intf_embvout_ckb;
IBOutlet id o_intf_fspanel_ckb;
IBOutlet id o_intf_lang_pop;
IBOutlet id o_intf_lang_txt;
IBOutlet id o_intf_meta_ckb;
IBOutlet id o_intf_network_box;
IBOutlet id o_intf_view;
IBOutlet id o_sprefs_basic_box;
IBOutlet id o_sprefs_basicFull_matrix;
IBOutlet id o_sprefs_cancel_btn;
IBOutlet id o_sprefs_controls_box;
IBOutlet id o_sprefs_reset_btn;
IBOutlet id o_sprefs_save_btn;
IBOutlet id o_sprefs_win;
BOOL b_audioSettingChanged;
BOOL b_intfSettingChanged;
id o_currentlyShownCategoryView;
NSToolbar *o_sprefs_toolbar;
intf_thread_t *p_intf;
}
+ (VLCSimplePrefs *)sharedInstance;
- (NSToolbarItem *) toolbar: (NSToolbar *)o_toolbar
itemForItemIdentifier: (NSString *)o_itemIdent
willBeInsertedIntoToolbar: (BOOL)b_willBeInserted;
- (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar;
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar;
- (void)initStrings;
- (void)showSimplePrefs;
- (IBAction)buttonAction:(id)sender;
- (void)sheetDidEnd:(NSWindow *)o_sheet
returnCode:(int)i_return
contextInfo:(void *)o_context;
/* interface */
- (IBAction)interfaceSettingChanged:(id)sender;
- (void)showInterfaceSettings;
/* audio */
- (IBAction)audioSettingChanged:(id)sender;
- (void)showAudioSettings;
/* video */
/* subtitles */
/* input & codecs */
/* hotkeys */
@end
/*****************************************************************************
* simple_prefs.m: Simple Preferences for Mac OS X
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id:$
*
* Authors: 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 "intf.h"
#import <vlc/vlc.h>
#import "simple_prefs.h"
#import "prefs.h"
static NSString* VLCSPrefsToolbarIdentifier = @"Our Simple Preferences Toolbar Identifier";
static NSString* VLCIntfSettingToolbarIdentifier = @"Intf Settings Item Identifier";
static NSString* VLCAudioSettingToolbarIdentifier = @"Audio Settings Item Identifier";
@implementation VLCSimplePrefs
static VLCSimplePrefs *_o_sharedInstance = nil;
+ (VLCSimplePrefs *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
- (id)init
{
if (_o_sharedInstance) {
[self dealloc];
} else {
p_intf = VLCIntf;
_o_sharedInstance = [super init];
}
return _o_sharedInstance;
}
- (void)dealloc
{
[o_currentlyShownCategoryView release];
[o_sprefs_toolbar release];
[super dealloc];
}
- (void)awakeFromNib
{
[self initStrings];
o_sprefs_toolbar = [[[NSToolbar alloc] initWithIdentifier: VLCSPrefsToolbarIdentifier] autorelease];
[o_sprefs_toolbar setAllowsUserCustomization: NO];
[o_sprefs_toolbar setAutosavesConfiguration: NO];
[o_sprefs_toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
[o_sprefs_toolbar setSizeMode: NSToolbarSizeModeRegular];
[o_sprefs_toolbar setDelegate: self];
[o_sprefs_win setToolbar: o_sprefs_toolbar];
}
- (NSToolbarItem *) toolbar: (NSToolbar *)o_sprefs_toolbar
itemForItemIdentifier: (NSString *)o_itemIdent
willBeInsertedIntoToolbar: (BOOL)b_willBeInserted
{
NSToolbarItem *o_toolbarItem = nil;
if( [o_itemIdent isEqual: VLCIntfSettingToolbarIdentifier] )
{
o_toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: o_itemIdent] autorelease];
[o_toolbarItem setLabel: _NS("Interface")];
[o_toolbarItem setPaletteLabel: _NS("Interface settings")];
[o_toolbarItem setToolTip: _NS("Interface settings")];
[o_toolbarItem setImage: [NSImage imageNamed: @"spref_cone_Interface_64"]];
[o_toolbarItem setTarget: self];
[o_toolbarItem setAction: @selector(showInterfaceSettings)];
[o_toolbarItem setEnabled: YES];
[o_toolbarItem setAutovalidates: YES];
}
else if( [o_itemIdent isEqual: VLCAudioSettingToolbarIdentifier] )
{
o_toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: o_itemIdent] autorelease];
[o_toolbarItem setLabel: _NS("Audio")];
[o_toolbarItem setPaletteLabel: _NS("General Audio settings")];
[o_toolbarItem setToolTip: _NS("General Audio settings")];
[o_toolbarItem setImage: [NSImage imageNamed: @"spref_cone_Audio_64"]];
[o_toolbarItem setTarget: self];
[o_toolbarItem setAction: @selector(showAudioSettings)];
[o_toolbarItem setEnabled: YES];
[o_toolbarItem setAutovalidates: YES];
}
return o_toolbarItem;
}
- (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
{
return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
}
- (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
{
return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
}
- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
}
- (void)initStrings
{
[o_sprefs_reset_btn setEnabled: NO];
msg_Warn( p_intf, "localisation of the simple preferences not implemented!" );
}
- (void)showSimplePrefs
{
/* we want to show the interface settings, if no category was chosen */
if( [o_sprefs_toolbar selectedItemIdentifier] == nil )
{
[o_sprefs_toolbar setSelectedItemIdentifier: VLCIntfSettingToolbarIdentifier];
[self showInterfaceSettings];
}
[o_sprefs_win makeKeyAndOrderFront: self];
}
- (IBAction)buttonAction:(id)sender
{
if( sender == o_sprefs_cancel_btn )
[o_sprefs_win orderOut: sender];
else if( sender == o_sprefs_save_btn )
{
msg_Warn( p_intf, "sprefs saving not implemented, your changes have no effect!" );
[o_sprefs_win orderOut: sender];
}
else if( sender == o_sprefs_reset_btn )
NSBeginInformationalAlertSheet( _NS("Reset Preferences"), _NS("Cancel"),
_NS("Continue"), nil, o_sprefs_win, self,
@selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
_NS("Beware this will reset the VLC media player preferences.\n"
"Are you sure you want to continue?") );
else if( sender == o_sprefs_basicFull_matrix )
{
[o_sprefs_win orderOut: self];
[[[VLCMain sharedInstance] getPreferences] showPrefs];
/* TODO: reset our selector controls here */
}
else
msg_Err( p_intf, "unknown buttonAction sender" );
}
- (void)sheetDidEnd:(NSWindow *)o_sheet
returnCode:(int)i_return
contextInfo:(void *)o_context
{
if( i_return == NSAlertAlternateReturn )
{
config_ResetAll( p_intf );
/* TODO: we need to reset our views here */
}
}
- (void)showSettingsForCategory: (id)o_new_category_view
{
msg_Dbg( p_intf, "switching to another category" );
NSRect o_win_rect, o_view_rect, o_old_view_rect;
o_win_rect = [o_sprefs_win frame];
o_view_rect = [o_new_category_view frame];
if( o_currentlyShownCategoryView != nil )
{
/* restore our window's height, if we've shown another category previously */
o_old_view_rect = [o_currentlyShownCategoryView frame];
o_win_rect.size.height = o_win_rect.size.height - o_old_view_rect.size.height;
/* remove our previous category view */
[o_currentlyShownCategoryView removeFromSuperviewWithoutNeedingDisplay];
}
o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
[o_sprefs_win displayIfNeeded];
[o_sprefs_win setFrame: o_win_rect display:YES animate: YES];
[o_new_category_view setFrame: NSMakeRect( 0,
[o_sprefs_controls_box frame].size.height,
o_view_rect.size.width,
o_view_rect.size.height )];
[o_new_category_view setNeedsDisplay: YES];
[o_new_category_view setAutoresizesSubviews: YES];
[[o_sprefs_win contentView] addSubview: o_new_category_view];
/* keep our current category for further reference */
[o_currentlyShownCategoryView release];
o_currentlyShownCategoryView = o_new_category_view;
[o_currentlyShownCategoryView retain];
}
- (IBAction)interfaceSettingChanged:(id)sender
{
}
- (void)showInterfaceSettings
{
msg_Dbg( p_intf, "showing interface settings" );
[self showSettingsForCategory: o_intf_view];
}
- (IBAction)audioSettingChanged:(id)sender
{
}
- (void)showAudioSettings
{
msg_Dbg( p_intf, "showing audio settings" );
[self showSettingsForCategory: o_audio_view];
}
@end
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