mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 11:30:19 +01:00
Cleaned up the code
This commit is contained in:
@@ -65,7 +65,7 @@ class DiscsController(Controller):
|
||||
pathinfo = treeview.get_path_at_pos(int(event.x), int(event.y))
|
||||
|
||||
if event.button == 3 and pathinfo:
|
||||
path, column, x, y = pathinfo
|
||||
path = pathinfo[0]
|
||||
|
||||
# Make sure, that there is selected row
|
||||
sel = treeview.get_selection()
|
||||
@@ -76,18 +76,10 @@ class DiscsController(Controller):
|
||||
return True
|
||||
|
||||
def on_discs_cursor_changed(self, widget):
|
||||
"""Show files on right treeview, after clicking the left disc
|
||||
treeview."""
|
||||
"""
|
||||
Show files on right treeview, after clicking the left disc treeview.
|
||||
"""
|
||||
LOG.debug('on_discs_cursor_changed')
|
||||
model = self.view['discs'].get_model()
|
||||
path, column = self.view['discs'].get_cursor()
|
||||
if path:
|
||||
iter = self.model.discs.get_iter(path)
|
||||
id = self.model.discs.get_value(iter, 0)
|
||||
# self.__set_files_hiden_columns_visible(False) # TODO: ale o so chozi???
|
||||
self.model.get_root_entries(id)
|
||||
|
||||
return
|
||||
|
||||
def on_discs_key_release_event(self, treeview, event):
|
||||
"""
|
||||
@@ -108,7 +100,6 @@ class DiscsController(Controller):
|
||||
else:
|
||||
treeview.expand_row(path, False)
|
||||
|
||||
|
||||
def on_expand_all_activate(self, menu_item):
|
||||
"""
|
||||
Expand all
|
||||
@@ -116,18 +107,33 @@ class DiscsController(Controller):
|
||||
self.view['discs'].expand_all()
|
||||
|
||||
def on_collapse_all_activate(self, menu_item):
|
||||
"""
|
||||
Collapse all
|
||||
"""
|
||||
self.view['discs'].collapse_all()
|
||||
|
||||
def on_update_activate(self, menu_item):
|
||||
"""
|
||||
Trigger update specified tree entry
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def on_rename_activate(self, menu_item):
|
||||
"""
|
||||
Rename disk or directory
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def on_delete_activate(self, menu_item):
|
||||
"""
|
||||
Delete disk or directory from catalog
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def on_statistics_activate(self, menu_item):
|
||||
"""
|
||||
Show statistics for selected item
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def _popup_menu(self, selection, event, button):
|
||||
@@ -138,11 +144,9 @@ class DiscsController(Controller):
|
||||
LOG.debug('_popup_menu')
|
||||
model, list_of_paths = selection.get_selected_rows()
|
||||
|
||||
#for path in list_of_paths:
|
||||
# if model.get_value(model.get_iter(path), 4).parent_id == 1:
|
||||
# self.view.popup_menu.disable_update(False)
|
||||
# else:
|
||||
# self.view.popup_menu.disable_update(True)
|
||||
for path in list_of_paths:
|
||||
self.view.menu.set_update_sensitivity(not model.get_value(\
|
||||
model.get_iter(path), 4).parent_id == 1)
|
||||
|
||||
self.view.menu['discs_popup'].popup(None, None, None,
|
||||
button, event.time)
|
||||
button, event.time)
|
||||
|
||||
@@ -76,7 +76,7 @@ class MainModel(ModelMT):
|
||||
self.cat_fname = filename
|
||||
|
||||
if self._open_or_decompress():
|
||||
return self._read_db()
|
||||
return self._populate_discs_from_db()
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -192,8 +192,10 @@ class MainModel(ModelMT):
|
||||
# http://www.logilab.org/blogentry/17873
|
||||
os.close(fd)
|
||||
|
||||
def _read_db(self):
|
||||
def _populate_discs_from_db(self):
|
||||
"""
|
||||
Read objects from database, fill TreeStore model with discs
|
||||
information
|
||||
"""
|
||||
session = Session()
|
||||
dirs = session.query(File).filter(File.type == 1)
|
||||
@@ -224,6 +226,5 @@ class MainModel(ModelMT):
|
||||
|
||||
return True
|
||||
|
||||
# TODO: get this thing right
|
||||
def get_root_entries(self, id):
|
||||
LOG.debug("get_root_entries, id: %s", str(id))
|
||||
LOG.debug("not implemented!, get_root_entries, id: %s", str(id))
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
"""
|
||||
import os.path
|
||||
|
||||
import gtk
|
||||
|
||||
from gtkmvc import View
|
||||
|
||||
|
||||
@@ -57,6 +55,7 @@ class DiscsView(View):
|
||||
View.__init__(self)
|
||||
self.menu = DiscsPopupView()
|
||||
|
||||
|
||||
class DiscsPopupView(View):
|
||||
"""
|
||||
Separate Discs PopUp subview.
|
||||
@@ -70,10 +69,13 @@ class DiscsPopupView(View):
|
||||
"""
|
||||
View.__init__(self)
|
||||
|
||||
def disable_update(self, state):
|
||||
def set_update_sensitivity(self, state):
|
||||
"""
|
||||
Update sensitivity for 'update' popup menu item
|
||||
|
||||
"""
|
||||
self['update1'].set_sensitive(not state)
|
||||
self['update'].set_sensitive(not state)
|
||||
|
||||
|
||||
class FilesView(View):
|
||||
"""
|
||||
@@ -117,4 +119,3 @@ class DetailsView(View):
|
||||
"""
|
||||
View.__init__(self)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user