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"; public const string INSTALL_DIR = "/app/share/sparkleshare";
} }
} }

View file

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

View file

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

View file

@ -19,11 +19,11 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using SparkleLib;
using Gtk; using Gtk;
using Mono.Unix.Native; using Mono.Unix.Native;
using SparkleLib;
namespace SparkleShare { namespace SparkleShare {
public class SparkleController : SparkleControllerBase { public class SparkleController : SparkleControllerBase {
@ -44,9 +44,7 @@ namespace SparkleShare {
// start SparkleShare automatically at login // start SparkleShare automatically at login
public override void CreateStartupItem () public override void CreateStartupItem ()
{ {
string autostart_path = Path.Combine ( string autostart_path = Path.Combine (Config.HomePath, ".config", "autostart");
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "autostart");
string autostart_file_path = Path.Combine (autostart_path, "org.sparkleshare.SparkleShare.Autostart.desktop"); string autostart_file_path = Path.Combine (autostart_path, "org.sparkleshare.SparkleShare.Autostart.desktop");
if (File.Exists (autostart_file_path)) if (File.Exists (autostart_file_path))
@ -55,23 +53,26 @@ namespace SparkleShare {
if (!Directory.Exists (autostart_path)) if (!Directory.Exists (autostart_path))
Directory.CreateDirectory (autostart_path); Directory.CreateDirectory (autostart_path);
string autostart_exec = "sparkleshare";
if (Defines.INSTALL_DIR.StartsWith ("/app/"))
autostart_exec = "xdg-app run org.sparkleshare.SparkleShare";
try { try {
File.WriteAllText (autostart_file_path, File.WriteAllText (autostart_file_path,
"[Desktop Entry]\n" + "[Desktop Entry]\n" +
"Type=Application\n" +
"Name=SparkleShare\n" + "Name=SparkleShare\n" +
"Exec=sparkleshare\n" + "Type=Application\n" +
"Exec=" + autostart_exec + "\n" +
"Icon=org.sparkleshare.SparkleShare\n" + "Icon=org.sparkleshare.SparkleShare\n" +
"Terminal=false\n" + "Terminal=false\n" +
"X-GNOME-Autostart-enabled=true\n" + "X-GNOME-Autostart-enabled=true\n");
"Categories=Network");
SparkleLogger.LogInfo ("Controller", "Added SparkleShare to login items"); SparkleLogger.LogInfo ("Controller", "Added SparkleShare to startup items");
} catch (Exception e) { } 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);
} }
} }
@ -142,10 +143,7 @@ namespace SparkleShare {
public override void OpenFile (string path) public override void OpenFile (string path)
{ {
Process process = new Process (); new SparkleProcess ("xdg-open", "\"" + path + "\"").Start ();
process.StartInfo.FileName = "xdg-open";
process.StartInfo.Arguments = "\"" + path + "\"";
process.Start ();
} }

View file

@ -48,10 +48,11 @@ namespace SparkleShare {
IconName = "org.sparkleshare.SparkleShare"; IconName = "org.sparkleshare.SparkleShare";
Gdk.Rectangle monitor_0_rect = Gdk.Screen.Default.GetMonitorGeometry (0); 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_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.size_label = new Label () { Xalign = 0, Markup = "<b>Size:</b> …" };
this.history_label = new Label () { Xalign = 0, Markup = "<b>History:</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 () public void HandleReopen ()
{ {
@ -323,7 +323,7 @@ namespace SparkleShare {
} }
private void CheckRepositories () void CheckRepositories ()
{ {
lock (this.check_repos_lock) { lock (this.check_repos_lock) {
string path = Config.FoldersPath; string path = Config.FoldersPath;
@ -385,7 +385,7 @@ namespace SparkleShare {
} }
private void AddRepository (string folder_path) void AddRepository (string folder_path)
{ {
SparkleRepoBase repo = null; SparkleRepoBase repo = null;
string folder_name = Path.GetFileName (folder_path); 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") && if (args != null && args.FullPath.EndsWith (".xml") &&
args.ChangeType == WatcherChangeTypes.Created) { args.ChangeType == WatcherChangeTypes.Created) {
@ -470,7 +470,7 @@ namespace SparkleShare {
} }
private void StartupInviteScan () void StartupInviteScan ()
{ {
foreach (string invite in Directory.GetFiles (FoldersPath, "*.xml")) { foreach (string invite in Directory.GetFiles (FoldersPath, "*.xml")) {
HandleInvite (invite); HandleInvite (invite);
@ -478,13 +478,13 @@ namespace SparkleShare {
} }
private void HandleInvite (FileSystemEventArgs args) void HandleInvite (FileSystemEventArgs args)
{ {
HandleInvite (args.FullPath); HandleInvite (args.FullPath);
} }
private void HandleInvite (string path) void HandleInvite (string path)
{ {
if (this.fetcher != null && if (this.fetcher != null &&
this.fetcher.IsActive) { this.fetcher.IsActive) {
@ -517,7 +517,7 @@ namespace SparkleShare {
// Fires events for the current syncing state // Fires events for the current syncing state
private void UpdateState () void UpdateState ()
{ {
bool has_unsynced_repos = false; bool has_unsynced_repos = false;
bool has_syncing_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)) if (!Directory.Exists (path))
return; return;
@ -723,7 +723,7 @@ namespace SparkleShare {
} }
private bool IsSymlink (string file) bool IsSymlink (string file)
{ {
FileAttributes attributes = File.GetAttributes (file); FileAttributes attributes = File.GetAttributes (file);
return ((attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint); return ((attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint);

View file

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