[gedit-plugins] [commander] Do not hide when loosing focus



commit 9a6eb45a5aa9d2b63c72055432b19e9096a2182f
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Thu Sep 4 18:55:24 2014 +0200

    [commander] Do not hide when loosing focus

 plugins/commander/commander/entry.py             |    8 +++-----
 plugins/commander/commander/windowactivatable.py |    6 ++++++
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/plugins/commander/commander/entry.py b/plugins/commander/commander/entry.py
index a0171a5..9b3d91a 100644
--- a/plugins/commander/commander/entry.py
+++ b/plugins/commander/commander/entry.py
@@ -154,7 +154,6 @@ GtkEntry#gedit-commander-entry {
         self._entry.set_margin_bottom(3)
         self._entry.set_margin_end(3)
 
-        self._entry.connect('focus-out-event', self._on_entry_focus_out)
         self._entry.connect('key-press-event', self._on_entry_key_press)
 
         self._entry.show()
@@ -265,15 +264,14 @@ GtkEntry#gedit-commander-entry {
         reveal.connect('notify::child-revealed', self._on_child_revealed)
         self._entry.grab_focus()
 
+    def grab_focus(self):
+        self._entry.grab_focus()
+
     def _on_child_revealed(self, widget, spec):
         if not self._reveal.get_child_revealed():
             self.destroy()
             widget.destroy()
 
-    def _on_entry_focus_out(self, widget, evnt):
-        if self._entry.get_sensitive():
-            self._reveal.set_reveal_child(False)
-
     def _on_entry_key_press(self, widget, evnt):
         state = evnt.state & Gtk.accelerator_get_default_mod_mask()
         text = self._entry.get_text()
diff --git a/plugins/commander/commander/windowactivatable.py 
b/plugins/commander/commander/windowactivatable.py
index 915a94c..15168fa 100644
--- a/plugins/commander/commander/windowactivatable.py
+++ b/plugins/commander/commander/windowactivatable.py
@@ -54,6 +54,11 @@ class CommanderWindowActivatable(GObject.Object, Gedit.WindowActivatable):
 
     def activate_toggle(self, action, parameter):
         state = action.get_state()
+
+        if state.get_boolean() and not self._entry is None:
+            self._entry.grab_focus()
+            return
+
         action.change_state(GLib.Variant.new_boolean(not state.get_boolean()))
 
     def commander_mode(self, action, state):
@@ -63,6 +68,7 @@ class CommanderWindowActivatable(GObject.Object, Gedit.WindowActivatable):
             return False
 
         active = state.get_boolean()
+
         if active:
             if not self._entry or view != self._view:
                 self._entry = Entry(view)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]