Add RestartAegisub() function with obvious purpose.

Replace existing code that restarts Aegisub with a call to that function.

Originally committed to SVN as r2644.
This commit is contained in:
Niels Martin Hansen 2009-01-04 11:45:06 +00:00
parent c98c5b10b9
commit 79b79d737f
4 changed files with 39 additions and 11 deletions

View File

@ -745,8 +745,9 @@ void DialogOptions::OnOK(wxCommandEvent &event) {
if (answer == wxYES) {
FrameMain *frame = (FrameMain*) GetParent();
if (frame->Close()) {
wxStandardPaths stand;
wxExecute(stand.GetExecutablePath());
RestartAegisub();
//wxStandardPaths stand;
//wxExecute(stand.GetExecutablePath());
}
}
}
@ -778,8 +779,9 @@ void DialogOptions::OnCancel(wxCommandEvent &event) {
if (answer == wxYES) {
FrameMain *frame = (FrameMain*) GetParent();
if (frame->Close()) {
wxStandardPaths stand;
wxExecute(stand.GetExecutablePath());
RestartAegisub();
//wxStandardPaths stand;
//wxExecute(stand.GetExecutablePath());
}
}
}
@ -921,8 +923,9 @@ void DialogOptions::WriteToOptions(bool justApply) {
if (answer == wxYES) {
FrameMain *frame = (FrameMain*) GetParent();
if (frame->Close()) {
wxStandardPaths stand;
wxExecute(stand.GetExecutablePath());
RestartAegisub();
//wxStandardPaths stand;
//wxExecute(stand.GetExecutablePath());
}
}
}

View File

@ -532,8 +532,9 @@ void FrameMain::OnOpenRecentAudio(wxCommandEvent &event) {
///////////////////
// Open new Window
void FrameMain::OnNewWindow(wxCommandEvent& WXUNUSED(event)) {
wxStandardPaths stand;
wxExecute(stand.GetExecutablePath());
RestartAegisub();
//wxStandardPaths stand;
//wxExecute(stand.GetExecutablePath());
}
@ -1675,8 +1676,9 @@ void FrameMain::OnChooseLanguage (wxCommandEvent &event) {
if (result == wxYES) {
// Restart Aegisub
if (Close()) {
wxStandardPaths stand;
wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\""));
RestartAegisub();
//wxStandardPaths stand;
//wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\""));
}
}
}

View File

@ -42,10 +42,14 @@
#include <wx/filename.h>
#include <wx/menu.h>
#include <wx/dcmemory.h>
#include <wx/stdpaths.h>
#include "utils.h"
#ifdef __UNIX__
#include <unistd.h>
#endif
#ifdef __APPLE__
#include "libosxutil/libosxutil.h"
#endif
#ifndef __LINUX__
@ -379,3 +383,21 @@ wxIcon BitmapToIcon(wxBitmap iconBmp) {
ico.CopyFromBitmap(bmp);
return ico;
}
///////////////////////
// Start Aegisub again
// It is assumed that something has prepared closing the current instance
// just before this is called.
void RestartAegisub() {
#if defined(__WXMSW__)
wxStandardPaths stand;
wxExecute(_T("\"") + stand.GetExecutablePath() + _T("\""));
#elif defined(__WXMAC__)
char *bundle_path = OSX_GetBundlePath();
if (!bundle_path) return; // oops
wxExecute(wxString::Format(_T("/usr/bin/open \"%s\""), wxString(bundle_path, wxConvUTF8)));
free(bundle_path);
#else
// someone fix this
#endif
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2005, Rodrigo Braz Monteiro
// Copyright (c) 2005-2009, Rodrigo Braz Monteiro, Niels Martin Hansen
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -71,6 +71,7 @@ void GetWordBoundaries(const wxString text,IntPairVector &results,int start=0,in
int StringToInt(const wxString &str,int start=0,int end=-1);
int StringToFix(const wxString &str,size_t decimalPlaces,int start=0,int end=-1);
wxIcon BitmapToIcon(wxBitmap bmp);
void RestartAegisub();
//////////