* Add a new function to libosxutil: OSX_OpenLocation which calls LSOpenCFURLRef, it accepts a URL (except for local paths) and opens the correct program using the Launcher.

* Add a new help menu option to access internal resources located within the bundle.

Closes #1033 and updates #1070.

Originally committed to SVN as r3895.
This commit is contained in:
Amar Takhar 2009-12-25 03:28:15 +00:00
parent fff128fcfa
commit 6b454601da
6 changed files with 45 additions and 2 deletions

View file

@ -551,6 +551,9 @@ void FrameMain::InitMenu() {
// Create help menu
helpMenu = new wxMenu();
AppendBitmapMenuItem (helpMenu,Menu_Help_Contents, MakeHotkeyText(_("&Contents..."), _T("Help")), _("Help topics"), GETIMAGE(contents_button_16));
#ifdef __WXMAC__
AppendBitmapMenuItem (helpMenu,Menu_Help_Files, MakeHotkeyText(_("&All Files") + _T("..."), _T("Help")), _("Help topics"), GETIMAGE(contents_button_16));
#endif
helpMenu->AppendSeparator();
AppendBitmapMenuItem(helpMenu,Menu_Help_Website, _("&Website..."), _("Visit Aegisub's official website"),GETIMAGE(website_button_16));
AppendBitmapMenuItem(helpMenu,Menu_Help_Forums, _("&Forums..."), _("Visit Aegisub's forums"),GETIMAGE(forums_button_16));

View file

@ -205,6 +205,7 @@ private:
void OnAbout (wxCommandEvent &event);
void OnCheckUpdates (wxCommandEvent &event);
void OnContents (wxCommandEvent &event);
void OnFiles (wxCommandEvent &event);
void OnWebsite (wxCommandEvent &event);
void OnForums (wxCommandEvent &event);
void OnBugTracker (wxCommandEvent &event);
@ -655,6 +656,9 @@ enum {
/// DOCME
Menu_Help_Contents,
/// DOCME
Menu_Help_Files,
/// DOCME
Menu_Help_IRCChannel,

View file

@ -95,6 +95,11 @@
#include "video_display.h"
#include "video_slider.h"
#ifdef __APPLE__
extern "C" {
#include "libosxutil/libosxutil.h"
}
#endif
////////////////////
// Menu event table
@ -193,6 +198,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
EVT_MENU(Menu_Video_Shift_To_Frame, FrameMain::OnShiftToFrame)
EVT_MENU(Menu_Help_Contents, FrameMain::OnContents)
EVT_MENU(Menu_Help_Files, FrameMain::OnFiles)
EVT_MENU(Menu_Help_Website, FrameMain::OnWebsite)
EVT_MENU(Menu_Help_Forums, FrameMain::OnForums)
EVT_MENU(Menu_Help_BugTracker, FrameMain::OnBugTracker)
@ -608,6 +614,17 @@ void FrameMain::OnContents(wxCommandEvent& WXUNUSED(event)) {
OpenHelp(_T(""));
}
/// @brief Open help files on OSX.
/// @param event
///
void FrameMain::OnFiles(wxCommandEvent& WXUNUSED(event)) {
#ifdef __WXMAC__
char *shared_path = OSX_GetBundleSharedSupportDirectory();
wxString help_path = wxString::Format(_T("%s/doc"), wxString(shared_path, wxConvUTF8).c_str());
OSX_OpenLocation(help_path.c_str());
#endif
}
/// @brief Open website

View file

@ -1,7 +1,8 @@
noinst_LIBRARIES = libosxutil.a
libosxutil_a_SOURCES = bundledirs.c
libosxutil_a_SOURCES = bundledirs.c launch.c
libosxutil_a_CFLAGS = -I/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Headers/
noinst_HEADERS = libosxutil.h
CLEANFILES = bundledirs-test
@ -10,4 +11,4 @@ EXTRA_DIST= bundledirs-test.c
bundledirs-test: libosxutil.a
$(CC) -c bundledirs-test.c
$(CC) -o bundledirs-test -framework CoreFoundation bundledirs-test.o libosxutil.a
$(CC) -o bundledirs-test -framework CoreFoundation libosxutil_a-bundledirs.o libosxutil_a-launch.o libosxutil.a

View file

@ -0,0 +1,11 @@
#include <LSOpen.h>
#include "libosxutil.h"
void OSX_OpenLocation (const char *location) {
CFStringRef CFSlocation = CFStringCreateWithCString(NULL, location, kCFStringEncodingUTF8);
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, CFSlocation , kCFURLPOSIXPathStyle, false);
OSStatus stat = LSOpenCFURLRef(url, NULL);
printf("libosxutil::OSX_OpenLocation: %s\n", GetMacOSStatusCommentString(stat));
}

View file

@ -119,3 +119,10 @@ char * OSX_GetBundleExecutablePath();
*/
char * OSX_GetBundleAuxillaryExecutablePath(const char *executableName);
/** @brief Open a URI using the Launcher.
* @param location URI of file
* @note If this is a FILE or DIRECTORY the path must be ABSOLUTE no 'file://'
* @return Error code.
*/
void OSX_OpenLocation(const char *location);