OpenLink() public static method

public static OpenLink ( Uri link ) : void
link System.Uri
return void
Esempio n. 1
0
        protected virtual void OnLinkTagTextEvent(object sender, Gtk.TextEventArgs e)
        {
            // logging noise
            //Trace.Call(sender, e);

            // if something in the textview is selected, bail out
            if (HasTextViewSelection)
            {
#if LOG4NET
                _Logger.Debug("OnLinkTagTextEvent(): active selection present, bailing out...");
#endif
                return;
            }

            var tag = (LinkTag)sender;
            _ActiveLink = tag.Link;

            if (e.Event.Type != Gdk.EventType.ButtonRelease)
            {
                return;
            }

            if (_ActiveLink == null)
            {
#if LOG4NET
                _Logger.Warn("OnLinkTagTextEvent(): _ActiveLink is null, ignoring...");
#endif
                return;
            }

            Frontend.OpenLink(_ActiveLink);
        }
Esempio n. 2
0
        public void OpenLink(string link)
        {
            if (Frontend.Session == null)
            {
                // we don't have a session yet, probably local instance that is
                // just starting or a remote engine that isn't connected yet
                EventHandler handler = null;
                handler = delegate {
                    if (Frontend.Session == null)
                    {
                        return;
                    }
                    // we can't know which thread invokes SessionPropertyChanged
                    Gtk.Application.Invoke((o, e) => {
#if LOG4NET
                        Logger.Info("Opening the link...");
#endif
                        Frontend.OpenLink(new Uri(link));
                    });
                    // only process the link once
                    Frontend.SessionPropertyChanged -= handler;
                };
#if LOG4NET
                Logger.Info("Delaying opening the link as the session isn't initialized yet...");
#endif
                // install event handler and wait till the session gets initialized
                Frontend.SessionPropertyChanged += handler;
            }
            else
            {
                Gtk.Application.Invoke((o, e) => {
                    Frontend.OpenLink(new Uri(link));
                });
            }
        }
Esempio n. 3
0
        protected void OnWebsiteActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                Frontend.OpenLink(new Uri("https://smuxi.im/"));
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            }
        }
Esempio n. 4
0
        protected virtual void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs e)
        {
            Trace.Call(sender, e);

            if (!_AtLinkTag)
            {
                return;
            }

            Gtk.Menu popup = e.Menu;
            // remove all items
            foreach (Gtk.Widget children in popup.Children)
            {
                popup.Remove(children);
            }

            Gtk.ImageMenuItem open_item = new Gtk.ImageMenuItem(Gtk.Stock.Open, null);
            open_item.Activated += delegate {
                if (_ActiveLink != null)
                {
                    Frontend.OpenLink(_ActiveLink);
                }
            };
            popup.Append(open_item);

            Gtk.ImageMenuItem copy_item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            copy_item.Activated += delegate {
                if (_ActiveLink == null)
                {
                    return;
                }
                Gdk.Atom      clipboardAtom = Gdk.Atom.Intern("CLIPBOARD", false);
                Gtk.Clipboard clipboard     = Gtk.Clipboard.Get(clipboardAtom);
                clipboard.Text = _ActiveLink.ToString();
            };
            popup.Append(copy_item);

            popup.ShowAll();
        }