Commit e03492ac authored by Kai Willadsen's avatar Kai Willadsen

Unify some pane focus handling in MeldDoc

parent 6a2c9e25
......@@ -283,7 +283,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.focus_out_events.append(handler_id)
self.current_path, self.prev_path, self.next_path = None, None, None
self.on_treeview_focus_out_event(None, None)
self.treeview_focussed = None
self.focus_pane = None
lastchanged_label = gtk.Label()
lastchanged_label.set_size_request(100, -1)
......@@ -379,10 +379,6 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self._create_filter_menu_button(ui)
self.ui_manager = ui
if self.treeview_focussed:
self.scheduler.add_task(self.treeview_focussed.grab_focus)
self.scheduler.add_task(self.on_treeview_cursor_changed)
def on_container_switch_out_event(self, ui):
self._cleanup_filter_menu_button(ui)
melddoc.MeldDoc.on_container_switch_out_event(self, ui)
......@@ -922,7 +918,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
treeview.handler_unblock(outid)
def on_treeview_focus_in_event(self, tree, event):
self.treeview_focussed = tree
self.focus_pane = tree
pane = self.treeview.index(tree)
self.actiongroup.get_action("DirCopyLeft").set_sensitive(pane > 0)
self.actiongroup.get_action("DirCopyRight").set_sensitive(pane+1 < self.num_panes)
......@@ -1232,8 +1228,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self._update_item_state( model.get_iter(path) )
def next_diff(self, direction):
if self.treeview_focussed:
pane = self.treeview.index(self.treeview_focussed)
if self.focus_pane:
pane = self.treeview.index(self.focus_pane)
else:
pane = 0
if direction == gtk.gdk.SCROLL_UP:
......
......@@ -176,7 +176,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.load_font()
self.deleted_lines_pending = -1
self.textview_overwrite = 0
self.textview_focussed = None
self.focus_pane = None
self.textview_overwrite_handlers = [ t.connect("toggle-overwrite", self.on_textview_toggle_overwrite) for t in self.textview ]
self.textbuffer = [v.get_buffer() for v in self.textview]
self.buffer_texts = [meldbuffer.BufferLines(b) for b in self.textbuffer]
......@@ -313,8 +313,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def on_container_switch_in_event(self, ui):
melddoc.MeldDoc.on_container_switch_in_event(self, ui)
# FIXME: If no focussed textview, action sensitivity will be unset
if self.textview_focussed:
self.scheduler.add_task(self.textview_focussed.grab_focus)
def on_text_filters_changed(self, app):
relevant_change = self.create_text_filters()
......@@ -647,7 +645,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.textview[new_pane].scroll_to_mark(new_buf.get_insert(), 0.1)
def on_textview_focus_in_event(self, view, event):
self.textview_focussed = view
self.focus_pane = view
self.findbar.textview = view
self.on_cursor_position_changed(view.get_buffer(), None, True)
self._set_merge_action_sensitivity()
......@@ -865,19 +863,19 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def on_find_activate(self, *args):
selected_text = self.get_selected_text()
self.findbar.start_find(self.textview_focussed, selected_text)
self.findbar.start_find(self.focus_pane, selected_text)
self.keymask = 0
def on_replace_activate(self, *args):
selected_text = self.get_selected_text()
self.findbar.start_replace(self.textview_focussed, selected_text)
self.findbar.start_replace(self.focus_pane, selected_text)
self.keymask = 0
def on_find_next_activate(self, *args):
self.findbar.start_find_next(self.textview_focussed)
self.findbar.start_find_next(self.focus_pane)
def on_find_previous_activate(self, *args):
self.findbar.start_find_previous(self.textview_focussed)
self.findbar.start_find_previous(self.focus_pane)
def on_filediff__key_press_event(self, entry, event):
if event.keyval == gtk.keysyms.Escape:
......
......@@ -149,6 +149,8 @@ class MeldDoc(gobject.GObject):
uimanager.insert_action_group(self.actiongroup, -1)
self.popup_menu = uimanager.get_widget("/Popup")
uimanager.ensure_update()
if hasattr(self, "focus_pane") and self.focus_pane:
self.scheduler.add_task(self.focus_pane.grab_focus)
def on_container_switch_out_event(self, uimanager):
"""Called when the container app switches away from this tab.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment