Skip to content
Browse files

[Frontend-GNOME] Gently move the focus from the notebook to the entry

  • Loading branch information...
1 parent 889185f commit 10616e5dcadf1f3ef1be99bca4e246a29b07f781 @meebey committed May 16, 2012
Showing with 16 additions and 21 deletions.
  1. +0 −20 src/Frontend-GNOME/Entry.cs
  2. +16 −1 src/Frontend-GNOME/MainWindow.cs
View
20 src/Frontend-GNOME/Entry.cs
@@ -121,7 +121,6 @@ public Entry(ChatViewManager chatViewManager)
Activated += _OnActivated;
KeyPressEvent += new Gtk.KeyPressEventHandler(_OnKeyPress);
- FocusOutEvent += new Gtk.FocusOutEventHandler(_OnFocusOut);
PasteClipboard += _OnClipboardPasted;
}
@@ -411,25 +410,6 @@ protected virtual void ProcessKey(Gtk.KeyPressEventArgs e)
}
}
- private void _OnFocusOut(object sender, Gtk.FocusOutEventArgs e)
- {
- Trace.Call(sender, e);
-
- if (Frontend.MainWindow.CaretMode) {
- return;
- }
-
- // we can't just move to focus directly back as that breaks the
- // notebook scrolling, see trac bug#11
- GLib.Timeout.Add(250, new GLib.TimeoutHandler(delegate {
- if (!Frontend.MainWindow.Notebook.HasFocus) {
- return false;
- }
- HasFocus = true;
- return true;
- }));
- }
-
private void _OnActivated(object sender, EventArgs e)
{
Trace.Call(sender, e);
View
17 src/Frontend-GNOME/MainWindow.cs
@@ -498,7 +498,8 @@ public MainWindow() : base("Smuxi")
// TODO: network treeview
_Notebook = new Notebook();
_Notebook.SwitchPage += OnNotebookSwitchPage;
-
+ _Notebook.FocusInEvent += OnNotebookFocusInEvent;
+
_ChatViewManager = new ChatViewManager(_Notebook, null);
Assembly asm = Assembly.GetExecutingAssembly();
_ChatViewManager.Load(asm);
@@ -1010,11 +1011,25 @@ protected virtual void OnNotebookSwitchPage(object sender, EventArgs e)
_OpenLogChatMenuItem.Sensitive =
File.Exists(chatView.ChatModel.LogFile);
}
+
+ // HACK: Gtk.Notebook moves the focus to the child after the
+ // page has been switched, so move the focus back to the entry
+ GLib.Idle.Add(delegate {
+ Entry.GrabFocus();
+ return false;
+ });
} catch (Exception ex) {
Frontend.ShowException(this, ex);
}
}
+ protected virtual void OnNotebookFocusInEvent(object sender, Gtk.FocusInEventArgs e)
+ {
+ // HACK: having the focus in the notebook doesn't make any sense,
+ // so move focus back to the entry
+ Entry.GrabFocus();
+ }
+
protected virtual void OnJoinWidgetActivated(object sender, EventArgs e)
{
Trace.Call(sender, e);

0 comments on commit 10616e5

Please sign in to comment.
Something went wrong with that request. Please try again.