* [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus
@ 2016-03-15 19:02 Programmingkid
2016-03-23 14:35 ` Peter Maydell
0 siblings, 1 reply; 5+ messages in thread
From: Programmingkid @ 2016-03-15 19:02 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel qemu-devel
Make the help menus actually work. The code will search thru three different
locations for the help file. If it can't be found a dialog will tell the user
the file can't be found.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
*v3 changes
Removed code that opens a web page.
Removed number_of_paths and added ARRAY_SIZE() macro.
*v2 changes
Moved opening code to one method.
Searches three different locations on the user's computer first.
Attempts to open file on web if file can't be found on user's computer.
ui/cocoa.m | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 7063a02..9295233 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -858,6 +858,7 @@ QemuCocoaView *cocoaView;
- (void)ejectDeviceMedia:(id)sender;
- (void)changeDeviceMedia:(id)sender;
- (BOOL)verifyQuit;
+- (void)openDocumentation:(NSString *)filename;
@end
@implementation QemuCocoaAppController
@@ -994,20 +995,42 @@ QemuCocoaView *cocoaView;
[cocoaView toggleFullScreen:sender];
}
+/* Tries to find then open the specified filename */
+- (void) openDocumentation: (NSString *) filename
+{
+ /* Where to look for local files */
+ NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../"};
+ NSString *full_file_path;
+
+ /* iterate thru the possible paths until the file is found */
+ int index;
+ for (index = 0; index < ARRAY_SIZE(path_array); index++) {
+ full_file_path = [[NSBundle mainBundle] executablePath];
+ full_file_path = [full_file_path stringByDeletingLastPathComponent];
+ full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path,
+ path_array[index], filename];
+ if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
+ return;
+ }
+ }
+
+ /* If none of the paths opened a file */
+ NSBeep();
+ QEMU_Alert(@"Failed to open file");
+}
+
- (void)showQEMUDoc:(id)sender
{
COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n");
- [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-doc.html",
- [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"];
+ [self openDocumentation: @"qemu-doc.html"];
}
- (void)showQEMUTec:(id)sender
{
COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n");
- [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html",
- [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"];
+ [self openDocumentation: @"qemu-tech.html"];
}
/* Stretches video to fit host monitor size */
--
2.7.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus
2016-03-15 19:02 [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus Programmingkid
@ 2016-03-23 14:35 ` Peter Maydell
2016-03-23 16:00 ` Gerd Hoffmann
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2016-03-23 14:35 UTC (permalink / raw)
To: Programmingkid; +Cc: qemu-devel qemu-devel
On 15 March 2016 at 19:02, Programmingkid <programmingkidx@gmail.com> wrote:
> Make the help menus actually work. The code will search thru three different
> locations for the help file. If it can't be found a dialog will tell the user
> the file can't be found.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Thanks; I have put this into the cocoa pullreq I've just sent.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus
2016-03-23 14:35 ` Peter Maydell
@ 2016-03-23 16:00 ` Gerd Hoffmann
2016-03-23 16:21 ` Peter Maydell
0 siblings, 1 reply; 5+ messages in thread
From: Gerd Hoffmann @ 2016-03-23 16:00 UTC (permalink / raw)
To: Peter Maydell; +Cc: Programmingkid, qemu-devel qemu-devel
On Mi, 2016-03-23 at 14:35 +0000, Peter Maydell wrote:
> On 15 March 2016 at 19:02, Programmingkid <programmingkidx@gmail.com> wrote:
> > Make the help menus actually work. The code will search thru three different
> > locations for the help file. If it can't be found a dialog will tell the user
> > the file can't be found.
> >
> > Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>
> Thanks; I have put this into the cocoa pullreq I've just sent.
/me looks a but surprised. Have you missed
https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg04528.html ?
cheers,
Gerd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus
2016-03-23 16:00 ` Gerd Hoffmann
@ 2016-03-23 16:21 ` Peter Maydell
2016-03-24 7:56 ` Gerd Hoffmann
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2016-03-23 16:21 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Programmingkid, qemu-devel qemu-devel
On 23 March 2016 at 16:00, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Mi, 2016-03-23 at 14:35 +0000, Peter Maydell wrote:
>> On 15 March 2016 at 19:02, Programmingkid <programmingkidx@gmail.com> wrote:
>> > Make the help menus actually work. The code will search thru three different
>> > locations for the help file. If it can't be found a dialog will tell the user
>> > the file can't be found.
>> >
>> > Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>>
>> Thanks; I have put this into the cocoa pullreq I've just sent.
>
> /me looks a but surprised. Have you missed
> https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg04528.html ?
Yes; the cover letter doesn't appear to have reached me so it is
not in my queue. (In any case you'd have needed to redo it since
you forgot to fix up the broken author information that you get
from John's emails by default.)
Can I get you to redo and resend, please (without the cocoa
patches)?
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus
2016-03-23 16:21 ` Peter Maydell
@ 2016-03-24 7:56 ` Gerd Hoffmann
0 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-03-24 7:56 UTC (permalink / raw)
To: Peter Maydell; +Cc: Programmingkid, qemu-devel qemu-devel
Hi,
> Yes; the cover letter doesn't appear to have reached me so it is
> not in my queue. (In any case you'd have needed to redo it since
> you forgot to fix up the broken author information that you get
> from John's emails by default.)
>
> Can I get you to redo and resend, please (without the cocoa
> patches)?
Done.
cheers,
Gerd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-24 7:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15 19:02 [Qemu-devel] [PATCH v3] ui/cocoa.m: fix help menus Programmingkid
2016-03-23 14:35 ` Peter Maydell
2016-03-23 16:00 ` Gerd Hoffmann
2016-03-23 16:21 ` Peter Maydell
2016-03-24 7:56 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).