From d047a5f2d59a6cdcf922dad927ffcd233767e1db Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 28 Mar 2016 14:38:58 +0100 Subject: [PATCH] linux: Fix custom folder icon name --- SparkleShare/Linux/SparkleController.cs | 33 ++++++++++--------------- SparkleShare/SparkleControllerBase.cs | 12 ++++++--- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/SparkleShare/Linux/SparkleController.cs b/SparkleShare/Linux/SparkleController.cs index e92aaf19..33581276 100755 --- a/SparkleShare/Linux/SparkleController.cs +++ b/SparkleShare/Linux/SparkleController.cs @@ -19,9 +19,10 @@ using System; using System.Diagnostics; using System.IO; +using SparkleLib; + using Gtk; using Mono.Unix.Native; -using SparkleLib; namespace SparkleShare { @@ -94,32 +95,15 @@ namespace SparkleShare { // Creates the SparkleShare folder in the user's home folder public override bool CreateSparkleShareFolder () { - bool folder_created = false; - if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) { Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath); Syscall.chmod (SparkleConfig.DefaultConfig.FoldersPath, (FilePermissions) 448); // 448 -> 700 SparkleLogger.LogInfo ("Controller", "Created '" + SparkleConfig.DefaultConfig.FoldersPath + "'"); - folder_created = true; + return true; } - string gvfs_command_path = new string [] { Path.VolumeSeparatorChar.ToString (), - "usr", "bin", "gvfs-set-attribute" }.Combine (); - - // Add a special icon to the SparkleShare folder - if (File.Exists (gvfs_command_path)) { - var process = new Process (); - - process.StartInfo.FileName = "gvfs-set-attribute"; - process.StartInfo.Arguments = SparkleConfig.DefaultConfig.FoldersPath + - " metadata::custom-icon-name 'folder-sparkleshare'"; - - process.Start (); - process.WaitForExit (); - } - - return folder_created; + return false; } @@ -177,5 +161,14 @@ namespace SparkleShare { public override void InstallProtocolHandler () { } + + + public override void SetFolderIcon () + { + var process = new SparkleProcess ("gvfs-set-attribute", SparkleConfig.DefaultConfig.FoldersPath + " " + + "metadata::custom-icon-name 'org.sparkleshare.SparkleShare'"); + + process.StartAndWaitForExit (); + } } } diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 296470c7..3a4d89f5 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -158,12 +158,14 @@ namespace SparkleShare { // Enables SparkleShare to start automatically at login public abstract void CreateStartupItem (); - + // Installs the sparkleshare:// protocol handler public abstract void InstallProtocolHandler (); + + // Installs the sparkleshare:// protocol handler + public abstract void SetFolderIcon (); - // Adds the SparkleShare folder to the user's - // list of bookmarked places + // Adds the SparkleShare folder to the sidebar public abstract void AddToBookmarks (); // Creates the SparkleShare folder in the user's home folder @@ -222,11 +224,13 @@ namespace SparkleShare { try { if (CreateSparkleShareFolder ()) AddToBookmarks (); - + } catch (DirectoryNotFoundException) { this.lost_folders_path = true; } + SetFolderIcon (); + // Watch the SparkleShare folder this.watcher = new FileSystemWatcher () { Filter = "*",