Skip to content

Commit e4cc4aa

Browse files
committed
Rewrite extractor config window without XRC
1 parent ca23d04 commit e4cc4aa

7 files changed

Lines changed: 108 additions & 163 deletions

File tree

Poedit.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
</ClCompile>
336336
<None Include="src\resources\manager.xrc" />
337337
<None Include="src\resources\menus.xrc" />
338-
<None Include="src\resources\prefs.xrc" />
339338
<None Include="src\resources\properties.xrc" />
340339
<None Include="src\resources\toolbar.xrc" />
341340
</ItemGroup>

Poedit.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,6 @@
493493
<None Include="src\resources\menus.xrc">
494494
<Filter>Data Files</Filter>
495495
</None>
496-
<None Include="src\resources\prefs.xrc">
497-
<Filter>Data Files</Filter>
498-
</None>
499496
<None Include="src\resources\properties.xrc">
500497
<Filter>Data Files</Filter>
501498
</None>

Poedit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
B295C6031E2A81C200CD71CD /* extractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B295C6001E2A81C200CD71CD /* extractor.cpp */; };
143143
B29AE89217103992008D1F8A /* manager.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB05F1709DA4A009C1328 /* manager.xrc */; };
144144
B29AE89317103992008D1F8A /* menus.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0601709DA4A009C1328 /* menus.xrc */; };
145-
B29AE89417103992008D1F8A /* prefs.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0611709DA4A009C1328 /* prefs.xrc */; };
146145
B29AE89617103992008D1F8A /* properties.xrc in Resources */ = {isa = PBXBuildFile; fileRef = B27EB0631709DA4A009C1328 /* properties.xrc */; };
147146
B2A012B321BEE4C5008051FD /* SuggestionTMTemplate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B2E7F16F1E04534A005FA992 /* SuggestionTMTemplate@2x.png */; };
148147
B2A3637C1E4B9DC800E96253 /* pretranslate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2A3637A1E4B9DC800E96253 /* pretranslate.cpp */; };
@@ -505,7 +504,6 @@
505504
B27D1FD419EFFAD600AB1913 /* uz */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uz; path = uz.lproj/MoveApplication.strings; sourceTree = "<group>"; };
506505
B27EB05F1709DA4A009C1328 /* manager.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = manager.xrc; sourceTree = "<group>"; };
507506
B27EB0601709DA4A009C1328 /* menus.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = menus.xrc; sourceTree = "<group>"; };
508-
B27EB0611709DA4A009C1328 /* prefs.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = prefs.xrc; sourceTree = "<group>"; };
509507
B27EB0631709DA4A009C1328 /* properties.xrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = properties.xrc; sourceTree = "<group>"; };
510508
B27EF64E1986D0DB00C502D2 /* bs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = bs; path = bs.lproj/MoveApplication.strings; sourceTree = "<group>"; };
511509
B27EF6521986D15400C502D2 /* pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/MoveApplication.strings; sourceTree = "<group>"; };
@@ -1110,7 +1108,6 @@
11101108
children = (
11111109
B27EB05F1709DA4A009C1328 /* manager.xrc */,
11121110
B27EB0601709DA4A009C1328 /* menus.xrc */,
1113-
B27EB0611709DA4A009C1328 /* prefs.xrc */,
11141111
B27EB0631709DA4A009C1328 /* properties.xrc */,
11151112
);
11161113
name = "XRC Resources";
@@ -1432,7 +1429,6 @@
14321429
B29AE89217103992008D1F8A /* manager.xrc in Resources */,
14331430
B29AE89317103992008D1F8A /* menus.xrc in Resources */,
14341431
B20F31D1216654DA005B7037 /* StatusWarningBlack@2x.png in Resources */,
1435-
B29AE89417103992008D1F8A /* prefs.xrc in Resources */,
14361432
B29AE89617103992008D1F8A /* properties.xrc in Resources */,
14371433
B25DB35E1E3E5102006D7228 /* ExtractorsGNUgettext@2x.png in Resources */,
14381434
B24D196A1E84503B00C6DD8D /* StatusWarning@2x.png in Resources */,

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ poedit_LDADD = $(WX_LIBS) $(LUCENE_LIBS) $(CLD2_LIBS) $(PUGIXML_LIBS) $(ACCOUNTS
9494
XRC_RESOURCES = \
9595
$(srcdir)/resources/manager.xrc \
9696
$(srcdir)/resources/menus.xrc \
97-
$(srcdir)/resources/prefs.xrc \
9897
$(srcdir)/resources/properties.xrc
9998

10099
compiled_xrc.cpp: $(XRC_RESOURCES)

src/layout_helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class StandardLayout : public Base
100100
void FitSizer()
101101
{
102102
this->SetSizerAndFit(m_topSizer);
103+
this->Layout();
104+
this->GetSizer()->SetSizeHints(this);
103105
}
104106

105107
protected:

src/prefsdlg.cpp

Lines changed: 106 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include <wx/spinctrl.h>
5050
#include <wx/textwrapper.h>
5151
#include <wx/progdlg.h>
52-
#include <wx/xrc/xmlres.h>
5352
#include <wx/numformatter.h>
5453

5554
#ifdef __WXOSX__
@@ -853,32 +852,126 @@ class ExtractorsPageWindow : public PrefsPanel
853852
class ExtractorEditDialog : public StandardDialog
854853
{
855854
public:
856-
ExtractorEditDialog(wxWindow *parent) : StandardDialog(parent, _("Extractor setup"))
855+
ExtractorEditDialog(wxWindow *parent)
856+
: StandardDialog(parent, _("Extractor setup"), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
857857
{
858858
auto sizer = ContentSizer();
859+
sizer->SetMinSize(PX(520), -1);
859860

860-
auto panel = wxXmlResource::Get()->LoadPanel(this, "edit_extractor");
861-
sizer->Add(panel, wxSizerFlags(1).Expand());
861+
#ifdef __WXOSX__
862+
sizer->Add(new HeadingLabel(this, _("Extractor setup")));
863+
sizer->AddSpacer(PX(16));
864+
#endif
862865

863-
CreateButtons(wxOK | wxCANCEL);
866+
m_language = AddTextField(_("Language:"));
867+
m_extensions = AddTextField(_("List of extensions separated by semicolons (e.g. *.cpp;*.h):"));
868+
869+
sizer->AddSpacer(PX(16));
870+
//sizer->Add(new wxStaticLine(this, wxID_ANY), wxSizerFlags().Expand());
871+
//sizer->AddSpacer(PX(8));
872+
sizer->Add(new HeadingLabel(this, _("Invocation:")));
873+
sizer->AddSpacer(PX(8));
874+
875+
m_command = AddTextField(_("Command to extract translations:"),
876+
"xgettext -L PHP --add-comments=TRANSLATORS: --force-po -o %o %C %K %F",
877+
LegacyXrcExplanation(_(
878+
"This is the command used to launch the extractor.\n"
879+
"%o expands to the name of output file, %K to list\n"
880+
"of keywords, %F to list of input files,\n"
881+
"%C to charset flag (see below).")));
882+
m_keywords = AddTextField(_("An item in keywords list:"),
883+
"-k%k",
884+
LegacyXrcExplanation(_(
885+
"This will be attached to the command line once\n"
886+
"for each keyword. %k expands to the keyword.")));
887+
m_files = AddTextField(_("An item in input files list:"),
888+
"%f",
889+
LegacyXrcExplanation(_(
890+
"This will be attached to the command line once\n"
891+
"for each input file. %f expands to the filename.")));
892+
m_charset = AddTextField(_("Source code charset:"),
893+
"--from-code=%c",
894+
LegacyXrcExplanation(_(
895+
"This will be attached to the command line\n"
896+
"only if source code charset was given. %c expands to charset value.")));
897+
898+
sizer->AddSpacer(PX(8));
899+
900+
CreateButtons()
901+
.Add(wxID_OK)
902+
.Add(wxID_CANCEL);
864903

865904
FitSizer();
866905
}
906+
907+
wxTextCtrl *Language() const { return m_language; }
908+
wxTextCtrl *Extensions() const { return m_extensions; }
909+
wxTextCtrl *Command() const { return m_command; }
910+
wxTextCtrl *Keywords() const { return m_keywords; }
911+
wxTextCtrl *Files() const { return m_files; }
912+
wxTextCtrl *Charset() const { return m_charset; }
913+
914+
private:
915+
wxTextCtrl *AddTextField(const wxString& label, const wxString& hint = wxEmptyString, const wxString& explanation = wxEmptyString)
916+
{
917+
auto sizer = ContentSizer();
918+
919+
auto labelCtrl = new wxStaticText(this, wxID_ANY, label);
920+
sizer->Add(labelCtrl, wxSizerFlags().Expand());
921+
922+
auto text = new wxTextCtrl(this, wxID_ANY);
923+
if (!hint.empty())
924+
text->SetHint(hint);
925+
sizer->Add(text, wxSizerFlags().Expand().Border(wxTOP|wxBOTTOM, PX(4)));
926+
927+
if (!explanation.empty())
928+
{
929+
sizer->Add(new ExplanationLabel(this, explanation), wxSizerFlags().Expand().Border(wxBOTTOM, PX(8)));
930+
}
931+
else
932+
{
933+
sizer->AddSpacer(PX(8));
934+
}
935+
936+
#ifdef __WXOSX__
937+
labelCtrl->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
938+
text->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
939+
#endif
940+
941+
return text;
942+
}
943+
944+
static wxString LegacyXrcExplanation(wxString text)
945+
{
946+
// This is done to preserve existing translations that were written with hardcoded newlines
947+
text.Replace("\n", " ");
948+
return text;
949+
}
950+
951+
private:
952+
wxTextCtrl *m_language = nullptr;
953+
wxTextCtrl *m_extensions = nullptr;
954+
wxTextCtrl *m_command = nullptr;
955+
wxTextCtrl *m_keywords = nullptr;
956+
wxTextCtrl *m_files = nullptr;
957+
wxTextCtrl *m_charset = nullptr;
867958
};
868959

869960
/// Called to launch dialog for editing parser properties.
870961
template<typename TFunctor>
871962
void EditExtractor(int num, TFunctor completionHandler)
872963
{
873964
wxWindowPtr<ExtractorEditDialog> dlg(new ExtractorEditDialog(this));
874-
dlg->Centre();
875-
876-
auto extractor_language = XRCCTRL(*dlg, "extractor_language", wxTextCtrl);
877-
auto extractor_extensions = XRCCTRL(*dlg, "extractor_extensions", wxTextCtrl);
878-
auto extractor_command = XRCCTRL(*dlg, "extractor_command", wxTextCtrl);
879-
auto extractor_keywords = XRCCTRL(*dlg, "extractor_keywords", wxTextCtrl);
880-
auto extractor_files = XRCCTRL(*dlg, "extractor_files", wxTextCtrl);
881-
auto extractor_charset = XRCCTRL(*dlg, "extractor_charset", wxTextCtrl);
965+
#ifndef __WXOSX__
966+
dlg->CenterOnParent();
967+
#endif
968+
969+
auto extractor_language = dlg->Language();
970+
auto extractor_extensions = dlg->Extensions();
971+
auto extractor_command = dlg->Command();
972+
auto extractor_keywords = dlg->Keywords();
973+
auto extractor_files = dlg->Files();
974+
auto extractor_charset = dlg->Charset();
882975

883976
{
884977
const LegacyExtractorSpec& nfo = m_extractors.Data[num];

src/resources/prefs.xrc

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)