[gtk+/gtk-3-8] Bug 691921 - GTK+ built on Leopard references [NSMenu removellItems]
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-8] Bug 691921 - GTK+ built on Leopard references [NSMenu removellItems]
- Date: Mon, 20 May 2013 22:20:43 +0000 (UTC)
commit 5753f69b68f504ca163034faaf1142c2e787c2ba
Author: John Ralls <jralls ceridwen us>
Date: Mon May 20 15:15:11 2013 -0700
Bug 691921 - GTK+ built on Leopard references [NSMenu removellItems]
Test it with respondsToSelector, and if it isn't available delete the
items one at a time.
gtk/gtkmodelmenu-quartz.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkmodelmenu-quartz.c b/gtk/gtkmodelmenu-quartz.c
index 2f05eac..dae2376 100644
--- a/gtk/gtkmodelmenu-quartz.c
+++ b/gtk/gtkmodelmenu-quartz.c
@@ -313,7 +313,19 @@ gtk_quartz_clear_main_menu (void)
- (void)populate
{
- [self removeAllItems];
+ /* removeAllItems is available only in 10.6 and later, but it's more
+ efficient than iterating over the array of
+ NSMenuItems. performSelector: suppresses a compiler warning when
+ building on earlier OSX versions. */
+ if ([self respondsToSelector: @selector (removeAllItems)])
+ [self performSelector: @selector (removeAllItems)];
+ else
+ {
+ /* Iterate from the bottom up to save reindexing the NSArray. */
+ int i;
+ for (i = [self numberOfItems]; i > 0; i--)
+ [self removeItemAtIndex: i];
+ }
[self appendFromModel:model withSeparators:with_separators];
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]