GetIcon() private method

private GetIcon ( string name, int size ) : Gdk.Pixbuf
name string
size int
return Gdk.Pixbuf
Example #1
0
 private void CreateAnimationFrames()
 {
     this.animation_frames = new Icon[] {
         UIHelpers.GetIcon("process-syncing-i"),
         UIHelpers.GetIcon("process-syncing-ii"),
         UIHelpers.GetIcon("process-syncing-iii"),
         UIHelpers.GetIcon("process-syncing-iiii"),
         UIHelpers.GetIcon("process-syncing-iiiii")
     };
 }
Example #2
0
 private void CreateAnimationFrames()
 {
     this.animation_frames = new Gdk.Pixbuf [] {
         UIHelpers.GetIcon("dataspacesync-process-syncing-i", 24),
         UIHelpers.GetIcon("dataspacesync-process-syncing-ii", 24),
         UIHelpers.GetIcon("dataspacesync-process-syncing-iii", 24),
         UIHelpers.GetIcon("dataspacesync-process-syncing-iiii", 24),
         UIHelpers.GetIcon("dataspacesync-process-syncing-iiiii", 24)
     };
 }
Example #3
0
 /// <summary>
 /// Create the animation frames from image files.
 /// </summary>
 private void CreateIcons()
 {
     this.animationFrames = new Icon[] {
         UIHelpers.GetIcon("process-syncing-i"),
         UIHelpers.GetIcon("process-syncing-ii"),
         UIHelpers.GetIcon("process-syncing-iii"),
         UIHelpers.GetIcon("process-syncing-iiii"),
         UIHelpers.GetIcon("process-syncing-iiiii")
     };
     this.errorIcon = UIHelpers.GetIcon("process-syncing-error");
 }
Example #4
0
        private void setSyncItemState(ImageMenuItem syncitem, SyncStatus status)
        {
            switch (status)
            {
            case SyncStatus.Idle:
                (syncitem.Child as Label).Text = CmisSync.Properties_Resources.PauseSync;
                syncitem.Image = new Image(UIHelpers.GetIcon("dataspacesync-pause", 12));
                break;

            case SyncStatus.Suspend:
                (syncitem.Child as Label).Text = CmisSync.Properties_Resources.ResumeSync;
                syncitem.Image = new Image(UIHelpers.GetIcon("dataspacesync-start", 12));
                break;
            }
        }
Example #5
0
        public Spinner(int size) : base()
        {
            this.Size = size;

            this.CycleDuration = 600;
            this.CurrentStep   = 0;

            Gdk.Pixbuf spinner_gallery = UIHelpers.GetIcon("process-working", this.Size);

            int frames_in_width  = spinner_gallery.Width / this.Size;
            int frames_in_height = spinner_gallery.Height / this.Size;

            this.NumSteps = frames_in_width * frames_in_height;
            this.Images   = new Gdk.Pixbuf[this.NumSteps - 1];

            int i = 0;

            for (int y = 0; y < frames_in_height; y++)
            {
                for (int x = 0; x < frames_in_width; x++)
                {
                    if (!(y == 0 && x == 0))
                    {
                        this.Images[i] = new Gdk.Pixbuf(spinner_gallery, x * this.Size, y * this.Size, this.Size, this.Size);
                        i++;
                    }
                }
            }

            this.Timer = new Timer()
            {
                Interval = (double)this.CycleDuration / this.NumSteps
            };

            this.Timer.Elapsed += delegate {
                this.NextImage();
            };

            this.Start();
        }
Example #6
0
        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;
                    }
                });
            };
        }
Example #7
0
        public TransmissionMenuItem(FileTransmissionEvent e) : base(e.Type.ToString())
        {
            Path       = e.Path;
            Type       = e.Type;
            TypeString = Type.ToString();
            switch (Type)
            {
            case FileTransmissionType.DOWNLOAD_NEW_FILE:
                Image      = new Image(UIHelpers.GetIcon("dataspacesync-downloading", 16));
                TypeString = Properties_Resources.NotificationFileDownload;
                break;

            case FileTransmissionType.UPLOAD_NEW_FILE:
                Image      = new Image(UIHelpers.GetIcon("dataspacesync-uploading", 16));
                TypeString = Properties_Resources.NotificationFileUpload;
                break;

            case FileTransmissionType.DOWNLOAD_MODIFIED_FILE:
                TypeString = Properties_Resources.NotificationFileUpdateLocal;
                Image      = new Image(UIHelpers.GetIcon("dataspacesync-updating", 16));
                break;

            case FileTransmissionType.UPLOAD_MODIFIED_FILE:
                TypeString = Properties_Resources.NotificationFileUpdateRemote;
                Image      = new Image(UIHelpers.GetIcon("dataspacesync-updating", 16));
                break;
            }

            double percent = (e.Status.Percent == null)? 0:(double)e.Status.Percent;
            Label  text    = this.Child as Label;

            if (text != null)
            {
                text.Text = String.Format("{0}: {1} ({2})", TypeString, System.IO.Path.GetFileName(Path), CmisSync.Lib.Utils.FormatPercent(percent));
            }

            if (ConfigManager.CurrentConfig.Notifications)
            {
                NotificationUtils.NotifyAsync(String.Format("{0}: {1}", TypeString, System.IO.Path.GetFileName(Path)), Path);
            }

            e.TransmissionStatus += delegate(object sender, TransmissionProgressEventArgs status) {
                TimeSpan diff = DateTime.Now - updateTime;
                if (diff.Seconds < 1)
                {
                    return;
                }

                updateTime = DateTime.Now;

                percent = (status.Percent != null)? (double)status.Percent: 0;
                long?bitsPerSecond = status.BitsPerSecond;
                if (status.Percent != null && bitsPerSecond != null && text != null)
                {
                    Application.Invoke(delegate {
                        text.Text = String.Format("{0}: {1} ({2} {3})",
                                                  TypeString,
                                                  System.IO.Path.GetFileName(Path),
                                                  CmisSync.Lib.Utils.FormatPercent(percent),
                                                  CmisSync.Lib.Utils.FormatBandwidth((long)bitsPerSecond));
                    });
                }
            };
            this.Activated += delegate(object sender, EventArgs args) {
                Utils.OpenFolder(System.IO.Directory.GetParent(Path).FullName);
            };
            Sensitive = true;
        }
Example #8
0
        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;
        }
Example #9
0
        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;
                        }
                    }
                });
            };
        }
Example #10
0
        public RepositoryMenuItem(Repository repo, StatusIconController controller) : base(repo.Name)
        {
            this.SetProperty("always-show-image", new GLib.Value(true));
            this.repository = repo;
            this.controller = controller;
            this.Image      = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16));
            this.repository.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.Status))
                {
                    this.Status = this.repository.Status;
                }

                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.LastFinishedSync))
                {
                    this.changesFoundAt = this.repository.LastFinishedSync;
                    this.UpdateStatusText();
                }

                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.NumberOfChanges))
                {
                    this.changesFound = this.repository.NumberOfChanges;
                    this.UpdateStatusText();
                }
            };

            this.openLocalFolderItem = new CmisSyncMenuItem(
                CmisSync.Properties_Resources.OpenLocalFolder)
            {
                Image = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16))
            };

            this.openLocalFolderItem.Activated += this.OpenFolderDelegate();

            this.editItem            = new CmisSyncMenuItem(CmisSync.Properties_Resources.Settings);
            this.editItem.Activated += this.EditFolderDelegate();

            this.suspendItem = new CmisSyncMenuItem(Properties_Resources.PauseSync);

            this.Status = this.repository.Status;

            this.suspendItem.Activated += this.SuspendSyncFolderDelegate();
            this.statusItem             = new MenuItem(Properties_Resources.StatusSearchingForChanges)
            {
                Sensitive = false
            };

            this.removeFolderFromSyncItem = new CmisSyncMenuItem(
                CmisSync.Properties_Resources.RemoveFolderFromSync)
            {
                Image = new Image(UIHelpers.GetIcon("dataspacesync-deleted", 12))
            };
            this.removeFolderFromSyncItem.Activated += this.RemoveFolderFromSyncDelegate();
            this.separator1 = new SeparatorMenuItem();
            this.separator2 = new SeparatorMenuItem();

            var subMenu = new Menu();

            subMenu.Add(this.statusItem);
            subMenu.Add(this.separator1);
            subMenu.Add(this.openLocalFolderItem);
            subMenu.Add(this.suspendItem);
            subMenu.Add(this.editItem);
            subMenu.Add(this.separator2);
            subMenu.Add(this.removeFolderFromSyncItem);
            this.Submenu = subMenu;
        }
Example #11
0
        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) {
                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();
                });
            };
        }
Example #12
0
        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
        }
Example #13
0
        /// <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;
        }
Example #14
0
        public StatusIcon()
        {
            this.CreateAnimationFrames();

#if HAVE_APP_INDICATOR
            this.indicator = new ApplicationIndicator("dataspacesync",
                                                      "dataspacesync-process-syncing-i", Category.ApplicationStatus);

            this.indicator.Status = Status.Active;
#else
            this.statusIcon        = new Gtk.StatusIcon();
            this.statusIcon.Pixbuf = this.animationFrames[0];

            this.statusIcon.Activate += delegate(object sender, EventArgs args) {
                this.Controller.LocalFolderClicked(null); // Primary mouse button click shows default folder
            };

            this.statusIcon.PopupMenu += this.ShowMenu; // Secondary mouse button click
#endif

            this.CreateMenu();

            this.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.statusIcon.Pixbuf = this.animationFrames[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.statusIcon.Pixbuf = UIHelpers.GetIcon("dataspacesync-process-syncing-error", 24);
#endif
                    }
                });
            };

            this.Controller.UpdateMenuEvent += delegate(IconState state) {
                Application.Invoke(delegate {
                    this.CreateMenu();
                });
            };

            this.Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) {
                if (!this.isHandleCreated)
                {
                    return;
                }

                Application.Invoke(delegate {
                    foreach (var repoItem in this.repoItems)
                    {
                        if (repoItem.RepositoryName == reponame)
                        {
                            foreach (var repo in Program.Controller.Repositories)
                            {
                                if (repo.Name.Equals(reponame))
                                {
                                    repoItem.Status = repo.Status;
                                    break;
                                }
                            }

                            break;
                        }
                    }
                });
            };
        }