/
poedit-2.0.2_revert_4b692e6_f98feb2_invoke-dde_line-switch.patch
323 lines (281 loc) · 10.2 KB
/
poedit-2.0.2_revert_4b692e6_f98feb2_invoke-dde_line-switch.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
diff --git a/src/catalog.cpp b/src/catalog.cpp
index dbc77ac97..fdc57bc6a 100644
--- a/src/catalog.cpp
+++ b/src/catalog.cpp
@@ -1365,19 +1365,13 @@ void Catalog::RemoveDeletedItems()
CatalogItemPtr Catalog::FindItemByLine(int lineno)
{
- int i = FindItemIndexByLine(lineno);
- return i == -1 ? CatalogItemPtr() : m_items[i];
-}
-
-int Catalog::FindItemIndexByLine(int lineno)
-{
- int last = -1;
+ CatalogItemPtr last;
for (auto& i: m_items)
{
- if (i->GetLineNumber() > lineno)
+ if ( i->GetLineNumber() > lineno )
return last;
- last++;
+ last = i;
}
return last;
diff --git a/src/catalog.h b/src/catalog.h
index 710a7e40f..494497dbd 100644
--- a/src/catalog.h
+++ b/src/catalog.h
@@ -709,9 +709,6 @@ class Catalog
/// Finds item by line number
CatalogItemPtr FindItemByLine(int lineno);
- /// Finds catalog index by line number
- int FindItemIndexByLine(int lineno);
-
/// Sets the given item to have the given bookmark and returns the index
/// of the item that previously had this bookmark (or -1)
int SetBookmark(int id, Bookmark bookmark);
diff --git a/src/edapp.cpp b/src/edapp.cpp
index 2d08b8d93..f220c5b1f 100644
--- a/src/edapp.cpp
+++ b/src/edapp.cpp
@@ -148,27 +148,19 @@ private:
wxString payload;
if (data == "Activate")
{
- dispatch::on_main([=] {
- m_app->OpenNewFile();
- });
+ m_app->OpenNewFile();
return true;
}
if (data.StartsWith("OpenURI:", &payload))
{
- dispatch::on_main([=] {
- m_app->HandleCustomURI(payload);
- });
+ m_app->HandleCustomURI(payload);
return true;
}
if (data.StartsWith("OpenFile:", &payload))
{
- long lineno = 0;
- payload.BeforeFirst(':').ToLong(&lineno);
wxArrayString a;
- a.push_back(payload.AfterFirst(':'));
- dispatch::on_main([=] {
- m_app->OpenFiles(a, lineno);
- });
+ a.push_back(payload);
+ m_app->OpenFiles(a);
return true;
}
return false;
@@ -242,11 +234,11 @@ public:
Command("OpenURI:" + uri);
}
- void OpenFile(const wxString& filename, int lineno = 0)
+ void OpenFile(const wxString& filename)
{
wxFileName fn(filename);
fn.MakeAbsolute();
- Command(wxString::Format("OpenFile:%d:%s", lineno, fn.GetFullPath()));
+ Command("OpenFile:" + fn.GetFullPath());
}
private:
@@ -320,7 +312,6 @@ bool PoeditApp::CheckForBetaUpdates() const
#ifndef __WXOSX__
static wxArrayString gs_filesToOpen;
#endif
-static int gs_lineToOpen = 0;
extern void InitXmlResource();
@@ -456,9 +447,8 @@ bool PoeditApp::OnInit()
// passing files on command line
if (!gs_filesToOpen.empty())
{
- OpenFiles(gs_filesToOpen, gs_lineToOpen);
+ OpenFiles(gs_filesToOpen);
gs_filesToOpen.clear();
- gs_lineToOpen = 0;
}
else
{
@@ -615,7 +605,7 @@ void PoeditApp::OpenNewFile()
PoeditFrame::CreateWelcome();
}
-void PoeditApp::OpenFiles(const wxArrayString& names, int lineno)
+void PoeditApp::OpenFiles(const wxArrayString& names)
{
PoeditFrame *active = PoeditFrame::UnusedActiveWindow();
@@ -638,12 +628,12 @@ void PoeditApp::OpenFiles(const wxArrayString& names, int lineno)
if (active)
{
- active->OpenFile(name, lineno);
+ active->OpenFile(name);
active = nullptr;
}
else
{
- PoeditFrame::Create(name, lineno);
+ PoeditFrame::Create(name);
}
}
}
@@ -674,7 +664,6 @@ namespace
{
const char *CL_KEEP_TEMP_FILES = "keep-temp-files";
const char *CL_HANDLE_POEDIT_URI = "handle-poedit-uri";
-const char *CL_LINE = "line";
}
void PoeditApp::OnInitCmdLine(wxCmdLineParser& parser)
@@ -685,8 +674,6 @@ void PoeditApp::OnInitCmdLine(wxCmdLineParser& parser)
_("don't delete temporary files (for debugging)"));
parser.AddLongOption(CL_HANDLE_POEDIT_URI,
_("handle a poedit:// URI"), wxCMD_LINE_VAL_STRING);
- parser.AddLongOption(CL_LINE,
- _("go to item at given line number"), wxCMD_LINE_VAL_NUMBER);
parser.AddParam("catalog.po", wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE);
}
@@ -696,10 +683,6 @@ bool PoeditApp::OnCmdLineParsed(wxCmdLineParser& parser)
if (!wxApp::OnCmdLineParsed(parser))
return false;
- long lineno = 0;
- if (parser.Found(CL_LINE, &lineno))
- gs_lineToOpen = (int)lineno;
-
if ( parser.Found(CL_KEEP_TEMP_FILES) )
TempDirectory::KeepFiles();
@@ -727,7 +710,7 @@ bool PoeditApp::OnCmdLineParsed(wxCmdLineParser& parser)
else
{
for (size_t i = 0; i < parser.GetParamCount(); i++)
- client.OpenFile(parser.GetParam(i), (int)lineno);
+ client.OpenFile(parser.GetParam(i));
}
return false; // terminate program
}
@@ -1021,13 +1004,6 @@ void PoeditApp::OpenPoeditWeb(const wxString& path)
#ifdef __WXOSX__
-void PoeditApp::MacOpenFiles(const wxArrayString& names)
-{
- OpenFiles(names, gs_lineToOpen);
- gs_lineToOpen = 0;
-}
-
-
static NSMenuItem *AddNativeItem(NSMenu *menu, int pos, const wxString&text, SEL ac, NSString *key)
{
NSString *str = str::to_NS(text);
diff --git a/src/edapp.h b/src/edapp.h
index 4e46452af..19e1cd176 100644
--- a/src/edapp.h
+++ b/src/edapp.h
@@ -61,7 +61,7 @@ class PoeditApp : public wxApp
bool CheckForBetaUpdates() const;
// opens files in new frame
- void OpenFiles(const wxArrayString& filenames, int lineno = 0);
+ void OpenFiles(const wxArrayString& filenames);
// opens empty frame or catalogs manager
void OpenNewFile();
@@ -70,7 +70,7 @@ class PoeditApp : public wxApp
#endif
#ifdef __WXOSX__
- virtual void MacOpenFiles(const wxArrayString& names);
+ virtual void MacOpenFiles(const wxArrayString& names) { OpenFiles(names); }
virtual void MacNewFile() { OpenNewFile(); }
virtual void MacOpenURL(const wxString &url) { HandleCustomURI(url); }
#endif
diff --git a/src/edframe.cpp b/src/edframe.cpp
index 59a383d27..0478dc202 100644
--- a/src/edframe.cpp
+++ b/src/edframe.cpp
@@ -212,7 +212,7 @@ bool g_focusToText = false;
return false;
}
-/*static*/ PoeditFrame *PoeditFrame::Create(const wxString& filename, int lineno)
+/*static*/ PoeditFrame *PoeditFrame::Create(const wxString& filename)
{
PoeditFrame *f = PoeditFrame::Find(filename);
if (f)
@@ -245,9 +245,7 @@ bool g_focusToText = false;
}
f->Show(true);
-
- // HACK: make sure this is called *after* the delayed call in PoeditListCtrl::CatalogChanged
- f->m_list->CallAfter([=]{ f->PlaceInitialFocus(lineno); });
+ f->PlaceInitialFocus();
return f;
}
@@ -788,23 +786,15 @@ PoeditFrame::~PoeditFrame()
}
-void PoeditFrame::PlaceInitialFocus(int lineno)
+void PoeditFrame::PlaceInitialFocus()
{
if (g_focusToText && m_editingArea)
m_editingArea->SetTextFocus();
else if (m_list)
m_list->SetFocus();
- if (m_catalog && m_list && m_list->GetItemCount() > 0)
- {
- int item = 0;
- if (lineno > 0)
- {
- item = m_catalog->FindItemIndexByLine(lineno);
- item = (item == -1) ? 0 : m_list->CatalogIndexToList(item);
- }
- m_list->SelectAndFocus(item);
- }
+ if (m_list && m_list->GetItemCount() > 0)
+ m_list->SelectAndFocus(0);
}
@@ -926,20 +916,19 @@ void PoeditFrame::OnCloseCmd(wxCommandEvent&)
#endif
-void PoeditFrame::OpenFile(const wxString& filename, int lineno)
+void PoeditFrame::OpenFile(const wxString& filename)
{
DoIfCanDiscardCurrentDoc([=]{
- DoOpenFile(filename, lineno);
+ DoOpenFile(filename);
});
}
-void PoeditFrame::DoOpenFile(const wxString& filename, int lineno)
+void PoeditFrame::DoOpenFile(const wxString& filename)
{
ReadCatalog(filename);
- // HACK: make sure this is called *after* the delayed call in PoeditListCtrl::CatalogChanged
- m_list->CallAfter([=]{ PlaceInitialFocus(lineno); });
+ PlaceInitialFocus();
}
diff --git a/src/edframe.h b/src/edframe.h
index 1ed599851..0ba310192 100644
--- a/src/edframe.h
+++ b/src/edframe.h
@@ -69,7 +69,7 @@ class PoeditFrame : public PoeditFrameBase
\param catalog filename of catalog to open.
*/
- static PoeditFrame *Create(const wxString& catalog, int lineno = 0);
+ static PoeditFrame *Create(const wxString& catalog);
/** Public constructor functions. Creates and shows frame
without catalog or other content.
@@ -83,7 +83,7 @@ class PoeditFrame : public PoeditFrameBase
/// Opens given file in this frame. Asks user for permission first
/// if there's unsaved document.
- void OpenFile(const wxString& filename, int lineno = 0);
+ void OpenFile(const wxString& filename);
/** Returns pointer to existing instance of PoeditFrame that currently
exists and edits \a catalog. If no such frame exists, returns NULL.
@@ -183,7 +183,7 @@ class PoeditFrame : public PoeditFrameBase
wxWindow* CreateContentViewEmptyPO();
void DestroyContentView();
- void PlaceInitialFocus(int lineno = 0);
+ void PlaceInitialFocus();
typedef std::set<PoeditFrame*> PoeditFramesList;
static PoeditFramesList ms_instances;
@@ -206,7 +206,7 @@ class PoeditFrame : public PoeditFrameBase
wxWindowPtr<wxMessageDialog> CreateAskAboutSavingDialog();
// implements opening of files, without asking user
- void DoOpenFile(const wxString& filename, int lineno = 0);
+ void DoOpenFile(const wxString& filename);
/// Updates statistics in statusbar.
void UpdateStatusBar();