Clean ups to torrents list and files tab focus code.

This commit is contained in:
Alex Dedul 2007-07-22 17:35:39 +00:00
parent 67976167aa
commit 6c78b6595f
2 changed files with 15 additions and 29 deletions

View File

@ -78,13 +78,7 @@ class FilesBaseManager(object):
self.file_view.set_model(self.file_store_sorted)
self.file_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
try:
self.file_view.get_selection().set_select_function(self.file_clicked,
full=True)
except TypeError:
self.torrent_view.get_selection().set_select_function(self.file_clicked_old)
self.file_view.connect("button-press-event", self.mouse_clicked)
self.right_click = False
def clear_file_store(self):
self.file_store.clear()
@ -125,16 +119,6 @@ class FilesBaseManager(object):
self.update_priorities()
def file_clicked_old(self, path):
return self.file_clicked(self.file_view.get_selection(),
self.file_store, path, False)
def file_clicked(self, selection, model, path, is_selected):
if is_selected:
return not self.right_click
return True
def mouse_clicked(self, widget, event):
if event.button == 3:
data = self.file_view.get_path_at_pos(int(event.x), int(event.y))
@ -142,13 +126,14 @@ class FilesBaseManager(object):
return True
path, col, cellx, celly = data
self.right_click = self.file_view.get_selection().path_is_selected(path)
self.file_view.grab_focus()
self.file_view.set_cursor(path, col, 0)
is_selected = self.file_view.get_selection().path_is_selected(path)
if not is_selected:
self.file_view.grab_focus()
self.file_view.set_cursor(path, col, 0)
self.file_menu.popup(None, None, None, event.button, event.time)
return True
return is_selected
else:
self.right_click = False
return False
def update_priorities(self):

View File

@ -522,7 +522,6 @@ class DelugeGTK:
except TypeError:
self.torrent_view.get_selection().set_select_function(self.old_t_click)
self.torrent_view.connect("button-press-event", self.torrent_view_clicked)
self.right_click = False
def torrent_model_append(self, unique_id):
state = self.manager.get_torrent_state(unique_id)
@ -546,7 +545,7 @@ class DelugeGTK:
def torrent_clicked(self, selection, model, path, is_selected):
if is_selected:
# Torrent is already selected, we don't need to do anything
return not self.right_click
return True
self.clear_peer_store()
self.clear_file_store()
@ -563,9 +562,11 @@ class DelugeGTK:
if data is None:
return True
path, col, cellx, celly = data
self.right_click = self.torrent_view.get_selection().path_is_selected(path)
self.torrent_view.grab_focus()
self.torrent_view.set_cursor(path, col, 0)
is_selected = self.torrent_view.get_selection().path_is_selected(path)
if not is_selected:
self.torrent_view.grab_focus()
self.torrent_view.set_cursor(path, col, 0)
unique_id = self.torrent_model.get_value(self.torrent_model.get_iter(path), 0)
# Get the torrent state so we can check if the torrent is paused.
torrent_state = self.manager.get_torrent_state(unique_id)
@ -577,11 +578,11 @@ class DelugeGTK:
widget.set_image(gtk.image_new_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU))
widget.get_children()[0].set_text(_("Pause"))
self.torrent_menu.popup(None, None, None, event.button, event.time)
self.torrent_menu.popup(None, None, None, event.button,
event.time)
return True
return is_selected
else:
self.right_click = False
return False
def start_pause(self, widget):