adium 3446:1818acad1728: Lazily building the menu won't work for...
commits at adium.im
commits at adium.im
Sat Oct 30 08:56:44 UTC 2010
details: http://hg.adium.im/adium/rev/1818acad1728
revision: 3446:1818acad1728
author: Evan Schoenberg
date: Sat Oct 30 03:53:55 2010 -0500
Lazily building the menu won't work for NSPopUpControls. Make it optional
(transplanted from bb3a063ecb3790d1f4f2cdf6a743e5e32a762d44)
diffs (91 lines):
diff -r 5fe839a881dd -r 1818acad1728 Frameworks/Adium Framework/Source/AIContactMenu.h
--- a/Frameworks/Adium Framework/Source/AIContactMenu.h Sat Oct 30 03:18:31 2010 -0500
+++ b/Frameworks/Adium Framework/Source/AIContactMenu.h Sat Oct 30 03:53:55 2010 -0500
@@ -25,6 +25,7 @@
BOOL shouldUseUserIcon;
BOOL shouldSetTooltip;
BOOL shouldIncludeContactListMenuItem;
+ BOOL populateMenuLazily;
}
+ (id)contactMenuWithDelegate:(id<AIContactMenuDelegate>)inDelegate forContactsInObject:(AIListObject *)inContainingObject;
@@ -43,6 +44,7 @@
- (BOOL)contactMenuShouldUseUserIcon:(AIContactMenu *)inContactMenu;
- (BOOL)contactMenuShouldSetTooltip:(AIContactMenu *)inContactMenu;
- (BOOL)contactMenuShouldIncludeContactListMenuItem:(AIContactMenu *)inContactMenu;
+- (BOOL)contactMenuShouldPopulateMenuLazily:(AIContactMenu *)inContactMenu;
// Called on each rebuild:
- (BOOL)contactMenuShouldDisplayGroupHeaders:(AIContactMenu *)inContactMenu; //only applies to contained groups
diff -r 5fe839a881dd -r 1818acad1728 Frameworks/Adium Framework/Source/AIContactMenu.m
--- a/Frameworks/Adium Framework/Source/AIContactMenu.m Sat Oct 30 03:18:31 2010 -0500
+++ b/Frameworks/Adium Framework/Source/AIContactMenu.m Sat Oct 30 03:53:55 2010 -0500
@@ -135,6 +135,8 @@
shouldIncludeContactListMenuItem = ([delegate respondsToSelector:@selector(contactMenuShouldIncludeContactListMenuItem:)] &&
[delegate contactMenuShouldIncludeContactListMenuItem:self]);
+ populateMenuLazily = ([delegate respondsToSelector:@selector(contactMenuShouldPopulateMenuLazily:)] &&
+ [delegate contactMenuShouldPopulateMenuLazily:self]);
}
- (id<AIContactMenuDelegate> )delegate
@@ -272,14 +274,19 @@
// The group isn't clickable.
[menuItem setEnabled:NO];
+ if (populateMenuLazily) {
+ /* Note that we'll call _updateMenuItem before the item is actually displayed, to set
+ * the title, image, etc. */
+ } else {
+ [self _updateMenuItem:menuItem];
+ }
+
// Add the group and contained objects to the array.
[menuItemArray addObject:menuItem];
[menuItemArray addObjectsFromArray:[self contactMenusForListObjects:containedListObjects]];
-
+
[menuItem release];
-
- /* Note that we'll call _updateMenuItem before the item is actually displayed, to set
- * the title, image, etc. */
+
}
} else {
// Just add the menu item.
@@ -291,8 +298,12 @@
[menuItemArray addObject:menuItem];
[menuItem release];
- /* Note that we'll call _updateMenuItem before the item is actually displayed, to set
- * the title, image, etc. */
+ if (populateMenuLazily) {
+ /* Note that we'll call _updateMenuItem before the item is actually displayed, to set
+ * the title, image, etc. */
+ } else {
+ [self _updateMenuItem:menuItem];
+ }
}
}
@@ -385,6 +396,20 @@
} else {
[self rebuildMenu];
}
+ } else {
+ if (populateMenuLazily) {
+ /* Note that we'll call _updateMenuItem before the item is actually displayed, to set
+ * the title, image, etc. */
+ } else {
+ [self _updateMenuItem:menuItem];
+ }
+ }
+ } else {
+ if (populateMenuLazily) {
+ /* Note that we'll call _updateMenuItem before the item is actually displayed, to set
+ * the title, image, etc. */
+ } else {
+ [self _updateMenuItem:menuItem];
}
}
}
More information about the commits
mailing list