linux: Fix custom folder icon name

This commit is contained in:
Hylke Bons 2016-03-28 14:38:58 +01:00
parent 2d371550f2
commit d047a5f2d5
2 changed files with 21 additions and 24 deletions

View file

@ -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 ();
}
}
}

View file

@ -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 = "*",