statusicon: adjust basic structure for appindicator
This commit is contained in:
parent
0a863371ef
commit
f549f6e13f
|
@ -27,14 +27,18 @@ 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 : StatusIcon {
|
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;
|
||||||
|
private ApplicationIndicator indicator;
|
||||||
|
private Menu menu;
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _ (string s)
|
public static string _ (string s)
|
||||||
{
|
{
|
||||||
|
@ -42,13 +46,23 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SparkleStatusIcon () : base ()
|
public SparkleStatusIcon ()
|
||||||
{
|
{
|
||||||
AnimationFrames = CreateAnimationFrames ();
|
AnimationFrames = CreateAnimationFrames ();
|
||||||
Animation = CreateAnimation ();
|
Animation = CreateAnimation ();
|
||||||
|
|
||||||
Activate += ShowMenu; // Primary mouse button click
|
if (UseIndicator) {
|
||||||
PopupMenu += ShowMenu; // Secondary mouse button click
|
this.indicator = new ApplicationIndicator ("sparkleshare",
|
||||||
|
"folder", Category.ApplicationStatus);
|
||||||
|
|
||||||
|
indicator.Status = Status.Attention;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.status_icon = new StatusIcon ();
|
||||||
|
|
||||||
|
this.status_icon.Activate += ShowMenu; // Primary mouse button click
|
||||||
|
this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
|
||||||
|
}
|
||||||
|
|
||||||
SetNormalState ();
|
SetNormalState ();
|
||||||
CreateMenu ();
|
CreateMenu ();
|
||||||
|
@ -122,7 +136,11 @@ namespace SparkleShare {
|
||||||
FrameNumber = 0;
|
FrameNumber = 0;
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
Pixbuf = AnimationFrames [FrameNumber];
|
if (UseIndicator) {
|
||||||
|
this.indicator.IconName = "folder-videos";
|
||||||
|
} else {
|
||||||
|
this.status_icon.Pixbuf = AnimationFrames [FrameNumber];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -186,6 +204,8 @@ namespace SparkleShare {
|
||||||
Menu.Add (no_folders_item);
|
Menu.Add (no_folders_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu.Add (new SeparatorMenuItem ());
|
||||||
|
|
||||||
// Opens the wizard to add a new remote folder
|
// Opens the wizard to add a new remote folder
|
||||||
MenuItem sync_item = new MenuItem (_("Add Remote Folder…"));
|
MenuItem sync_item = new MenuItem (_("Add Remote Folder…"));
|
||||||
|
|
||||||
|
@ -263,6 +283,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Menu.Add (quit_item);
|
Menu.Add (quit_item);
|
||||||
Menu.ShowAll ();
|
Menu.ShowAll ();
|
||||||
|
|
||||||
|
if (UseIndicator)
|
||||||
|
this.indicator.Menu = Menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -301,7 +324,7 @@ namespace SparkleShare {
|
||||||
// Makes sure the menu pops up in the right position
|
// Makes sure the menu pops up in the right position
|
||||||
private void SetPosition (Menu menu, out int x, out int y, out bool push_in)
|
private void SetPosition (Menu menu, out int x, out int y, out bool push_in)
|
||||||
{
|
{
|
||||||
PositionMenu (menu, out x, out y, out push_in, Handle);
|
StatusIcon.PositionMenu (menu, out x, out y, out push_in, this.status_icon.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,19 +344,31 @@ namespace SparkleShare {
|
||||||
StateText = _("Welcome to SparkleShare!");
|
StateText = _("Welcome to SparkleShare!");
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
Pixbuf = AnimationFrames [0];
|
if (UseIndicator) {
|
||||||
|
this.indicator.IconName = "folder-pictures";
|
||||||
|
} else {
|
||||||
|
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (error) {
|
if (error) {
|
||||||
StateText = _("Not everything is synced");
|
StateText = _("Not everything is synced");
|
||||||
|
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
|
if (UseIndicator) {
|
||||||
|
this.indicator.IconName = "folder-music";
|
||||||
|
} else {
|
||||||
|
this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
|
StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")";
|
||||||
Application.Invoke (delegate {
|
Application.Invoke (delegate {
|
||||||
Pixbuf = AnimationFrames [0];
|
if (UseIndicator) {
|
||||||
|
this.indicator.IconName = "folder-pictures";
|
||||||
|
} else {
|
||||||
|
this.status_icon.Pixbuf = AnimationFrames [0];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,6 @@ namespace SparkleShare {
|
||||||
// Initialize the application
|
// Initialize the application
|
||||||
Application.Init ();
|
Application.Init ();
|
||||||
|
|
||||||
foreach (SparkleChangeSet change_set in SparkleShare.Controller.GetLog ()) {
|
|
||||||
Console.WriteLine (change_set.Timestamp.ToString ());
|
|
||||||
}
|
|
||||||
// Create the statusicon
|
// Create the statusicon
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue