linux: Detect right Run method for installed GTK+ bindings

This commit is contained in:
Hylke Bons 2018-02-11 13:31:13 +00:00
parent 1e799c5ce7
commit 3e74b2cb6f

View file

@ -16,6 +16,7 @@
using System; using System;
using System.Reflection;
using Gtk; using Gtk;
using Sparkles; using Sparkles;
@ -68,17 +69,18 @@ namespace SparkleShare
public void Run (string [] args) public void Run (string [] args)
{ {
// FIXME: Hack to cover API differences between Ubuntu and latest GNOME MethodInfo run_method = typeof (GLib.Application).GetMethod ("Run");
if (InstallationInfo.OperatingSystem == OS.Ubuntu) { ParameterInfo [] run_parameters = run_method.GetParameters ();
#if HAVE_APP_INDICATOR
(application as GLib.Application).Run (0, null); // Use the right Run method arguments depending on the installed GTK bindings
#endif if (run_parameters [0].ParameterType == typeof (System.Int32) &&
run_parameters [1].ParameterType == typeof (System.String)) {
run_method.Invoke ((application as GLib.Application), new object [] { 0, null });
} else { } else {
#if HAVE_APP_INDICATOR run_method.Invoke ((application as GLib.Application), new object [] { "org.sparkleshare.SparkleShare", new string [0] });
#else }
(application as GLib.Application).Run ("org.sparkleshare.SparkleShare", new string [0]);
#endif
}
} }