Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
* Monsoon/MainWindow.cs:
Browse files Browse the repository at this point in the history
* Monsoon/PreferencesDialog.cs: Switch from Egg.TrayIcon to
  Gtk.StatusIcon

svn path=/trunk/monsoon/; revision=131594
  • Loading branch information
alanmcgovern committed Apr 13, 2009
1 parent 46b3fc8 commit 484a2f6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 39 deletions.
6 changes: 6 additions & 0 deletions Monsoon/ChangeLog
@@ -1,3 +1,9 @@
2009-04-13 Alan McGovern <alan.mcgovern@gmail.com>

* MainWindow.cs:
* PreferencesDialog.cs: Switch from Egg.TrayIcon to
Gtk.StatusIcon

2009-04-13 Alan McGovern <alan.mcgovern@gmail.com>

* MainWindow.cs:
Expand Down
56 changes: 20 additions & 36 deletions Monsoon/MainWindow.cs
Expand Up @@ -83,7 +83,7 @@ public partial class MainWindow: Gtk.Window

private Menu trayMenu;
//private ImageMenuItem quitItem;
private Egg.TrayIcon trayIcon;
private Gtk.StatusIcon trayIcon;

private RssManagerController rssManagerController;

Expand Down Expand Up @@ -310,13 +310,12 @@ void InitNatStatus ()
});
}

public Egg.TrayIcon TrayIcon {
public Gtk.StatusIcon TrayIcon {
get { return trayIcon; }
}

private void BuildTray()
{
EventBox eventBox = new EventBox ();
trayMenu = new Menu ();

ImageMenuItem quitItem = new ImageMenuItem (_("Quit"));
Expand Down Expand Up @@ -352,48 +351,28 @@ private void BuildTray()
trayMenu.Append (notifications);
trayMenu.Append (new SeparatorMenuItem());
trayMenu.Append (quitItem);

eventBox.Add (new Image (Stock.GoDown, IconSize.Menu));
eventBox.ButtonPressEvent += OnTrayClicked;
trayIcon = new Egg.TrayIcon (Defines.ApplicationName);
trayIcon.Icon = new Image (Stock.Network, IconSize.Menu).Pixbuf;
trayIcon.Add (eventBox);

Tooltips trayTip = new Tooltips();

trayIcon.EnterNotifyEvent += Event.Wrap ((EnterNotifyEventHandler) delegate {
trayTip.SetTip(trayIcon, "Monsoon - D: " + ByteConverter.ConvertSpeed(torrentController.Engine.TotalDownloadSpeed) +
" U: " + ByteConverter.ConvertSpeed(torrentController.Engine.TotalUploadSpeed), null);
});

if (Preferences.EnableTray)
trayIcon.ShowAll ();
}

private void OnTrayClicked(object sender, ButtonPressEventArgs args)
{
Gdk.EventButton eventButton = args.Event;

if(eventButton.Button == 1){

Gdk.Pixbuf image = Stetic.IconLoader.LoadIcon (this, Stock.GoDown, IconSize.SmallToolbar, 16);
trayIcon = new Gtk.StatusIcon (image);
TrayIcon.Activate += delegate {
if (Visible) {
int x, y;
GetPosition (out x, out y);
interfaceSettings.WindowXPos = x;
interfaceSettings.WindowYPos = y;
Hide();
} else {
Show();
Move (interfaceSettings.WindowXPos, interfaceSettings.WindowYPos);
}
}

if(eventButton.Button == 3){
// show context menu
Visible = !Visible;
};
TrayIcon.PopupMenu += delegate {
trayMenu.ShowAll ();
trayMenu.Popup();
}
trayMenu.Popup ();
};
TrayIcon.Tooltip = Defines.ApplicationName;
ShowAll ();
}

private void LoadAllSettings ()
{
try
Expand Down Expand Up @@ -614,7 +593,7 @@ void HandleStateChanged(object sender, StateChangedEventArgs args)
try {
Notifications.Notification notify = new Notifications.Notification (_("Download Complete"), manager.Torrent.Name, Stock.GoDown);
if (Preferences.EnableTray)
notify.AttachToWidget (TrayIcon);
notify.Show ();
notify.Urgency = Notifications.Urgency.Low;
notify.Timeout = 5000;
notify.Show ();
Expand Down Expand Up @@ -840,6 +819,11 @@ private void updateStatusBar()

statusUpButton.Text = string.Format("{0}{1}", limited,
ByteConverter.ConvertSpeed (torrentController.Engine.TotalUploadSpeed));

TrayIcon.Tooltip = string.Format ("{0} - D: {1} U: {2}",
Defines.ApplicationName,
ByteConverter.ConvertSpeed(torrentController.Engine.TotalDownloadSpeed),
ByteConverter.ConvertSpeed(torrentController.Engine.TotalUploadSpeed));
}


Expand Down
6 changes: 3 additions & 3 deletions Monsoon/PreferencesDialog.cs
Expand Up @@ -49,7 +49,7 @@ public partial class PreferencesDialog : Gtk.Dialog
private LabelController labelController;
private LabelTreeView labelTreeView;

private Egg.TrayIcon trayIcon;
private Gtk.StatusIcon trayIcon;
//private IconEntry selectIcon;
private string selectedIcon;
private Button selectButton;
Expand Down Expand Up @@ -151,11 +151,11 @@ private void OnEnableTrayToggled (object sender, EventArgs args)
{
prefSettings.EnableTray = enableTrayCheckButton.Active;
if(!prefSettings.EnableTray){
trayIcon.HideAll();
trayIcon.Visible = false;
prefSettings.QuitOnClose = prefSettings.EnableTray;
minimizeTrayCheckButton.Active = prefSettings.EnableTray;
} else {
trayIcon.ShowAll();
trayIcon.Visible = true;
}

minimizeTrayCheckButton.Sensitive = prefSettings.EnableTray;
Expand Down

0 comments on commit 484a2f6

Please sign in to comment.