Clean ups to torrents list and files tab focus code.
This commit is contained in:
parent
67976167aa
commit
6c78b6595f
23
src/files.py
23
src/files.py
|
@ -78,13 +78,7 @@ class FilesBaseManager(object):
|
||||||
self.file_view.set_model(self.file_store_sorted)
|
self.file_view.set_model(self.file_store_sorted)
|
||||||
self.file_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
|
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.file_view.connect("button-press-event", self.mouse_clicked)
|
||||||
self.right_click = False
|
|
||||||
|
|
||||||
def clear_file_store(self):
|
def clear_file_store(self):
|
||||||
self.file_store.clear()
|
self.file_store.clear()
|
||||||
|
@ -125,16 +119,6 @@ class FilesBaseManager(object):
|
||||||
|
|
||||||
self.update_priorities()
|
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):
|
def mouse_clicked(self, widget, event):
|
||||||
if event.button == 3:
|
if event.button == 3:
|
||||||
data = self.file_view.get_path_at_pos(int(event.x), int(event.y))
|
data = self.file_view.get_path_at_pos(int(event.x), int(event.y))
|
||||||
|
@ -142,13 +126,14 @@ class FilesBaseManager(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
path, col, cellx, celly = data
|
path, col, cellx, celly = data
|
||||||
self.right_click = self.file_view.get_selection().path_is_selected(path)
|
is_selected = self.file_view.get_selection().path_is_selected(path)
|
||||||
|
if not is_selected:
|
||||||
self.file_view.grab_focus()
|
self.file_view.grab_focus()
|
||||||
self.file_view.set_cursor(path, col, 0)
|
self.file_view.set_cursor(path, col, 0)
|
||||||
self.file_menu.popup(None, None, None, event.button, event.time)
|
self.file_menu.popup(None, None, None, event.button, event.time)
|
||||||
return True
|
|
||||||
|
return is_selected
|
||||||
else:
|
else:
|
||||||
self.right_click = False
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def update_priorities(self):
|
def update_priorities(self):
|
||||||
|
|
|
@ -522,7 +522,6 @@ class DelugeGTK:
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.torrent_view.get_selection().set_select_function(self.old_t_click)
|
self.torrent_view.get_selection().set_select_function(self.old_t_click)
|
||||||
self.torrent_view.connect("button-press-event", self.torrent_view_clicked)
|
self.torrent_view.connect("button-press-event", self.torrent_view_clicked)
|
||||||
self.right_click = False
|
|
||||||
|
|
||||||
def torrent_model_append(self, unique_id):
|
def torrent_model_append(self, unique_id):
|
||||||
state = self.manager.get_torrent_state(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):
|
def torrent_clicked(self, selection, model, path, is_selected):
|
||||||
if is_selected:
|
if is_selected:
|
||||||
# Torrent is already selected, we don't need to do anything
|
# Torrent is already selected, we don't need to do anything
|
||||||
return not self.right_click
|
return True
|
||||||
|
|
||||||
self.clear_peer_store()
|
self.clear_peer_store()
|
||||||
self.clear_file_store()
|
self.clear_file_store()
|
||||||
|
@ -563,9 +562,11 @@ class DelugeGTK:
|
||||||
if data is None:
|
if data is None:
|
||||||
return True
|
return True
|
||||||
path, col, cellx, celly = data
|
path, col, cellx, celly = data
|
||||||
self.right_click = self.torrent_view.get_selection().path_is_selected(path)
|
is_selected = self.torrent_view.get_selection().path_is_selected(path)
|
||||||
|
if not is_selected:
|
||||||
self.torrent_view.grab_focus()
|
self.torrent_view.grab_focus()
|
||||||
self.torrent_view.set_cursor(path, col, 0)
|
self.torrent_view.set_cursor(path, col, 0)
|
||||||
|
|
||||||
unique_id = self.torrent_model.get_value(self.torrent_model.get_iter(path), 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.
|
# Get the torrent state so we can check if the torrent is paused.
|
||||||
torrent_state = self.manager.get_torrent_state(unique_id)
|
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.set_image(gtk.image_new_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU))
|
||||||
widget.get_children()[0].set_text(_("Pause"))
|
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:
|
else:
|
||||||
self.right_click = False
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def start_pause(self, widget):
|
def start_pause(self, widget):
|
||||||
|
|
Loading…
Reference in New Issue