gnome: Simplify launch script now that we're using GtkApplication

This commit is contained in:
Hylke Bons 2013-10-14 14:10:31 +02:00
parent edee2eec69
commit ec03fed186
3 changed files with 15 additions and 59 deletions

View file

@ -25,36 +25,36 @@ namespace SparkleShare {
public class SparkleUI { public class SparkleUI {
public static string AssetsPath = Defines.INSTALL_DIR;
public SparkleStatusIcon StatusIcon; public SparkleStatusIcon StatusIcon;
public SparkleEventLog EventLog; public SparkleEventLog EventLog;
public SparkleBubbles Bubbles; public SparkleBubbles Bubbles;
public SparkleSetup Setup; public SparkleSetup Setup;
public SparkleAbout About; public SparkleAbout About;
public static string AssetsPath = Defines.INSTALL_DIR;
private Gtk.Application application; private Gtk.Application application;
// TODO: port sparkleshare.in
public SparkleUI () public SparkleUI ()
{ {
application = new Gtk.Application ("org.sparkleshare.sparkleshare", 0); this.application = new Gtk.Application ("org.sparkleshare.sparkleshare", 0);
application.Register (null); this.application.Register (null);
application.Activated += ApplicationActivatedDelegate; this.application.Activated += ApplicationActivatedDelegate;
} }
public void Run () 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) private void ApplicationActivatedDelegate (object sender, EventArgs args)
{ {
if (application.Windows.Length > 0) { if (this.application.Windows.Length > 0) {
foreach (Window window in application.Windows) { foreach (Window window in this.application.Windows) {
if (window.Visible) if (window.Visible)
window.Present (); window.Present ();
} }
@ -66,9 +66,9 @@ namespace SparkleShare {
Bubbles = new SparkleBubbles (); Bubbles = new SparkleBubbles ();
StatusIcon = new SparkleStatusIcon (); StatusIcon = new SparkleStatusIcon ();
Setup.Application = application; Setup.Application = this.application;
EventLog.Application = application; EventLog.Application = this.application;
About.Application = application; About.Application = this.application;
Program.Controller.UIHasLoaded (); Program.Controller.UIHasLoaded ();
} }

View file

@ -5,62 +5,18 @@ if [[ $UID -eq 0 ]]; then
exit 1 exit 1
fi fi
if [ "$XDG_RUNTIME_DIR" ]; then
pidfile=${XDG_RUNTIME_DIR}/sparkleshare.pid
else
pidfile=~/.sparkleshare-$(hostname)-${USER}.pid
fi
start() { 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 if [ -n "${SSH_AGENT_PID}" -o -n "${SSH_AUTH_SOCK}" ] ; then
mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 &
else else
ssh-agent mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 & ssh-agent mono "@expanded_libdir@/@PACKAGE@/SparkleShare.exe" $2 &
fi 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 case $1 in
start|--start) start|--start)
start start
;; ;;
stop|--stop)
stop
;;
restart|--restart)
stop
start
;;
open|--open) open|--open)
invite=`date -u +%N` invite=`date -u +%N`
open=`echo $2 | sed 's/sparkleshare:\/\/addProject\///'` open=`echo $2 | sed 's/sparkleshare:\/\/addProject\///'`

View file

@ -36,7 +36,7 @@ namespace SparkleShare {
#endif #endif
public static void Main (string [] args) 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.MacOSX &&
SparkleBackend.Platform != PlatformID.Win32NT) { SparkleBackend.Platform != PlatformID.Win32NT) {
@ -47,13 +47,13 @@ namespace SparkleShare {
"designed to keep things simple and to stay out of your way." + n + "designed to keep things simple and to stay out of your way." + n +
n + n +
"Version: " + SparkleLib.SparkleBackend.Version + 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 + "This program comes with ABSOLUTELY NO WARRANTY." + n +
n + n +
"This is free software, and you are welcome to redistribute it" + n + "This is free software, and you are welcome to redistribute it" + n +
"under certain conditions. Please read the GNU GPLv3 for details." + n + "under certain conditions. Please read the GNU GPLv3 for details." + n +
n + n +
"Usage: sparkleshare [start|stop|restart]"); "Usage: sparkleshare [start|open]");
Environment.Exit (-1); Environment.Exit (-1);
} }