The Font Collector can now collect fonts as script attachments.

Originally committed to SVN as r447.
This commit is contained in:
Rodrigo Braz Monteiro 2006-07-01 04:35:50 +00:00
parent d6c3e6492a
commit 33a6ba558a
5 changed files with 52 additions and 3 deletions

View file

@ -38,6 +38,7 @@
// Includes // Includes
#include <list> #include <list>
#include <fstream> #include <fstream>
#include <wx/filename.h>
#include "ass_file.h" #include "ass_file.h"
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_style.h" #include "ass_style.h"
@ -539,6 +540,30 @@ void AssFile::InsertAttachment (AssAttachment *attach) {
} }
///////////////////////////////
// Insert attachment from file
void AssFile::InsertAttachment (wxString filename) {
// Get name
wxFileName fname(filename);
// Create
AssAttachment *newAttach = new AssAttachment(fname.GetFullName());
// Load
try {
newAttach->Import(filename);
}
catch (...) {
delete newAttach;
throw;
}
// Insert
newAttach->group = _T("[Fonts]");
InsertAttachment(newAttach);
}
//////////////////// ////////////////////
// Gets script info // Gets script info
wxString AssFile::GetScriptInfo(const wxString _key) { wxString AssFile::GetScriptInfo(const wxString _key) {

View file

@ -85,6 +85,7 @@ public:
void LoadDefault(bool noline=true); // Loads default file. Pass true to prevent it from adding a default line too void LoadDefault(bool noline=true); // Loads default file. Pass true to prevent it from adding a default line too
void InsertStyle(AssStyle *style); // Inserts a style to file void InsertStyle(AssStyle *style); // Inserts a style to file
void InsertAttachment(AssAttachment *attach); // Inserts an attachment void InsertAttachment(AssAttachment *attach); // Inserts an attachment
void InsertAttachment(wxString filename); // Inserts a file as an attachment
wxArrayString GetStyles(); // Gets a list of all styles available wxArrayString GetStyles(); // Gets a list of all styles available
AssStyle *GetStyle(wxString name); // Gets style by its name AssStyle *GetStyle(wxString name); // Gets style by its name

View file

@ -88,6 +88,7 @@ Please visit http://aegisub.net to download latest version
- Saving back to SRT directly (that is, via "save", not "export" or "save as") is now allowed, as long as no data will be lost. (AMZ) - Saving back to SRT directly (that is, via "save", not "export" or "save as") is now allowed, as long as no data will be lost. (AMZ)
- Aegisub now supports file attachments, which are stored decoded (to save memory) and are not part of the undo stack (for the same reason). Previously, they were simply left ignored in the file as unknown lines. (AMZ) - Aegisub now supports file attachments, which are stored decoded (to save memory) and are not part of the undo stack (for the same reason). Previously, they were simply left ignored in the file as unknown lines. (AMZ)
- Implemented an Attached files list, where you can attach new fonts, extract them, or remove them from the script file. (AMZ) - Implemented an Attached files list, where you can attach new fonts, extract them, or remove them from the script file. (AMZ)
- The Font Collector can now collect fonts as script attachments. (AMZ)
= 1.09 beta - 2006.01.16 =========================== = 1.09 beta - 2006.01.16 ===========================

View file

@ -61,6 +61,7 @@ DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
wxFileName filename(AssFile::top->filename); wxFileName filename(AssFile::top->filename);
dest = filename.GetPath(); dest = filename.GetPath();
} }
AttachmentCheck = new wxCheckBox(this,ATTACHMENT_CHECK,_T("As attachments"),wxDefaultPosition);
DestBox = new wxTextCtrl(this,-1,dest,wxDefaultPosition,wxSize(250,20),0); DestBox = new wxTextCtrl(this,-1,dest,wxDefaultPosition,wxSize(250,20),0);
BrowseButton = new wxButton(this,BROWSE_BUTTON,_("&Browse...")); BrowseButton = new wxButton(this,BROWSE_BUTTON,_("&Browse..."));
wxSizer *DestBottomSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *DestBottomSizer = new wxBoxSizer(wxHORIZONTAL);
@ -70,6 +71,7 @@ DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
wxSizer *DestSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Destination")); wxSizer *DestSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Destination"));
DestSizer->Add(DestLabel,0,wxEXPAND | wxBOTTOM,5); DestSizer->Add(DestLabel,0,wxEXPAND | wxBOTTOM,5);
DestSizer->Add(DestBottomSizer,0,wxEXPAND,0); DestSizer->Add(DestBottomSizer,0,wxEXPAND,0);
DestSizer->Add(AttachmentCheck,0,wxTOP,5);
// Log box // Log box
LogBox = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(300,210),wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH); LogBox = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(300,210),wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH);
@ -142,6 +144,7 @@ BEGIN_EVENT_TABLE(DialogFontsCollector, wxDialog)
EVT_BUTTON(START_BUTTON,DialogFontsCollector::OnStart) EVT_BUTTON(START_BUTTON,DialogFontsCollector::OnStart)
EVT_BUTTON(BROWSE_BUTTON,DialogFontsCollector::OnBrowse) EVT_BUTTON(BROWSE_BUTTON,DialogFontsCollector::OnBrowse)
EVT_BUTTON(wxID_CLOSE,DialogFontsCollector::OnClose) EVT_BUTTON(wxID_CLOSE,DialogFontsCollector::OnClose)
EVT_CHECKBOX(ATTACHMENT_CHECK,DialogFontsCollector::OnCheck)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -176,6 +179,7 @@ void DialogFontsCollector::OnStart(wxCommandEvent &event) {
BrowseButton->Enable(false); BrowseButton->Enable(false);
DestBox->Enable(false); DestBox->Enable(false);
CloseButton->Enable(false); CloseButton->Enable(false);
AttachmentCheck->Enable(false);
if (!worker->IsDetached()) worker->Wait(); if (!worker->IsDetached()) worker->Wait();
} }
@ -203,6 +207,14 @@ void DialogFontsCollector::OnBrowse(wxCommandEvent &event) {
} }
////////////
// Checkbox
void DialogFontsCollector::OnCheck(wxCommandEvent &event) {
BrowseButton->Enable(!AttachmentCheck->IsChecked());
DestBox->Enable(!AttachmentCheck->IsChecked());
}
////////////////////// //////////////////////
// Get font filenames // Get font filenames
wxArrayString FontsCollectorThread::GetFontFiles (wxString face) { wxArrayString FontsCollectorThread::GetFontFiles (wxString face) {
@ -352,6 +364,7 @@ void FontsCollectorThread::Collect() {
// Get font file names // Get font file names
wxArrayString work; wxArrayString work;
wxArrayString copied; wxArrayString copied;
bool attaching = collector->AttachmentCheck->IsChecked();
for (size_t i=0;i<fonts.GetCount();i++) { for (size_t i=0;i<fonts.GetCount();i++) {
try { try {
work = GetFontFiles(fonts[i]); work = GetFontFiles(fonts[i]);
@ -372,7 +385,7 @@ void FontsCollectorThread::Collect() {
copied.Add(work[j]); copied.Add(work[j]);
// Check if it exists // Check if it exists
if (wxFileName::FileExists(dstFile)) { if (!attaching && wxFileName::FileExists(dstFile)) {
wxMutexGuiEnter(); wxMutexGuiEnter();
LogBox->SetDefaultStyle(wxTextAttr(wxColour(255,128,0))); LogBox->SetDefaultStyle(wxTextAttr(wxColour(255,128,0)));
LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" already exists on destination.\n")); LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" already exists on destination.\n"));
@ -385,7 +398,13 @@ void FontsCollectorThread::Collect() {
// Copy // Copy
else { else {
// Copy font // Copy font
bool success = Copy(srcFile,dstFile); bool success;
if (attaching) {
success = true;
try { subs->InsertAttachment(srcFile); }
catch (...) { success = false; }
}
else success = Copy(srcFile,dstFile);
// Report // Report
wxMutexGuiEnter(); wxMutexGuiEnter();

View file

@ -93,10 +93,12 @@ private:
wxButton *BrowseButton; wxButton *BrowseButton;
wxButton *StartButton; wxButton *StartButton;
wxButton *CloseButton; wxButton *CloseButton;
wxCheckBox *AttachmentCheck;
void OnStart(wxCommandEvent &event); void OnStart(wxCommandEvent &event);
void OnClose(wxCommandEvent &event); void OnClose(wxCommandEvent &event);
void OnBrowse(wxCommandEvent &event); void OnBrowse(wxCommandEvent &event);
void OnCheck(wxCommandEvent &event);
public: public:
DialogFontsCollector(wxWindow *parent); DialogFontsCollector(wxWindow *parent);
@ -110,5 +112,6 @@ public:
// IDs // IDs
enum { enum {
BROWSE_BUTTON = 1100, BROWSE_BUTTON = 1100,
START_BUTTON START_BUTTON,
ATTACHMENT_CHECK
}; };