From 6b454601da3a6d669119e8a9e3bc1f25501bdecb Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Fri, 25 Dec 2009 03:28:15 +0000 Subject: [PATCH] * 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. --- aegisub/src/frame_main.cpp | 3 +++ aegisub/src/frame_main.h | 4 ++++ aegisub/src/frame_main_events.cpp | 17 +++++++++++++++++ aegisub/src/libosxutil/Makefile.am | 5 +++-- aegisub/src/libosxutil/launch.c | 11 +++++++++++ aegisub/src/libosxutil/libosxutil.h | 7 +++++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 aegisub/src/libosxutil/launch.c diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index d469b5fa6..b4f1d23d5 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -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)); diff --git a/aegisub/src/frame_main.h b/aegisub/src/frame_main.h index d3d81c69f..8dc923bd5 100644 --- a/aegisub/src/frame_main.h +++ b/aegisub/src/frame_main.h @@ -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, diff --git a/aegisub/src/frame_main_events.cpp b/aegisub/src/frame_main_events.cpp index 3b8c2e820..bcd99b2b1 100644 --- a/aegisub/src/frame_main_events.cpp +++ b/aegisub/src/frame_main_events.cpp @@ -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 diff --git a/aegisub/src/libosxutil/Makefile.am b/aegisub/src/libosxutil/Makefile.am index b512b7015..69d1e882d 100644 --- a/aegisub/src/libosxutil/Makefile.am +++ b/aegisub/src/libosxutil/Makefile.am @@ -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 diff --git a/aegisub/src/libosxutil/launch.c b/aegisub/src/libosxutil/launch.c new file mode 100644 index 000000000..bfdddd731 --- /dev/null +++ b/aegisub/src/libosxutil/launch.c @@ -0,0 +1,11 @@ +#include +#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)); +} diff --git a/aegisub/src/libosxutil/libosxutil.h b/aegisub/src/libosxutil/libosxutil.h index 2e6780b8b..d4612ccbb 100644 --- a/aegisub/src/libosxutil/libosxutil.h +++ b/aegisub/src/libosxutil/libosxutil.h @@ -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);