Skip to content

Commit 5774551

Browse files
committed
Add warning on saving under Flatpak, typo fix
1 parent 6b1f07a commit 5774551

3 files changed

Lines changed: 37 additions & 6 deletions

File tree

src/main/java/wprover/AnimateC.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void Setstep(double step) {
210210
gap = step;
211211
step_time = (int) (1000 / step);
212212
}
213-
this.reClaclulate();
213+
this.reCalculate();
214214
}
215215

216216
/**
@@ -261,14 +261,14 @@ public int getInitValue() {
261261
} else {
262262
CMisc.print("Error,undifined on type ");
263263
}
264-
reClaclulate();
264+
reCalculate();
265265

266266
}
267267

268268
/**
269269
* Recalculates the animation parameters based on the current settings.
270270
*/
271-
public void reClaclulate() {
271+
public void reCalculate() {
272272
if (onType == 2) {
273273
Circle c = (Circle) onObj;
274274
CPoint pt = c.getSidePoint();
@@ -310,7 +310,7 @@ public void reClaclulate() {
310310
* Starts the animation by recalculating initial values and setting initial positions.
311311
*/
312312
public void startAnimate() {
313-
reClaclulate();
313+
reCalculate();
314314

315315
bx = pA.getx();
316316
by = pA.gety();

src/main/java/wprover/GExpert.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,29 @@ else if (command.equalsIgnoreCase("Calculation")) {
22142214
}
22152215
}
22162216

2217+
/**
2218+
* Show a warning on saving file in an unsafe folder that will be removed after closing JGEX.
2219+
* In a Flathub sandbox, this is an important message for the user because the OS
2220+
* does not inform the user on saving a file in a temporary folder.
2221+
* @param file The user wants to use as the saved file.
2222+
*/
2223+
private void showWarningUnsafeFolder(File file) {
2224+
// Linux Flathub related code.
2225+
String absolutePath = file.getAbsolutePath();
2226+
String documentsDir = System.getenv("XDG_DOCUMENTS_DIR");
2227+
String downloadDir = System.getenv("XDG_DOWNLOAD_DIR");
2228+
String flatpakId = System.getenv("FLATPAK_ID");
2229+
if (flatpakId != null && documentsDir != null && downloadDir != null
2230+
&& !absolutePath.startsWith(documentsDir) && !absolutePath.startsWith(downloadDir)) {
2231+
JOptionPane.showMessageDialog(null,
2232+
"The application is running in Flatpak's sandbox.\n" +
2233+
"It is not possible to save data permanently in an arbitrary folder.\n" +
2234+
"Please save your data in your Documents or Downloads folder\n" +
2235+
"in order to avoid data loss after closing the program."
2236+
);
2237+
}
2238+
}
2239+
22172240
/**
22182241
* Saves the GDD proof as a GraphViz file.
22192242
*
@@ -2252,6 +2275,7 @@ private void saveGDDProofAsGraphViz(Object src) {
22522275
} catch (Exception ee) {
22532276
ee.printStackTrace();
22542277
}
2278+
showWarningUnsafeFolder(ff);
22552279
}
22562280

22572281
/**
@@ -2424,6 +2448,7 @@ public boolean saveAFile(boolean n) {
24242448
}
24252449
if (file != null)
24262450
try {
2451+
showWarningUnsafeFolder(file);
24272452
String path = file.getPath();
24282453
if (!path.endsWith(".gex")) {
24292454
path += ".gex";
@@ -2583,6 +2608,8 @@ public void saveProofAsGIF() {
25832608
chooser.setCurrentDirectory(new File(dr));
25842609

25852610
File ff = chooser.getSelectedFile();
2611+
showWarningUnsafeFolder(ff);
2612+
25862613
String p = ff.getPath();
25872614
if (!p.endsWith("gif") && !p.endsWith("GIF")) {
25882615
p = p + ".gif";
@@ -2657,14 +2684,16 @@ public void saveAsGIF() {
26572684

26582685

26592686
File ff = chooser.getSelectedFile();
2687+
showWarningUnsafeFolder(ff);
2688+
26602689
String p = ff.getPath();
26612690
if (!p.endsWith("gif") && !p.endsWith("GIF")) {
26622691
p = p + ".gif";
26632692
ff = new File(p);
26642693
}
26652694

26662695

2667-
am.reClaclulate();
2696+
am.reCalculate();
26682697
int n = am.getRounds();
26692698
if (n == 0) return;
26702699

@@ -2759,6 +2788,8 @@ public void saveAsImage() {
27592788
}
27602789

27612790
File ff = chooser.getSelectedFile();
2791+
showWarningUnsafeFolder(ff);
2792+
27622793
FileFilter f = chooser.getFileFilter();
27632794
String endfix = f.getDescription();
27642795
if (endfix == null)

src/main/java/wprover/GIFProcessDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void run() {
8787
am.width = rect.getX() + rect.getWidth() - 5;
8888
am.height = rect.getY() + rect.getHeight() - 5;
8989

90-
am.reClaclulate();
90+
am.reCalculate();
9191
total = am.getRounds();
9292

9393
GIFProcessDialog.this.setVisible(true);

0 commit comments

Comments
 (0)