linux: Fix autostart for xdg-app

This commit is contained in:
Hylke Bons 2016-03-30 11:20:22 +01:00
parent 324fa1f508
commit 5ff930300f
7 changed files with 36 additions and 42 deletions

View file

@ -28,4 +28,3 @@ namespace SparkleLib {
public const string INSTALL_DIR = "/app/share/sparkleshare";
}
}

View file

@ -28,4 +28,3 @@ namespace SparkleLib {
public const string INSTALL_DIR = "@expanded_datadir@/sparkleshare";
}
}

View file

@ -25,7 +25,7 @@ namespace SparkleLib {
public event ChangeEventEventHandler ChangeEvent = delegate { };
public delegate void ChangeEventEventHandler (FileSystemEventArgs args);
private Object thread_lock = new Object ();
private object thread_lock = new object ();
public SparkleWatcher (string path) : base (path)

View file

@ -19,11 +19,11 @@ using System;
using System.Diagnostics;
using System.IO;
using SparkleLib;
using Gtk;
using Mono.Unix.Native;
using SparkleLib;
namespace SparkleShare {
public class SparkleController : SparkleControllerBase {
@ -44,34 +44,35 @@ namespace SparkleShare {
// start SparkleShare automatically at login
public override void CreateStartupItem ()
{
string autostart_path = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "autostart");
string autostart_path = Path.Combine (Config.HomePath, ".config", "autostart");
string autostart_file_path = Path.Combine (autostart_path, "org.sparkleshare.SparkleShare.Autostart.desktop");
if (File.Exists (autostart_file_path))
return;
return;
if (!Directory.Exists (autostart_path))
if (!Directory.Exists (autostart_path))
Directory.CreateDirectory (autostart_path);
try {
string autostart_exec = "sparkleshare";
if (Defines.INSTALL_DIR.StartsWith ("/app/"))
autostart_exec = "xdg-app run org.sparkleshare.SparkleShare";
try {
File.WriteAllText (autostart_file_path,
"[Desktop Entry]\n" +
"Type=Application\n" +
"Name=SparkleShare\n" +
"Exec=sparkleshare\n" +
"Type=Application\n" +
"Exec=" + autostart_exec + "\n" +
"Icon=org.sparkleshare.SparkleShare\n" +
"Terminal=false\n" +
"X-GNOME-Autostart-enabled=true\n" +
"Categories=Network");
"X-GNOME-Autostart-enabled=true\n");
SparkleLogger.LogInfo ("Controller", "Added SparkleShare to login items");
SparkleLogger.LogInfo ("Controller", "Added SparkleShare to startup items");
} catch (Exception e) {
SparkleLogger.LogInfo ("Controller", "Failed adding SparkleShare to login items: " + e.Message);
SparkleLogger.LogInfo ("Controller", "Failed to add SparkleShare to startup items", e);
}
}
@ -130,7 +131,7 @@ namespace SparkleShare {
var process = new SparkleProcess ("gvfs-set-attribute", SparkleConfig.DefaultConfig.FoldersPath + " " +
"metadata::custom-icon-name org.sparkleshare.SparkleShare");
process.StartAndWaitForExit ();
process.StartAndWaitForExit ();
}
@ -142,10 +143,7 @@ namespace SparkleShare {
public override void OpenFile (string path)
{
Process process = new Process ();
process.StartInfo.FileName = "xdg-open";
process.StartInfo.Arguments = "\"" + path + "\"";
process.Start ();
new SparkleProcess ("xdg-open", "\"" + path + "\"").Start ();
}

View file

@ -48,10 +48,11 @@ namespace SparkleShare {
IconName = "org.sparkleshare.SparkleShare";
Gdk.Rectangle monitor_0_rect = Gdk.Screen.Default.GetMonitorGeometry (0);
SetSizeRequest (480, (int) (monitor_0_rect.Height * 0.8));
SetSizeRequest (480, 640);
Resize (480, (int)(monitor_0_rect.Height * 0.8));
this.pos_x = (int) (monitor_0_rect.Width * 0.61);
this.pos_y = (int) (monitor_0_rect.Height * 0.5 - (HeightRequest * 0.5));
this.pos_y = (int) (monitor_0_rect.Height * 0.5 - (AllocatedHeight * 0.5));
this.size_label = new Label () { Xalign = 0, Markup = "<b>Size:</b> …" };
this.history_label = new Label () { Xalign = 0, Markup = "<b>History:</b> …" };

View file

@ -239,7 +239,7 @@ namespace SparkleShare {
}
private int reopen_attempt_counts = 0;
int reopen_attempt_counts = 0;
public void HandleReopen ()
{
@ -323,7 +323,7 @@ namespace SparkleShare {
}
private void CheckRepositories ()
void CheckRepositories ()
{
lock (this.check_repos_lock) {
string path = Config.FoldersPath;
@ -385,7 +385,7 @@ namespace SparkleShare {
}
private void AddRepository (string folder_path)
void AddRepository (string folder_path)
{
SparkleRepoBase repo = null;
string folder_name = Path.GetFileName (folder_path);
@ -459,7 +459,7 @@ namespace SparkleShare {
}
private void OnFolderActivity (object o, FileSystemEventArgs args)
void OnFolderActivity (object o, FileSystemEventArgs args)
{
if (args != null && args.FullPath.EndsWith (".xml") &&
args.ChangeType == WatcherChangeTypes.Created) {
@ -470,7 +470,7 @@ namespace SparkleShare {
}
private void StartupInviteScan ()
void StartupInviteScan ()
{
foreach (string invite in Directory.GetFiles (FoldersPath, "*.xml")) {
HandleInvite (invite);
@ -478,13 +478,13 @@ namespace SparkleShare {
}
private void HandleInvite (FileSystemEventArgs args)
void HandleInvite (FileSystemEventArgs args)
{
HandleInvite (args.FullPath);
}
private void HandleInvite (string path)
void HandleInvite (string path)
{
if (this.fetcher != null &&
this.fetcher.IsActive) {
@ -517,7 +517,7 @@ namespace SparkleShare {
// Fires events for the current syncing state
private void UpdateState ()
void UpdateState ()
{
bool has_unsynced_repos = false;
bool has_syncing_repos = false;
@ -705,7 +705,7 @@ namespace SparkleShare {
}
private void ClearDirectoryAttributes (string path)
void ClearDirectoryAttributes (string path)
{
if (!Directory.Exists (path))
return;
@ -723,7 +723,7 @@ namespace SparkleShare {
}
private bool IsSymlink (string file)
bool IsSymlink (string file)
{
FileAttributes attributes = File.GetAttributes (file);
return ((attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint);

View file

@ -24,21 +24,18 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Forms = System.Windows.Forms;
using Microsoft.Win32;
using SparkleLib;
using System.Windows;
using Forms = System.Windows.Forms;
using Microsoft.Win32;
using SparkleLib;
namespace SparkleShare {
public class SparkleController : SparkleControllerBase {
private int ssh_agent_pid;
public SparkleController () : base ()
public SparkleController ()
{
}