mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00:00
ui/cocoa: Add console items to the View menu
Add any console that is available to the current emulator as a menu item under the View menu. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> [PMM: Adjusted to apply after zoom-to-fit menu item was added; create the View menu at the same time as all the others, and only add the dynamically-determined items to it later] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
8617989eae
commit
b4c6a112dc
39
ui/cocoa.m
39
ui/cocoa.m
@ -799,6 +799,7 @@ - (void)toggleFullScreen:(id)sender;
|
|||||||
- (void)showQEMUDoc:(id)sender;
|
- (void)showQEMUDoc:(id)sender;
|
||||||
- (void)showQEMUTec:(id)sender;
|
- (void)showQEMUTec:(id)sender;
|
||||||
- (void)zoomToFit:(id) sender;
|
- (void)zoomToFit:(id) sender;
|
||||||
|
- (void)displayConsole:(id)sender;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation QemuCocoaAppController
|
@implementation QemuCocoaAppController
|
||||||
@ -970,8 +971,13 @@ - (void)zoomToFit:(id) sender
|
|||||||
[sender setState: NSOffState];
|
[sender setState: NSOffState];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@end
|
|
||||||
|
|
||||||
|
/* Displays the console on the screen */
|
||||||
|
- (void)displayConsole:(id)sender
|
||||||
|
{
|
||||||
|
console_select([sender tag]);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, const char * argv[]) {
|
int main (int argc, const char * argv[]) {
|
||||||
@ -1144,6 +1150,32 @@ static void cocoa_cleanup(void)
|
|||||||
.dpy_refresh = cocoa_refresh,
|
.dpy_refresh = cocoa_refresh,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Returns a name for a given console */
|
||||||
|
static NSString * getConsoleName(QemuConsole * console)
|
||||||
|
{
|
||||||
|
return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add an entry to the View menu for each console */
|
||||||
|
static void add_console_menu_entries(void)
|
||||||
|
{
|
||||||
|
NSMenu *menu;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
menu = [[[NSApp mainMenu] itemWithTitle:@"View"] submenu];
|
||||||
|
|
||||||
|
[menu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
while (qemu_console_lookup_by_index(index) != NULL) {
|
||||||
|
menuItem = [[[NSMenuItem alloc] initWithTitle: getConsoleName(qemu_console_lookup_by_index(index))
|
||||||
|
action: @selector(displayConsole:) keyEquivalent: @""] autorelease];
|
||||||
|
[menuItem setTag: index];
|
||||||
|
[menu addItem: menuItem];
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cocoa_display_init(DisplayState *ds, int full_screen)
|
void cocoa_display_init(DisplayState *ds, int full_screen)
|
||||||
{
|
{
|
||||||
COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
|
COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
|
||||||
@ -1162,4 +1194,9 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
|
|||||||
|
|
||||||
// register cleanup function
|
// register cleanup function
|
||||||
atexit(cocoa_cleanup);
|
atexit(cocoa_cleanup);
|
||||||
|
|
||||||
|
/* At this point QEMU has created all the consoles, so we can add View
|
||||||
|
* menu entries for them.
|
||||||
|
*/
|
||||||
|
add_console_menu_entries();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user