[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch v5] ui/cocoa.m: Adds console items to the View menu
From: |
Programmingkid |
Subject: |
[Qemu-devel] [patch v5] ui/cocoa.m: Adds console items to the View menu |
Date: |
Mon, 11 May 2015 11:18:07 -0400 |
Adds any console that is available to the current emulator as a menu item under
the View menu.
Signed-off-by: John Arbuckle <address@hidden>
---
Removed the initConsoleVariables() function.
Removed global variables.
Rewrote how console menu items are added.
ui/cocoa.m | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index d37c29b..b4b7adb 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -801,6 +801,7 @@ QemuCocoaView *cocoaView;
- (void)toggleFullScreen:(id)sender;
- (void)showQEMUDoc:(id)sender;
- (void)showQEMUTec:(id)sender;
+- (void)displayConsole:(id)sender;
@end
@implementation QemuCocoaAppController
@@ -943,8 +944,14 @@ QemuCocoaView *cocoaView;
[[NSWorkspace sharedWorkspace] openFile:[NSString
stringWithFormat:@"%@/../doc/qemu/qemu-tech.html",
[[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"];
}
address@hidden
+/* Displays the console on the screen */
+- (void)displayConsole:(id)sender
+{
+ console_select([sender tag]);
+}
+
address@hidden
int main (int argc, const char * argv[]) {
@@ -1003,13 +1010,6 @@ int main (int argc, const char * argv[]) {
[[NSApp mainMenu] addItem:menuItem];
[NSApp performSelector:@selector(setAppleMenu:) withObject:menu]; //
Workaround (this method is private since 10.4+)
- // View menu
- menu = [[NSMenu alloc] initWithTitle:@"View"];
- [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen"
action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; //
Fullscreen
- menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil
keyEquivalent:@""] autorelease];
- [menuItem setSubmenu:menu];
- [[NSApp mainMenu] addItem:menuItem];
-
// Window menu
menu = [[NSMenu alloc] initWithTitle:@"Window"];
[menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Minimize"
action:@selector(performMiniaturize:) keyEquivalent:@"m"] autorelease]]; //
Miniaturize
@@ -1116,6 +1116,37 @@ static const DisplayChangeListenerOps dcl_ops = {
.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)];
+}
+
+// Creates the view menu
+static void create_view_menu()
+{
+ NSMenu * menu;
+ NSMenuItem * menuItem;
+ int index = 0;
+
+ menu = [[NSMenu alloc] initWithTitle:@"View"];
+ [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen"
action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; //
Fullscreen
+ [menu addItem:[NSMenuItem separatorItem]]; //Separator
+
+ // Give each console its own menu item in the View menu
+ 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++;
+ }
+
+ menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil
keyEquivalent:@""] autorelease];
+ [menuItem setSubmenu:menu];
+ [[NSApp mainMenu] insertItem: menuItem atIndex: 1]; // insert View menu
after Application menu
+}
+
void cocoa_display_init(DisplayState *ds, int full_screen)
{
COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
@@ -1128,4 +1159,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
// register cleanup function
atexit(cocoa_cleanup);
+
+ // QEMU needs to be running first before we can create the view menu
+ create_view_menu();
}
--
1.7.5.4
- [Qemu-devel] [patch v5] ui/cocoa.m: Adds console items to the View menu,
Programmingkid <=