From ec03fed1868de1f17f0f9047e13ca0e518af2f56 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 14 Oct 2013 14:10:31 +0200 Subject: [PATCH] gnome: Simplify launch script now that we're using GtkApplication --- SparkleShare/Linux/SparkleUI.cs | 24 ++++++++-------- SparkleShare/Linux/sparkleshare.in | 44 ------------------------------ SparkleShare/Program.cs | 6 ++-- 3 files changed, 15 insertions(+), 59 deletions(-) diff --git a/SparkleShare/Linux/SparkleUI.cs b/SparkleShare/Linux/SparkleUI.cs index e7af9c2b..afa4442f 100644 --- a/SparkleShare/Linux/SparkleUI.cs +++ b/SparkleShare/Linux/SparkleUI.cs @@ -25,36 +25,36 @@ namespace SparkleShare { public class SparkleUI { + public static string AssetsPath = Defines.INSTALL_DIR; + public SparkleStatusIcon StatusIcon; public SparkleEventLog EventLog; public SparkleBubbles Bubbles; public SparkleSetup Setup; public SparkleAbout About; - public static string AssetsPath = Defines.INSTALL_DIR; - private Gtk.Application application; - // TODO: port sparkleshare.in + public SparkleUI () { - application = new Gtk.Application ("org.sparkleshare.sparkleshare", 0); + this.application = new Gtk.Application ("org.sparkleshare.sparkleshare", 0); - application.Register (null); - application.Activated += ApplicationActivatedDelegate; + this.application.Register (null); + this.application.Activated += ApplicationActivatedDelegate; } public void Run () { - (application as GLib.Application).Run (0, null); + (this.application as GLib.Application).Run (0, null); } private void ApplicationActivatedDelegate (object sender, EventArgs args) { - if (application.Windows.Length > 0) { - foreach (Window window in application.Windows) { + if (this.application.Windows.Length > 0) { + foreach (Window window in this.application.Windows) { if (window.Visible) window.Present (); } @@ -66,9 +66,9 @@ namespace SparkleShare { Bubbles = new SparkleBubbles (); StatusIcon = new SparkleStatusIcon (); - Setup.Application = application; - EventLog.Application = application; - About.Application = application; + Setup.Application = this.application; + EventLog.Application = this.application; + About.Application = this.application; Program.Controller.UIHasLoaded (); } diff --git a/SparkleShare/Linux/sparkleshare.in b/SparkleShare/Linux/sparkleshare.in index a075609d..5af417c9 100755 --- a/SparkleShare/Linux/sparkleshare.in +++ b/SparkleShare/Linux/sparkleshare.in @@ -5,62 +5,18 @@ if [[ $UID -eq 0 ]]; then exit 1 fi -if [ "$XDG_RUNTIME_DIR" ]; then - pidfile=${XDG_RUNTIME_DIR}/sparkleshare.pid -else - pidfile=~/.sparkleshare-$(hostname)-${USER}.pid -fi - start() { - if [ -e "${pidfile}" ]; then - sparklepid=`cat ${pidfile}` - if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then - echo "SparkleShare is already running." - exit 0 - else - echo "Stale SparkleShare PID file found, starting a new instance..." - rm -f $pidfile - fi - fi - - echo -n "Starting SparkleShare... " if [ -n "${SSH_AGENT_PID}" -o -n "${SSH_AUTH_SOCK}" ] ; then mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & else ssh-agent mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & fi - ( umask 066; echo $! > ${pidfile} ) - echo "Done." -} - -stop() { - if [ -e "${pidfile}" ]; then - sparklepid=`cat ${pidfile}` - if [ -n "`ps -p ${sparklepid} | grep ${sparklepid}`" ]; then - echo -n "Stopping SparkleShare... " - kill ${sparklepid} - rm -f ${pidfile} - echo "Done." - else - echo "SparkleShare is not running, removing stale PID file..." - rm -f ${pidfile} - fi - else - echo "SparkleShare is not running." - fi } case $1 in start|--start) start ;; - stop|--stop) - stop - ;; - restart|--restart) - stop - start - ;; open|--open) invite=`date -u +%N` open=`echo $2 | sed 's/sparkleshare:\/\/addProject\///'` diff --git a/SparkleShare/Program.cs b/SparkleShare/Program.cs index 096c7959..7087e9e8 100644 --- a/SparkleShare/Program.cs +++ b/SparkleShare/Program.cs @@ -36,7 +36,7 @@ namespace SparkleShare { #endif public static void Main (string [] args) { - if (args.Length != 0 && !args [0].Equals ("start") && + if (args.Length != 0 && !args [0].Equals ("help") && SparkleBackend.Platform != PlatformID.MacOSX && SparkleBackend.Platform != PlatformID.Win32NT) { @@ -47,13 +47,13 @@ namespace SparkleShare { "designed to keep things simple and to stay out of your way." + n + n + "Version: " + SparkleLib.SparkleBackend.Version + n + - "Copyright (C) 2010 Hylke Bons" + n + + "Copyright (C) 2010 Hylke Bons and others" + n + "This program comes with ABSOLUTELY NO WARRANTY." + n + n + "This is free software, and you are welcome to redistribute it" + n + "under certain conditions. Please read the GNU GPLv3 for details." + n + n + - "Usage: sparkleshare [start|stop|restart]"); + "Usage: sparkleshare [start|open]"); Environment.Exit (-1); }