mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:40:48 +00:00
* Source/GSToolbarView.m: Added code to save the configuration when
deleting an item as well as saving an item. * Source/NSToolbarFrameworkPrivate.h: removed old _loadConfig method added new methods to track changes to toolbars. * Source/NSToolbar.m: Added check for items already in the toolbar, removed calls to _loadConfig which were commented out, implemented setConfigurationFromDictionary: as described in the documentation, changed _build to get dictionary from defaults if it's there. Implemented new method _containsItemWithIdentifier: and _itemsFromConfig. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28084 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e1b4fe3b38
commit
31e0c9633c
4 changed files with 126 additions and 21 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2009-03-16 03:29-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/GSToolbarView.m: Added code to save the configuration when
|
||||||
|
deleting an item as well as saving an item.
|
||||||
|
* Source/NSToolbarFrameworkPrivate.h: removed old _loadConfig method
|
||||||
|
added new methods to track changes to toolbars.
|
||||||
|
* Source/NSToolbar.m: Added check for items already in the toolbar,
|
||||||
|
removed calls to _loadConfig which were commented out, implemented
|
||||||
|
setConfigurationFromDictionary: as described in the documentation,
|
||||||
|
changed _build to get dictionary from defaults if it's there.
|
||||||
|
Implemented new method _containsItemWithIdentifier: and
|
||||||
|
_itemsFromConfig.
|
||||||
|
|
||||||
2009-03-16 01:22-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
2009-03-16 01:22-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/GSToolbarView.m: Call the _insertItemWithItemIdentifier:..
|
* Source/GSToolbarView.m: Call the _insertItemWithItemIdentifier:..
|
||||||
|
|
|
@ -397,13 +397,16 @@ static void initSystemExtensionsColors(void)
|
||||||
NSToolbar *toolbar = [self toolbar];
|
NSToolbar *toolbar = [self toolbar];
|
||||||
NSToolbarItem *item = [[info draggingSource] toolbarItem];
|
NSToolbarItem *item = [[info draggingSource] toolbarItem];
|
||||||
int newIndex = [self _insertionIndexAtPoint: [info draggingLocation]];
|
int newIndex = [self _insertionIndexAtPoint: [info draggingLocation]];
|
||||||
// Calculate the index
|
|
||||||
|
|
||||||
if(index == -1)
|
if(index == -1)
|
||||||
{
|
{
|
||||||
[toolbar _insertItemWithItemIdentifier: [item itemIdentifier]
|
NSString *identifier = [item itemIdentifier];
|
||||||
atIndex: newIndex
|
if([_toolbar _containsItemWithIdentifier: identifier] == NO)
|
||||||
broadcast: YES];
|
{
|
||||||
|
[toolbar _insertItemWithItemIdentifier: identifier
|
||||||
|
atIndex: newIndex
|
||||||
|
broadcast: YES];
|
||||||
|
}
|
||||||
RELEASE(item);
|
RELEASE(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -412,6 +415,9 @@ static void initSystemExtensionsColors(void)
|
||||||
RELEASE(item);
|
RELEASE(item);
|
||||||
[toolbar _moveItemFromIndex: index toIndex: newIndex broadcast: YES];
|
[toolbar _moveItemFromIndex: index toIndex: newIndex broadcast: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save the configuration...
|
||||||
|
[toolbar _saveConfig];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSTimer.h>
|
#include <Foundation/NSTimer.h>
|
||||||
#include <Foundation/NSUserDefaults.h>
|
#include <Foundation/NSUserDefaults.h>
|
||||||
|
#include <Foundation/NSDecimalNumber.h>
|
||||||
#include "AppKit/NSApplication.h"
|
#include "AppKit/NSApplication.h"
|
||||||
#include "AppKit/NSEvent.h"
|
#include "AppKit/NSEvent.h"
|
||||||
#include "AppKit/NSMenu.h"
|
#include "AppKit/NSMenu.h"
|
||||||
|
@ -520,8 +521,6 @@ static GSValidationCenter *vc = nil;
|
||||||
_displayMode = [toolbarModel displayMode];
|
_displayMode = [toolbarModel displayMode];
|
||||||
_sizeMode = [toolbarModel sizeMode];
|
_sizeMode = [toolbarModel sizeMode];
|
||||||
_visible = [toolbarModel isVisible];
|
_visible = [toolbarModel isVisible];
|
||||||
|
|
||||||
// [self _loadConfig];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -532,8 +531,6 @@ static GSValidationCenter *vc = nil;
|
||||||
_displayMode = NSToolbarDisplayModeIconAndLabel;
|
_displayMode = NSToolbarDisplayModeIconAndLabel;
|
||||||
_sizeMode = NSToolbarSizeModeRegular;
|
_sizeMode = NSToolbarSizeModeRegular;
|
||||||
_visible = YES;
|
_visible = YES;
|
||||||
|
|
||||||
// [self _loadConfig];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_delegate = nil;
|
_delegate = nil;
|
||||||
|
@ -707,7 +704,33 @@ static GSValidationCenter *vc = nil;
|
||||||
|
|
||||||
- (void) setConfigurationFromDictionary: (NSDictionary *)configDict
|
- (void) setConfigurationFromDictionary: (NSDictionary *)configDict
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
|
id item = nil;
|
||||||
|
NSArray *items = nil;
|
||||||
|
NSEnumerator *en = nil;
|
||||||
|
|
||||||
ASSIGN(_configurationDictionary, configDict);
|
ASSIGN(_configurationDictionary, configDict);
|
||||||
|
|
||||||
|
// set
|
||||||
|
_visible = [[_configurationDictionary objectForKey: @"isVisible"] boolValue];
|
||||||
|
_displayMode = [[_configurationDictionary objectForKey: @"displayMode"] intValue];
|
||||||
|
|
||||||
|
// remove all items...
|
||||||
|
for(i = 0; i < [_items count]; i++)
|
||||||
|
{
|
||||||
|
[self _removeItemAtIndex: 0 broadcast: YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
// add all of the items...
|
||||||
|
i = 0;
|
||||||
|
items = [_configurationDictionary objectForKey: @"items"];
|
||||||
|
en = [items objectEnumerator];
|
||||||
|
while((item = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
[self _insertItemWithItemIdentifier: item
|
||||||
|
atIndex: i++
|
||||||
|
broadcast: YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -885,15 +908,19 @@ static GSValidationCenter *vc = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarModel = [self _toolbarModel];
|
toolbarModel = [self _toolbarModel];
|
||||||
|
|
||||||
if (toolbarModel != nil)
|
wantedItemIdentifiers = [self _itemsFromConfig];
|
||||||
|
if(wantedItemIdentifiers == nil)
|
||||||
{
|
{
|
||||||
wantedItemIdentifiers =
|
if (toolbarModel != nil)
|
||||||
[[toolbarModel items] valueForKey: @"_itemIdentifier"];
|
{
|
||||||
}
|
wantedItemIdentifiers =
|
||||||
else
|
[[toolbarModel items] valueForKey: @"_itemIdentifier"];
|
||||||
{
|
}
|
||||||
wantedItemIdentifiers = [_delegate toolbarDefaultItemIdentifiers:self];
|
else
|
||||||
|
{
|
||||||
|
wantedItemIdentifiers = [_delegate toolbarDefaultItemIdentifiers:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e = [wantedItemIdentifiers objectEnumerator];
|
e = [wantedItemIdentifiers objectEnumerator];
|
||||||
|
@ -947,8 +974,64 @@ static GSValidationCenter *vc = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _loadConfig
|
- (void) _saveConfig
|
||||||
{
|
{
|
||||||
|
if (_identifier != nil)
|
||||||
|
{
|
||||||
|
NSUserDefaults *defaults;
|
||||||
|
NSString *tableKey;
|
||||||
|
id config;
|
||||||
|
NSMutableArray *items = [NSMutableArray array];
|
||||||
|
id item;
|
||||||
|
NSEnumerator *en = [_items objectEnumerator];
|
||||||
|
|
||||||
|
defaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
tableKey =
|
||||||
|
[NSString stringWithFormat: @"NSToolbar Config %@",_identifier];
|
||||||
|
|
||||||
|
config = [defaults objectForKey: tableKey];
|
||||||
|
|
||||||
|
if (config == nil)
|
||||||
|
{
|
||||||
|
config = [NSMutableDictionary dictionary];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config = [config mutableCopy];
|
||||||
|
}
|
||||||
|
|
||||||
|
[config setObject: [NSNumber numberWithBool: _visible] forKey: @"isVisible"];
|
||||||
|
[config setObject: [NSNumber numberWithInt: _displayMode] forKey: @"displayMode"];
|
||||||
|
while((item = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
[items addObject: [item itemIdentifier]];
|
||||||
|
}
|
||||||
|
[config setObject: items forKey: @"items"];
|
||||||
|
|
||||||
|
// write to defaults
|
||||||
|
[defaults setObject: config forKey: tableKey];
|
||||||
|
ASSIGN(_configurationDictionary, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) _containsItemWithIdentifier: (NSString *)identifier
|
||||||
|
{
|
||||||
|
NSEnumerator *en = [_items objectEnumerator];
|
||||||
|
id item = nil;
|
||||||
|
|
||||||
|
while((item = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if([identifier isEqual: [item itemIdentifier]])
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) _itemsFromConfig
|
||||||
|
{
|
||||||
|
NSArray *items = nil;
|
||||||
if (_identifier != nil)
|
if (_identifier != nil)
|
||||||
{
|
{
|
||||||
NSUserDefaults *defaults;
|
NSUserDefaults *defaults;
|
||||||
|
@ -958,14 +1041,15 @@ static GSValidationCenter *vc = nil;
|
||||||
defaults = [NSUserDefaults standardUserDefaults];
|
defaults = [NSUserDefaults standardUserDefaults];
|
||||||
tableKey =
|
tableKey =
|
||||||
[NSString stringWithFormat: @"NSToolbar Config %@",_identifier];
|
[NSString stringWithFormat: @"NSToolbar Config %@",_identifier];
|
||||||
|
|
||||||
config = [defaults objectForKey: tableKey];
|
config = [defaults objectForKey: tableKey];
|
||||||
|
|
||||||
if (config != nil)
|
if (config != nil)
|
||||||
{
|
{
|
||||||
[self setConfigurationFromDictionary: config];
|
items = [config objectForKey: @"items"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSToolbar *) _toolbarModel
|
- (NSToolbar *) _toolbarModel
|
||||||
|
@ -1098,6 +1182,7 @@ static GSValidationCenter *vc = nil;
|
||||||
{
|
{
|
||||||
[_items removeObject: item];
|
[_items removeObject: item];
|
||||||
[_toolbarView _reload];
|
[_toolbarView _reload];
|
||||||
|
[self _saveConfig];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _concludeRemoveItem: (NSToolbarItem *)item atIndex: (int)index broadcast: (BOOL)broadcast
|
- (void) _concludeRemoveItem: (NSToolbarItem *)item atIndex: (int)index broadcast: (BOOL)broadcast
|
||||||
|
|
|
@ -86,7 +86,6 @@
|
||||||
|
|
||||||
// Few other private methods
|
// Few other private methods
|
||||||
- (void) _build;
|
- (void) _build;
|
||||||
|
|
||||||
- (int) _indexOfItem: (NSToolbarItem *)item;
|
- (int) _indexOfItem: (NSToolbarItem *)item;
|
||||||
- (void) _concludeRemoveItem: (NSToolbarItem *)item
|
- (void) _concludeRemoveItem: (NSToolbarItem *)item
|
||||||
atIndex: (int)index
|
atIndex: (int)index
|
||||||
|
@ -96,11 +95,13 @@
|
||||||
toIndex: (int)newIndex
|
toIndex: (int)newIndex
|
||||||
broadcast: (BOOL)broacast;
|
broadcast: (BOOL)broacast;
|
||||||
- (void) _performRemoveItem: (NSToolbarItem *)item; // Used by drag setup
|
- (void) _performRemoveItem: (NSToolbarItem *)item; // Used by drag setup
|
||||||
- (void) _loadConfig;
|
|
||||||
- (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent;
|
- (NSToolbarItem *) _toolbarItemForIdentifier: (NSString *)itemIdent;
|
||||||
- (NSToolbar *) _toolbarModel;
|
- (NSToolbar *) _toolbarModel;
|
||||||
- (void) _validate: (NSWindow *)observedWindow;
|
- (void) _validate: (NSWindow *)observedWindow;
|
||||||
- (void) _toolbarViewWillMoveToSuperview: (NSView *)newSuperview;
|
- (void) _toolbarViewWillMoveToSuperview: (NSView *)newSuperview;
|
||||||
|
- (void) _saveConfig;
|
||||||
|
- (NSArray *) _itemsFromConfig;
|
||||||
|
- (BOOL) _containsItemWithIdentifier: (NSString *) identifier;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
- (void) _setCustomizationPaletteIsRunning: (BOOL)isRunning;
|
- (void) _setCustomizationPaletteIsRunning: (BOOL)isRunning;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue