# Path: meld/misc.py
#     def select(rlist, wlist, xlist, timeout):
# def shelljoin( command ):
#     def quote(s):
# def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=gtk.BUTTONS_OK, extrabuttons=()):
# def open_uri(uri, timestamp=0):
# def position_menu_under_widget(menu, widget):
# def make_tool_button_widget(label):
# def gdk_to_cairo_color(color):
# def all_equal(alist):
# def shorten_names(*names):
#             def firstpart(alist):
# def read_pipe_iter(command, errorstream, yield_interval=0.1, workdir=None):
#         def __init__(self):
#         def __del__(self):
#         def __call__(self):
# def write_pipe(command, text, error=None):
# def commonprefix(dirs):
# def copy2(src, dst):
# def copytree(src, dst):
# def shell_escape(glob_pat):
# def shell_to_regex(pat):
#     class sentinel(object):
# 
# Path: meld/paths.py
# def locale_dir(*args): # i18n files
# def help_dir(*args): # help
# def share_dir(*args):
# def ui_dir(*args):
# def icon_dir(*args):


import gtk
import re
from meld import misc
from meld import paths
from . import gnomeglade
from gettext import gettext as _
### Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
### USA.




class FindBar(gnomeglade.Component):
    def __init__(self, parent):
        gnomeglade.Component.__init__(self, paths.ui_dir("findbar.ui"),
                                      "findbar", ["arrow_left", "arrow_right"])
        gnomeglade.connect_signal_handlers(self)
        self.textview = None
        self.orig_base_color = self.find_entry.get_style().base[0]
        self.arrow_left.show()
        self.arrow_right.show()
        parent.connect('set-focus-child', self.on_focus_child)

    def on_focus_child(self, container, widget):
        if widget is not None:
            # TODO: Not in PyGtk 2.16; remove this check later
            if hasattr(self.widget, "get_visible"):
                visible = self.widget.get_visible()
            else:
                visible = self.widget.props.visible
            if widget is not self.widget and visible:
                self.hide()
        return False

    def hide(self):
        self.textview = None

# Path: meld/misc.py
#     def select(rlist, wlist, xlist, timeout):
# def shelljoin( command ):
#     def quote(s):
# def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=gtk.BUTTONS_OK, extrabuttons=()):
# def open_uri(uri, timestamp=0):
# def position_menu_under_widget(menu, widget):
# def make_tool_button_widget(label):
# def gdk_to_cairo_color(color):
# def all_equal(alist):
# def shorten_names(*names):
#             def firstpart(alist):
# def read_pipe_iter(command, errorstream, yield_interval=0.1, workdir=None):
#         def __init__(self):
#         def __del__(self):
#         def __call__(self):
# def write_pipe(command, text, error=None):
# def commonprefix(dirs):
# def copy2(src, dst):
# def copytree(src, dst):
# def shell_escape(glob_pat):
# def shell_to_regex(pat):
#     class sentinel(object):
# 
# Path: meld/paths.py
# def locale_dir(*args): # i18n files
# def help_dir(*args): # help
# def share_dir(*args):
# def ui_dir(*args):
# def icon_dir(*args):


# Path: meld/ui/findbar.py
import gtk
import re
from meld import misc
from meld import paths
from . import gnomeglade
from gettext import gettext as _

### Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
### USA.




class FindBar(gnomeglade.Component):
    def __init__(self, parent):
        gnomeglade.Component.__init__(self, paths.ui_dir("findbar.ui"),
                                      "findbar", ["arrow_left", "arrow_right"])
        gnomeglade.connect_signal_handlers(self)
        self.textview = None
        self.orig_base_color = self.find_entry.get_style().base[0]
        self.arrow_left.show()
        self.arrow_right.show()
        parent.connect('set-focus-child', self.on_focus_child)

    def on_focus_child(self, container, widget):
        if widget is not None:
            # TODO: Not in PyGtk 2.16; remove this check later
            if hasattr(self.widget, "get_visible"):
                visible = self.widget.get_visible()
            else:
                visible = self.widget.props.visible
            if widget is not self.widget and visible:
                self.hide()
        return False

    def hide(self):
        self.textview = None

        self.wrap_box.set_visible(False)