Hello, I’m working on the IP menulet thats been floating around. I have it displaying the IP address instead of an Icon. What I would like to do is, on initialize, check the info.plist and see what the bool is telling it to display. Either IP Address, or Icon. I have added a submenu to the menulet called “Display”, the sub menu choices are “IP Address”, and “IP Icon”. I would like to toggle the bit in the info.plist with the sub menu items to control what is being displayed. Would I use an “if” statement?, and are submenu’s indexed a b c. Thanks
//-Here is the IP Address display
@implementation IPMenulet
NSString * externalIP;
-(void)dealloc
{
[statusItem release];
[super dealloc];
}
-
(void)awakeFromNib
{
statusItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength]
retain];
[statusItem setHighlightMode:YES];[statusItem setEnabled:YES];
[statusItem setToolTip:@“IP Notifier”];[statusItem setMenu:theMenu];
[self getExtenalIP];
ipMenuItem = [[NSMenuItem alloc] initWithTitle:externalIP
action:@selector(updateIPAddress:) keyEquivalent:@“”];[ipMenuItem setTarget:self];
[theMenu insertItem:ipMenuItem atIndex:1];[statusItem setTitle:[NSString stringWithString:externalIP]];
[NSTimer scheduledTimerWithTimeInterval:3600 target:self selector:@selector(updateIPAddress:) userInfo:nil repeats:YES];
}
-(IBAction)updateIPAddress:(id)sender
{
[ipMenuItem setTitle:@“Updating…”];
[statusItem setTitle:@“Updating…”];
[self getExtenalIP];
[ipMenuItem setTitle:[NSString stringWithString:externalIP]];
[statusItem setTitle:externalIP];
}
-
(void)getExtenalIP
{externalIP=@“”;
NSUInteger an_Integer;
NSArray * ipItemsArray;
######################################################################################
//-Here is the Icon Display
[ipMenuItem setTarget:self];
[theMenu insertItem:ipMenuItem atIndex:1];
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@“ip” ofType:@“png”];
menuIcon= [[NSImage alloc] initWithContentsOfFile:path];
[statusItem setTitle:[NSString stringWithString:@“”]];
[statusItem setImage];
[menuIcon release];