[meld] Make FindBar close on focus loss and remove close button



commit e9958e51ef95c5357bf45c490f56763492042a69
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Feb 14 17:22:09 2011 +1000

    Make FindBar close on focus loss and remove close button

 data/ui/findbar.ui |   19 -------------------
 meld/filediff.py   |    2 +-
 meld/ui/findbar.py |   13 +++++++++----
 3 files changed, 10 insertions(+), 24 deletions(-)
---
diff --git a/data/ui/findbar.ui b/data/ui/findbar.ui
index c09662e..85cdc5f 100644
--- a/data/ui/findbar.ui
+++ b/data/ui/findbar.ui
@@ -85,25 +85,6 @@
           </packing>
         </child>
         <child>
-          <object class="GtkButton" id="findbar_close">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="focus_on_click">False</property>
-            <child>
-              <object class="GtkImage" id="image2">
-                <property name="visible">True</property>
-                <property name="stock">gtk-cancel</property>
-                <property name="icon_size">1</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="x_options">GTK_FILL</property>
-            <property name="y_options">GTK_FILL</property>
-          </packing>
-        </child>
-        <child>
           <object class="GtkLabel" id="find_label">
             <property name="visible">True</property>
             <property name="label" translatable="yes">_Search for</property>
diff --git a/meld/filediff.py b/meld/filediff.py
index d4e8dff..a0f4f26 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -325,7 +325,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         self.set_num_panes(num_panes)
         gobject.idle_add( lambda *args: self.load_font()) # hack around Bug 316730
         gnomeglade.connect_signal_handlers(self)
-        self.findbar = findbar.FindBar()
+        self.findbar = findbar.FindBar(self.filediff)
         self.filediff.pack_end(self.findbar.widget, False)
         self.cursor = CursorDetails()
         self.connect("current-diff-changed", self.on_current_diff_changed)
diff --git a/meld/ui/findbar.py b/meld/ui/findbar.py
index 342bda5..ddaf5e7 100644
--- a/meld/ui/findbar.py
+++ b/meld/ui/findbar.py
@@ -1,4 +1,5 @@
 ### Copyright (C) 2002-2009 Stephen Kennedy <stevek gnome org>
+### Copyright (C) 2012 Kai Willadsen <kai willadsen gmail com>
 
 ### This program is free software; you can redistribute it and/or modify
 ### it under the terms of the GNU General Public License as published by
@@ -22,11 +23,18 @@ import re
 from gettext import gettext as _
 
 class FindBar(gnomeglade.Component):
-    def __init__(self):
+    def __init__(self, parent):
         gnomeglade.Component.__init__(self, paths.ui_dir("findbar.ui"), "findbar")
         gnomeglade.connect_signal_handlers(self)
         self.textview = None
         self.orig_base_color = self.find_entry.get_style().base[0]
+        parent.connect('set-focus-child', self.on_focus_child)
+
+    def on_focus_child(self, container, widget):
+        if widget is not None:
+            if widget is not self.widget and self.widget.get_visible():
+                self.hide()
+        return False
 
     def hide(self):
         self.textview = None
@@ -64,9 +72,6 @@ class FindBar(gnomeglade.Component):
         self.widget.show_all()
         self.find_entry.grab_focus()
 
-    def on_findbar_close__clicked(self, button):
-        self.hide()
-
     def on_find_entry__activate(self, entry):
         self.find_next_button.activate()
 



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