public void CreateMenu() { this.menu = new Menu(); // State Menu this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { Menu submenu = new Menu(); ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name) { Image = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16)), Submenu = submenu, RepoName = folder_name }; ImageMenuItem open_localfolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.OpenLocalFolder) { Image = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16)) }; open_localfolder_item.Activated += OpenFolderDelegate(folder_name); ImageMenuItem edit_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.EditTitle); edit_folder_item.Activated += EditFolderDelegate(folder_name); ImageMenuItem suspend_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.PauseSync) { RepoName = folder_name }; foreach (Repository aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(folder_name)) { setSyncItemState(suspend_folder_item, aRepo.Status); break; } } suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name); ImageMenuItem remove_folder_from_sync_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.RemoveFolderFromSync) { Image = new Image(UIHelpers.GetIcon("dataspacesync-deleted", 12)) }; remove_folder_from_sync_item.Activated += RemoveFolderFromSyncDelegate(folder_name); submenu.Add(open_localfolder_item); submenu.Add(suspend_folder_item); // GUI workaround to remove ignore folder {{ //submenu.Add(edit_folder_item); // GUI workaround to remove ignore folder }} submenu.Add(new SeparatorMenuItem()); submenu.Add(remove_folder_from_sync_item); this.menu.Add(subfolder_item); } this.menu.Add(new SeparatorMenuItem()); } // Add Menu MenuItem add_item = new MenuItem( CmisSync.Properties_Resources.AddARemoteFolder); add_item.Activated += delegate { Controller.AddRemoteFolderClicked(); }; this.menu.Add(add_item); this.menu.Add(new SeparatorMenuItem()); // Log Menu MenuItem log_item = new MenuItem( CmisSync.Properties_Resources.ViewLog); log_item.Activated += delegate { Controller.LogClicked(); }; this.menu.Add(log_item); // About Menu MenuItem about_item = new MenuItem( String.Format(CmisSync.Properties_Resources.About, Properties_Resources.ApplicationName)); about_item.Activated += delegate { Controller.AboutClicked(); }; this.menu.Add(about_item); this.quit_item = new MenuItem( CmisSync.Properties_Resources.Exit) { Sensitive = true }; 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 this.IsHandleCreated = true; }
public StatusIcon() { CreateAnimationFrames(); #if HAVE_APP_INDICATOR this.indicator = new ApplicationIndicator("dataspacesync", "dataspacesync-process-syncing-i", Category.ApplicationStatus); this.indicator.Status = Status.Active; #else this.status_icon = new Gtk.StatusIcon(); this.status_icon.Pixbuf = this.animation_frames [0]; this.status_icon.Activate += OpenFolderDelegate(null); // Primary mouse button click shows default folder this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click #endif CreateMenu(); Controller.UpdateIconEvent += delegate(int icon_frame) { Application.Invoke(delegate { if (icon_frame > -1) { #if HAVE_APP_INDICATOR string icon_name = "dataspacesync-process-syncing-"; for (int i = 0; i <= icon_frame; i++) { icon_name += "i"; } this.indicator.IconName = icon_name; // Force update of the icon this.indicator.Status = Status.Attention; this.indicator.Status = Status.Active; #else this.status_icon.Pixbuf = this.animation_frames [icon_frame]; #endif } else { #if HAVE_APP_INDICATOR this.indicator.IconName = "dataspacesync-process-syncing-error"; // Force update of the icon this.indicator.Status = Status.Attention; this.indicator.Status = Status.Active; #else this.status_icon.Pixbuf = UIHelpers.GetIcon("dataspacesync-process-syncing-error", 24); #endif } }); }; Controller.UpdateStatusItemEvent += delegate(string state_text) { if (!IsHandleCreated) { return; } Application.Invoke(delegate { (this.state_item.Child as Label).Text = state_text; this.state_item.ShowAll(); }); }; Controller.UpdateMenuEvent += delegate(IconState state) { Application.Invoke(delegate { CreateMenu(); }); }; Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) { if (!IsHandleCreated) { return; } Application.Invoke(delegate { foreach (var menuItem in this.menu.Children) { if (menuItem is CmisSyncMenuItem && reponame.Equals(((CmisSyncMenuItem)menuItem).RepoName)) { foreach (Repository aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(reponame)) { Menu submenu = (Menu)((CmisSyncMenuItem)menuItem).Submenu; CmisSyncMenuItem pauseItem = (CmisSyncMenuItem)submenu.Children[1]; setSyncItemState(pauseItem, aRepo.Status); break; } } break; } } }); }; Controller.UpdateTransmissionMenuEvent += delegate { if (!IsHandleCreated) { return; } Application.Invoke(delegate { List <FileTransmissionEvent> transmissionEvents = Program.Controller.ActiveTransmissions(); if (transmissionEvents.Count != 0) { this.state_item.Sensitive = true; Menu submenu = new Menu(); this.state_item.Submenu = submenu; foreach (FileTransmissionEvent e in transmissionEvents) { ImageMenuItem transmission_sub_menu_item = new TransmissionMenuItem(e); submenu.Add(transmission_sub_menu_item); state_item.ShowAll(); } } else { this.state_item.Submenu = null; this.state_item.Sensitive = false; } }); }; }
public StatusIcon() { CreateAnimationFrames(); #if HAVE_APP_INDICATOR this.indicator = new ApplicationIndicator("cmissync", "process-syncing-i", Category.ApplicationStatus); this.indicator.Status = Status.Active; #else this.status_icon = new Gtk.StatusIcon(); this.status_icon.Pixbuf = this.animation_frames [0]; this.status_icon.Activate += ShowMenu; // Primary mouse button click this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click #endif CreateMenu(); Controller.UpdateIconEvent += delegate(int icon_frame) { Application.Invoke(delegate { if (icon_frame > -1) { #if HAVE_APP_INDICATOR string icon_name = "process-syncing-"; for (int i = 0; i <= icon_frame; i++) { icon_name += "i"; } this.indicator.IconName = icon_name; // Force update of the icon this.indicator.Status = Status.Attention; this.indicator.Status = Status.Active; #else this.status_icon.Pixbuf = this.animation_frames [icon_frame]; #endif } else { #if HAVE_APP_INDICATOR this.indicator.IconName = "process-syncing-error"; // Force update of the icon this.indicator.Status = Status.Attention; this.indicator.Status = Status.Active; #else this.status_icon.Pixbuf = UIHelpers.GetIcon("process-syncing-error", 24); #endif } }); }; Controller.UpdateStatusItemEvent += delegate(string state_text) { if (!IsHandleCreated) { return; } Application.Invoke(delegate { (this.state_item.Child as Label).Text = state_text; this.state_item.ShowAll(); }); }; Controller.UpdateMenuEvent += delegate(IconState state) { Application.Invoke(delegate { CreateMenu(); }); }; Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) { if (!IsHandleCreated) { return; } Application.Invoke(delegate { foreach (var menuItem in this.menu.Children) { if (menuItem is CmisSyncMenuItem && reponame.Equals(((CmisSyncMenuItem)menuItem).RepoName)) { foreach (RepoBase aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(reponame)) { Menu submenu = (Menu)((CmisSyncMenuItem)menuItem).Submenu; CmisSyncMenuItem pauseItem = (CmisSyncMenuItem)submenu.Children[1]; setSyncItemState(pauseItem, aRepo.Status); break; } } break; } } }); }; }
public void CreateMenu() { this.menu = new Menu(); // State Menu this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { Menu submenu = new Menu(); ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name) { Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16)), Submenu = submenu }; ImageMenuItem open_localfolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture)) { Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16)) }; open_localfolder_item.Activated += OpenFolderDelegate(folder_name); ImageMenuItem browse_remotefolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture)) { Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16)) }; browse_remotefolder_item.Activated += OpenRemoteFolderDelegate(folder_name); ImageMenuItem suspend_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture)) { Image = new Image(UIHelpers.GetIcon("media_playback_pause", 16)) }; suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name); submenu.Add(open_localfolder_item); submenu.Add(browse_remotefolder_item); submenu.Add(suspend_folder_item); this.menu.Add(subfolder_item); } this.menu.Add(new SeparatorMenuItem()); } // Add Menu MenuItem add_item = new MenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture)); add_item.Activated += delegate { Controller.AddRemoteFolderClicked(); }; this.menu.Add(add_item); this.menu.Add(new SeparatorMenuItem()); // Log Menu MenuItem log_item = new MenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("ViewLog", CultureInfo.CurrentCulture)); log_item.Activated += delegate { Controller.LogClicked(); }; this.menu.Add(log_item); // About Menu MenuItem about_item = new MenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("About", CultureInfo.CurrentCulture)); about_item.Activated += delegate { Controller.AboutClicked(); }; this.menu.Add(about_item); this.quit_item = new MenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture)) { Sensitive = true }; 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 }
public void CreateMenu () { this.menu = new Menu (); // State Menu this.state_item = new MenuItem (Controller.StateText) { Sensitive = false }; this.menu.Add (this.state_item); this.menu.Add (new SeparatorMenuItem ()); // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { Menu submenu = new Menu(); ImageMenuItem subfolder_item = new CmisSyncMenuItem (folder_name) { Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)), Submenu = submenu }; ImageMenuItem open_localfolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture)) { Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)) }; open_localfolder_item.Activated += OpenFolderDelegate(folder_name); ImageMenuItem browse_remotefolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture)) { Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)) }; browse_remotefolder_item.Activated += OpenRemoteFolderDelegate(folder_name); ImageMenuItem suspend_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture)) { Image = new Image (UIHelpers.GetIcon ("media_playback_pause", 16)) }; suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name); submenu.Add(open_localfolder_item); submenu.Add(browse_remotefolder_item); submenu.Add(suspend_folder_item); this.menu.Add (subfolder_item); } this.menu.Add (new SeparatorMenuItem ()); } // Add Menu MenuItem add_item = new MenuItem ( CmisSync.Properties_Resources.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture)); add_item.Activated += delegate { Controller.AddRemoteFolderClicked (); }; this.menu.Add(add_item); this.menu.Add (new SeparatorMenuItem ()); // Log Menu MenuItem log_item = new MenuItem( CmisSync.Properties_Resources.ResourceManager.GetString("ViewLog", CultureInfo.CurrentCulture)); log_item.Activated += delegate { Controller.LogClicked(); }; this.menu.Add(log_item); // About Menu MenuItem about_item = new MenuItem ( CmisSync.Properties_Resources.ResourceManager.GetString("About", CultureInfo.CurrentCulture)); about_item.Activated += delegate { Controller.AboutClicked (); }; this.menu.Add (about_item); this.quit_item = new MenuItem ( CmisSync.Properties_Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture)) { Sensitive = true }; 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 }
/// <summary> /// Create the GUI elements of the menu. /// </summary> public void CreateMenu() { this.menu = new Menu(); // State Menu this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { Menu submenu = new Menu(); ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name) { Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16)), Submenu = submenu, RepoName = folder_name }; // Sub-item: open locally. ImageMenuItem open_localfolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.OpenLocalFolder) { Image = new Image(UIHelpers.GetIcon("folder-cmissync", 16)) }; open_localfolder_item.Activated += OpenFolderDelegate(folder_name); /* * // Sub-item: open remotely. * ImageMenuItem browse_remotefolder_item = new CmisSyncMenuItem( * CmisSync.Properties_Resources.BrowseRemoteFolder) { * Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)) * }; * browse_remotefolder_item.Activated += OpenRemoteFolderDelegate(folder_name); */ ImageMenuItem edit_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.EditTitle); edit_folder_item.Activated += EditFolderDelegate(folder_name); // Sub-item: suspend sync. ImageMenuItem suspend_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.PauseSync) { RepoName = folder_name }; foreach (RepoBase aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(folder_name)) { setSyncItemState(suspend_folder_item, aRepo.Status); break; } } suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name); // Sub-item: remove folder from sync ImageMenuItem remove_folder_from_sync_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.RemoveFolderFromSync) { Image = new Image(UIHelpers.GetIcon("document-deleted", 12)) }; remove_folder_from_sync_item.Activated += RemoveFolderFromSyncDelegate(folder_name); // Add the sub-items. submenu.Add(open_localfolder_item); //submenu.Add(browse_remotefolder_item); submenu.Add(suspend_folder_item); submenu.Add(edit_folder_item); submenu.Add(new SeparatorMenuItem()); submenu.Add(remove_folder_from_sync_item); // Add the main item. this.menu.Add(subfolder_item); } this.menu.Add(new SeparatorMenuItem()); } // Add Menu MenuItem add_item = new MenuItem( CmisSync.Properties_Resources.AddARemoteFolder); add_item.Activated += delegate { Controller.AddRemoteFolderClicked(); }; this.menu.Add(add_item); this.menu.Add(new SeparatorMenuItem()); // Log Menu MenuItem log_item = new MenuItem( CmisSync.Properties_Resources.ViewLog); log_item.Activated += delegate { Controller.LogClicked(); }; this.menu.Add(log_item); // About Menu MenuItem about_item = new MenuItem( CmisSync.Properties_Resources.About); about_item.Activated += delegate { Controller.AboutClicked(); }; this.menu.Add(about_item); this.quit_item = new MenuItem( CmisSync.Properties_Resources.Exit) { Sensitive = true }; 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 this.IsHandleCreated = true; }
public void CreateMenu () { this.menu = new Menu (); // State Menu this.state_item = new MenuItem (Controller.StateText) { Sensitive = false }; this.menu.Add (this.state_item); this.menu.Add (new SeparatorMenuItem ()); // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { Menu submenu = new Menu(); ImageMenuItem subfolder_item = new CmisSyncMenuItem (folder_name) { Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)), Submenu = submenu, RepoName = folder_name }; ImageMenuItem open_localfolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.OpenLocalFolder) { Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)) }; open_localfolder_item.Activated += OpenFolderDelegate(folder_name); /* ImageMenuItem browse_remotefolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.BrowseRemoteFolder) { Image = new Image (UIHelpers.GetIcon ("folder-cmissync", 16)) }; browse_remotefolder_item.Activated += OpenRemoteFolderDelegate(folder_name); */ ImageMenuItem edit_folder_item = new CmisSyncMenuItem ( CmisSync.Properties_Resources.EditTitle); edit_folder_item.Activated += EditFolderDelegate(folder_name); ImageMenuItem suspend_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.PauseSync) { RepoName = folder_name }; foreach (RepoBase aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(folder_name)) { setSyncItemState(suspend_folder_item, aRepo.Status); break; } } suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name); ImageMenuItem remove_folder_from_sync_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.RemoveFolderFromSync) { Image = new Image (UIHelpers.GetIcon ("document-deleted", 12)) }; remove_folder_from_sync_item.Activated += RemoveFolderFromSyncDelegate(folder_name); submenu.Add(open_localfolder_item); //submenu.Add(browse_remotefolder_item); submenu.Add(suspend_folder_item); submenu.Add(edit_folder_item); submenu.Add(new SeparatorMenuItem()); submenu.Add(remove_folder_from_sync_item); this.menu.Add (subfolder_item); } this.menu.Add (new SeparatorMenuItem ()); } // Add Menu MenuItem add_item = new MenuItem ( CmisSync.Properties_Resources.AddARemoteFolder); add_item.Activated += delegate { Controller.AddRemoteFolderClicked (); }; this.menu.Add(add_item); this.menu.Add (new SeparatorMenuItem ()); // Log Menu MenuItem log_item = new MenuItem( CmisSync.Properties_Resources.ViewLog); log_item.Activated += delegate { Controller.LogClicked(); }; this.menu.Add(log_item); // About Menu MenuItem about_item = new MenuItem ( CmisSync.Properties_Resources.About); about_item.Activated += delegate { Controller.AboutClicked (); }; this.menu.Add (about_item); this.quit_item = new MenuItem ( CmisSync.Properties_Resources.Exit) { Sensitive = true }; 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 this.IsHandleCreated = true; }