[chronojump] Fixed open folders on Linux
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed open folders on Linux
- Date: Wed, 15 Jul 2020 11:10:56 +0000 (UTC)
commit 93bd5f8c5faa5e94b9900ae2f897dc3c9a9839a3
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jul 15 12:40:41 2020 +0200
Fixed open folders on Linux
src/gui/app1/chronojump.cs | 7 ++-----
src/gui/app1/encoder.cs | 2 +-
src/gui/app1/forceSensor.cs | 4 ++--
src/gui/app1/runEncoder.cs | 4 ++--
src/gui/app1/session/main.cs | 6 +-----
src/gui/dialogMessage.cs | 5 +----
src/gui/preferences.cs | 13 +++----------
src/gui/splash.cs | 12 ++----------
src/util.cs | 18 +++++++++++++++++-
9 files changed, 31 insertions(+), 40 deletions(-)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 6f151b34..e4a31db5 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -6570,12 +6570,9 @@ LogB.Debug("mc finished 5");
Catalog.GetString("Newer versions will be on this site:") +"\n" +
"<i>http://www.chronojump.org/multimedia.html</i>");
*/
- LogB.Information("Opening manual at: " + System.IO.Path.GetFullPath(Util.GetManualDir()));
- try {
- System.Diagnostics.Process.Start(System.IO.Path.GetFullPath(Util.GetManualDir()));
- } catch {
+
+ if(! Util.OpenFolder(System.IO.Path.GetFullPath(Util.GetManualDir())))
new DialogMessage(Constants.MessageTypes.WARNING, "Sorry, manual folder does not
exist.");
- }
}
private void on_menuitem_formulas_activate (object o, EventArgs args) {
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index 95e6c37a..4596013b 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -7287,7 +7287,7 @@ public partial class ChronoJumpWindow
/*
string dir = textview_video_encoder_folder.Buffer.Text;
try {
- System.Diagnostics.Process.Start(dir);
+ System.Diagnostics.Process.Start(dir); //also use Util.OpenFolder
}
catch {
new DialogMessage(Constants.MessageTypes.WARNING,
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index a17e25a4..d79e9560 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -2255,7 +2255,7 @@ LogB.Information(" fs R ");
if(currentSession == null || currentSession.UniqueID == -1)
{
try {
- System.Diagnostics.Process.Start(ForceSensorGraph.GetDataDir(-1));
+ System.Diagnostics.Process.Start(ForceSensorGraph.GetDataDir(-1)); //also use
Util.OpenFolder
} catch {
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Error. Cannot open directory.") + "\n\n" +
ForceSensorGraph.GetDataDir(-1));
@@ -2267,7 +2267,7 @@ LogB.Information(" fs R ");
if(dataDir != "")
{
try {
- System.Diagnostics.Process.Start(dataDir);
+ System.Diagnostics.Process.Start(dataDir); //also use Util.OpenFolder
} catch {
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Error. Cannot open directory.") + "\n\n" +
dataDir);
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index 2489b324..d9c446cc 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -1293,7 +1293,7 @@ public partial class ChronoJumpWindow
if(currentSession == null || currentSession.UniqueID == -1)
{
try {
- System.Diagnostics.Process.Start(RunEncoderGraph.GetDataDir(-1));
+ System.Diagnostics.Process.Start(RunEncoderGraph.GetDataDir(-1)); //also use
Util.OpenFolder
} catch {
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Error. Cannot open directory.") + "\n\n" +
RunEncoderGraph.GetDataDir(-1));
@@ -1305,7 +1305,7 @@ public partial class ChronoJumpWindow
if(dataDir != "")
{
try {
- System.Diagnostics.Process.Start(dataDir);
+ System.Diagnostics.Process.Start(dataDir); //also use Util.OpenFolder
} catch {
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Error. Cannot open directory.") + "\n\n" +
dataDir);
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index f45465cb..f1671144 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -215,13 +215,9 @@ public partial class ChronoJumpWindow
else if(file2.Exists)
dir = Util.GetDatabaseTempDir();
- try {
- System.Diagnostics.Process.Start(dir);
- } catch {
+ if(! Util.OpenFolder(dir))
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Error. Cannot open directory.") + "\n\n" + dir);
- return;
- }
}
}
diff --git a/src/gui/dialogMessage.cs b/src/gui/dialogMessage.cs
index 5b521de3..246a34ed 100644
--- a/src/gui/dialogMessage.cs
+++ b/src/gui/dialogMessage.cs
@@ -127,11 +127,8 @@ public class DialogMessage
public void on_button_go_clicked (object obj, EventArgs args)
{
LogB.Information("Opening browser (r mac install) to: " + button_go_link);
- try {
- System.Diagnostics.Process.Start(button_go_link);
- } catch {
+ if(! Util.OpenFolder(button_go_link))
label_message.Text = Constants.WebsiteNotFoundStr();
- }
}
public void on_close_button_clicked (object obj, EventArgs args)
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index a993425b..c9e08086 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -1450,14 +1450,10 @@ public class PreferencesWindow
return;
}
}
-
- try {
- System.Diagnostics.Process.Start(dir);
- }
- catch {
+
+ if(! Util.OpenFolder(dir))
new DialogMessage(Constants.MessageTypes.WARNING,
Constants.DirectoryCannotOpenStr() + "\n\n" + dir);
- }
}
void on_button_tmp_folder_open_clicked (object o, EventArgs args)
@@ -1470,12 +1466,9 @@ public class PreferencesWindow
return;
}
- try {
- System.Diagnostics.Process.Start(dir);
- } catch {
+ if(! Util.OpenFolder(dir))
new DialogMessage(Constants.MessageTypes.WARNING,
Constants.DirectoryCannotOpenStr() + "\n\n" + dir);
- }
}
void on_button_import_configuration_clicked (object o, EventArgs args)
diff --git a/src/gui/splash.cs b/src/gui/splash.cs
index 4e8af5e7..454476fb 100644
--- a/src/gui/splash.cs
+++ b/src/gui/splash.cs
@@ -136,13 +136,9 @@ public class SplashWindow
else if(file2.Exists)
dir = Util.GetDatabaseTempDir();
- try {
- System.Diagnostics.Process.Start(dir);
- } catch {
+ if(! Util.OpenFolder(dir))
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Error. Cannot open directory.") + "\n\n" + dir);
- return;
- }
}
public void Show_button_open_docs_folder () {
@@ -150,15 +146,11 @@ public class SplashWindow
}
private void on_button_open_docs_folder_clicked (object o, EventArgs args)
{
- LogB.Information("Opening docs at: " + Path.GetFullPath(Util.GetManualDir()));
- try {
- System.Diagnostics.Process.Start(Path.GetFullPath(Util.GetManualDir()));
- } catch {
+ if(! Util.OpenFolder(Path.GetFullPath(Util.GetManualDir())))
new DialogMessage(Constants.MessageTypes.WARNING,
"Sorry, folder does not exist." + "\n\n" +
Path.GetFullPath(Util.GetManualDir())
);
- }
}
public void ShowButtonClose()
diff --git a/src/util.cs b/src/util.cs
index 13779dff..e5fb6a2b 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1472,7 +1472,23 @@ public class Util
//maybe R is not installed
}
}
-
+
+ public static bool OpenFolder(string url)
+ {
+ LogB.Information("OpenFolder: " + url);
+ try {
+ //more system specific methods on: https://stackoverflow.com/a/49664847/12366369
+ //also if do not work, check about relative paths here:
https://stackoverflow.com/questions/52599105/c-sharp-under-linux-process-start-exception-of-no-such-file-or-directory
+ if(operatingSystem == UtilAll.OperatingSystems.LINUX)
+ System.Diagnostics.Process.Start("xdg-open", url);
+ else
+ System.Diagnostics.Process.Start(url);
+
+ return true;
+ } catch {
+ return false;
+ }
+ }
/*
* currently not used, we copy the assemblies now
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]