[controller] Fix size not being updated in statusicon

This commit is contained in:
Hylke Bons 2011-02-07 19:25:28 +00:00
parent 634a9a8b9d
commit 2d7e133137
4 changed files with 44 additions and 13 deletions

View file

@ -63,16 +63,6 @@ namespace SparkleShare {
Directory.CreateDirectory (SparklePaths.SparklePath); Directory.CreateDirectory (SparklePaths.SparklePath);
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
"Pixmaps", "sparkleshare-folder.icns");
NSImage folder_icon = new NSImage (folder_icon_path);
NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon,
SparklePaths.SparklePath, 0);
return true; return true;
} else { } else {

View file

@ -16,6 +16,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Timers; using System.Timers;
using MonoMac.Foundation; using MonoMac.Foundation;
using MonoMac.AppKit; using MonoMac.AppKit;
@ -69,7 +70,12 @@ namespace SparkleShare {
SparkleShare.Controller.FolderSizeChanged += delegate { SparkleShare.Controller.FolderSizeChanged += delegate {
InvokeOnMainThread (delegate { InvokeOnMainThread (delegate {
if (!Animation.Enabled)
SetNormalState ();
UpdateMenu (); UpdateMenu ();
}); });
}; };
@ -160,8 +166,12 @@ namespace SparkleShare {
FolderMenuItem.Activated += delegate { FolderMenuItem.Activated += delegate {
SparkleShare.Controller.OpenSparkleShareFolder (); SparkleShare.Controller.OpenSparkleShareFolder ();
}; };
FolderMenuItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare-mac-16.png"); string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
"sparkleshare.icns");
FolderMenuItem.Image = new NSImage (folder_icon_path);
FolderMenuItem.Image.Size = new SizeF (16, 16); FolderMenuItem.Image.Size = new SizeF (16, 16);
Menu.AddItem (FolderMenuItem); Menu.AddItem (FolderMenuItem);

View file

@ -44,7 +44,8 @@ namespace SparkleShare {
{ {
NSApplication.Init (); NSApplication.Init ();
SetSparkleIcon ();
// TODO: Getting crashes when I remove this // TODO: Getting crashes when I remove this
NSApplication.SharedApplication.ApplicationIconImage NSApplication.SharedApplication.ApplicationIconImage
@ -92,7 +93,21 @@ namespace SparkleShare {
}); });
}; };
}
public void SetSparkleIcon ()
{
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
"sparkleshare.icns");
NSImage folder_icon = new NSImage (folder_icon_path);
NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon,
SparkleShare.Controller.SparklePath, 0);
} }

View file

@ -36,6 +36,8 @@ namespace SparkleShare {
public List <SparkleRepo> Repositories; public List <SparkleRepo> Repositories;
public string FolderSize; public string FolderSize;
public bool FirstRun; public bool FirstRun;
public readonly string SparklePath;
public event OnQuitWhileSyncingEventHandler OnQuitWhileSyncing; public event OnQuitWhileSyncingEventHandler OnQuitWhileSyncing;
@ -86,7 +88,9 @@ namespace SparkleShare {
AddToBookmarks (); AddToBookmarks ();
FolderSize = GetFolderSize (); FolderSize = GetFolderSize ();
SparklePath = SparklePaths.SparklePath;
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config"); string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
@ -555,6 +559,12 @@ namespace SparkleShare {
if (FolderListChanged != null) if (FolderListChanged != null)
FolderListChanged (); FolderListChanged ();
FolderSize = GetFolderSize ();
if (FolderSizeChanged != null)
FolderSizeChanged (FolderSize);
} }
@ -584,6 +594,12 @@ namespace SparkleShare {
if (FolderListChanged != null) if (FolderListChanged != null)
FolderListChanged (); FolderListChanged ();
FolderSize = GetFolderSize ();
if (FolderSizeChanged != null)
FolderSizeChanged (FolderSize);
} }