Example #1
0
 protected override void CreateTrayInstance()
 {
     m_themeFolder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SVGIcons");
     m_themeFolder = System.IO.Path.Combine(m_themeFolder, "dark");
     
     m_appIndicator = new ApplicationIndicator("duplicati", "normal", Category.ApplicationStatus, m_themeFolder);
 }
Example #2
0
 /// <summary>
 /// Loads tray plugin.
 /// </summary>
 /// <param name="menu">Menu reference.</param>		
 /// <param name="rebuildMenuFunc">Rebuild menu function.</param>		
 public void Load(Gtk.Menu menu, MenuFunc rebuildMenuFunc)
 {
     this.RebuildMenu = rebuildMenuFunc;
     this.indicator = new ApplicationIndicator("glippy", EnvironmentVariables.PanelIcon, Category.Other);
     this.indicator.Status = Status.Active;
     this.indicator.Menu = menu;
 }
Example #3
0
 /// <summary>
 /// Loads tray plugin.
 /// </summary>
 /// <param name="menu">Menu reference.</param>
 /// <param name="rebuildMenuFunc">Rebuild menu function.</param>
 public void Load(Gtk.Menu menu, MenuFunc rebuildMenuFunc)
 {
     this.RebuildMenu      = rebuildMenuFunc;
     this.indicator        = new ApplicationIndicator("glippy", EnvironmentVariables.PanelIcon, Category.Other);
     this.indicator.Status = Status.Active;
     this.indicator.Menu   = menu;
 }
Example #4
0
        private bool DrawAppIndicator()
        {
            try {
                indicator = new ApplicationIndicator("banshee",
                                                     (IconThemeUtils.HasIcon("banshee-panel")) ?
                                                     "banshee-panel" :
                                                     Banshee.ServiceStack.Application.IconName,
                                                     Category.ApplicationStatus);

                // Load the menu
                Gtk3.Menu menu = (Gtk3.Menu)interface_action_service.UIManager.GetWidget("/AppIndicatorTrayMenu");
                menu.Show();

                //This cannot be enabled at the moment because of the Gtk3/Gtk2 conflict. Need to find a solution
                //indicator.Menu = menu;

                // Show the tray icon
                indicator.Status = Status.Active;

                if (!QuitOnCloseSchema.Get())
                {
                    RegisterCloseHandler();
                }
            } catch (Exception e) {
                Hyena.Log.Warning("Error while trying to create the Application Indicator.", e.Message, false);
                return(false);
            }

            return(true);
        }
Example #5
0
        protected override void CreateTrayInstance()
        {
            m_themeFolder = SystemIO.IO_OS.PathCombine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SVGIcons");
            m_themeFolder = SystemIO.IO_OS.PathCombine(m_themeFolder, "dark");

            m_appIndicator = new ApplicationIndicator("duplicati", "normal", Category.ApplicationStatus, m_themeFolder);
        }
Example #6
0
        public Indicator(string name)
        {
            logger = LogManager.Logger;

            indicator = new ApplicationIndicator(name, name, Category.ApplicationStatus);

            symbols = config.Symbols;

            BuildMenu();

            config.Subscribe(this);
        }
        public void Init()
        {
            Application.Init ();

                        Console.WriteLine ("Init()");

                        indicator = new ApplicationIndicator ("my-id", "my-name", AppIndicatorCategory.ApplicationStatus);

                        Console.WriteLine ("Created indicator");

                        Update();
        }
Example #8
0
        public void Init()
        {
            Application.Init();

            Console.WriteLine("Init()");

            indicator = new ApplicationIndicator("my-id", "my-name", Category.ApplicationStatus);

            Console.WriteLine("Created indicator");

            Update();
        }
Example #9
0
        public TomboyIndicatorTray(NoteManager manager)
        {
            this.manager = manager;
            indicator    = new ApplicationIndicator("tomboy-notes", "tomboy", Category.ApplicationStatus);

            SetMenuItems();
            indicator.Status = Status.Active;
            indicator.Title  = Catalog.GetString("Tomboy Notes");

            manager.NoteDeleted += OnNoteDeleted;
            manager.NoteAdded   += OnNoteAdded;
            manager.NoteRenamed += OnNoteRenamed;
            manager.NotesLoaded += OnNotesLoaded;
        }
Example #10
0
        public AppIndicatorTray()
        {
            appIndicator = new ApplicationIndicator ("TasqueTray", IconName,
                                                     AppIndicator.Category.ApplicationStatus);
            appIndicator.Status = Status.Active;

            var menu = Menu;
            var toggleTaskWindowMenuItem = new MenuItem ();
            ToggleTaskWindowAction.ConnectProxy (toggleTaskWindowMenuItem);
            menu.Insert (toggleTaskWindowMenuItem, 0);
            menu.Insert (new SeparatorMenuItem (), 1);
            menu.ShowAll ();

            appIndicator.Menu = menu;
        }
Example #11
0
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            if (current_nf != null)
            {
                try {
                    current_nf.Close();
                } catch {}
            }

            // Hide the AppIndicator before disposing
            indicator.Status = Status.Passive;
            indicator.Dispose();
            indicator = null;

            ServiceManager.PlayerEngine.DisconnectEvent(OnPlayerEvent);

            elements_service.PrimaryWindowClose = null;

            Gtk3.Action close_action = interface_action_service.GlobalActions["CloseAction"];
            if (close_action != null)
            {
                interface_action_service.GlobalActions.Remove(close_action);
            }

            if (ui_manager_id >= 0)
            {
                interface_action_service.RemoveActionGroup("AppIndicator");
                interface_action_service.UIManager.RemoveUi((uint)ui_manager_id);
                ui_manager_id = -1;
            }

            elements_service         = null;
            interface_action_service = null;

            AddinManager.AddinLoaded -= OnAddinLoaded;

            disposed = true;
        }
Example #12
0
		public AppIndicatorTray (GtkApplicationBase application) : base  (application)
		{
			appIndicator = new ApplicationIndicator ("TasqueTray", IconName, Category.ApplicationStatus);
			appIndicator.Status = Status.Active;

			var menu = Menu;
			var toggleTaskWindowMenuItem = new MenuItem ();
			ToggleTaskWindowAction.ConnectProxy (toggleTaskWindowMenuItem);
			menu.Insert (toggleTaskWindowMenuItem, 0);
			menu.Insert (new SeparatorMenuItem (), 1);

			tooltipProxyMenuItem = new MenuItem (Tooltip);
			tooltipProxyMenuItem.Sensitive = false;
			menu.Insert (tooltipProxyMenuItem, 2);
			menu.Insert (new SeparatorMenuItem (), 3);

			menu.ShowAll ();
			
			appIndicator.Menu = menu;
		}
Example #13
0
        public AppIndicatorTray(GtkApplicationBase application)
            : base(application)
        {
            appIndicator = new ApplicationIndicator ("TasqueTray", IconName, Category.ApplicationStatus);
            appIndicator.Status = Status.Active;

            var menu = Menu;
            var toggleTaskWindowMenuItem = new MenuItem ();
            ToggleTaskWindowAction.ConnectProxy (toggleTaskWindowMenuItem);
            menu.Insert (toggleTaskWindowMenuItem, 0);
            menu.Insert (new SeparatorMenuItem (), 1);

            tooltipProxyMenuItem = new MenuItem (Tooltip);
            tooltipProxyMenuItem.Sensitive = false;
            menu.Insert (tooltipProxyMenuItem, 2);
            menu.Insert (new SeparatorMenuItem (), 3);

            menu.ShowAll ();

            appIndicator.Menu = menu;
        }
Example #14
0
    public static void Main()
    {
        Application.Init();

        Window win = new Window("Test");

        win.Resize(200, 200);

        Label label = new Label();

        label.Text = "Hello, world!";

        win.Add(label);

        ApplicationIndicator indicator = new ApplicationIndicator("Example",
                                                                  "applications-microblogging-panel",
                                                                  AppIndicatorCategory.ApplicationStatus);

        indicator.AppIndicatorStatus = AppIndicatorStatus.Attention;

        Menu menu = new Menu();
        var  foo  = new MenuItem("Foo");

        menu.Append(foo);
        foo.Activated += delegate {
            System.Console.WriteLine("Foo item has been activated");
        };

        menu.Append(new MenuItem("Bar"));

        indicator.Menu = menu;
        indicator.Menu.ShowAll();

        indicator.SecondaryActivateTarget = foo;

        win.ShowAll();

        Application.Run();
    }
    public static void Main()
    {
        Application.Init ();

                Window win = new Window ("Test");
                win.Resize (200, 200);

                Label label = new Label ();
                label.Text = "Hello, world!";

                win.Add (label);

                ApplicationIndicator indicator = new ApplicationIndicator ("Example",
                                                                           "applications-microblogging-panel",
                                                                           AppIndicatorCategory.ApplicationStatus);

                indicator.AppIndicatorStatus = AppIndicatorStatus.Attention;

                Menu menu = new Menu ();
                var foo = new MenuItem ("Foo");
                menu.Append (foo);
                foo.Activated += delegate {
                        System.Console.WriteLine ("Foo item has been activated");
                };

                menu.Append (new MenuItem ("Bar"));

                indicator.Menu = menu;
                indicator.Menu.ShowAll ();

                indicator.SecondaryActivateTarget = foo;

                win.ShowAll ();

                Application.Run ();
    }
Example #16
0
        public SparkleStatusIcon()
        {
            AnimationFrames = CreateAnimationFrames ();
            Animation       = CreateAnimation ();

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

                Status = Status.Attention
            };
            #else
            this.status_icon = new StatusIcon ();

            this.status_icon.Activate += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            this.status_icon.Pixbuf = AnimationFrames [0];
            #endif

            if (Controller.Folders.Length == 0)
                StateText = _("Welcome to SparkleShare!");
            else
                StateText = _("Up to date") + " — " + Controller.FolderSize;

            CreateMenu ();

            Controller.UpdateMenuEvent += delegate (IconState state) {
                Application.Invoke (delegate {
                        switch (state) {
                        case IconState.Idle:

                            Animation.Stop ();

                            if (Controller.Folders.Length == 0)
                                StateText = _("Welcome to SparkleShare!");
                            else
                                StateText = _("Up to date") + " — " + Controller.FolderSize;

                            #if HAVE_APP_INDICATOR
                            this.indicator.IconName = "process-syncing-sparkleshare-i";
                            #else
                            this.status_icon.Pixbuf = AnimationFrames [0];
                            #endif

                            UpdateStateText ();
                            CreateMenu ();

                            break;

                        case IconState.Syncing:

                            StateText = _("Syncing…");
                            UpdateStateText ();

                            if (!Animation.Enabled)
                                Animation.Start ();

                            break;

                        case IconState.Error:

                            StateText = _("Not everything is synced");
                            UpdateStateText ();
                            CreateMenu ();

                            #if HAVE_APP_INDICATOR
                            this.indicator.IconName = "sparkleshare-syncing-error";
                            #else
                            this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
                            #endif

                            break;
                        }
                });
            };
        }
        public SparkleStatusIcon()
        {
            #if HAVE_APP_INDICATOR
            this.indicator = new ApplicationIndicator ("sparkleshare", "sparkleshare", Category.ApplicationStatus);
            this.indicator.IconName = "process-syncing-idle";
            this.indicator.Status   = Status.Active;
            #else
            this.status_icon        = new StatusIcon ();
            this.status_icon.Pixbuf = this.syncing_idle_image;

            this.status_icon.Activate  += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            #endif

            CreateMenu ();

            Controller.UpdateIconEvent += delegate (IconState state) {
                Application.Invoke (delegate {
                    switch (state) {
                    case IconState.Idle: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-idle";
                        #else
                        this.status_icon.Pixbuf = this.syncing_idle_image;
                        #endif
                        break;
                    }
                    case IconState.SyncingUp: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-up";
                        #else
                        this.status_icon.Pixbuf = this.syncing_up_image;
                        #endif
                        break;
                    }
                    case IconState.SyncingDown: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-down";
                        #else
                        this.status_icon.Pixbuf = this.syncing_down_image;
                        #endif
                        break;
                    }
                    case IconState.Syncing: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing";
                        #else
                        this.status_icon.Pixbuf = this.syncing_image;
                        #endif
                        break;
                    }
                    case IconState.Error: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-error";
                        #else
                        this.status_icon.Pixbuf = this.syncing_error_image;
                        #endif
                        break;
                    }
                    }

                    #if HAVE_APP_INDICATOR
                    // Force update of the status icon
                    this.indicator.Status = Status.Attention;
                    this.indicator.Status = Status.Active;
                    #endif
                });
            };

            Controller.UpdateStatusItemEvent += delegate (string state_text) {
                Application.Invoke (delegate {
                    (this.state_item.Child as Label).Text = state_text;
                    this.state_item.ShowAll ();
                });
            };

            Controller.UpdateQuitItemEvent += delegate (bool item_enabled) {
                Application.Invoke (delegate {
                    this.quit_item.Sensitive = item_enabled;
                    this.quit_item.ShowAll ();
                });
            };

            Controller.UpdateRecentEventsItemEvent += delegate (bool item_enabled) {
                Application.Invoke (delegate {
                    this.recent_events_item.Sensitive = item_enabled;
                    this.recent_events_item.ShowAll ();
                });
            };

            Controller.UpdateMenuEvent += delegate (IconState state) {
                Application.Invoke (delegate {
                    CreateMenu ();
                });
            };
        }
Example #18
0
        /// <summary>
        /// Initalize Gtk and DBus stuff
        /// </summary>
        private void GtkDBusInit()
        {
            /* setup ApplicationIndicator */

            indicator =
                new ApplicationIndicator("keepass2-plugin-appindicator" + instanceCount++,
                                         "keepass2-locked",
                                         AppIndicator.Category.ApplicationStatus);
#if DEBUG
            indicator.IconThemePath = Path.GetFullPath("Resources/icons");
#endif
            indicator.Title  = PwDefs.ProductName;
            indicator.Status = AppIndicator.Status.Active;

            appIndicatorMenu = new Gtk.Menu();

            var trayContextMenu = pluginHost.MainWindow.TrayContextMenu;
            // make copy of item list to prevent list changed exception when iterating
            var menuItems =
                new System.Windows.Forms.ToolStripItem[trayContextMenu.Items.Count];
            trayContextMenu.Items.CopyTo(menuItems, 0);
            trayContextMenu.ItemAdded += (sender, e) =>
                                         DBusBackgroundWorker.InvokeGtkThread
                                             (() => ConvertAndAddMenuItem(e.Item, appIndicatorMenu));

            foreach (System.Windows.Forms.ToolStripItem item in menuItems)
            {
                ConvertAndAddMenuItem(item, appIndicatorMenu);
            }

            indicator.Menu = appIndicatorMenu;
            try {
                // This is a hack to get the about-to-show event from the dbusmenu
                // that is created by the appindicator.
                var getPropertyMethod =
                    typeof(GLib.Object).GetMethod("GetProperty",
                                                  BindingFlags.NonPublic | BindingFlags.Instance);
                var dbusMenuServer =
                    (GLib.Value)getPropertyMethod.Invoke(indicator,
                                                         new object[] { "dbus-menu-server" });
                var rootNode =
                    (GLib.Value)getPropertyMethod.Invoke(dbusMenuServer.Val,
                                                         new object[] { "root-node" });
                aboutToShowSignal =
                    GLib.Signal.Lookup((GLib.Object)rootNode.Val, "about-to-show");
                aboutToShowSignal.AddDelegate((EventHandler)OnAppIndicatorMenuShown);
            } catch (Exception ex) {
                Debug.Fail(ex.Message);
                // On desktops that don't support application indicators, libappinidicator
                // creates a fallback GtkStatusIcon. This event only fires in that case.
                appIndicatorMenu.Shown += OnAppIndicatorMenuShown;
            }

            // when mouse cursor is over application indicator, scroll up will untray
            // and scroll down will tray KeePass
            indicator.ScrollEvent += (o, args) =>
            {
                /* Workaround for bug in mono/appindicator-sharp.
                 *
                 * args.Direction throws InvalidCastException
                 * Can't cast args.Arg[1] to Gdk.ScrollDirection for some reason, so we
                 * have to cast to uint first (that is the underlying data type) and
                 * then cast to Gdk.ScrollDirection
                 */
                var scrollDirectionUint = (uint)args.Args[1];
                var scrollDirection     = (Gdk.ScrollDirection)scrollDirectionUint;

                var trayMenuItem = trayContextMenu.Items["m_ctxTrayTray"];
                if (trayMenuItem.Enabled && (scrollDirection == Gdk.ScrollDirection.Up ^
                                             pluginHost.MainWindow.Visible))
                {
                    DBusBackgroundWorker.InvokeWinformsThread
                        (() => trayMenuItem.PerformClick());
                }
            };
        }
        public SparkleStatusIcon()
        {
            AnimationFrames = CreateAnimationFrames ();
            Animation = CreateAnimation ();

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

                Status = Status.Attention
            };
            #else
            this.status_icon = new StatusIcon ();

            this.status_icon.Activate += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            #endif

            SetNormalState ();
            CreateMenu ();

            SparkleShare.Controller.FolderSizeChanged += delegate {
                Application.Invoke (delegate {
                    if (!Animation.Enabled)
                        SetNormalState ();

                    UpdateMenu ();
                });
            };

            SparkleShare.Controller.FolderListChanged += delegate {
                Application.Invoke (delegate {
                    SetNormalState ();
                    CreateMenu ();
                });
            };

            SparkleShare.Controller.OnIdle += delegate {
                Application.Invoke (delegate {
                    SetNormalState ();
                    UpdateMenu ();
                });
            };

            SparkleShare.Controller.OnSyncing += delegate {
                Application.Invoke (delegate {
                    SetAnimationState ();
                    UpdateMenu ();
                });
            };

            SparkleShare.Controller.OnError += delegate {
                Application.Invoke (delegate {
                    SetNormalState (true);
                    UpdateMenu ();
                });
            };
        }
Example #20
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 #21
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 #22
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 #23
0
        public void Dispose ()
        {
            if (disposed) {
                return;
            }

            if (current_nf != null) {
                try {
                    current_nf.Close ();
                } catch {}
            }

            // Hide the AppIndicator before disposing
            indicator.Status = Status.Passive;
            indicator.Dispose();
            indicator = null;

            ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);

            elements_service.PrimaryWindowClose = null;

            Gtk.Action close_action = interface_action_service.GlobalActions["CloseAction"];
            if (close_action != null) {
                interface_action_service.GlobalActions.Remove (close_action);
            }

            if (ui_manager_id >= 0) {
                interface_action_service.RemoveActionGroup ("AppIndicator");
                interface_action_service.UIManager.RemoveUi ((uint)ui_manager_id);
                ui_manager_id = -1;
            }

            elements_service = null;
            interface_action_service = null;

            AddinManager.AddinLoaded -= OnAddinLoaded;

            disposed = true;
        }
        public SparkleStatusIcon()
        {
            AnimationFrames = CreateAnimationFrames();
            Animation       = CreateAnimation();

            #if HAVE_APP_INDICATOR
            this.indicator = new ApplicationIndicator("sparkleshare",
                                                      "process-syncing-sparkleshare-i", Category.ApplicationStatus)
            {
                Status = Status.Attention
            };
            #else
            this.status_icon = new StatusIcon();

            this.status_icon.Activate  += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            this.status_icon.Pixbuf     = AnimationFrames [0];
            #endif

            if (Controller.Folders.Length == 0)
            {
                StateText = _("Welcome to SparkleShare!");
            }
            else
            {
                StateText = _("Up to date") + " — " + Controller.FolderSize;
            }

            CreateMenu();

            Controller.UpdateMenuEvent += delegate(IconState state) {
                Application.Invoke(delegate {
                    switch (state)
                    {
                    case IconState.Idle:

                        Animation.Stop();

                        if (Controller.Folders.Length == 0)
                        {
                            StateText = _("Welcome to SparkleShare!");
                        }
                        else
                        {
                            StateText = _("Up to date") + " — " + Controller.FolderSize;
                        }

                            #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-sparkleshare-i";
                            #else
                        this.status_icon.Pixbuf = AnimationFrames [0];
                            #endif

                        UpdateStateText();
                        CreateMenu();

                        break;

                    case IconState.Syncing:

                        StateText = _("Syncing…");
                        UpdateStateText();

                        if (!Animation.Enabled)
                        {
                            Animation.Start();
                        }

                        break;

                    case IconState.Error:

                        Animation.Stop();

                        StateText = _("Not everything is synced");
                        UpdateStateText();
                        CreateMenu();

                            #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "sparkleshare-syncing-error";
                            #else
                        this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon("sparkleshare-syncing-error", 24);
                            #endif

                        break;
                    }
                });
            };
        }
        public SparkleStatusIcon()
        {
            #if HAVE_APP_INDICATOR
            this.indicator          = new ApplicationIndicator("sparkleshare", "sparkleshare", Category.ApplicationStatus);
            this.indicator.IconName = "process-syncing-idle";
            this.indicator.Status   = Status.Active;
            #else
            this.status_icon          = new StatusIcon();
            this.status_icon.IconName = "sparkleshare";

            this.status_icon.Activate  += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            #endif

            CreateMenu();

            Controller.UpdateIconEvent += delegate(IconState state) {
                Application.Invoke(delegate {
                    switch (state)
                    {
                    case IconState.Idle: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-idle";
                        #else
                        this.status_icon.IconName = "sparkleshare";
                        #endif
                        break;
                    }

                    case IconState.SyncingUp: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-up";
                        #else
                        this.status_icon.IconName = "process-syncing-up";
                        #endif
                        break;
                    }

                    case IconState.SyncingDown: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-down";
                        #else
                        this.status_icon.IconName = "process-syncing-down";
                        #endif
                        break;
                    }

                    case IconState.Syncing: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing";
                        #else
                        this.status_icon.IconName = "process-syncing";
                        #endif
                        break;
                    }

                    case IconState.Error: {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-error";
                        #else
                        this.status_icon.IconName = "process-syncing-error";
                        #endif
                        break;
                    }
                    }

                    #if HAVE_APP_INDICATOR
                    // Force update of the status icon
                    this.indicator.Status = Status.Attention;
                    this.indicator.Status = Status.Active;
                    #endif
                });
            };

            Controller.UpdateStatusItemEvent += delegate(string state_text) {
                Application.Invoke(delegate {
                    (this.state_item.Child as Label).Text = state_text;
                    this.state_item.ShowAll();
                });
            };

            Controller.UpdateQuitItemEvent += delegate(bool item_enabled) {
                Application.Invoke(delegate {
                    this.quit_item.Sensitive = item_enabled;
                    this.quit_item.ShowAll();
                });
            };

            Controller.UpdateMenuEvent += delegate(IconState state) {
                Application.Invoke(delegate { CreateMenu(); });
            };
        }
        public SparkleStatusIcon()
        {
            #if HAVE_APP_INDICATOR
            this.indicator = new ApplicationIndicator ("sparkleshare", "sparkleshare", Category.ApplicationStatus);
            this.indicator.IconName = "process-syncing-idle";
            this.indicator.Status   = Status.Active;
            #else
            this.status_icon          = new StatusIcon ();
            this.status_icon.IconName = "sparkleshare";

            this.status_icon.Activate  += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            #endif

            CreateMenu ();

            Controller.UpdateIconEvent += delegate (IconState state) {
                Application.Invoke (delegate {
                    #if HAVE_APP_INDICATOR
                    string icon_name = "process-syncing-idle";
                    #else
                    string icon_name = "sparkleshare";
                    #endif

                    if (state == IconState.SyncingUp)
                        icon_name = "process-syncing-up";
                    else if (state == IconState.SyncingDown)
                        icon_name = "process-syncing-down";
                    else if (state == IconState.Syncing)
                        icon_name = "process-syncing";
                    else if (state == IconState.Error)
                        icon_name = "process-syncing-error";

                    #if HAVE_APP_INDICATOR
                    this.indicator.IconName = icon_name;

                    this.indicator.Status = Status.Attention;
                    this.indicator.Status = Status.Active;
                    #else
                    this.status_icon.IconName = icon_name;
                    #endif
                });
            };

            Controller.UpdateStatusItemEvent += delegate (string state_text) {
                Application.Invoke (delegate {
                    (this.state_item.Child as Label).Text = state_text;
                    this.state_item.ShowAll ();
                });
            };

            Controller.UpdateQuitItemEvent += delegate (bool item_enabled) {
                Application.Invoke (delegate {
                    this.quit_item.Sensitive = item_enabled;
                    this.quit_item.ShowAll ();
                });
            };

            Controller.UpdateMenuEvent += delegate (IconState state) {
                Application.Invoke (delegate { CreateMenu (); });
            };
        }
        private void Run()
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => { return true; };

            Gtk.Application.Init ();

            redFilePath = CreateTempFileFromResource ("circlecinotification.resources.red.svg");
            greenFilePath = CreateTempFileFromResource ("circlecinotification.resources.green.svg");

            indicator = new ApplicationIndicator ("CircleCi Indicator", redFilePath, Category.ApplicationStatus);
            Preferences prefs = Preferences.load ();

            menu = new Gtk.Menu ();

            Gtk.MenuItem loadingProjects = new Gtk.ImageMenuItem ("Loading projects...", null);
            projectMenuItems.Clear ();
            projectMenuItems.Add (loadingProjects);

            Gtk.MenuItem aboutMenuItem = new Gtk.ImageMenuItem (Gtk.Stock.About, null);
            aboutMenuItem.Activated += HandleAbout;

            Gtk.MenuItem setTokenMenuItem = new Gtk.ImageMenuItem ("Set CircleCi Token", null);
            setTokenMenuItem.Activated += HandleResetToken;

            Gtk.MenuItem exitMenuItem = new Gtk.ImageMenuItem (Gtk.Stock.Quit, null);
            exitMenuItem.Activated += HandleQuit;

            menu.Add (loadingProjects);
            menu.Add (new Gtk.SeparatorMenuItem ());
            menu.Add (setTokenMenuItem);
            menu.Add (aboutMenuItem);
            menu.Add (new Gtk.SeparatorMenuItem ());
            menu.Add (exitMenuItem);
            menu.ShowAll ();
            indicator.Menu = menu;
            indicator.Status = Status.Active;

            if (prefs.token == null) {
                ResetToken ();
            } else {
                RefreshStatus ();
            }

            Gtk.Application.Run ();
        }
Example #28
0
        private bool DrawAppIndicator ()
        {
            try {
                indicator = new ApplicationIndicator ("banshee",
                                                      (IconThemeUtils.HasIcon ("banshee-panel")) ?
                                                      "banshee-panel" :
                                                      Banshee.ServiceStack.Application.IconName,
                                                      Category.ApplicationStatus);

                // Load the menu
                Menu menu = (Menu) interface_action_service.UIManager.GetWidget("/AppIndicatorTrayMenu");
                menu.Show ();

                indicator.Menu = menu;

                // Show the tray icon
                indicator.Status = Status.Active;

                if (!QuitOnCloseSchema.Get ()) {
                    RegisterCloseHandler ();
                }
            } catch (Exception e) {
                Hyena.Log.Warning ("Error while trying to create the Application Indicator.", e.Message, false);
                return false;
            }

            return true;
        }
Example #29
0
    public void LoadEverything()
    {
        MainWindow.Instance = this;

        if (HidSharp.PlatformDetector.RunningPlatform() == HidSharp.PlatformDetector.Platform.Windows)
        {
            SetupSingleInstanceEvent();
        }

        Build();

        String brandingPath = global::System.IO.Path.Combine(global::System.AppDomain.CurrentDomain.BaseDirectory, "branding.png");

        if (File.Exists(brandingPath))
        {
            this.imageBranding.File = brandingPath;

            this.SetSizeRequest(500, this.imageBranding.Pixbuf.Height + 500);
        }

        if (ApplicationSettings.ApplicationTitle != "")
        {
            this.Title = String.Format(ApplicationSettings.ApplicationTitle, ApplicationDataModel.ApplicationVersion);
        }
        else
        {
            this.Title = "BlinkStick " + ApplicationDataModel.ApplicationVersion;
        }

        log.Info("Loading data");
        DataModel.Load();

        log.Debug("Registering/Unregistering startup");
        RegisterStartup(ApplicationSettings.StartWithWindows);

        log.Debug("Loading main form icon");
        this.Icon = new global::Gdk.Pixbuf(global::System.IO.Path.Combine(global::System.AppDomain.CurrentDomain.BaseDirectory, "icon.png"));

        DeviceMonitor = new UsbMonitor();
        DeviceMonitor.UsbDevicesChanged += (object sender, EventArgs e) => {
            Gtk.Application.Invoke(delegate {
                RefreshDevices();
            });
        };
        DeviceMonitor.Start();

        log.Debug("Building popup menu");
        //Build Popup Menu for TrayIcon
        popupMenu = new Menu();

        //Settings menu item
        ImageMenuItem menuItemSettings = new ImageMenuItem("Settings");

        menuItemSettings.Image      = new Gtk.Image("icons-dark-cog-small", IconSize.Menu);
        menuItemSettings.Activated += ToggleMainWindow;
        popupMenu.Append(menuItemSettings);

        popupMenu.Append(new SeparatorMenuItem());

        //Quit menu item
        ImageMenuItem menuItemQuit = new ImageMenuItem("Quit");

        menuItemQuit.Image      = new Gtk.Image("icon-dark-sign-out-small", IconSize.Menu);
        menuItemQuit.Activated += OnQuitActionActivated;
        popupMenu.Append(menuItemQuit);

        log.Debug("Showing popup menu");
        popupMenu.ShowAll();
        //TODO: Remove ifdef and use platform detection
        #if LINUX
        indicator        = new ApplicationIndicator("blinkstick", "icon", Category.ApplicationStatus, ExecutableFolder);
        indicator.Menu   = popupMenu;
        indicator.Status = AppIndicator.Status.Active;
        #else
        log.Debug("Setting up tray icon");
        if (HidSharp.PlatformDetector.RunningPlatform() == HidSharp.PlatformDetector.Platform.Windows)
        {
            trayIcon = new StatusIcon(new Pixbuf(System.IO.Path.Combine(ExecutableFolder, "icon.ico")));
        }
        else if (HidSharp.PlatformDetector.RunningPlatform() == HidSharp.PlatformDetector.Platform.Mac)
        {
            trayIcon = new StatusIcon(new Pixbuf(System.IO.Path.Combine(ExecutableFolder, "icon-osx.ico")));
        }
        trayIcon.Tooltip = this.Title;
        trayIcon.Visible = true;

        // Show/Hide the window (even from the Panel/Taskbar) when the TrayIcon has been clicked.
        if (HidSharp.PlatformDetector.RunningPlatform() == HidSharp.PlatformDetector.Platform.Windows)
        {
            trayIcon.Activate += ToggleMainWindow;
        }

        trayIcon.PopupMenu += delegate {
            if (HidSharp.PlatformDetector.RunningPlatform() == HidSharp.PlatformDetector.Platform.Mac)
            {
                this.Show();
            }
            else
            {
                popupMenu.ShowAll();
                popupMenu.Popup();
            }
        };
        #endif
        if (HidSharp.PlatformDetector.RunningPlatform() == HidSharp.PlatformDetector.Platform.Mac)
        {
            //enable the global key handler for keyboard shortcuts
            MacMenu.GlobalKeyHandlerEnabled = true;

            //Tell the IGE library to use your GTK menu as the Mac main menu
            //MacMenu.MenuBar = menubar2;

            //tell IGE which menu item should be used for the app menu's quit item
            MacMenu.QuitMenuItem = menuItemQuit;

            //add a new group to the app menu, and add some items to it
            var           appGroup      = MacMenu.AddAppMenuGroup();
            ImageMenuItem menuItemAbout = new ImageMenuItem("About");
            menuItemAbout.Activated += (sender, e) => {
                this.Show();
                VisiblePage = this.Pages[this.Pages.Count - 1];
            };

            appGroup.AddMenuItem(menuItemAbout, "About BlinkStick Client...");

            ImageMenuItem menuItemPreferences = new ImageMenuItem("Preferences");
            menuItemPreferences.Activated += (sender, e) => {
                this.Show();
                VisiblePage = this.Pages[this.Pages.Count - 2];
            };
            appGroup.AddMenuItem(menuItemPreferences, "Preferences...");

            ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e)
            {
                OnQuitActionActivated(null, null);
                e.Handled = true;
            };

            ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) {
                this.Deiconify();
                this.Visible = true;
                e.Handled    = true;
            };

            //optional, only need this if your Info.plist registers to handle urls
            ApplicationEvents.OpenUrls += delegate(object sender, ApplicationUrlEventArgs e) {
                if (e.Urls != null || e.Urls.Count > 0)
                {
                    //OpenUrls (e.Urls);
                }
                e.Handled = true;
            };
        }

        NotificationRegistry.Register("Utilities",
                                      "Simple test notification",
                                      typeof(NotificationTest),
                                      typeof(TestEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-test.png"));

        NotificationRegistry.Register("Utilities",
                                      "Play pattern after BlinkStick Client application starts",
                                      typeof(NotificationStart),
                                      typeof(TestEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-test.png"));

        NotificationRegistry.Register("Utilities",
                                      "Play pattern before BlinkStick Client application exits",
                                      typeof(NotificationExit),
                                      typeof(TestEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-test.png"));

        NotificationRegistry.Register("Background",
                                      "Creates an ambilight effect",
                                      typeof(NotificationAmbilight),
                                      null,
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-ambilight.png"));

        NotificationRegistry.Register("Background",
                                      "Runs a Boblight service prefonfigured for BlinkStick " +
                                      "which allows applications supporting Boblight protocol " +
                                      "to control the device and create ambilight effects",
                                      typeof(NotificationBoblight), null);

        NotificationRegistry.Register("Email",
                                      "Checks your GMail account and notifies when new mail arrives",
                                      typeof(NotificationGmail),
                                      typeof(GmailEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-gmail.png"));

        NotificationRegistry.Register("Email",
                                      "Checks your IMAP email account and notifies when new mail arrives",
                                      typeof(NotificationImap),
                                      typeof(EmailEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-mail.png"));

        NotificationRegistry.Register("Email",
                                      "Checks your POP3 email account and notifies when new mail arrives",
                                      typeof(NotificationPop3),
                                      typeof(EmailEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-mail.png"));

        NotificationRegistry.Register("Background",
                                      "Randomly changes BlinkStick color to create color mood",
                                      typeof(NotificationMood),
                                      typeof(MoodlightEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-moodlight.png"));

        NotificationRegistry.Register("Background",
                                      "Sets color for currently activated application",
                                      typeof(NotificationApplication),
                                      typeof(ApplicationEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-application.png"));

        NotificationRegistry.Register("Hardware",
                                      "Displays a notification when CPU usage is above limit",
                                      typeof(NotificationCpu),
                                      typeof(CpuEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-cpu.png"));

        NotificationRegistry.Register("Hardware",
                                      "Displays a notification when RAM usage is above limit",
                                      typeof(NotificationRam),
                                      typeof(CpuEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-ram.png"));

        NotificationRegistry.Register("Hardware",
                                      "Displays a notification when battery charge drops below certain limit",
                                      typeof(NotificationBattery),
                                      typeof(CpuEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-battery.png"));

        NotificationRegistry.Register("Hardware",
                                      "Displays a notification when available disk space drops below certain limit",
                                      typeof(NotificationDiskSpace),
                                      typeof(DiskSpaceEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-hdd.png"));

        NotificationRegistry.Register("Hardware",
                                      "Activate pattern when keyboard key combination is pressed",
                                      typeof(NotificationKeyboard),
                                      typeof(KeyboardEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-key.png"));

        NotificationRegistry.Register("Services",
                                      "Creates a remote control server accessible via HTTP.",
                                      typeof(NotificationRemoteControl),
                                      typeof(RemoteControlEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-remote-control.png"));

        NotificationRegistry.Register("Services",
                                      "Creates an MQTT server which allows remote control of connected BlinkStick devices via MQTT protocol.",
                                      typeof(NotificationMqtt),
                                      null);

        NotificationRegistry.Register("Services",
                                      "Connects to www.blinkstick.com and allows remote control of a BlinkStick device",
                                      typeof(NotificationBlinkStickDotCom),
                                      typeof(BlinkStickDotComEditorWidget),
                                      Gdk.Pixbuf.LoadFromResource("BlinkStickClient.Resources.notifications.notification-blinkstickdotcom.png"));

        NotificationRegistry.Register("Services",
                                      "Connects to IFTTT and allows remote control of a BlinkStick device",
                                      typeof(NotificationIfttt),
                                      null);

        if (ApplicationSettings.SingleBlinkStickMode)
        {
            overviewWidget = new OverviewSingleWidget();
            hbox1.PackEnd(overviewWidget, true, true, 0);
            Pages.Add(overviewWidget);
            VisiblePage = overviewWidget;
        }
        else
        {
            overviewWidget = new OverviewWidget();
            hbox1.PackEnd(overviewWidget, true, true, 0);
            Pages.Add(overviewWidget);
            VisiblePage = overviewWidget;
        }

        notificationsWidget                     = new NotificationsWidget();
        notificationsWidget.ParentForm          = this;
        notificationsWidget.DataModel           = DataModel;
        notificationsWidget.ApplicationSettings = this.ApplicationSettings;
        notificationsWidget.Initialize();
        hbox1.PackEnd(notificationsWidget, true, true, 0);
        Pages.Add(notificationsWidget);

        PatternEditorWidget patternEditorWidget = new PatternEditorWidget();
        patternEditorWidget.DataModel = this.DataModel;
        hbox1.PackEnd(patternEditorWidget, true, true, 0);
        Pages.Add(patternEditorWidget);

        eventsWidget           = new EventsWidget();
        eventsWidget.DataModel = this.DataModel;
        hbox1.PackEnd(eventsWidget, true, true, 0);
        Pages.Add(eventsWidget);

        SettingsWidget settingsWidget = new SettingsWidget();
        settingsWidget.LoadSettings(ApplicationSettings);
        hbox1.PackEnd(settingsWidget, true, true, 0);
        Pages.Add(settingsWidget);

        HelpWidget helpWidget = new HelpWidget();
        hbox1.PackEnd(helpWidget, true, true, 0);
        Pages.Add(helpWidget);

        if (overviewWidget is OverviewWidget)
        {
            ((OverviewWidget)overviewWidget).DataModel = this.DataModel;
        }
        else
        {
            ((OverviewSingleWidget)overviewWidget).DataModel           = this.DataModel;
            ((OverviewSingleWidget)overviewWidget).ApplicationSettings = this.ApplicationSettings;
            ((OverviewSingleWidget)overviewWidget).UpdateUI();
        }
        notificationsWidget.DataModel           = this.DataModel;
        notificationsWidget.ApplicationSettings = this.ApplicationSettings;

        RefreshDevices();

        notificationService           = new NotificationService();
        notificationService.DataModel = this.DataModel;
        notificationService.Start();

        log.Debug("Initialization done");
    }
        public SparkleStatusIcon()
        {
            CreateAnimationFrames ();
            CreateAnimation ();

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

                Status = Status.Attention
            };
            #else
            this.status_icon = new StatusIcon ();

            this.status_icon.Activate += ShowMenu; // Primary mouse button click
            this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click
            this.status_icon.Pixbuf = this.animation_frames [0];
            #endif

            if (Controller.Folders.Length == 0)
                this.state_text = _("Welcome to SparkleShare!");
            else
                this.state_text = _("Files up to date") + Controller.FolderSize;

            CreateMenu ();

            Controller.UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
                Application.Invoke (delegate {
                    if (this.quit_item != null) {
                        this.quit_item.Sensitive = quit_item_enabled;
                        this.menu.ShowAll ();
                    }
                });
            };

            Controller.UpdateMenuEvent += delegate (IconState state) {
                Application.Invoke (delegate {
                    switch (state) {
                    case IconState.Idle:

                        this.animation.Stop ();

                        if (Controller.Folders.Length == 0)
                            this.state_text = _("Welcome to SparkleShare!");
                        else
                            this.state_text = _("Files up to date") + Controller.FolderSize;

                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "process-syncing-sparkleshare-i";
                        #else
                        this.status_icon.Pixbuf = this.animation_frames [0];
                        #endif

                        UpdateStateText ();
                        CreateMenu ();

                        break;

                    case IconState.Syncing:

                        this.state_text = _("Syncing… ") +
                                    Controller.ProgressPercentage + "%  " +
                                    Controller.ProgressSpeed;

                        UpdateStateText ();

                        if (!this.animation.Enabled)
                            this.animation.Start ();

                        break;

                    case IconState.Error:

                        this.animation.Stop ();

                        this.state_text = _("Not everything is synced");
                        UpdateStateText ();
                        CreateMenu ();

                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "sparkleshare-syncing-error";
                        #else
                        this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon ("sparkleshare-syncing-error", 24);
                        #endif

                        break;
                    }

                    this.menu.ShowAll ();
                });
            };
        }
Example #31
0
 /// <summary>
 /// Unloads plugin.
 /// </summary>
 public void Unload()
 {
     this.indicator.Status = Status.Passive;
     this.indicator = null;
     System.GC.Collect(); // HACK: Ugly way to remove appindicator icon instantly.
 }
Example #32
0
 /// <summary>
 /// Unloads plugin.
 /// </summary>
 public void Unload()
 {
     this.indicator.Status = Status.Passive;
     this.indicator        = null;
     System.GC.Collect();             // HACK: Ugly way to remove appindicator icon instantly.
 }
Example #33
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 #34
0
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		if (!BlinkstickDeviceFinder.IsUnix())
		{
			SetupSingleInstanceEvent();
		}

		Build ();

		this.Title = "BlinkStick " + ApplicationVersion;

		log.Debug("Setting up controls");

		Gtk.TreeViewColumn eventTitleColumn = new Gtk.TreeViewColumn ();
		eventTitleColumn.Title = "Name";

		Gtk.TreeViewColumn eventTypeColumn = new Gtk.TreeViewColumn ();
		eventTypeColumn.Title = "Type";

		Gtk.TreeViewColumn eventColorColumn = new Gtk.TreeViewColumn ();
		eventColorColumn.Title = "Color";

		// Create the text cell that will display the artist name
		Gtk.CellRendererText eventTitleCell = new Gtk.CellRendererText ();
		Gtk.CellRendererText eventTypeCell = new Gtk.CellRendererText ();
		Gtk.CellRendererPixbuf eventColorCell = new Gtk.CellRendererPixbuf ();

		log.Debug ("Loading main form icon");
		this.Icon = new global::Gdk.Pixbuf (global::System.IO.Path.Combine (global::System.AppDomain.CurrentDomain.BaseDirectory, "icon.png"));
			 
		log.Debug( "Setting up treeview");
		// Add the cell to the column
		eventColorColumn.PackStart (eventColorCell, false);
		eventTypeColumn.PackEnd (eventTypeCell, true);
		eventTitleColumn.PackEnd (eventTitleCell, true);
	 
		// Tell the Cell Renderers which items in the model to display
		//eventTitleColumn.AddAttribute (eventTitleCell, "name", 0);
		eventTitleColumn.SetCellDataFunc (eventTitleCell, new Gtk.TreeCellDataFunc (RenderEventName));
		eventTypeColumn.SetCellDataFunc (eventTypeCell, new Gtk.TreeCellDataFunc (RenderEventType));
		eventColorColumn.SetCellDataFunc (eventColorCell, new Gtk.TreeCellDataFunc (RenderEventColor));

		treeviewEvents.Model = EventListStore;

		treeviewEvents.AppendColumn (eventColorColumn);
		treeviewEvents.AppendColumn (eventTypeColumn);
		treeviewEvents.AppendColumn (eventTitleColumn);

		log.Debug("Updating buttons");
		UpdateButtons ();

		log.Debug("Setting up notification manager");
		Manager = new NotificationManager ();
		Manager.NotificationUpdated += HandleNotificationUpdated;
		Manager.Load ();
		Manager.UpdateControllers();

		DeviceMonitor = new UsbMonitor(this.GdkWindow.Handle);
		DeviceMonitor.UsbDeviceAdded += (object sender, EventArgs e) => {
			Gtk.Application.Invoke (delegate {
				Manager.UpdateControllers();

				if (testForm != null)
				{
					testForm.PopulateForm();
				}
			});
		};
		DeviceMonitor.Start ();

		log.Debug("Adding notifications to the tree");
		//Gtk.TreeIter customEventRoot = EventListStore.AppendValues(new TriggeredEvent("Custom"));
		foreach (CustomNotification e in Manager.Notifications) {
			//EventListStore.AppendValues(customEventRoot, e);
			EventListStore.AppendValues (e);
		}

		log.Debug("Starting notification manager");
		Manager.Start ();

		log.Debug ("Building popup menu");
		//Build Popup Menu for TrayIcon
		popupMenu = new Menu ();

		//Settings menu item
		ImageMenuItem menuItemSettings = new ImageMenuItem ("Settings");
		menuItemSettings.Image = new Gtk.Image(Stock.Preferences, IconSize.Menu);
		menuItemSettings.Activated += ToggleMainWindow;
		popupMenu.Append(menuItemSettings);

		popupMenu.Append(new SeparatorMenuItem());

		//Quit menu item
		ImageMenuItem menuItemQuit = new ImageMenuItem ("Quit");
		menuItemQuit.Image = new Gtk.Image (Stock.Quit, IconSize.Menu);
		menuItemQuit.Activated += OnQuitActionActivated;
		popupMenu.Append (menuItemQuit);

		log.Debug("Showing popup menu");
		popupMenu.ShowAll();

#if LINUX
		indicator = new ApplicationIndicator ("blinkstick", "icon", Category.ApplicationStatus, ExecutableFolder);	
		indicator.Menu = popupMenu;
		indicator.Status = AppIndicator.Status.Active;	
#else

		log.Debug ("Setting up tray icon");
		trayIcon = new StatusIcon (new Pixbuf (System.IO.Path.Combine(ExecutableFolder, "icon.ico")));
		trayIcon.Tooltip = this.Title;
		trayIcon.Visible = true;

		// Show/Hide the window (even from the Panel/Taskbar) when the TrayIcon has been clicked.
		trayIcon.Activate += ToggleMainWindow;

		trayIcon.PopupMenu += delegate {
			popupMenu.ShowAll ();
			popupMenu.Popup ();
		};
#endif
		log.Debug("Initialization done");
	}
Example #35
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;
                        }
                    }
                });
            };
        }
Example #36
0
        public SparkleStatusIcon()
        {
            CreateAnimationFrames();

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

            this.indicator.Status = Status.Attention;
            #else
            this.status_icon        = new 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-sparkleshare-";
                        for (int i = 0; i <= icon_frame; i++)
                        {
                            icon_name += "i";
                        }

                        this.indicator.IconName = icon_name;
                        #else
                        this.status_icon.Pixbuf = this.animation_frames [icon_frame];
                        #endif
                    }
                    else
                    {
                        #if HAVE_APP_INDICATOR
                        this.indicator.IconName = "sparkleshare-syncing-error";
                        #else
                        this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon("sparkleshare-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.UpdateQuitItemEvent += delegate(bool item_enabled) {
                Application.Invoke(delegate {
                    this.quit_item.Sensitive = item_enabled;
                    this.quit_item.ShowAll();
                });
            };

            Controller.UpdateOpenRecentEventsItemEvent += delegate(bool item_enabled) {
                Application.Invoke(delegate {
                    this.recent_events_item.Sensitive = item_enabled;
                    this.recent_events_item.ShowAll();
                });
            };

            Controller.UpdateMenuEvent += delegate(IconState state) {
                Application.Invoke(delegate {
                    CreateMenu();
                });
            };
        }
Example #37
0
        public SparkleStatusIcon()
        {
            CreateAnimationFrames ();

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

            this.indicator.Status = Status.Active;
            #else
            this.status_icon        = new 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 = SparkleUIHelpers.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.UpdateQuitItemEvent += delegate (bool item_enabled) {
                Application.Invoke (delegate {
                    this.quit_item.Sensitive = item_enabled;
                    this.quit_item.ShowAll ();
                });
            };

            Controller.UpdateOpenRecentEventsItemEvent += delegate (bool item_enabled) {
                Application.Invoke (delegate {
                    this.recent_events_item.Sensitive = item_enabled;
                    this.recent_events_item.ShowAll ();
                });
            };

            Controller.UpdateMenuEvent += delegate (IconState state) {
                Application.Invoke (delegate {
                    CreateMenu ();
                });
            };
        }
Example #38
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;
                        }
                    }
                });
            };
        }