Smuxi.Frontend.Gnome.MainWindow.OnFocusInEvent C# (CSharp) Method

OnFocusInEvent() protected method

protected OnFocusInEvent ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        protected virtual void OnFocusInEvent(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                UrgencyHint = false;

                // HACK: users sometimes click into the person list by accident
                // when they try to bring the focus back to the Smuxi window.
                // We try to be nice and do what they probably meant and move
                // the focus to the input entry instead.
                // HACK: we have to use a timeout here as the ButtonPressEvent
                // is directly raised _after_ the FocusInEvent. The idle loop
                // turned out to be too racy and works only sometimes.
                GLib.Timeout.Add(10, delegate {
                    Entry.GrabFocus();
                    return false;
                });

                if (Notebook.IsBrowseModeEnabled) {
                    return;
                }

                var chatView = ChatViewManager.CurrentChatView;
                if (chatView != null) {
                    // clear activity and highlight
                    chatView.HasHighlight = false;
                    chatView.HasActivity = false;
                    chatView.HasEvent = false;
                    var lastMsg = chatView.OutputMessageTextView.LastMessage;
                    if (lastMsg == null || Frontend.UseLowBandwidthMode) {
                        return;
                    }
                    // update last seen highlight
                    ThreadPool.QueueUserWorkItem(delegate {
                        try {
                            // REMOTING CALL 1
                            chatView.ChatModel.LastSeenHighlight = lastMsg.TimeStamp;
                        } catch (Exception ex) {
            #if LOG4NET
                            f_Logger.Error("OnFocusInEvent(): Exception", ex);
            #endif
                        }
                    });
                }
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }