PageRenderTime 17ms CodeModel.GetById 8ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/SparkleShare/Mac/SparkleUI.cs

http://github.com/hbons/SparkleShare
C# | 97 lines | 57 code | 23 blank | 17 comment | 4 complexity | 122836acd53dd068ea4b502f985beb29 MD5 | raw file
 1//   SparkleShare, a collaboration and sharing tool.
 2//   Copyright (C) 2010  Hylke Bons <hylkebons@gmail.com>
 3//
 4//   This program is free software: you can redistribute it and/or modify
 5//   it under the terms of the GNU General Public License as published by
 6//   the Free Software Foundation, either version 3 of the License, or
 7//   (at your option) any later version.
 8//
 9//   This program is distributed in the hope that it will be useful,
10//   but WITHOUT ANY WARRANTY; without even the implied warranty of
11//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//   GNU General Public License for more details.
13//
14//   You should have received a copy of the GNU General Public License
15//   along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17    
18using System;
19
20using MonoMac.Foundation;
21using MonoMac.AppKit;
22
23namespace SparkleShare {
24
25    public class SparkleUI : AppDelegate {
26
27        public SparkleStatusIcon StatusIcon;
28        public SparkleEventLog EventLog;
29        public SparkleSetup Setup;
30        public SparkleBubbles Bubbles;
31        public SparkleAbout About;
32        public SparkleNote Note;
33		
34        public static string FontName = "Helvetica Neue";
35
36        public SparkleUI ()
37        {
38            if (Environment.OSVersion.Version.Major < 14)
39                FontName = "Lucida Grande";
40
41            Program.Controller.Invoke (() => {
42                if (Environment.OSVersion.Version.Major >= 14) {
43                    NSWorkspace.SharedWorkspace.SetIconforFile (
44                        NSImage.ImageNamed ("sparkleshare-folder-yosemite.icns"),
45                        Program.Controller.FoldersPath, 0);
46
47                } else {
48                    NSWorkspace.SharedWorkspace.SetIconforFile (
49                        NSImage.ImageNamed ("sparkleshare-folder.icns"),
50                        Program.Controller.FoldersPath, 0);
51                }
52
53                NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns");
54    
55                Setup      = new SparkleSetup ();
56                EventLog   = new SparkleEventLog ();
57                About      = new SparkleAbout ();
58                Note       = new SparkleNote ();
59                Bubbles    = new SparkleBubbles ();
60                StatusIcon = new SparkleStatusIcon ();
61            });
62
63            Program.Controller.UIHasLoaded ();
64        }
65
66
67        public void Run ()
68        {
69            NSApplication.Main (Program.Arguments);
70        }
71
72
73        public void UpdateDockIconVisibility ()
74        {
75//          if (Setup.IsVisible || EventLog.IsVisible || About.IsVisible)
76//              NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
77        }
78    }
79
80
81    public partial class AppDelegate : NSApplicationDelegate {
82     
83        public override void WillTerminate (NSNotification notification)
84        {
85            Program.Controller.Quit ();
86        }
87
88        
89        public override bool ApplicationShouldHandleReopen (NSApplication sender, bool has_visible_windows)
90        {
91            if (!has_visible_windows)
92                Program.Controller.HandleReopen ();
93
94            return true;
95        }
96    }
97}