Inheritance: Gtk.ImageMenuItem
        // Creates the menu that is popped up when the
        // user clicks the status icon
        public void CreateMenu()
        {
            this.menu = new Menu ();

                // The menu item showing the status and size of the SparkleShare folder
                MenuItem status_menu_item = new MenuItem (this.state_text) {
                    Sensitive = false
                };

            this.menu.Add (status_menu_item);
            this.menu.Add (new SeparatorMenuItem ());

                ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare"){
                    Image = new Image (SparkleUIHelpers.GetIcon ("folder-sparkleshare", 16))
                };

                folder_item.Activated += delegate {
                    Controller.SparkleShareClicked ();
                };

            this.menu.Add (folder_item);

                if (Program.Controller.Folders.Count > 0) {

                    // Creates a menu item for each repository with a link to their logs
                    foreach (string folder_name in Program.Controller.Folders) {
                        Gdk.Pixbuf folder_icon;

                        if (Program.Controller.UnsyncedFolders.Contains (folder_name)) {
                            folder_icon = IconTheme.Default.LoadIcon ("dialog-error", 16,
                                IconLookupFlags.GenericFallback);

                        } else {
                            folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
                                IconLookupFlags.GenericFallback);
                        }

                        ImageMenuItem subfolder_item = new SparkleMenuItem (folder_name) {
                            Image = new Image (folder_icon)
                        };

                        subfolder_item.Activated += OpenFolderDelegate (folder_name);
                        this.menu.Add (subfolder_item);
                    }

                } else {
                    MenuItem no_folders_item = new MenuItem (_("No projects yet")) {
                        Sensitive   = false
                    };

                    this.menu.Add (no_folders_item);
                }

                this.menu.Add (new SeparatorMenuItem ());

                // Opens the wizard to add a new remote folder
                MenuItem sync_item = new MenuItem (_("Add Hosted Project…"));

                sync_item.Activated += delegate {
                    Controller.AddHostedProjectClicked ();
                };

            this.menu.Add (sync_item);
            this.menu.Add (new SeparatorMenuItem ());

            MenuItem recent_events_item = new MenuItem (_("View Recent Changes…"));

                recent_events_item.Sensitive = (Controller.Folders.Length > 0);

                recent_events_item.Activated += delegate {
                    Controller.OpenRecentEventsClicked ();
                };

            this.menu.Add (recent_events_item);

            MenuItem notify_item;

                if (Program.Controller.NotificationsEnabled)
                    notify_item = new MenuItem (_("Turn Notifications Off"));
                else
                    notify_item = new MenuItem (_("Turn Notifications On"));

                notify_item.Activated += delegate {
                    Program.Controller.ToggleNotifications ();
                    CreateMenu ();
                };

            this.menu.Add (notify_item);
            this.menu.Add (new SeparatorMenuItem ());

                // A menu item that takes the user to http://www.sparkleshare.org/
                MenuItem about_item = new MenuItem (_("About SparkleShare"));

                about_item.Activated += delegate {
                    Controller.AboutClicked ();
                };

            this.menu.Add (about_item);
            this.menu.Add (new SeparatorMenuItem ());

                // A menu item that quits the application
                this.quit_item = new MenuItem (_("Quit")) {
                    Sensitive = Controller.QuitItemEnabled
                };

                this.quit_item.Activated += delegate {
                    Program.Controller.Quit ();
                };

            this.menu.Add (this.quit_item);
            this.menu.ShowAll ();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
            #endif
        }
        public void CreateMenu()
        {
            this.menu = new Menu ();

                this.state_item = new MenuItem (Controller.StateText) {
                    Sensitive = false
                };

            this.menu.Add (this.state_item);
            this.menu.Add (new SeparatorMenuItem ());

                ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare"){
                    Image = new Image (SparkleUIHelpers.GetIcon ("folder-sparkleshare", 16))
                };

                folder_item.Activated += delegate {
                    Controller.SparkleShareClicked ();
                };

            this.menu.Add (folder_item);

                if (Program.Controller.Folders.Count > 0) {
                    foreach (string folder_name in Controller.Folders) {
                        Gdk.Pixbuf folder_icon;

                        if (Program.Controller.UnsyncedFolders.Contains (folder_name)) {
                            folder_icon = IconTheme.Default.LoadIcon ("dialog-error", 16,
                                IconLookupFlags.GenericFallback);

                        } else {
                            folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
                                IconLookupFlags.GenericFallback);
                        }

                        ImageMenuItem subfolder_item = new SparkleMenuItem (folder_name) {
                            Image = new Image (folder_icon)
                        };

                        subfolder_item.Activated += OpenFolderDelegate (folder_name);
                        this.menu.Add (subfolder_item);
                    }

                    Menu submenu = new Menu ();

                    foreach (string folder_name in Controller.OverflowFolders) {
                        Gdk.Pixbuf folder_icon;

                        if (Program.Controller.UnsyncedFolders.Contains (folder_name)) {
                            folder_icon = IconTheme.Default.LoadIcon ("dialog-error", 16,
                                IconLookupFlags.GenericFallback);

                        } else {
                            folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
                                IconLookupFlags.GenericFallback);
                        }

                        ImageMenuItem subfolder_item = new SparkleMenuItem (folder_name) {
                            Image = new Image (folder_icon)
                        };

                        subfolder_item.Activated += OpenFolderDelegate (folder_name);
                        submenu.Add (subfolder_item);
                    }

                    if (submenu.Children.Length > 0) {
                        SparkleMenuItem more_item = new SparkleMenuItem ("More Projects") {
                            Submenu = submenu
                        };

                        this.menu.Add (new SeparatorMenuItem ());
                        this.menu.Add (more_item);
                    }

                }

                this.menu.Add (new SeparatorMenuItem ());

                MenuItem sync_item = new MenuItem (_("Add Hosted Project…"));

                sync_item.Activated += delegate {
                    Controller.AddHostedProjectClicked ();
                };

            this.menu.Add (sync_item);

            this.recent_events_item = new MenuItem (_("Recent Changes…"));

                this.recent_events_item.Sensitive = Controller.OpenRecentEventsItemEnabled;

                this.recent_events_item.Activated += delegate {
                    Controller.OpenRecentEventsClicked ();
                };

            this.menu.Add (this.recent_events_item);
            this.menu.Add (new SeparatorMenuItem ());

            MenuItem notify_item;

                if (Program.Controller.NotificationsEnabled)
                    notify_item = new MenuItem (_("Turn Notifications Off"));
                else
                    notify_item = new MenuItem (_("Turn Notifications On"));

                notify_item.Activated += delegate {
                    Application.Invoke (delegate {
                        Program.Controller.ToggleNotifications ();

                        if (Program.Controller.NotificationsEnabled)
                            (notify_item.Child as Label).Text = _("Turn Notifications Off");
                        else
                            (notify_item.Child as Label).Text = _("Turn Notifications On");
                    });
                };

            this.menu.Add (notify_item);
            this.menu.Add (new SeparatorMenuItem ());

                MenuItem about_item = new MenuItem (_("About SparkleShare"));

                about_item.Activated += delegate {
                    Controller.AboutClicked ();
                };

            this.menu.Add (about_item);
            this.menu.Add (new SeparatorMenuItem ());

                this.quit_item = new MenuItem (_("Quit")) {
                    Sensitive = Controller.QuitItemEnabled
                };

                this.quit_item.Activated += delegate {
                    Controller.QuitClicked ();
                };

            this.menu.Add (this.quit_item);
            this.menu.ShowAll ();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
            #endif
        }
Example #3
0
        public void CreateMenu()
        {
            this.context_menu = new ContextMenu ();

            status_item = new SparkleMenuItem () {
                Header    = StateText,
                IsEnabled = false
            };

            Image folder_image = new Image () {
                Source = SparkleUIHelpers.GetImageSource ("folder-sparkleshare-windows-16"),
                Width  = 16,
                Height = 16
            };

            SparkleMenuItem folder_item = new SparkleMenuItem () {
                Header = "SparkleShare",
                Icon   = folder_image
            };

                folder_item.Click += delegate {
                    Controller.SparkleShareClicked ();
                };

            SparkleMenuItem add_item = new SparkleMenuItem () {
                Header    = "Add hosted project…"
            };

                add_item.Click += delegate {
                    Controller.AddHostedProjectClicked ();
                };

            SparkleMenuItem log_item = new SparkleMenuItem () {
                Header    = "View recent changes…",
                IsEnabled = (Program.Controller.Folders.Count > 0)
            };

                log_item.Click += delegate {
                    Controller.OpenRecentEventsClicked ();
                };

            SparkleMenuItem notify_item = new SparkleMenuItem () {
                Header      = "Notifications"
            };

                CheckBox notify_check_box = new CheckBox () {
                    Margin = new Thickness (6,0,0,0),
                    IsChecked   = Program.Controller.NotificationsEnabled
                };

                notify_item.Icon = notify_check_box;

                notify_item.Click += delegate {
                    Program.Controller.ToggleNotifications ();
                    notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
                };

            SparkleMenuItem about_item = new SparkleMenuItem () {
                Header = "About SparkleShare"
            };

                about_item.Click += delegate {
                     Controller.AboutClicked ();
                };

            exit_item = new SparkleMenuItem () {
                Header = "Exit"
            };

                this.exit_item.Click += delegate {
                    this.notify_icon.Dispose ();
                    Controller.QuitClicked ();
                };

            this.context_menu.Items.Add (status_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (folder_item);

            if (Program.Controller.Folders.Count > 0) {
                foreach (string folder_name in Program.Controller.Folders) {
                    SparkleMenuItem subfolder_item = new SparkleMenuItem () {
                        Header = folder_name
                    };

                    subfolder_item.Click += OpenFolderDelegate (folder_name);

                    Image subfolder_image = new Image () {
                        Source = SparkleUIHelpers.GetImageSource ("folder-windows-16"),
                        Width  = 16,
                        Height = 16
                    };

                    subfolder_item.Icon = subfolder_image;

                    /* TODO
                    if (Program.Controller.UnsyncedFolders.Contains (folder_name))
                        subfolder_item.Icon = Icons.dialog_error_16;
                    else
                        subfolder_item.Icon = Icons.sparkleshare_windows_status;
                     */

                    this.context_menu.Items.Add (subfolder_item);
                }

            } else {
                SparkleMenuItem no_folders_item = new SparkleMenuItem () {
                    Header    = "No projects yet",
                    IsEnabled = false
                };

                this.context_menu.Items.Add (no_folders_item);
            }

            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (add_item);
            this.context_menu.Items.Add (log_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (notify_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (about_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (this.exit_item);

            this.notify_icon.ContextMenu = this.context_menu;
        }
        public void CreateMenu()
        {
            this.menu       = new Menu ();
            this.state_item = new MenuItem (Controller.StateText) { Sensitive = false };

            ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare");
            folder_item.Image = new Image (SparkleUIHelpers.GetIcon ("sparkleshare", 16));

            this.menu.Add (this.state_item);
            this.menu.Add (new SeparatorMenuItem ());
            this.menu.Add (folder_item);

            if (Program.Controller.Folders.Count > 0) {
                int i = 0;
                foreach (string folder_name in Controller.Folders) {
                    ImageMenuItem item = new SparkleMenuItem (folder_name);
                    Gdk.Pixbuf folder_icon;

                    if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
                        folder_icon = IconTheme.Default.LoadIcon ("dialog-warning", 16, IconLookupFlags.GenericFallback);
                        item.Submenu = new Menu ();

                        MenuItem error_item = new MenuItem (Controller.FolderErrors [i]) { Sensitive = false };
                        MenuItem try_again_item = new MenuItem ("Try Again");
                        try_again_item.Activated += Controller.TryAgainDelegate (folder_name);

                        (item.Submenu as Menu).Add (error_item);
                        (item.Submenu as Menu).Add (new SeparatorMenuItem ());
                        (item.Submenu as Menu).Add (try_again_item);

                    } else {
                        folder_icon = IconTheme.Default.LoadIcon ("folder", 16, IconLookupFlags.GenericFallback);
                        item.Activated += Controller.OpenFolderDelegate (folder_name);
                    }

                    (item.Child as Label).UseUnderline = false;
                    item.Image = new Image (folder_icon);
                    this.menu.Add (item);

                    i++;
                }
            }

            this.recent_events_item = new MenuItem ("Recent Changes…");
            this.recent_events_item.Sensitive = Controller.RecentEventsItemEnabled;
            this.quit_item    = new MenuItem ("Quit") { Sensitive = Controller.QuitItemEnabled };
            MenuItem add_item = new MenuItem ("Add Hosted Project…");
            MenuItem notify_item;

            if (Program.Controller.NotificationsEnabled)
                notify_item = new MenuItem ("Turn Notifications Off");
            else
                notify_item = new MenuItem ("Turn Notifications On");

            notify_item.Activated += delegate {
                Program.Controller.ToggleNotifications ();

                Application.Invoke (delegate {
                    if (Program.Controller.NotificationsEnabled)
                        (notify_item.Child as Label).Text = "Turn Notifications Off";
                    else
                        (notify_item.Child as Label).Text = "Turn Notifications On";
                });
            };

            MenuItem link_code_item = new MenuItem ("Link Code");

            if (Controller.LinkCodeItemEnabled) {
                link_code_item.Submenu = new Menu ();

                MenuItem code_item = new MenuItem ();
                (code_item.Child as Label).Text = Program.Controller.CurrentUser.PublicKey.Substring (0, 20) + "...";

                MenuItem copy_item = new MenuItem ("Copy to Clipboard");
                copy_item.Activated += delegate { Controller.CopyToClipboardClicked (); };

                (link_code_item.Submenu as Menu).Add (code_item);
                (link_code_item.Submenu as Menu).Add (new SeperatorMenuItem ());
                (link_code_item.Submenu as Menu).Add (copy_item);
            }

            MenuItem about_item = new MenuItem ("About SparkleShare");

            about_item.Activated              += delegate { Controller.AboutClicked (); };
            add_item.Activated                += delegate { Controller.AddHostedProjectClicked (); };
            this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked (); };
            this.quit_item.Activated          += delegate { Controller.QuitClicked (); };

            folder_item.Submenu = new Menu ();
            (folder_item.Submenu as Menu).Add (this.recent_events_item);
            (folder_item.Submenu as Menu).Add (add_item);
            (folder_item.Submenu as Menu).Add (new SeparatorMenuItem ());
            (folder_item.Submenu as Menu).Add (notify_item);
            (folder_item.Submenu as Menu).Add (new SeparatorMenuItem ());
            (folder_item.Submenu as Menu).Add (link_code_item);
            (folder_item.Submenu as Menu).Add (new SeparatorMenuItem ());
            (folder_item.Submenu as Menu).Add (about_item);

            this.menu.Add (new SeparatorMenuItem ());
            this.menu.Add (this.quit_item);
            this.menu.ShowAll ();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
            #endif
        }
Example #5
0
        // Creates the menu that is popped up when the
        // user clicks the status icon
        public void CreateMenu()
        {
            Menu = new Menu();

            // The menu item showing the status and size of the SparkleShare folder
            MenuItem status_menu_item = new MenuItem(StateText)
            {
                Sensitive = false
            };

            Menu.Add(status_menu_item);
            Menu.Add(new SeparatorMenuItem());

            ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare")
            {
                Image = new Image(SparkleUIHelpers.GetIcon("folder-sparkleshare", 16))
            };

            folder_item.Activated += delegate {
                SparkleShare.Controller.OpenSparkleShareFolder();
            };

            Menu.Add(folder_item);

            if (SparkleShare.Controller.Folders.Count > 0)
            {
                // Creates a menu item for each repository with a link to their logs
                foreach (string path in SparkleShare.Controller.Folders)
                {
                    Gdk.Pixbuf folder_icon = IconTheme.Default.LoadIcon("folder", 16,
                                                                        IconLookupFlags.GenericFallback);

                    ImageMenuItem subfolder_item = new SparkleMenuItem(Path.GetFileName(path))
                    {
                        Image = new Image(folder_icon)
                    };

//						if (repo.HasUnsyncedChanges)
//							folder_action.IconName = "dialog-error";

                    subfolder_item.Activated += OpenEventLogDelegate(path);

                    Menu.Add(subfolder_item);
                }
            }
            else
            {
                MenuItem no_folders_item = new MenuItem(_("No Remote Folders Yet"))
                {
                    Sensitive = false
                };

                Menu.Add(no_folders_item);
            }

            // Opens the wizard to add a new remote folder
            MenuItem sync_item = new MenuItem(_("Add Remote Folder…"));

            if (SparkleShare.Controller.FirstRun)
            {
                sync_item.Sensitive = false;
            }

            sync_item.Activated += delegate {
                Application.Invoke(delegate {
                    if (SparkleUI.Intro == null)
                    {
                        SparkleUI.Intro = new SparkleIntro();
                        SparkleUI.Intro.ShowServerForm(true);
                    }

                    if (!SparkleUI.Intro.Visible)
                    {
                        SparkleUI.Intro.ShowServerForm(true);
                    }

                    SparkleUI.Intro.ShowAll();
                    SparkleUI.Intro.Present();
                });
            };

            Menu.Add(sync_item);
            Menu.Add(new SeparatorMenuItem());

            MenuItem notify_item;

            if (SparkleShare.Controller.NotificationsEnabled)
            {
                notify_item = new MenuItem(_("Turn Notifications Off"));
            }
            else
            {
                notify_item = new MenuItem(_("Turn Notifications On"));
            }

            notify_item.Activated += delegate {
                SparkleShare.Controller.ToggleNotifications();
                CreateMenu();
            };

            Menu.Add(notify_item);
            Menu.Add(new SeparatorMenuItem());

            // A menu item that takes the user to http://www.sparkleshare.org/
            MenuItem about_item = new MenuItem(_("About SparkleShare"));

            about_item.Activated += delegate {
                SparkleDialog dialog = new SparkleDialog();
                dialog.ShowAll();
            };

            Menu.Add(about_item);
            Menu.Add(new SeparatorMenuItem());

            // A menu item that quits the application
            MenuItem quit_item = new MenuItem(_("Quit"));

            quit_item.Activated += delegate {
                SparkleShare.Controller.Quit();
            };

            Menu.Add(quit_item);

            Menu.ShowAll();
        }
        public void CreateMenu ()
        {
            this.context_menu = new ContextMenu ();

            this.state_item = new SparkleMenuItem () {
                Header    = Controller.StateText,
                IsEnabled = false
            };
            
            Image folder_image = new Image () {
                Source = SparkleUIHelpers.GetImageSource ("sparkleshare-folder"),
                Width  = 16,
                Height = 16
            };
            
            SparkleMenuItem folder_item = new SparkleMenuItem () {
                Header = "SparkleShare",
                Icon   = folder_image
            };
            
            SparkleMenuItem add_item = new SparkleMenuItem () { Header = "Add hosted project…" };
            
            this.log_item = new SparkleMenuItem () {
                Header    = "Recent changes…",
                IsEnabled = Controller.RecentEventsItemEnabled
            };

            SparkleMenuItem link_code_item = new SparkleMenuItem () { Header = "Client ID" };
            
            if (Controller.LinkCodeItemEnabled) {
                SparkleMenuItem code_item = new SparkleMenuItem ();
                code_item.Header = Program.Controller.CurrentUser.PublicKey.Substring (0, 20) + "...";
                
                SparkleMenuItem copy_item = new SparkleMenuItem () { Header = "Copy to Clipboard" };
                copy_item.Click += delegate { Controller.CopyToClipboardClicked (); };
                
                link_code_item.Items.Add (code_item);
                link_code_item.Items.Add (new Separator());
                link_code_item.Items.Add (copy_item);
            }

            CheckBox notify_check_box = new CheckBox () {
                Margin    = new Thickness (6, 0, 0, 0),
                IsChecked = Program.Controller.NotificationsEnabled
            };
            
            SparkleMenuItem notify_item = new SparkleMenuItem () { Header = "Notifications" };
            notify_item.Icon = notify_check_box;

            SparkleMenuItem about_item = new SparkleMenuItem () { Header = "About SparkleShare" };
            this.exit_item = new SparkleMenuItem () { Header = "Exit" };
            
            
			add_item.Click      += delegate { Controller.AddHostedProjectClicked (); };
			this.log_item.Click += delegate { Controller.RecentEventsClicked (); };
			about_item.Click    += delegate { Controller.AboutClicked (); };
            
            notify_check_box.Click += delegate {
                this.context_menu.IsOpen = false;
                Program.Controller.ToggleNotifications ();
                notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
            };
            
            notify_item.Click += delegate {
                Program.Controller.ToggleNotifications ();
                notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
            };
            
            this.exit_item.Click += delegate {
                this.notify_icon.Dispose ();
                Controller.QuitClicked ();
            };
            
            
            this.context_menu.Items.Add (this.state_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (folder_item);

            if (Controller.Folders.Length > 0) {
                int i = 0;
                foreach (string folder_name in Controller.Folders) {     
                    SparkleMenuItem subfolder_item = new SparkleMenuItem () {
                        Header = folder_name.Replace ("_", "__")
                    };
                    
                    Image subfolder_image = new Image () {
                        Source = SparkleUIHelpers.GetImageSource ("folder"),
                        Width  = 16,
                        Height = 16
                    };
                    
                    if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
                        subfolder_item.Icon = new Image () {
                            Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon (
                                System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
                                BitmapSizeOptions.FromWidthAndHeight (16,16))
                        };

                        SparkleMenuItem error_item = new SparkleMenuItem () {
                            Header    = Controller.FolderErrors [i],
                            IsEnabled = false
                        };
                        
                        SparkleMenuItem try_again_item = new SparkleMenuItem () {
                            Header = "Try again"
                        };

						try_again_item.Click += delegate { Controller.TryAgainDelegate (folder_name); };

                        subfolder_item.Items.Add (error_item);
                        subfolder_item.Items.Add (new Separator ());
                        subfolder_item.Items.Add (try_again_item);
                        
                    } else {
                        subfolder_item.Icon = subfolder_image;
						subfolder_item.Click += new RoutedEventHandler (Controller.OpenFolderDelegate (folder_name));
                    }
                    
                    this.context_menu.Items.Add (subfolder_item);
                    i++;
                }
            }

            folder_item.Items.Add (this.log_item);
            folder_item.Items.Add (add_item);
            folder_item.Items.Add (new Separator ());
            folder_item.Items.Add (notify_item);
            folder_item.Items.Add (new Separator ());
            folder_item.Items.Add (link_code_item);
            folder_item.Items.Add (new Separator ());
            folder_item.Items.Add (about_item);

            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (this.exit_item);
            
            this.notify_icon.ContextMenu = this.context_menu;
        }
Example #7
0
        public void CreateMenu()
        {
            this.context_menu = new ContextMenu();

            this.state_item = new SparkleMenuItem {
                Header = Controller.StateText,
                IsEnabled = false
            };

            Image folder_image = new Image {
                Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"),
                Width = 16,
                Height = 16
            };

            SparkleMenuItem folder_item = new SparkleMenuItem {
                Header = "SparkleShare",
                Icon = folder_image
            };

            SparkleMenuItem add_item = new SparkleMenuItem {
                Header = "Add hosted project…"
            };

            this.log_item = new SparkleMenuItem {
                Header = "Recent changes…",
                IsEnabled = Controller.RecentEventsItemEnabled
            };

            SparkleMenuItem link_code_item = new SparkleMenuItem {
                Header = "Client ID"
            };

            if(Controller.LinkCodeItemEnabled) {
                SparkleMenuItem code_item = new SparkleMenuItem {
                    Header = SparkleShare.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..."
                };

                SparkleMenuItem copy_item = new SparkleMenuItem {
                    Header = "Copy to Clipboard"
                };
                copy_item.Click += delegate {
                    Controller.CopyToClipboardClicked();
                };

                link_code_item.Items.Add(code_item);
                link_code_item.Items.Add(new Separator());
                link_code_item.Items.Add(copy_item);
            }

            CheckBox notify_check_box = new CheckBox {
                Margin = new Thickness(6, 0, 0, 0),
                IsChecked = SparkleShare.Controller.NotificationsEnabled
            };

            SparkleMenuItem notify_item = new SparkleMenuItem {
                Header = "Notifications",
                Icon = notify_check_box
            };

            SparkleMenuItem about_item = new SparkleMenuItem {
                Header = "About SparkleShare"
            };
            this.exit_item = new SparkleMenuItem {
                Header = "Exit"
            };

            add_item.Click += delegate {
                Controller.AddHostedProjectClicked();
            };
            this.log_item.Click += delegate {
                Controller.RecentEventsClicked();
            };
            about_item.Click += delegate {
                Controller.AboutClicked();
            };

            notify_check_box.Click += delegate {
                this.context_menu.IsOpen = false;
                SparkleShare.Controller.ToggleNotifications();
                notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled;
            };

            notify_item.Click += delegate {
                SparkleShare.Controller.ToggleNotifications();
                notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled;
            };

            this.exit_item.Click += delegate {
                this.notify_icon.Dispose();
                Controller.QuitClicked();
            };

            this.context_menu.Items.Add(this.state_item);
            this.context_menu.Items.Add(new Separator());
            this.context_menu.Items.Add(folder_item);

            state_menu_items = new SparkleMenuItem[Controller.Projects.Length];

            if(Controller.Projects.Length > 0) {
                int i = 0;
                foreach(ProjectInfo project in Controller.Projects) {

                    SparkleMenuItem subfolder_item = new SparkleMenuItem {
                        Header = project.Name.Replace("_", "__"),
                        Icon = new Image {
                            Source = SparkleUIHelpers.GetImageSource("folder"),
                            Width = 16,
                            Height = 16
                        }
                    };

                    state_menu_items[i] = new SparkleMenuItem {
                        Header = project.StatusMessage,
                        IsEnabled = false
                    };

                    subfolder_item.Items.Add(state_menu_items[i]);
                    subfolder_item.Items.Add(new Separator());

                    SparkleMenuItem open_item = new SparkleMenuItem {
                        Header = "Open folder",
                        Icon = new Image
                        {
                            Source = SparkleUIHelpers.GetImageSource("folder"),
                            Width = 16,
                            Height = 16
                        }
                    };

                    open_item.Click += new RoutedEventHandler(Controller.OpenFolderDelegate(project.Name));
                    subfolder_item.Items.Add(open_item);
                    subfolder_item.Items.Add(new Separator());

                    if(project.IsPaused) {
                        SparkleMenuItem resume_item;

                        if(project.UnsyncedChangesInfo.Count > 0) {
                            foreach(KeyValuePair<string, string> pair in project.UnsyncedChangesInfo)
                                subfolder_item.Items.Add(new SparkleMenuItem {
                                    Header = pair.Key,
                                    // TODO image
                                    IsEnabled = false
                                });

                            if(!string.IsNullOrEmpty(project.MoreUnsyncedChanges)) {
                                subfolder_item.Items.Add(new SparkleMenuItem {
                                    Header = project.MoreUnsyncedChanges,
                                    IsEnabled = false
                                });
                            }

                            subfolder_item.Items.Add(new Separator());
                            resume_item = new SparkleMenuItem {
                                Header = "Sync and Resume…"
                            };

                        } else {
                            resume_item = new SparkleMenuItem {
                                Header = "Resume"
                            };
                        }

                        resume_item.Click += (sender, e) => Controller.ResumeDelegate(project.Name)(sender, e);
                        subfolder_item.Items.Add(resume_item);

                    } else {
                        if(Controller.Projects[i].HasError) {
                            subfolder_item.Icon = new Image {
                                Source = Imaging.CreateBitmapSourceFromHIcon(
                                    Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
                                    BitmapSizeOptions.FromWidthAndHeight(16, 16))
                            };

                            SparkleMenuItem try_again_item = new SparkleMenuItem {
                                Header = "Retry Sync"
                            };
                            try_again_item.Click += (sender, e) => Controller.TryAgainDelegate(project.Name)(sender, e);
                            subfolder_item.Items.Add(try_again_item);

                        } else {
                            SparkleMenuItem pause_item = new SparkleMenuItem {
                                Header = "Pause"
                            };
                            pause_item.Click +=
                                (sender, e) => Controller.PauseDelegate(project.Name)(sender, e);
                            subfolder_item.Items.Add(pause_item);
                        }
                    }

                    this.context_menu.Items.Add(subfolder_item);
                    i++;
                };
            }

            folder_item.Items.Add(this.log_item);
            folder_item.Items.Add(add_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(notify_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(link_code_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(about_item);

            this.context_menu.Items.Add(new Separator());
            this.context_menu.Items.Add(this.exit_item);

            this.notify_icon.ContextMenu = this.context_menu;
        }
        public void CreateMenu()
        {
            this.context_menu = new ContextMenu();

            this.state_item = new SparkleMenuItem()
            {
                Header    = Controller.StateText,
                IsEnabled = false
            };

            Image folder_image = new Image()
            {
                Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"),
                Width  = 16,
                Height = 16
            };

            SparkleMenuItem folder_item = new SparkleMenuItem()
            {
                Header = "SparkleShare",
                Icon   = folder_image
            };

            SparkleMenuItem add_item = new SparkleMenuItem()
            {
                Header = "Add hosted project…"
            };

            this.log_item = new SparkleMenuItem()
            {
                Header    = "Recent changes…",
                IsEnabled = Controller.RecentEventsItemEnabled
            };

            CheckBox notify_check_box = new CheckBox()
            {
                Margin    = new Thickness(6, 0, 0, 0),
                IsChecked = (Controller.Folders.Length > 0 && Program.Controller.NotificationsEnabled)
            };

            SparkleMenuItem notify_item = new SparkleMenuItem()
            {
                Header = "Notifications"
            };

            notify_item.Icon = notify_check_box;

            SparkleMenuItem about_item = new SparkleMenuItem()
            {
                Header = "About SparkleShare"
            };

            this.exit_item = new SparkleMenuItem()
            {
                Header = "Exit"
            };


            add_item.Click      += Controller.AddHostedProjectClicked;
            this.log_item.Click += Controller.RecentEventsClicked;
            about_item.Click    += Controller.AboutClicked;

            notify_check_box.Click += delegate {
                this.context_menu.IsOpen = false;
                Program.Controller.ToggleNotifications();
                notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
            };

            notify_item.Click += delegate {
                Program.Controller.ToggleNotifications();
                notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
            };

            this.exit_item.Click += delegate {
                this.notify_icon.Dispose();
                Controller.QuitClicked();
            };


            this.context_menu.Items.Add(this.state_item);
            this.context_menu.Items.Add(new Separator());
            this.context_menu.Items.Add(folder_item);

            if (Controller.Folders.Length > 0)
            {
                int i = 0;
                foreach (string folder_name in Controller.Folders)
                {
                    SparkleMenuItem subfolder_item = new SparkleMenuItem()
                    {
                        Header = folder_name.Replace("_", "__")
                    };

                    Image subfolder_image = new Image()
                    {
                        Source = SparkleUIHelpers.GetImageSource("folder"),
                        Width  = 16,
                        Height = 16
                    };

                    if (!string.IsNullOrEmpty(Controller.FolderErrors [i]))
                    {
                        subfolder_item.Icon = new Image()
                        {
                            Source = (BitmapSource)Imaging.CreateBitmapSourceFromHIcon(
                                System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
                                BitmapSizeOptions.FromWidthAndHeight(16, 16))
                        };

                        SparkleMenuItem error_item = new SparkleMenuItem()
                        {
                            Header    = Controller.FolderErrors [i],
                            IsEnabled = false
                        };

                        SparkleMenuItem try_again_item = new SparkleMenuItem()
                        {
                            Header = "Try again"
                        };

                        try_again_item.Click += Controller.TryAgainDelegate(folder_name);

                        subfolder_item.Items.Add(error_item);
                        subfolder_item.Items.Add(new Separator());
                        subfolder_item.Items.Add(try_again_item);
                    }
                    else
                    {
                        subfolder_item.Icon   = subfolder_image;
                        subfolder_item.Click += Controller.OpenFolderDelegate(folder_name);
                    }

                    this.context_menu.Items.Add(subfolder_item);
                    i++;
                }
            }

            folder_item.Items.Add(this.log_item);
            folder_item.Items.Add(add_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(notify_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(about_item);

            this.context_menu.Items.Add(new Separator());
            this.context_menu.Items.Add(this.exit_item);

            this.notify_icon.ContextMenu = this.context_menu;
        }
Example #9
0
        public void CreateMenu()
        {
            this.menu       = new Menu();
            this.state_item = new MenuItem(Controller.StateText)
            {
                Sensitive = false
            };

            ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare");

            folder_item.Image = new Image(UserInterfaceHelpers.GetIcon("org.sparkleshare.SparkleShare", 16));

            this.menu.Add(this.state_item);
            this.menu.Add(new SeparatorMenuItem());
            this.menu.Add(folder_item);


            this.state_menu_items = new SparkleMenuItem [Controller.Projects.Length];

            if (Controller.Projects.Length > 0)
            {
                int i = 0;
                foreach (ProjectInfo project in Controller.Projects)
                {
                    SparkleMenuItem item        = new SparkleMenuItem(project.Name);
                    Gdk.Pixbuf      folder_icon = UserInterfaceHelpers.GetIcon("folder", 16);

                    item.Submenu = new Menu();

                    this.state_menu_items [i] = new SparkleMenuItem(project.StatusMessage)
                    {
                        Sensitive = false
                    };

                    (item.Submenu as Menu).Add(this.state_menu_items [i]);
                    (item.Submenu as Menu).Add(new SeparatorMenuItem());

                    if (project.IsPaused)
                    {
                        MenuItem resume_item;

                        if (project.UnsyncedChangesInfo.Count > 0)
                        {
                            string icons_path = Path.Combine(UserInterface.AssetsPath, "icons", "hicolor", "12x12", "status");

                            foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo)
                            {
                                string icon_path = Path.Combine(icons_path, pair.Value.Replace("-12", ""));

                                (item.Submenu as Menu).Add(new SparkleMenuItem(pair.Key)
                                {
                                    Image     = new Image(icon_path),
                                    Sensitive = false
                                });
                            }

                            if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges))
                            {
                                (item.Submenu as Menu).Add(new MenuItem(project.MoreUnsyncedChanges)
                                {
                                    Sensitive = false
                                });
                            }

                            (item.Submenu as Menu).Add(new SeparatorMenuItem());
                            resume_item = new MenuItem("Sync and Resume…");
                        }
                        else
                        {
                            resume_item = new MenuItem("Resume");
                        }

                        resume_item.Activated += Controller.ResumeDelegate(project.Name);
                        (item.Submenu as Menu).Add(resume_item);
                    }
                    else
                    {
                        if (Controller.Projects [i].HasError)
                        {
                            folder_icon = IconTheme.Default.LoadIcon("dialog-warning", 16, IconLookupFlags.GenericFallback);

                            MenuItem try_again_item = new MenuItem("Retry Sync");
                            try_again_item.Activated += Controller.TryAgainDelegate(project.Name);
                            (item.Submenu as Menu).Add(try_again_item);
                        }
                        else
                        {
                            MenuItem pause_item = new MenuItem("Pause");
                            pause_item.Activated += Controller.PauseDelegate(project.Name);
                            (item.Submenu as Menu).Add(pause_item);
                        }
                    }

                    (item.Child as Label).UseUnderline = false;
                    item.Image = new Image(folder_icon);
                    this.menu.Add(item);

                    i++;
                }
                ;
            }

            this.recent_events_item           = new MenuItem("History…");
            this.recent_events_item.Sensitive = Controller.RecentEventsItemEnabled;
            this.quit_item = new MenuItem("Quit")
            {
                Sensitive = Controller.QuitItemEnabled
            };
            MenuItem add_item = new MenuItem("Sync Remote Project…");

            MenuItem link_code_item = new MenuItem("Computer ID");

            if (Controller.LinkCodeItemEnabled)
            {
                link_code_item.Submenu = new Menu();

                string   link_code = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring(0, 20) + "...";
                MenuItem code_item = new MenuItem(link_code)
                {
                    Sensitive = false
                };

                MenuItem copy_item = new MenuItem("Copy to Clipboard");
                copy_item.Activated += delegate { Controller.CopyToClipboardClicked(); };

                (link_code_item.Submenu as Menu).Add(code_item);
                (link_code_item.Submenu as Menu).Add(new SeparatorMenuItem());
                (link_code_item.Submenu as Menu).Add(copy_item);
            }

            MenuItem about_item = new MenuItem("About SparkleShare");

            about_item.Activated += delegate { Controller.AboutClicked(); };
            add_item.Activated   += delegate { Controller.AddHostedProjectClicked(); };
            this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked(); };
            this.quit_item.Activated          += delegate { Controller.QuitClicked(); };

            folder_item.Submenu = new Menu();
            (folder_item.Submenu as Menu).Add(this.recent_events_item);

            if (InstallationInfo.OperatingSystem == OS.Ubuntu)
            {
                MenuItem notify_item;

                if (SparkleShare.Controller.NotificationsEnabled)
                {
                    notify_item = new MenuItem("Turn Notifications Off");
                }
                else
                {
                    notify_item = new MenuItem("Turn Notifications On");
                }

                notify_item.Activated += delegate {
                    SparkleShare.Controller.ToggleNotifications();

                    Application.Invoke(delegate {
                        if (SparkleShare.Controller.NotificationsEnabled)
                        {
                            (notify_item.Child as Label).Text = "Turn Notifications Off";
                        }
                        else
                        {
                            (notify_item.Child as Label).Text = "Turn Notifications On";
                        }
                    });
                };

                (folder_item.Submenu as Menu).Add(new SeparatorMenuItem());
                (folder_item.Submenu as Menu).Add(notify_item);
            }

            (folder_item.Submenu as Menu).Add(new SeparatorMenuItem());
            (folder_item.Submenu as Menu).Add(link_code_item);
            (folder_item.Submenu as Menu).Add(new SeparatorMenuItem());
            (folder_item.Submenu as Menu).Add(about_item);

            this.menu.Add(new SeparatorMenuItem());
            this.menu.Add(add_item);
            this.menu.Add(new SeparatorMenuItem());
            this.menu.Add(this.quit_item);
            this.menu.ShowAll();

            if (InstallationInfo.OperatingSystem == OS.Ubuntu)
            {
                #if HAVE_APP_INDICATOR
                indicator.Menu = this.menu;
                #endif
            }
        }
Example #10
0
        // Creates the menu that is popped up when the
        // user clicks the status icon
        public void CreateMenu()
        {
            Menu = new Menu();

            // The menu item showing the status and size of the SparkleShare folder
            MenuItem status_menu_item = new MenuItem(StateText)
            {
                Sensitive = false
            };

            Menu.Add(status_menu_item);
            Menu.Add(new SeparatorMenuItem());

            ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare")
            {
                Image = new Image(SparkleUIHelpers.GetIcon("folder-sparkleshare", 16))
            };

            folder_item.Activated += delegate {
                Program.Controller.OpenSparkleShareFolder();
            };

            Menu.Add(folder_item);

            if (Program.Controller.Folders.Count > 0)
            {
                // Creates a menu item for each repository with a link to their logs
                foreach (string folder_name in Program.Controller.Folders)
                {
                    Gdk.Pixbuf folder_icon;

                    if (Program.Controller.UnsyncedFolders.Contains(folder_name))
                    {
                        folder_icon = IconTheme.Default.LoadIcon("dialog-error", 16,
                                                                 IconLookupFlags.GenericFallback);
                    }
                    else
                    {
                        folder_icon = IconTheme.Default.LoadIcon("folder", 16,
                                                                 IconLookupFlags.GenericFallback);
                    }

                    ImageMenuItem subfolder_item = new SparkleMenuItem(folder_name)
                    {
                        Image = new Image(folder_icon)
                    };

                    subfolder_item.Activated += OpenFolderDelegate(folder_name);
                    Menu.Add(subfolder_item);
                }
            }
            else
            {
                MenuItem no_folders_item = new MenuItem(_("No projects yet"))
                {
                    Sensitive = false
                };

                Menu.Add(no_folders_item);
            }

            Menu.Add(new SeparatorMenuItem());

            // Opens the wizard to add a new remote folder
            MenuItem sync_item = new MenuItem(_("Add Hosted Project…"));

            if (Program.Controller.FirstRun)
            {
                sync_item.Sensitive = false;
            }

            sync_item.Activated += delegate {
                Application.Invoke(delegate {
                    if (SparkleUI.Setup == null)
                    {
                        SparkleUI.Setup = new SparkleSetup();
                        SparkleUI.Setup.Controller.ShowAddPage();
                    }

                    if (!SparkleUI.Setup.Visible)
                    {
                        SparkleUI.Setup.Controller.ShowAddPage();
                    }

                    //SparkleUI.Intro.ShowAll ();
                    //SparkleUI.Intro.Present ();
                });
            };

            Menu.Add(sync_item);
            Menu.Add(new SeparatorMenuItem());

            MenuItem recent_events_item = new MenuItem(_("Open Recent Events"));

            if (Program.Controller.Folders.Count < 1)
            {
                recent_events_item.Sensitive = false;
            }

            recent_events_item.Activated += delegate {
                Application.Invoke(delegate {
                    if (SparkleUI.EventLog == null)
                    {
                        SparkleUI.EventLog = new SparkleEventLog();
                    }

                    SparkleUI.EventLog.ShowAll();
                    SparkleUI.EventLog.Present();
                });
            };

            Menu.Add(recent_events_item);

            MenuItem notify_item;

            if (Program.Controller.NotificationsEnabled)
            {
                notify_item = new MenuItem(_("Turn Notifications Off"));
            }
            else
            {
                notify_item = new MenuItem(_("Turn Notifications On"));
            }

            notify_item.Activated += delegate {
                Program.Controller.ToggleNotifications();
                CreateMenu();
            };

            Menu.Add(notify_item);
            Menu.Add(new SeparatorMenuItem());

            // A menu item that takes the user to http://www.sparkleshare.org/
            MenuItem about_item = new MenuItem(_("About SparkleShare"));

            about_item.Activated += delegate {
                Application.Invoke(delegate {
                    if (SparkleUI.About == null)
                    {
                        SparkleUI.About = new SparkleAbout();
                    }

                    SparkleUI.About.ShowAll();
                    SparkleUI.About.Present();
                });
            };

            Menu.Add(about_item);
            Menu.Add(new SeparatorMenuItem());

            // A menu item that quits the application
            MenuItem quit_item = new MenuItem(_("Quit"));

            quit_item.Activated += delegate {
                Program.Controller.Quit();
            };

            Menu.Add(quit_item);
            Menu.ShowAll();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = Menu;
            #endif
        }
        public void CreateMenu ()
        {
            this.menu       = new Menu ();
            this.state_item = new MenuItem (Controller.StateText) { Sensitive = false };

            ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare");
            folder_item.Image = new Image (SparkleUIHelpers.GetIcon ("sparkleshare", 16));

            this.menu.Add (this.state_item);
            this.menu.Add (new SeparatorMenuItem ());                
            this.menu.Add (folder_item);

            
            this.state_menu_items = new SparkleMenuItem [Controller.Projects.Length];

            if (Controller.Projects.Length > 0) {
                int i = 0;
                foreach (ProjectInfo project in Controller.Projects) {
                    SparkleMenuItem item = new SparkleMenuItem (project.Name);

                    Gdk.Pixbuf folder_icon;
                    folder_icon = IconTheme.Default.LoadIcon ("folder", 16, IconLookupFlags.GenericFallback);

                    item.Submenu = new Menu ();

                    this.state_menu_items [i] = new SparkleMenuItem (project.StatusMessage) { Sensitive = false };

                    (item.Submenu as Menu).Add (this.state_menu_items [i]);
                    (item.Submenu as Menu).Add (new SeparatorMenuItem ());

                    if (project.IsPaused) {
                        MenuItem resume_item;

                        if (project.UnsyncedChangesInfo.Count > 0) {
                            string icons_path = new string [] {
                                SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status"}.Combine ();

                            foreach (KeyValuePair<string, string> pair in project.UnsyncedChangesInfo) {
                                string icon_path = new string [] {
                                    icons_path, pair.Value.Replace ("-12", "")}.Combine ();

                                (item.Submenu as Menu).Add (new SparkleMenuItem (pair.Key) {
                                    Image     = new Image (icon_path),
                                    Sensitive = false
                                });
                            }

                            if (!string.IsNullOrEmpty (project.MoreUnsyncedChanges)) {
                                (item.Submenu as Menu).Add (new MenuItem (project.MoreUnsyncedChanges) {
                                    Sensitive = false
                                });
                            }
                            
                            (item.Submenu as Menu).Add (new SeparatorMenuItem ());
                            resume_item = new MenuItem ("Sync and Resume…"); 
                            
                        } else {
                            resume_item = new MenuItem ("Resume");
                        }
                        
                        resume_item.Activated += Controller.ResumeDelegate (project.Name);
                        (item.Submenu as Menu).Add (resume_item);
                        
                    } else {
                        if (Controller.Projects [i].HasError) {
                            folder_icon = IconTheme.Default.LoadIcon ("dialog-warning", 16, IconLookupFlags.GenericFallback);
                            
                            MenuItem try_again_item = new MenuItem ("Try Again");
                            try_again_item.Activated += Controller.TryAgainDelegate (project.Name);
                            (item.Submenu as Menu).Add (try_again_item);

                        } else {
                            MenuItem pause_item = new MenuItem ("Pause");
                            pause_item.Activated += Controller.PauseDelegate (project.Name);
                            (item.Submenu as Menu).Add (pause_item);
                        }
                    }

                    (item.Child as Label).UseUnderline = false;
                    item.Image = new Image (folder_icon);
                    this.menu.Add (item);

                    i++;
                };
            }

			this.recent_events_item = new MenuItem ("Recent Changes…");
			this.recent_events_item.Sensitive = Controller.RecentEventsItemEnabled;
            this.quit_item    = new MenuItem ("Quit") { Sensitive = Controller.QuitItemEnabled };
            MenuItem add_item = new MenuItem ("Add Hosted Project…");

            #if HAVE_APP_INDICATOR
            MenuItem notify_item;
                                                             
            if (Program.Controller.NotificationsEnabled)
                notify_item = new MenuItem ("Turn Notifications Off");
            else
                notify_item = new MenuItem ("Turn Notifications On");

            notify_item.Activated += delegate {
                Program.Controller.ToggleNotifications ();

				Application.Invoke (delegate {				
				    if (Program.Controller.NotificationsEnabled)
                    	(notify_item.Child as Label).Text = "Turn Notifications Off";
                	else
                    	(notify_item.Child as Label).Text = "Turn Notifications On";
				});
            };
            #endif

            MenuItem link_code_item = new MenuItem ("Client ID");
            
            if (Controller.LinkCodeItemEnabled) {
                link_code_item.Submenu = new Menu ();
                
                string link_code = Program.Controller.CurrentUser.PublicKey.Substring (0, 20) + "...";
                MenuItem code_item = new MenuItem (link_code) { Sensitive = false };
                
                MenuItem copy_item = new MenuItem ("Copy to Clipboard");
                copy_item.Activated += delegate { Controller.CopyToClipboardClicked (); };
                
                (link_code_item.Submenu as Menu).Add (code_item);
                (link_code_item.Submenu as Menu).Add (new SeparatorMenuItem ());
                (link_code_item.Submenu as Menu).Add (copy_item);
            }

            MenuItem about_item = new MenuItem ("About SparkleShare");
            
            about_item.Activated              += delegate { Controller.AboutClicked (); };
            add_item.Activated                += delegate { Controller.AddHostedProjectClicked (); };
			this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked (); };
            this.quit_item.Activated          += delegate { Controller.QuitClicked (); };

            folder_item.Submenu = new Menu ();
			(folder_item.Submenu as Menu).Add (this.recent_events_item);
            (folder_item.Submenu as Menu).Add (add_item);
            #if HAVE_APP_INDICATOR
            (folder_item.Submenu as Menu).Add (new SeparatorMenuItem ());
            (folder_item.Submenu as Menu).Add (notify_item);
            #endif
            (folder_item.Submenu as Menu).Add (new SeparatorMenuItem ());
            (folder_item.Submenu as Menu).Add (link_code_item);
            (folder_item.Submenu as Menu).Add (new SeparatorMenuItem ());
            (folder_item.Submenu as Menu).Add (about_item);

            this.menu.Add (new SeparatorMenuItem ());            
            this.menu.Add (this.quit_item);
            this.menu.ShowAll ();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
            #endif
        }
        public void CreateMenu()
        {
            this.context_menu = new ContextMenu();

            this.state_item = new SparkleMenuItem {
                Header    = Controller.StateText,
                IsEnabled = false
            };

            Image folder_image = new Image {
                Source = UserInterfaceHelpers.GetImageSource("sparkleshare-folder"),
                Width  = 16,
                Height = 16
            };

            SparkleMenuItem folder_item = new SparkleMenuItem {
                Header = "SparkleShare",
                Icon   = folder_image
            };

            SparkleMenuItem add_item = new SparkleMenuItem {
                Header = "Add hosted project…"
            };

            this.log_item = new SparkleMenuItem {
                Header    = "Recent changes…",
                IsEnabled = Controller.RecentEventsItemEnabled
            };

            SparkleMenuItem link_code_item = new SparkleMenuItem {
                Header = "Client ID"
            };

            if (Controller.LinkCodeItemEnabled)
            {
                SparkleMenuItem code_item = new SparkleMenuItem {
                    Header = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring(0, 20) + "..."
                };

                SparkleMenuItem copy_item = new SparkleMenuItem {
                    Header = "Copy to Clipboard"
                };
                copy_item.Click += delegate {
                    Controller.CopyToClipboardClicked();
                };

                link_code_item.Items.Add(code_item);
                link_code_item.Items.Add(new Separator());
                link_code_item.Items.Add(copy_item);
            }

            CheckBox notify_check_box = new CheckBox {
                Margin    = new Thickness(6, 0, 0, 0),
                IsChecked = SparkleShare.Controller.NotificationsEnabled
            };

            SparkleMenuItem notify_item = new SparkleMenuItem {
                Header = "Notifications",
                Icon   = notify_check_box
            };

            SparkleMenuItem about_item = new SparkleMenuItem {
                Header = "About SparkleShare"
            };

            this.exit_item = new SparkleMenuItem {
                Header = "Exit"
            };


            add_item.Click += delegate {
                Controller.AddHostedProjectClicked();
            };
            this.log_item.Click += delegate {
                Controller.RecentEventsClicked();
            };
            about_item.Click += delegate {
                Controller.AboutClicked();
            };

            notify_check_box.Click += delegate {
                this.context_menu.IsOpen = false;
                SparkleShare.Controller.ToggleNotifications();
                notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled;
            };

            notify_item.Click += delegate {
                SparkleShare.Controller.ToggleNotifications();
                notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled;
            };

            this.exit_item.Click += delegate {
                this.notify_icon.Dispose();
                Controller.QuitClicked();
            };


            this.context_menu.Items.Add(this.state_item);
            this.context_menu.Items.Add(new Separator());
            this.context_menu.Items.Add(folder_item);

            state_menu_items = new SparkleMenuItem[Controller.Projects.Length];

            if (Controller.Projects.Length > 0)
            {
                int i = 0;
                foreach (ProjectInfo project in Controller.Projects)
                {
                    SparkleMenuItem subfolder_item = new SparkleMenuItem {
                        Header = project.Name.Replace("_", "__"),
                        Icon   = new Image {
                            Source = UserInterfaceHelpers.GetImageSource("folder"),
                            Width  = 16,
                            Height = 16
                        }
                    };

                    state_menu_items[i] = new SparkleMenuItem {
                        Header    = project.StatusMessage,
                        IsEnabled = false
                    };

                    subfolder_item.Items.Add(state_menu_items[i]);
                    subfolder_item.Items.Add(new Separator());

                    SparkleMenuItem open_item = new SparkleMenuItem {
                        Header = "Open folder",
                        Icon   = new Image
                        {
                            Source = UserInterfaceHelpers.GetImageSource("folder"),
                            Width  = 16,
                            Height = 16
                        }
                    };

                    open_item.Click += new RoutedEventHandler(Controller.OpenFolderDelegate(project.Name));
                    subfolder_item.Items.Add(open_item);
                    subfolder_item.Items.Add(new Separator());

                    if (project.IsPaused)
                    {
                        SparkleMenuItem resume_item;

                        if (project.UnsyncedChangesInfo.Count > 0)
                        {
                            foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo)
                            {
                                subfolder_item.Items.Add(new SparkleMenuItem {
                                    Header = pair.Key,
                                    // TODO image
                                    IsEnabled = false
                                });
                            }

                            if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges))
                            {
                                subfolder_item.Items.Add(new SparkleMenuItem {
                                    Header    = project.MoreUnsyncedChanges,
                                    IsEnabled = false
                                });
                            }

                            subfolder_item.Items.Add(new Separator());
                            resume_item = new SparkleMenuItem {
                                Header = "Sync and Resume…"
                            };
                        }
                        else
                        {
                            resume_item = new SparkleMenuItem {
                                Header = "Resume"
                            };
                        }

                        resume_item.Click += (sender, e) => Controller.ResumeDelegate(project.Name)(sender, e);
                        subfolder_item.Items.Add(resume_item);
                    }
                    else
                    {
                        if (Controller.Projects[i].HasError)
                        {
                            subfolder_item.Icon = new Image {
                                Source = Imaging.CreateBitmapSourceFromHIcon(
                                    Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
                                    BitmapSizeOptions.FromWidthAndHeight(16, 16))
                            };

                            SparkleMenuItem try_again_item = new SparkleMenuItem {
                                Header = "Retry Sync"
                            };
                            try_again_item.Click += (sender, e) => Controller.TryAgainDelegate(project.Name)(sender, e);
                            subfolder_item.Items.Add(try_again_item);
                        }
                        else
                        {
                            SparkleMenuItem pause_item = new SparkleMenuItem {
                                Header = "Pause"
                            };
                            pause_item.Click +=
                                (sender, e) => Controller.PauseDelegate(project.Name)(sender, e);
                            subfolder_item.Items.Add(pause_item);
                        }
                    }

                    this.context_menu.Items.Add(subfolder_item);
                    i++;
                }
                ;
            }

            folder_item.Items.Add(this.log_item);
            folder_item.Items.Add(add_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(notify_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(link_code_item);
            folder_item.Items.Add(new Separator());
            folder_item.Items.Add(about_item);

            this.context_menu.Items.Add(new Separator());
            this.context_menu.Items.Add(this.exit_item);

            this.notify_icon.ContextMenu = this.context_menu;
        }
Example #13
0
        public void CreateMenu()
        {
            this.menu       = new Menu();
            this.state_item = new MenuItem(Controller.StateText)
            {
                Sensitive = false
            };

            ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare");

            folder_item.Image = new Image(SparkleUIHelpers.GetIcon("sparkleshare", 16));

            this.menu.Add(this.state_item);
            this.menu.Add(new SeparatorMenuItem());
            this.menu.Add(folder_item);

            if (Program.Controller.Folders.Count > 0)
            {
                int i = 0;
                foreach (string folder_name in Controller.Folders)
                {
                    ImageMenuItem item = new SparkleMenuItem(folder_name);
                    Gdk.Pixbuf    folder_icon;

                    if (!string.IsNullOrEmpty(Controller.FolderErrors [i]))
                    {
                        folder_icon  = IconTheme.Default.LoadIcon("dialog-warning", 16, IconLookupFlags.GenericFallback);
                        item.Submenu = new Menu();

                        MenuItem error_item = new MenuItem(Controller.FolderErrors [i])
                        {
                            Sensitive = false
                        };
                        MenuItem try_again_item = new MenuItem("Try Again");
                        try_again_item.Activated += Controller.TryAgainDelegate(folder_name);

                        (item.Submenu as Menu).Add(error_item);
                        (item.Submenu as Menu).Add(new SeparatorMenuItem());
                        (item.Submenu as Menu).Add(try_again_item);
                    }
                    else
                    {
                        folder_icon     = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback);
                        item.Activated += Controller.OpenFolderDelegate(folder_name);
                    }

                    (item.Child as Label).UseUnderline = false;
                    item.Image = new Image(folder_icon);
                    this.menu.Add(item);

                    i++;
                }
            }

            this.recent_events_item            = new MenuItem("Recent Changes…");
            this.recent_events_item.Sensitive  = Controller.RecentEventsItemEnabled;
            this.recent_events_item.Activated += Controller.RecentEventsClicked;

            MenuItem add_item = new MenuItem("Add Hosted Project…");

            add_item.Activated += Controller.AddHostedProjectClicked;

            MenuItem notify_item;

            if (Program.Controller.NotificationsEnabled)
            {
                notify_item = new MenuItem("Turn Notifications Off");
            }
            else
            {
                notify_item = new MenuItem("Turn Notifications On");
            }

            notify_item.Activated += delegate {
                Program.Controller.ToggleNotifications();

                Application.Invoke(delegate {
                    if (Program.Controller.NotificationsEnabled)
                    {
                        (notify_item.Child as Label).Text = "Turn Notifications Off";
                    }
                    else
                    {
                        (notify_item.Child as Label).Text = "Turn Notifications On";
                    }
                });
            };

            MenuItem about_item = new MenuItem("About SparkleShare");

            about_item.Activated += Controller.AboutClicked;

            this.quit_item = new MenuItem("Quit")
            {
                Sensitive = Controller.QuitItemEnabled
            };
            this.quit_item.Activated += Controller.QuitClicked;

            folder_item.Submenu = new Menu();
            (folder_item.Submenu as Menu).Add(this.recent_events_item);
            (folder_item.Submenu as Menu).Add(add_item);
            (folder_item.Submenu as Menu).Add(new SeparatorMenuItem());
            (folder_item.Submenu as Menu).Add(notify_item);
            (folder_item.Submenu as Menu).Add(new SeparatorMenuItem());
            (folder_item.Submenu as Menu).Add(about_item);

            this.menu.Add(this.quit_item);
            this.menu.ShowAll();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
            #endif
        }
        public void CreateMenu()
        {
            this.context_menu = new ContextMenu ();

            this.state_item = new SparkleMenuItem () {
                Header    = Controller.StateText,
                IsEnabled = false
            };

            this.notify_icon.HeaderText = "SparkleShare\n" + Controller.StateText;

            Image folder_image = new Image () {
                Source = SparkleUIHelpers.GetImageSource ("sparkleshare-folder"),
                Width  = 16,
                Height = 16
            };

            SparkleMenuItem folder_item = new SparkleMenuItem () {
                Header = "SparkleShare",
                Icon   = folder_image
            };

                folder_item.Click += delegate {
                    Controller.SparkleShareClicked ();
                };

            SparkleMenuItem add_item = new SparkleMenuItem () {
                Header = "Add hosted project…"
            };

                add_item.Click += delegate {
                    Controller.AddHostedProjectClicked ();
                };

            this.log_item = new SparkleMenuItem () {
                Header    = "Recent changes…",
                IsEnabled = Controller.RecentEventsItemEnabled
            };

                this.log_item.Click += delegate {
                    Controller.RecentEventsClicked ();
                };

            SparkleMenuItem notify_item = new SparkleMenuItem () {
                Header = "Notifications"
            };

                CheckBox notify_check_box = new CheckBox () {
                    Margin    = new Thickness (6, 0, 0, 0),
                    IsChecked = (Controller.Folders.Length > 0 && Program.Controller.NotificationsEnabled)
                };

                notify_item.Icon = notify_check_box;

                notify_check_box.Click += delegate {
                    this.context_menu.IsOpen = false;
                    Program.Controller.ToggleNotifications ();
                    notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
                };

                notify_item.Click += delegate {
                    Program.Controller.ToggleNotifications ();
                    notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
                };

            SparkleMenuItem about_item = new SparkleMenuItem () {
                Header = "About SparkleShare"
            };

                about_item.Click += delegate {
                     Controller.AboutClicked ();
                };

            this.exit_item = new SparkleMenuItem () {
                Header = "Exit"
            };

                this.exit_item.Click += delegate {
                    this.notify_icon.Dispose ();
                    Controller.QuitClicked ();
                };

            this.context_menu.Items.Add (this.state_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (folder_item);

            if (Controller.Folders.Length > 0) {
                int i = 0;
                foreach (string folder_name in Controller.Folders) {
                    SparkleMenuItem subfolder_item = new SparkleMenuItem () {
                        Header = folder_name
                    };

                    subfolder_item.Click += OpenFolderDelegate (folder_name);

                    Image subfolder_image = new Image () {
                        Source = SparkleUIHelpers.GetImageSource ("folder"),
                        Width  = 16,
                        Height = 16
                    };

                    if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
                        subfolder_item.Icon = new Image () {
                            Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon (
                                System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
                                BitmapSizeOptions.FromWidthAndHeight (16,16)
                            )
                        };

                        SparkleMenuItem error_item = new SparkleMenuItem () {
                            Header    = Controller.FolderErrors [i],
                            IsEnabled = false
                        };

                        subfolder_item.Items.Add (error_item);

                    } else {
                        subfolder_item.Icon = subfolder_image;
                    }

                    this.context_menu.Items.Add (subfolder_item);

                    i++;
                }

                SparkleMenuItem more_item = new SparkleMenuItem () {
                    Header = "More projects"
                };

                i = 0;
                foreach (string folder_name in Controller.OverflowFolders) {
                    SparkleMenuItem subfolder_item = new SparkleMenuItem () {
                        Header = folder_name
                    };

                    subfolder_item.Click += OpenFolderDelegate (folder_name);

                    Image subfolder_image = new Image () {
                        Source = SparkleUIHelpers.GetImageSource ("folder"),
                        Width  = 16,
                        Height = 16
                    };

                    if (!string.IsNullOrEmpty (Controller.OverflowFolderErrors [i])) {
                        subfolder_item.Icon = new Image () {
                            Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon (
                                System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
                                BitmapSizeOptions.FromWidthAndHeight (16,16)
                            )
                        };

                        SparkleMenuItem error_item = new SparkleMenuItem () {
                            Header    = Controller.OverflowFolderErrors [i],
                            IsEnabled = false
                        };

                        subfolder_item.Items.Add (error_item);

                    } else {
                        subfolder_item.Icon = subfolder_image;
                    }

                    more_item.Items.Add (subfolder_item);

                    i++;
                }

                if (more_item.Items.Count > 0) {
                    this.context_menu.Items.Add (new Separator ());
                    this.context_menu.Items.Add (more_item);
                }

            }

            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (add_item);
            this.context_menu.Items.Add (this.log_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (notify_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (about_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (this.exit_item);

            this.notify_icon.ContextMenu = this.context_menu;
        }
Example #15
0
        public void CreateMenu()
        {
            this.menu = new Menu();

            this.state_item = new MenuItem(Controller.StateText)
            {
                Sensitive = false
            };

            this.menu.Add(this.state_item);
            this.menu.Add(new SeparatorMenuItem());

            ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare")
            {
                Image = new Image(SparkleUIHelpers.GetIcon("folder-sparkleshare", 16))
            };

            folder_item.Activated += delegate {
                Controller.SparkleShareClicked();
            };

            this.menu.Add(folder_item);

            if (Program.Controller.Folders.Count > 0)
            {
                foreach (string folder_name in Controller.Folders)
                {
                    Gdk.Pixbuf folder_icon;

                    if (Program.Controller.UnsyncedFolders.Contains(folder_name))
                    {
                        folder_icon = IconTheme.Default.LoadIcon("dialog-error", 16,
                                                                 IconLookupFlags.GenericFallback);
                    }
                    else
                    {
                        folder_icon = IconTheme.Default.LoadIcon("folder", 16,
                                                                 IconLookupFlags.GenericFallback);
                    }

                    ImageMenuItem subfolder_item = new SparkleMenuItem(folder_name)
                    {
                        Image = new Image(folder_icon)
                    };

                    subfolder_item.Activated += OpenFolderDelegate(folder_name);
                    this.menu.Add(subfolder_item);
                }

                Menu submenu = new Menu();

                foreach (string folder_name in Controller.OverflowFolders)
                {
                    Gdk.Pixbuf folder_icon;

                    if (Program.Controller.UnsyncedFolders.Contains(folder_name))
                    {
                        folder_icon = IconTheme.Default.LoadIcon("dialog-error", 16,
                                                                 IconLookupFlags.GenericFallback);
                    }
                    else
                    {
                        folder_icon = IconTheme.Default.LoadIcon("folder", 16,
                                                                 IconLookupFlags.GenericFallback);
                    }

                    ImageMenuItem subfolder_item = new SparkleMenuItem(folder_name)
                    {
                        Image = new Image(folder_icon)
                    };

                    subfolder_item.Activated += OpenFolderDelegate(folder_name);
                    submenu.Add(subfolder_item);
                }

                if (submenu.Children.Length > 0)
                {
                    SparkleMenuItem more_item = new SparkleMenuItem("More Projects")
                    {
                        Submenu = submenu
                    };

                    this.menu.Add(new SeparatorMenuItem());
                    this.menu.Add(more_item);
                }
            }

            this.menu.Add(new SeparatorMenuItem());

            MenuItem sync_item = new MenuItem(_("Add Hosted Project…"));

            sync_item.Activated += delegate {
                Controller.AddHostedProjectClicked();
            };

            this.menu.Add(sync_item);

            this.recent_events_item = new MenuItem(_("View Recent Changes…"));

            this.recent_events_item.Sensitive = Controller.OpenRecentEventsItemEnabled;

            this.recent_events_item.Activated += delegate {
                Controller.OpenRecentEventsClicked();
            };

            this.menu.Add(this.recent_events_item);
            this.menu.Add(new SeparatorMenuItem());


            MenuItem notify_item;

            if (Program.Controller.NotificationsEnabled)
            {
                notify_item = new MenuItem(_("Turn Notifications Off"));
            }
            else
            {
                notify_item = new MenuItem(_("Turn Notifications On"));
            }

            notify_item.Activated += delegate {
                Application.Invoke(delegate {
                    Program.Controller.ToggleNotifications();

                    if (Program.Controller.NotificationsEnabled)
                    {
                        (notify_item.Child as Label).Text = _("Turn Notifications Off");
                    }
                    else
                    {
                        (notify_item.Child as Label).Text = _("Turn Notifications On");
                    }
                });
            };

            this.menu.Add(notify_item);
            this.menu.Add(new SeparatorMenuItem());


            MenuItem about_item = new MenuItem(_("About SparkleShare"));

            about_item.Activated += delegate {
                Controller.AboutClicked();
            };

            this.menu.Add(about_item);
            this.menu.Add(new SeparatorMenuItem());


            this.quit_item = new MenuItem(_("Quit"))
            {
                Sensitive = Controller.QuitItemEnabled
            };

            this.quit_item.Activated += delegate {
                Controller.QuitClicked();
            };

            this.menu.Add(this.quit_item);
            this.menu.ShowAll();

            #if HAVE_APP_INDICATOR
            this.indicator.Menu = this.menu;
            #endif
        }
        // Creates the menu that is popped up when the
        // user clicks the status icon
        public void CreateMenu()
        {
            Menu = new Menu ();

                // The menu item showing the status and size of the SparkleShare folder
                MenuItem status_menu_item = new MenuItem (StateText) {
                    Sensitive = false
                };

            Menu.Add (status_menu_item);
            Menu.Add (new SeparatorMenuItem ());

                ImageMenuItem folder_item = new SparkleMenuItem ("SparkleShare"){
                    Image = new Image (SparkleUIHelpers.GetIcon ("folder-sparkleshare", 16))
                };

                folder_item.Activated += delegate {
                    SparkleShare.Controller.OpenSparkleShareFolder ();
                };

            Menu.Add (folder_item);

                if (SparkleShare.Controller.Folders.Count > 0) {

                    // Creates a menu item for each repository with a link to their logs
                    foreach (string folder_name in SparkleShare.Controller.Folders) {

                        Gdk.Pixbuf folder_icon;

                        if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name)) {
                            folder_icon = IconTheme.Default.LoadIcon ("dialog-error", 16,
                                IconLookupFlags.GenericFallback);

                        } else {
                            folder_icon = IconTheme.Default.LoadIcon ("folder", 16,
                                IconLookupFlags.GenericFallback);
                        }

                        ImageMenuItem subfolder_item = new SparkleMenuItem (folder_name) {
                            Image = new Image (folder_icon)
                        };

                        subfolder_item.Activated += OpenFolderDelegate (folder_name);
                        Menu.Add (subfolder_item);
                    }

                } else {
                    MenuItem no_folders_item = new MenuItem (_("No Remote Folders Yet")) {
                        Sensitive   = false
                    };

                    Menu.Add (no_folders_item);
                }

                // Opens the wizard to add a new remote folder
                MenuItem sync_item = new MenuItem (_("Add Remote Folder…"));

                if (SparkleShare.Controller.FirstRun)
                    sync_item.Sensitive = false;

                sync_item.Activated += delegate {
                    Application.Invoke (delegate {

                        if (SparkleUI.Intro == null) {
                            SparkleUI.Intro = new SparkleIntro ();
                            SparkleUI.Intro.ShowServerForm (true);
                        }

                        if (!SparkleUI.Intro.Visible)
                            SparkleUI.Intro.ShowServerForm (true);

                        SparkleUI.Intro.ShowAll ();
                        SparkleUI.Intro.Present ();
                    });
                };

            Menu.Add (sync_item);
            Menu.Add (new SeparatorMenuItem ());

            MenuItem recent_events_item = new MenuItem (_("Show Recent Events"));

                if (SparkleShare.Controller.Folders.Count < 1)
                    recent_events_item.Sensitive = false;

                recent_events_item.Activated += delegate {
                    Application.Invoke (delegate {
                        if (SparkleUI.EventLog == null)
                            SparkleUI.EventLog = new SparkleEventLog ();

                        SparkleUI.EventLog.ShowAll ();
                        SparkleUI.EventLog.Present ();
                    });
                };

            Menu.Add (recent_events_item);

            MenuItem notify_item;

                if (SparkleShare.Controller.NotificationsEnabled)
                    notify_item = new MenuItem (_("Turn Notifications Off"));
                else
                    notify_item = new MenuItem (_("Turn Notifications On"));

                notify_item.Activated += delegate {
                    SparkleShare.Controller.ToggleNotifications ();
                    CreateMenu ();
                };

            Menu.Add (notify_item);
            Menu.Add (new SeparatorMenuItem ());

                // A menu item that takes the user to http://www.sparkleshare.org/
                MenuItem about_item = new MenuItem (_("About SparkleShare"));

                about_item.Activated += delegate {
                    SparkleAbout about = new SparkleAbout ();
                    about.ShowAll ();
                };

            Menu.Add (about_item);
            Menu.Add (new SeparatorMenuItem ());

                // A menu item that quits the application
                MenuItem quit_item = new MenuItem (_("Quit"));

                quit_item.Activated += delegate {
                    SparkleShare.Controller.Quit ();
                };

            Menu.Add (quit_item);
            Menu.ShowAll ();
        }
        public void CreateMenu()
        {
            this.context_menu = new ContextMenu ();

            status_item = new SparkleMenuItem () {
                Header    = StateText,
                IsEnabled = false
            };

            System.Windows.Controls.Image i = new System.Windows.Controls.Image();
            i.Source = SparkleUIHelpers.GetImageSource ("folder-sparkleshare-windows-16");
                i.Width = 16;
            i.Height = 16;

            SparkleMenuItem folder_item = new SparkleMenuItem () {
                Header = "SparkleShare",
                Icon   = i
            };

                folder_item.Click += delegate {
                    Controller.SparkleShareClicked ();
                };

            SparkleMenuItem add_item = new SparkleMenuItem () {
                Header    = "Add Hosted Project…"
            };

                add_item.Click += delegate {
                    Controller.AddHostedProjectClicked ();
                };

            SparkleMenuItem log_item = new SparkleMenuItem () {
                Header    = "View Recent Changes…",
                IsEnabled = (Program.Controller.Folders.Count > 0)
            };

                log_item.Click += delegate {
                    Controller.OpenRecentEventsClicked ();
                };

            SparkleMenuItem notify_item = new SparkleMenuItem ();

                if (Program.Controller.NotificationsEnabled)
                    notify_item = new SparkleMenuItem () { Header = "Turn Notifications Off" };
                else
                    notify_item = new SparkleMenuItem () { Header = "Turn Notifications On" };

                notify_item.Click += delegate {
                    Program.Controller.ToggleNotifications ();
                    CreateMenu ();
                };

            SparkleMenuItem about_item = new SparkleMenuItem () {
                Header = "About SparkleShare"
            };

                about_item.Click += delegate {
                     Controller.AboutClicked ();
                };

            exit_item = new SparkleMenuItem () {
                Header = "Exit"
            };

                this.exit_item.Click += delegate {
                    this.notify_icon.Dispose ();
                    Controller.QuitClicked ();
                };

            this.context_menu.Items.Add (status_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (folder_item);

            if (Program.Controller.Folders.Count > 0) {
                foreach (string folder_name in Program.Controller.Folders) {
                    SparkleMenuItem subfolder_item = new SparkleMenuItem () {
                        Header = folder_name
                    };

                    subfolder_item.Click += OpenFolderDelegate (folder_name);

                    System.Windows.Controls.Image i2 = new System.Windows.Controls.Image();
            i2.Source = SparkleUIHelpers.GetImageSource ("folder-windows-16");
                i2.Width = 16;
            i2.Height = 16;
                    subfolder_item.Icon = i2;
                    /* TODO
                    if (Program.Controller.UnsyncedFolders.Contains (folder_name))
                        subfolder_item.Icon = Icons.dialog_error_16;
                    else
                        subfolder_item.Icon = Icons.sparkleshare_windows_status;
                     */

                    this.context_menu.Items.Add (subfolder_item);
                }

            } else {
                SparkleMenuItem no_folders_item = new SparkleMenuItem () {
                    Header    = "No projects yet",
                    IsEnabled = false
                };

                this.context_menu.Items.Add (no_folders_item);
            }

            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (add_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (log_item);
            this.context_menu.Items.Add (notify_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (about_item);
            this.context_menu.Items.Add (new Separator ());
            this.context_menu.Items.Add (this.exit_item);

            this.notify_icon.ContextMenu = this.context_menu;
        }