From c362e511a86c2ea609af4f14c415de4104374fa2 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 12 Mar 2019 09:04:51 -0600 Subject: [PATCH] Additions and fixes for #178 --- GBM/Forms/frmMain.vb | 12 ++++++++++-- GBM/Forms/frmSettings.vb | 8 ++++---- GBM/Managers/mgrPath.vb | 13 +++++++++++++ GBM/My Project/Resources.Designer.vb | 2 +- GBM/My Project/Resources.resx | 2 +- GBM/readme.txt | 6 +++--- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 527a737..52fac50 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -30,6 +30,7 @@ Public Class frmMain Private bMenuEnabled As Boolean = True Private bLockdown As Boolean = True Private bFirstRun As Boolean = False + Private bInitialLoad As Boolean = True Private bProcessIsAdmin As Boolean = False Private bLogToggle As Boolean = False Private bShowToggle As Boolean = True @@ -1748,10 +1749,11 @@ Public Class frmMain Private Function VerifyAutoStartLinux(ByRef sErrorMessage As String) As Boolean Dim oProcess As Process + Dim sDesktopFile As String = String.Empty Dim sAutoStartFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & Path.DirectorySeparatorChar & ".config/autostart/" 'Check if the app is still properly installed - If File.Exists("/usr/share/applications/gbm.desktop") Then + If mgrPath.VerifyLinuxDesktopFileLocation(sDesktopFile) Then If File.Exists(sAutoStartFolder & Path.DirectorySeparatorChar & "gbm.desktop") Then Return True Else @@ -1763,7 +1765,7 @@ Public Class frmMain Try oProcess = New Process oProcess.StartInfo.FileName = "/bin/ln" - oProcess.StartInfo.Arguments = "-s /usr/share/applications/gbm.desktop " & sAutoStartFolder + oProcess.StartInfo.Arguments = "-s " & sDesktopFile & " " & sAutoStartFolder oProcess.StartInfo.UseShellExecute = False oProcess.StartInfo.RedirectStandardOutput = True oProcess.StartInfo.CreateNoWindow = True @@ -1973,6 +1975,12 @@ Public Class frmMain End Sub Private Sub frmMain_Activated(sender As System.Object, e As System.EventArgs) Handles MyBase.Activated + If bInitialLoad Then + If oSettings.StartToTray And mgrCommon.IsUnix Then + Me.WindowState = FormWindowState.Minimized + End If + bInitialLoad = False + End If txtLog.Select(txtLog.TextLength, 0) txtLog.ScrollToCaret() End Sub diff --git a/GBM/Forms/frmSettings.vb b/GBM/Forms/frmSettings.vb index 29ace88..2e3d228 100644 --- a/GBM/Forms/frmSettings.vb +++ b/GBM/Forms/frmSettings.vb @@ -18,9 +18,10 @@ Public Class frmSettings Private Sub HandleLinuxAutoStart(ByVal bToggle As Boolean) Dim oProcess As Process + Dim sDesktopFile = String.Empty Dim sAutoStartFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & Path.DirectorySeparatorChar & ".config/autostart/" - If bToggle Then + If bToggle And mgrPath.VerifyLinuxDesktopFileLocation(sDesktopFile) Then 'Create the autostart folder if it doesn't exist yet If Not Directory.Exists(sAutoStartFolder) Then Directory.CreateDirectory(sAutoStartFolder) @@ -29,7 +30,7 @@ Public Class frmSettings Try oProcess = New Process oProcess.StartInfo.FileName = "/bin/ln" - oProcess.StartInfo.Arguments = "-s /usr/share/applications/gbm.desktop " & sAutoStartFolder + oProcess.StartInfo.Arguments = "-s " & sDesktopFile & " " & sAutoStartFolder oProcess.StartInfo.UseShellExecute = False oProcess.StartInfo.RedirectStandardOutput = True oProcess.StartInfo.CreateNoWindow = True @@ -358,10 +359,9 @@ Public Class frmSettings If mgrCommon.IsUnix Then 'Only enable this option on Linux if GBM was installed with an official method - If Not File.Exists("/usr/share/applications/gbm.desktop") Then + If Not mgrPath.VerifyLinuxDesktopFileLocation() Then chkAutoStart.Enabled = False End If - chkStartMinimized.Enabled = False End If 'Handle Panels diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index 32c080c..8348e2b 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -652,4 +652,17 @@ Public Class mgrPath Return True End Function + + Public Shared Function VerifyLinuxDesktopFileLocation(Optional ByRef sFoundPath As String = "") As Boolean + Dim sLocations As String() = New String() {"/usr/share/applications/gbm.desktop", "/usr/local/share/applications/gbm.desktop"} + + For Each s As String In sLocations + If File.Exists(s) Then + sFoundPath = s + Return True + End If + Next + + Return False + End Function End Class diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 452c854..1821ce0 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -3310,7 +3310,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to GBM is set to start automatically, but the desktop link is missing. Automatic start has been disabled, please re-install GBM using a package manager.. + ''' Looks up a localized string similar to GBM is set to start automatically, but the desktop link is missing. Automatic start has been disabled, please re-install GBM using a package manager or the makefile.. ''' Friend ReadOnly Property frmMain_ErrorLinuxAutoStartLinkMissing() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 588ce2d..93ecc85 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2369,7 +2369,7 @@ [PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to restore this backup. - GBM is set to start automatically, but the desktop link is missing. Automatic start has been disabled, please re-install GBM using a package manager. + GBM is set to start automatically, but the desktop link is missing. Automatic start has been disabled, please re-install GBM using a package manager or the makefile. Current Folder diff --git a/GBM/readme.txt b/GBM/readme.txt index 46f3099..b579295 100644 --- a/GBM/readme.txt +++ b/GBM/readme.txt @@ -31,9 +31,9 @@ Windows: Linux: -- You can now set GBM to automatically start on log-in via the "Startup" Settings. - - This requires that GBM be installed via a package manager, so any required files are in a known location. The option will be disabled otherwise. - - The "Start Minimized" option is still unavailable in Linux due to issues with Mono. +- You can now set GBM to automatically start on log-in via the "Startup" settings. + - This requires that GBM be installed via a package manager or the makefile, so any required files are in a known location. The option will be disabled otherwise. +- The "Start Minimized" option is now available in "Startup" settings. - GBM now stores all Wine configuration data seperately from the core game configuration: - The core configuration is no longer altered in any way when a game is detected running in Wine or Proton. - The Wine configuration data is now automatically updated each time a game is detected, such as when running the game from a new prefix.