statusicon: add ifdefs
This commit is contained in:
parent
008c833dab
commit
e1ecdfb800
|
@ -19,27 +19,29 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
|
||||||
|
#ifdef USE_APPINDICATOR
|
||||||
|
using AppIndicator;
|
||||||
|
#endif
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using Mono.Unix;
|
using Mono.Unix;
|
||||||
|
|
||||||
using AppIndicator;
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
// The statusicon that stays in the
|
// The statusicon that stays in the
|
||||||
// user's notification area
|
// user's notification area
|
||||||
public class SparkleStatusIcon {
|
public class SparkleStatusIcon {
|
||||||
|
|
||||||
public bool UseIndicator = true;
|
|
||||||
|
|
||||||
private Timer Animation;
|
private Timer Animation;
|
||||||
private Gdk.Pixbuf [] AnimationFrames;
|
private Gdk.Pixbuf [] AnimationFrames;
|
||||||
private int FrameNumber;
|
private int FrameNumber;
|
||||||
private string StateText;
|
private string StateText;
|
||||||
private Menu Menu;
|
private Menu Menu;
|
||||||
|
|
||||||
private StatusIcon status_icon;
|
#ifdef USE_APPINDICATOR
|
||||||
private ApplicationIndicator indicator;
|
private ApplicationIndicator indicator;
|
||||||
|
#else
|
||||||
|
private StatusIcon status_icon;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _ (string s)
|
public static string _ (string s)
|
||||||
|
@ -53,19 +55,18 @@ namespace SparkleShare {
|
||||||
AnimationFrames = CreateAnimationFrames ();
|
AnimationFrames = CreateAnimationFrames ();
|
||||||
Animation = CreateAnimation ();
|
Animation = CreateAnimation ();
|
||||||
|
|
||||||
if (UseIndicator) {
|
#ifdef USE_APPINDICATOR
|
||||||
this.indicator = new ApplicationIndicator ("sparkleshare",
|
this.indicator = new ApplicationIndicator ("sparkleshare",
|
||||||
"process-syncing-sparkleshare-i", Category.ApplicationStatus) {
|
"process-syncing-sparkleshare-i", Category.ApplicationStatus) {
|
||||||
|
|
||||||
Status = Status.Attention
|
Status = Status.Attention
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
} else {
|
|
||||||
this.status_icon = new StatusIcon ();
|
this.status_icon = new StatusIcon ();
|
||||||
|
|
||||||
this.status_icon.Activate += ShowMenu; // Primary mouse button click
|
this.status_icon.Activate += ShowMenu; // Primary mouse button click
|
||||||
this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
|
this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
|
||||||
}
|
#endif
|
||||||
|
|
||||||
SetNormalState ();
|
SetNormalState ();
|
||||||
CreateMenu ();
|
CreateMenu ();
|
||||||
|
@ -144,11 +145,11 @@ namespace SparkleShare {
|
||||||
icon_name += "i";
|
icon_name += "i";
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
if (UseIndicator) {
|
#ifdef USE_APPINDICATOR
|
||||||
this.indicator.IconName = icon_name;
|
this.indicator.IconName = icon_name;
|
||||||
} else {
|
#else
|
||||||
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon (icon_name, 24);
|
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon (icon_name, 24);
|
||||||
}
|
#endif
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -291,8 +292,9 @@ namespace SparkleShare {
|
||||||
Menu.Add (quit_item);
|
Menu.Add (quit_item);
|
||||||
Menu.ShowAll ();
|
Menu.ShowAll ();
|
||||||
|
|
||||||
if (UseIndicator)
|
#ifdef USE_APPINDICATOR
|
||||||
this.indicator.Menu = Menu;
|
this.indicator.Menu = Menu;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -350,11 +352,11 @@ namespace SparkleShare {
|
||||||
StateText = _("Welcome to SparkleShare!");
|
StateText = _("Welcome to SparkleShare!");
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
if (UseIndicator) {
|
#ifdef USE_APPINDICATOR
|
||||||
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
||||||
} else {
|
#else
|
||||||
this.status_icon.Pixbuf = AnimationFrames [0];
|
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||||
}
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -362,20 +364,20 @@ namespace SparkleShare {
|
||||||
StateText = _("Not everything is synced");
|
StateText = _("Not everything is synced");
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
if (UseIndicator) {
|
#ifdef USE_APPINDICATOR
|
||||||
this.indicator.IconName = "sparkleshare-syncing-error";
|
this.indicator.IconName = "sparkleshare-syncing-error";
|
||||||
} else {
|
#else
|
||||||
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
|
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
|
||||||
}
|
#endif
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
|
StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
if (UseIndicator) {
|
#ifdef USE_APPINDICATOR
|
||||||
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
this.indicator.IconName = "process-syncing-sparkleshare-i";
|
||||||
} else {
|
#else
|
||||||
this.status_icon.Pixbuf = AnimationFrames [0];
|
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||||
}
|
#endif
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue