Source/AIChatCyclingPlugin.m
author Evan Schoenberg
Wed, 05 Sep 2012 23:36:01 -0500
changeset 5031 1a2cd53342c5
parent 4084 295cfdd71c39
child 5709 7c547c4f63b0
permissions -rw-r--r--
Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     1
/* 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     2
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     3
 * with this source distribution.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     4
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     6
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     7
 * or (at your option) any later version.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     8
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    11
 * Public License for more details.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    12
 * 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    13
 * You should have received a copy of the GNU General Public License along with this program; if not,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    14
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    15
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    16
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    17
#import "AIChatCyclingPlugin.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    18
#import <Adium/AIInterfaceControllerProtocol.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    19
#import <Adium/AIMenuControllerProtocol.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    20
#import "ESGeneralPreferencesPlugin.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    21
#import <AIUtilities/AIMenuAdditions.h>
5031
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    22
#import <AIUtilities/AIDictionaryAdditions.h>
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    23
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    24
#define PREVIOUS_MESSAGE_MENU_TITLE		AILocalizedString(@"Previous Chat",nil)
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    25
#define NEXT_MESSAGE_MENU_TITLE			AILocalizedString(@"Next Chat",nil)
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    26
5031
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    27
#define DEFAULT_CHAT_CYCLING_PREFS		@"ChatCyclingDefaults"
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    28
#define OLD_DEFAULT_CHAT_CYCLING_PREFS	@"ChatCyclingDefaults-Old"
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    29
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    30
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    31
 * @class AIChatCyclingPlugin
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    32
 * @brief Component to manage the chat cycling menu items
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    33
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    34
 * Adium supports several different key combinations for switching tabs, configuring via the General Preferences.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    35
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    36
@implementation AIChatCyclingPlugin
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    37
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    38
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    39
 * @brief Install
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    40
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    41
- (void)installPlugin
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    42
{
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    43
	id<AIMenuController> menuController = adium.menuController;
4082
1d46ca9df856 Backout of 4063:b2f504303835 ("Added Cmd-Shift-Arrows and Cmd-Shift-Brackets to cycle tabs."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4063
diff changeset
    44
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    45
	//Cycling menu items
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    46
	previousChatMenuItem = [[NSMenuItem alloc] initWithTitle:PREVIOUS_MESSAGE_MENU_TITLE
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    47
													  target:self 
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    48
													  action:@selector(previousChat:)
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    49
											   keyEquivalent:@""];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    50
	[menuController addMenuItem:previousChatMenuItem toLocation:LOC_Window_Commands];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    51
4057
546c8a28502f Selecting next(previous) chat now corresponds to Safaris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 2914
diff changeset
    52
	nextChatMenuItem = [[NSMenuItem alloc] initWithTitle:NEXT_MESSAGE_MENU_TITLE 
546c8a28502f Selecting next(previous) chat now corresponds to Safaris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 2914
diff changeset
    53
												  target:self
546c8a28502f Selecting next(previous) chat now corresponds to Safaris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 2914
diff changeset
    54
												  action:@selector(nextChat:)
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    55
										   keyEquivalent:@""];
4057
546c8a28502f Selecting next(previous) chat now corresponds to Safaris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 2914
diff changeset
    56
	[menuController addMenuItem:nextChatMenuItem toLocation:LOC_Window_Commands];
5031
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    57
		
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    58
	/* Adium 1.5.4+ use the new defaults for chat switching, ctrl+tab, to match Safari's default user-visible behavior */
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    59
	NSDictionary *defaults = [NSDictionary dictionaryNamed:(([adium compareVersion:adium.earliestLaunchedAdiumVersion
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    60
																		 toVersion:@"1.5.4"] == NSOrderedAscending) ?
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    61
															OLD_DEFAULT_CHAT_CYCLING_PREFS :
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    62
															DEFAULT_CHAT_CYCLING_PREFS)
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    63
												  forClass:[self class]];
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    64
	[adium.preferenceController registerDefaults:defaults
1a2cd53342c5 Tab switching now defaults to ctrl+tab, matching Safari's user visible default, as per discussion on IRC today. This only applies to new users as of Adium 1.5.4 and later; anyone who has run a previous version will inherit the keep the old default of command+arrows (unless they've changed it previously, of course). Fixes #16102.
Evan Schoenberg
parents: 4084
diff changeset
    65
											forGroup:PREF_GROUP_CHAT_CYCLING];
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    66
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    67
	//Prefs
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    68
	[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_CHAT_CYCLING];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    69
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    70
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    71
- (void)uninstallPlugin
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    72
{
95
47acbc0cc17a Propertyize AIListObject and convert some more controller accesses to dot syntax
David Smith
parents: 84
diff changeset
    73
	[adium.preferenceController unregisterPreferenceObserver:self];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    74
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    75
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    76
/*!
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    77
 * @brief Preferences changed
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    78
 *
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    79
 * Update the key equivalents for our previous and next chat menu items
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    80
 */
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    81
- (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    82
							object:(AIListObject *)object preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    83
{	
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    84
	//Configure our tab switching hotkeys
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    85
	unichar 		left = NSLeftArrowFunctionKey;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    86
	unichar 		right = NSRightArrowFunctionKey;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    87
	NSString		*leftKey, *rightKey;
4084
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
    88
	NSUInteger		leftKeyMask = NSCommandKeyMask, rightKeyMask = NSCommandKeyMask;
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    89
	
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    90
	switch ([[prefDict objectForKey:KEY_TAB_SWITCH_KEYS] integerValue]) {
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    91
		case AISwitchArrows:
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    92
		default:
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    93
			leftKey = [NSString stringWithCharacters:&left length:1];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    94
			rightKey = [NSString stringWithCharacters:&right length:1];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    95
			break;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    96
		case AISwitchShiftArrows:
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    97
			leftKey = [NSString stringWithCharacters:&left length:1];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
    98
			rightKey = [NSString stringWithCharacters:&right length:1];
4084
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
    99
			leftKeyMask = rightKeyMask = (NSCommandKeyMask | NSShiftKeyMask);
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   100
			break;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   101
		case AIBrackets:
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   102
			leftKey = @"[";
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   103
			rightKey = @"]";
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   104
			break;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   105
		case AIBraces:
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   106
			leftKey = @"{";
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   107
			rightKey = @"}";
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   108
			break;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   109
		case AIOptArrows:
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   110
			leftKey = [NSString stringWithCharacters:&left length:1];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   111
			rightKey = [NSString stringWithCharacters:&right length:1];
4084
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   112
			leftKeyMask = rightKeyMask = (NSCommandKeyMask | NSAlternateKeyMask);
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   113
			break;
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   114
		case AICtrlTab:
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   115
			leftKey = rightKey = @"\t";
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   116
			leftKeyMask = (NSControlKeyMask | NSShiftKeyMask);
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   117
			rightKeyMask = NSControlKeyMask;
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   118
			break;
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   119
	}
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   120
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   121
	//Previous and nextMessage menuItems are in the same menu, so the setMenuChangedMessagesEnabled applies to both.
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   122
	[[previousChatMenuItem menu] setMenuChangedMessagesEnabled:NO];		
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   123
	[previousChatMenuItem setKeyEquivalent:@""];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   124
	[previousChatMenuItem setKeyEquivalent:leftKey];
4084
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   125
	[previousChatMenuItem setKeyEquivalentModifierMask:leftKeyMask];
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   126
	[nextChatMenuItem setKeyEquivalent:@""];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   127
	[nextChatMenuItem setKeyEquivalent:rightKey];
4084
295cfdd71c39 Added the Ctrl(+Shift)+Tab shortcut for Next(Previous) Chat. Fixes #15221.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4083
diff changeset
   128
	[nextChatMenuItem setKeyEquivalentModifierMask:rightKeyMask];
4083
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   129
	[[previousChatMenuItem menu] setMenuChangedMessagesEnabled:YES];
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   130
}
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   131
97b1da37d5c7 Backout of 4057:546c8a28502f ("Selecting next(previous) chat now corresponds to Safris keybinding Ctrl(+Shift)+Tab. The preference regarding this shortcut has been removed."). Refs #15221, refs #15344.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 4082
diff changeset
   132
/*!
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   133
 * @brief Menu item validation
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   134
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   135
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   136
{
2914
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 1946
diff changeset
   137
	if (!adium.interfaceController.activeChat) return NO;
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 1946
diff changeset
   138
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 1946
diff changeset
   139
	NSString *containerID = [adium.interfaceController containerIDForChat:adium.interfaceController.activeChat];
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 1946
diff changeset
   140
	
def06ccb99eb When cycling chats (using "Next Chat" and "Previous Chat") stay in the current window. Do nothing if outside of a chat window.
Zachary West <zacw@adium.im>
parents: 1946
diff changeset
   141
	return ([adium.interfaceController openChatsInContainerWithID:containerID].count > 0);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   142
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   143
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   144
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   145
 * @brief Select the next chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   146
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   147
- (IBAction)nextChat:(id)sender
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   148
{
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   149
	[adium.interfaceController nextChat:nil];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   150
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   151
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   152
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   153
 * @brief Select the previous chat
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   154
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   155
- (IBAction)previousChat:(id)sender
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   156
{
100
68210ab2807a sed is evil. All [adium *Controller]s are now adium.*Controller.
David Smith
parents: 95
diff changeset
   157
	[adium.interfaceController previousChat:nil];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   158
}	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   159
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   160
@end