diff options
author | Sven Weidauer <sven@5sw.de> | 2017-06-05 10:47:34 +0200 |
---|---|---|
committer | Sven Weidauer <sven@5sw.de> | 2017-06-05 10:51:19 +0200 |
commit | 3ee40a10b123c36be3e29602767840a7a71aaafa (patch) | |
tree | 64123d0bf6a6cf5a5a4c1fd8349756db68e09483 /frontends/cocoa/FormSelectMenu.m | |
parent | ce4e059ea67cee7f35b4b810a4387f343fa74650 (diff) | |
download | netsurf-3ee40a10b123c36be3e29602767840a7a71aaafa.tar.gz netsurf-3ee40a10b123c36be3e29602767840a7a71aaafa.tar.bz2 |
Fix up cocoa frontend.
- Convert to ARC
- Fix crash due to endless responder chain recursion
- Update makefile to find openssl installed via home-brew
- Fix most compiler warnings
Diffstat (limited to 'frontends/cocoa/FormSelectMenu.m')
-rw-r--r-- | frontends/cocoa/FormSelectMenu.m | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/frontends/cocoa/FormSelectMenu.m b/frontends/cocoa/FormSelectMenu.m index b7d168e0f..a29d00811 100644 --- a/frontends/cocoa/FormSelectMenu.m +++ b/frontends/cocoa/FormSelectMenu.m @@ -25,16 +25,16 @@ static inline NSRect cocoa_rect_for_control( struct browser_window *bw, struct form_control *control) { - struct rect r; - form_control_bounding_rect(control, &r); - return cocoa_scaled_rect(browser_window_get_scale(bw), - r.x0, - r.y0, - r.x1, - r.y1); + struct rect r; + form_control_bounding_rect(control, &r); + return cocoa_scaled_rect(browser_window_get_scale(bw), + r.x0, + r.y0, + r.x1, + r.y1); } -@interface FormSelectMenu () +@interface FormSelectMenu () <NSMenuDelegate> - (void) itemSelected: (id) sender; @@ -45,70 +45,61 @@ static inline NSRect cocoa_rect_for_control( struct browser_window *bw, struct f - (id) initWithControl: (struct form_control *) c forWindow: (struct browser_window *) w { - if ((self = [super init]) == nil) return nil; - - control = c; - browser = w; - - menu = [[NSMenu alloc] initWithTitle: @"Select"]; - if (menu == nil) { - [self release]; - return nil; - } - - [menu addItemWithTitle: @"" action: NULL keyEquivalent: @""]; - - NSInteger currentItemIndex = 0; - struct form_option *opt; - for (opt = form_select_get_option(control, 0); - opt != NULL; - opt = opt->next) { - NSMenuItem *item = [[NSMenuItem alloc] initWithTitle: [NSString stringWithUTF8String: opt->text] - action: @selector( itemSelected: ) - keyEquivalent: @""]; - if (opt->selected) { - [item setState: NSOnState]; - } - [item setTarget: self]; - [item setTag: currentItemIndex++]; - [menu addItem: item]; - [item release]; + if ((self = [super init]) == nil) return nil; + + control = c; + browser = w; + + menu = [[NSMenu alloc] initWithTitle: @"Select"]; + if (menu == nil) { + return nil; + } + + [menu addItemWithTitle: @"" action: NULL keyEquivalent: @""]; + + NSInteger currentItemIndex = 0; + struct form_option *opt; + for (opt = form_select_get_option(control, 0); + opt != NULL; + opt = opt->next) { + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle: [NSString stringWithUTF8String: opt->text] + action: @selector( itemSelected: ) + keyEquivalent: @""]; + if (opt->selected) { + [item setState: NSOnState]; } + [item setTarget: self]; + [item setTag: currentItemIndex++]; + [menu addItem: item]; + } - [menu setDelegate: self]; + [menu setDelegate: self]; - return self; + return self; } -- (void) dealloc -{ - [cell release]; - [menu release]; - - [super dealloc]; -} - (void) runInView: (NSView *) view { - [self retain]; + (void)(__bridge_retained void *)self; - cell = [[NSPopUpButtonCell alloc] initTextCell: @"" pullsDown: YES]; - [cell setMenu: menu]; + cell = [[NSPopUpButtonCell alloc] initTextCell: @"" pullsDown: YES]; + [cell setMenu: menu]; - const NSRect rect = cocoa_rect_for_control(browser, control); + const NSRect rect = cocoa_rect_for_control(browser, control); - [cell attachPopUpWithFrame: rect inView: view]; - [cell performClickWithFrame: rect inView: view]; + [cell attachPopUpWithFrame: rect inView: view]; + [cell performClickWithFrame: rect inView: view]; } - (void) itemSelected: (id) sender { - form_select_process_selection( control, [sender tag] ); + form_select_process_selection( control, (int)[sender tag] ); } - (void) menuDidClose: (NSMenu *) sender { - [self release]; + (void)(__bridge_transfer id)((__bridge void *)self); } @end |