Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Small reworking of Linux's desktop shortcuts #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions GUI.NET/Config/FileAssociationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,7 @@ static public void ConfigureLinuxMimeTypes()
}


//Use a GUID to get a unique filename and then delete old files to force a reset of file associations
//Otherwise they are sometimes not refreshed properly
string desktopFilename = "mesen." + Guid.NewGuid().ToString() + ".desktop";
string desktopFile = Path.Combine(desktopFolder, desktopFilename);

foreach(string file in Directory.GetFiles(desktopFolder, "mesen.*.desktop")) {
if(File.Exists(file)) {
try {
File.Delete(file);
} catch { }
}
}
string desktopFile = Path.Combine(desktopFolder, "mesen.desktop");

List<string> mimeTypes = new List<string>();
CreateMimeType("x-mesen-nes", "nes", "NES ROM", mimeTypes, preferenceInfo.AssociateNesFiles);
Expand Down Expand Up @@ -137,4 +126,4 @@ static public void UpdateFileAssociation(string extension, bool associate)
}
}
}
}
}
4 changes: 1 addition & 3 deletions GUI.NET/Config/PreferenceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ static public void ApplyConfig()
{
PreferenceInfo preferenceInfo = ConfigManager.Config.PreferenceInfo;

if(Program.IsMono) {
FileAssociationHelper.ConfigureLinuxMimeTypes();
} else {
if(!Program.IsMono) {
FileAssociationHelper.UpdateFileAssociation("nes", preferenceInfo.AssociateNesFiles);
FileAssociationHelper.UpdateFileAssociation("fds", preferenceInfo.AssociateFdsFiles);
FileAssociationHelper.UpdateFileAssociation("mmo", preferenceInfo.AssociateMmoFiles);
Expand Down
1 change: 1 addition & 0 deletions GUI.NET/Forms/frmConfigWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private void CreateShortcut()
string shortcutFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "mesen.desktop");
FileAssociationHelper.CreateShortcutFile(shortcutFile);
Process.Start("chmod", "775 " + shortcutFile);
FileAssociationHelper.ConfigureLinuxMimeTypes();
} else {
Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
dynamic shell = Activator.CreateInstance(t);
Expand Down