[Pkg-bazaar-commits] ./bzr-gtk/unstable r584: Merge Olive filelist improvements
Jasper Groenewegen
colbrac at xs4al.nl
Fri Apr 10 07:44:31 UTC 2009
------------------------------------------------------------
revno: 584
committer: Jasper Groenewegen <colbrac at xs4al.nl>
branch nick: trunk
timestamp: Sun 2008-08-03 10:14:24 +0200
message:
Merge Olive filelist improvements
Adds status messages for folders
Fixes bug 12544 (broken symlink handling)
Moves file list liststore generation to olive/window.py
modified:
NEWS
olive/__init__.py
olive/window.py
------------------------------------------------------------
revno: 560.10.1
committer: Jasper Groenewegen <colbrac at xs4all.nl>
branch nick: redo-files
timestamp: Sun 2008-07-20 19:31:07 +0200
message:
File list changes
Supersedes the earlier symlink in workingtree + status for folders patches
Moves ListView creation to OliveGui
Removes duplication _load_right/refresh_right by removing _load_right
Adds statusmapper method that checks status both for files and folders
modified:
olive/__init__.py
olive/window.py
------------------------------------------------------------
revno: 560.10.2
committer: Jasper Groenewegen <colbrac at xs4all.nl>
branch nick: redo-files
timestamp: Sun 2008-07-20 19:33:42 +0200
message:
Forgot three treeview_right -> window.treeview_right
modified:
olive/__init__.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2008-08-02 20:38:35 +0000
+++ b/NEWS 2008-08-03 08:14:24 +0000
@@ -26,6 +26,8 @@
* Made merge dialog to give choice between folder and custom location (Jasper Groenewegen)
* Add new dialog to browse looms and switch to threads in loom branches. (Jelmer Vernooij)
+
+ * Show status for folders in Olive file list (Jasper Groenewegen)
BUG FIXES
=== modified file 'olive/__init__.py'
--- a/olive/__init__.py 2008-08-03 00:08:00 +0000
+++ b/olive/__init__.py 2008-08-03 08:14:24 +0000
@@ -98,7 +98,6 @@
# Get the TreeViews
self.treeview_left = self.window.treeview_left
- self.treeview_right = self.window.treeview_right
# Get the drive selector
self.combobox_drive = gtk.combo_box_new_text()
@@ -155,7 +154,7 @@
self.remote_revision = None
self.set_path(os.getcwd())
- self._load_right()
+ self.refresh_right()
self._just_started = False
@@ -212,7 +211,7 @@
# We're local
try:
- self.wt, self.wtpath = WorkingTree.open_containing(path)
+ self.wt, self.wtpath = WorkingTree.open_containing(os.path.realpath(path))
except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
self.notbranch = True
@@ -904,175 +903,10 @@
# Expand the tree
self.treeview_left.expand_all()
-
- def _load_right(self):
- """ Load data into the right panel. (Filelist) """
- # Create ListStore
- # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
- liststore = gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_INT,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING)
-
- dirs = []
- files = []
-
- # Fill the appropriate lists
- dotted_files = self.pref.get_preference('dotted_files', 'bool')
- for item in os.listdir(self.path):
- if not dotted_files and item[0] == '.':
- continue
- if os.path.isdir(self.path + os.sep + item):
- dirs.append(item)
- else:
- files.append(item)
-
- if not self.notbranch:
- branch = self.wt.branch
- tree2 = self.wt.branch.repository.revision_tree(branch.last_revision())
-
- delta = self.wt.changes_from(tree2, want_unchanged=True)
-
- # Add'em to the ListStore
- for item in dirs:
- try:
- statinfo = os.stat(self.path + os.sep + item)
- except OSError, e:
- if e.errno in self.acceptable_errors:
- continue
- else:
- raise
- liststore.append([ gtk.STOCK_DIRECTORY,
- True,
- item,
- '',
- '',
- "<DIR>",
- "<DIR>",
- statinfo.st_mtime,
- self._format_date(statinfo.st_mtime),
- ''])
- for item in files:
- status = 'unknown'
- fileid = ''
- if not self.notbranch:
- filename = self.wt.relpath(self.path + os.sep + item)
-
- try:
- self.wt.lock_read()
-
- for rpath, rpathnew, id, kind, text_modified, meta_modified in delta.renamed:
- if rpathnew == filename:
- status = 'renamed'
- fileid = id
- for rpath, id, kind in delta.added:
- if rpath == filename:
- status = 'added'
- fileid = id
- for rpath, id, kind in delta.removed:
- if rpath == filename:
- status = 'removed'
- fileid = id
- for rpath, id, kind, text_modified, meta_modified in delta.modified:
- if rpath == filename:
- status = 'modified'
- fileid = id
- for rpath, id, kind in delta.unchanged:
- if rpath == filename:
- status = 'unchanged'
- fileid = id
- for rpath, file_class, kind, id, entry in self.wt.list_files():
- if rpath == filename and file_class == 'I':
- status = 'ignored'
- finally:
- self.wt.unlock()
-
- if status == 'renamed':
- st = _i18n('renamed')
- elif status == 'removed':
- st = _i18n('removed')
- elif status == 'added':
- st = _i18n('added')
- elif status == 'modified':
- st = _i18n('modified')
- elif status == 'unchanged':
- st = _i18n('unchanged')
- elif status == 'ignored':
- st = _i18n('ignored')
- else:
- st = _i18n('unknown')
-
- try:
- statinfo = os.stat(self.path + os.sep + item)
- except OSError, e:
- if e.errno in self.acceptable_errors:
- continue
- else:
- raise
- liststore.append([gtk.STOCK_FILE,
- False,
- item,
- st,
- status,
- str(statinfo.st_size), # NOTE: if int used there it will fail for large files (size expressed as long int)
- self._format_size(statinfo.st_size),
- statinfo.st_mtime,
- self._format_date(statinfo.st_mtime),
- fileid])
-
- # Create the columns and add them to the TreeView
- self.treeview_right.set_model(liststore)
- self._tvcolumn_filename = gtk.TreeViewColumn(_i18n('Filename'))
- self._tvcolumn_status = gtk.TreeViewColumn(_i18n('Status'))
- self._tvcolumn_size = gtk.TreeViewColumn(_i18n('Size'))
- self._tvcolumn_mtime = gtk.TreeViewColumn(_i18n('Last modified'))
- self.treeview_right.append_column(self._tvcolumn_filename)
- self.treeview_right.append_column(self._tvcolumn_status)
- self.treeview_right.append_column(self._tvcolumn_size)
- self.treeview_right.append_column(self._tvcolumn_mtime)
-
- # Set up the cells
- cellpb = gtk.CellRendererPixbuf()
- cell = gtk.CellRendererText()
- self._tvcolumn_filename.pack_start(cellpb, False)
- self._tvcolumn_filename.pack_start(cell, True)
- self._tvcolumn_filename.set_attributes(cellpb, stock_id=0)
- self._tvcolumn_filename.add_attribute(cell, 'text', 2)
- self._tvcolumn_status.pack_start(cell, True)
- self._tvcolumn_status.add_attribute(cell, 'text', 3)
- self._tvcolumn_size.pack_start(cell, True)
- self._tvcolumn_size.add_attribute(cell, 'text', 6)
- self._tvcolumn_mtime.pack_start(cell, True)
- self._tvcolumn_mtime.add_attribute(cell, 'text', 8)
-
- # Set up the properties of the TreeView
- self.treeview_right.set_headers_visible(True)
- self.treeview_right.set_headers_clickable(True)
- self.treeview_right.set_search_column(1)
- self._tvcolumn_filename.set_resizable(True)
- self._tvcolumn_status.set_resizable(True)
- self._tvcolumn_size.set_resizable(True)
- self._tvcolumn_mtime.set_resizable(True)
- # Set up sorting
- liststore.set_sort_func(13, self._sort_filelist_callback, None)
- liststore.set_sort_column_id(13, gtk.SORT_ASCENDING)
- self._tvcolumn_filename.set_sort_column_id(13)
- self._tvcolumn_status.set_sort_column_id(3)
- self._tvcolumn_size.set_sort_column_id(5)
- self._tvcolumn_mtime.set_sort_column_id(7)
-
- # Set sensitivity
- self.set_sensitivity()
-
+
def get_selected_fileid(self):
""" Get the file_id of the selected file. """
- treeselection = self.treeview_right.get_selection()
+ treeselection = self.window.treeview_right.get_selection()
(model, iter) = treeselection.get_selected()
if iter is None:
@@ -1082,7 +916,7 @@
def get_selected_right(self):
""" Get the selected filename. """
- treeselection = self.treeview_right.get_selection()
+ treeselection = self.window.treeview_right.get_selection()
(model, iter) = treeselection.get_selected()
if iter is None:
@@ -1157,11 +991,11 @@
return
# Get ListStore and clear it
- liststore = self.treeview_right.get_model()
+ liststore = self.window.filelist
liststore.clear()
# Show Status column
- self._tvcolumn_status.set_visible(True)
+ self.window.col_status.set_visible(True)
dirs = []
files = []
@@ -1181,7 +1015,7 @@
# Try to open the working tree
notbranch = False
try:
- tree1 = WorkingTree.open_containing(path)[0]
+ tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
notbranch = True
@@ -1193,6 +1027,16 @@
# Add'em to the ListStore
for item in dirs:
+ status = ''
+ st = ''
+ fileid = ''
+ if not notbranch:
+ filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
+
+ st, status = self.statusmapper(filename, delta)
+ if not ignored_files and status == 'ignored':
+ continue
+
try:
statinfo = os.stat(self.path + os.sep + item)
except OSError, e:
@@ -1200,67 +1044,26 @@
continue
else:
raise
- liststore.append([gtk.STOCK_DIRECTORY,
- True,
- item,
- '',
- '',
- "<DIR>",
- "<DIR>",
- statinfo.st_mtime,
- self._format_date(statinfo.st_mtime),
- ''])
+ liststore.append([ gtk.STOCK_DIRECTORY,
+ True,
+ item,
+ st,
+ status,
+ "<DIR>",
+ "<DIR>",
+ statinfo.st_mtime,
+ self._format_date(statinfo.st_mtime),
+ ''])
for item in files:
- status = 'unknown'
+ status = ''
+ st = ''
fileid = ''
if not notbranch:
- filename = tree1.relpath(path + os.sep + item)
+ filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
- try:
- self.wt.lock_read()
-
- for rpath, rpathnew, id, kind, text_modified, meta_modified in delta.renamed:
- if rpathnew == filename:
- status = 'renamed'
- fileid = id
- for rpath, id, kind in delta.added:
- if rpath == filename:
- status = 'added'
- fileid = id
- for rpath, id, kind in delta.removed:
- if rpath == filename:
- status = 'removed'
- fileid = id
- for rpath, id, kind, text_modified, meta_modified in delta.modified:
- if rpath == filename:
- status = 'modified'
- fileid = id
- for rpath, id, kind in delta.unchanged:
- if rpath == filename:
- status = 'unchanged'
- fileid = id
- for rpath, file_class, kind, id, entry in self.wt.list_files():
- if rpath == filename and file_class == 'I':
- status = 'ignored'
- finally:
- self.wt.unlock()
-
- if status == 'renamed':
- st = _i18n('renamed')
- elif status == 'removed':
- st = _i18n('removed')
- elif status == 'added':
- st = _i18n('added')
- elif status == 'modified':
- st = _i18n('modified')
- elif status == 'unchanged':
- st = _i18n('unchanged')
- elif status == 'ignored':
- st = _i18n('ignored')
- if not ignored_files:
+ st, status = self.statusmapper(filename, delta)
+ if not ignored_files and status == 'ignored':
continue
- else:
- st = _i18n('unknown')
try:
statinfo = os.stat(self.path + os.sep + item)
@@ -1283,11 +1086,11 @@
# We're remote
# Get ListStore and clear it
- liststore = self.treeview_right.get_model()
+ liststore = self.window.filelist
liststore.clear()
# Hide Status column
- self._tvcolumn_status.set_visible(False)
+ self.window.col_status.set_visible(False)
dirs = []
files = []
@@ -1360,10 +1163,57 @@
self.image_location_error.destroy()
# Columns should auto-size
- self.treeview_right.columns_autosize()
+ self.window.treeview_right.columns_autosize()
# Set sensitivity
self.set_sensitivity()
+
+ def statusmapper(self, filename, delta):
+ status = 'unknown'
+ try:
+ self.wt.lock_read()
+
+ for rpath, rpathnew, id, kind, text_modified, meta_modified in delta.renamed:
+ if rpathnew == filename:
+ status = 'renamed'
+ fileid = id
+ for rpath, id, kind in delta.added:
+ if rpath == filename:
+ status = 'added'
+ fileid = id
+ for rpath, id, kind in delta.removed:
+ if rpath == filename:
+ status = 'removed'
+ fileid = id
+ for rpath, id, kind, text_modified, meta_modified in delta.modified:
+ if rpath == filename:
+ status = 'modified'
+ fileid = id
+ for rpath, id, kind in delta.unchanged:
+ if rpath == filename:
+ status = 'unchanged'
+ fileid = id
+ for rpath, file_class, kind, id, entry in self.wt.list_files():
+ if rpath == filename and file_class == 'I':
+ status = 'ignored'
+ finally:
+ self.wt.unlock()
+
+ if status == 'renamed':
+ st = _i18n('renamed')
+ elif status == 'removed':
+ st = _i18n('removed')
+ elif status == 'added':
+ st = _i18n('added')
+ elif status == 'modified':
+ st = _i18n('modified')
+ elif status == 'unchanged':
+ st = _i18n('unchanged')
+ elif status == 'ignored':
+ st = _i18n('ignored')
+ else:
+ st = _i18n('unknown')
+ return st, status
def _harddisks(self):
""" Returns hard drive letters under Win32. """
=== modified file 'olive/window.py'
--- a/olive/window.py 2008-07-25 19:54:31 +0000
+++ b/olive/window.py 2008-08-03 08:14:24 +0000
@@ -382,7 +382,6 @@
def _create_filelist(self):
""" Creates the file list (a ListStore in a TreeView in a ScrolledWindow)"""
- # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
self.scrolledwindow_right = gtk.ScrolledWindow()
self.scrolledwindow_right.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
@@ -390,8 +389,62 @@
self.treeview_right.connect("button-press-event", self.signal.on_treeview_right_button_press_event)
self.treeview_right.connect("row-activated", self.signal.on_treeview_right_row_activated)
self.scrolledwindow_right.add(self.treeview_right)
-
- # Move olive/__init__.py _load_right List creation here
+
+ # Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
+ self.filelist = gtk.ListStore(gobject.TYPE_STRING,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_STRING,
+ gobject.TYPE_STRING,
+ gobject.TYPE_STRING,
+ gobject.TYPE_STRING,
+ gobject.TYPE_STRING,
+ gobject.TYPE_INT,
+ gobject.TYPE_STRING,
+ gobject.TYPE_STRING)
+ self.treeview_right.set_model(self.filelist)
+
+ # Set up the cells
+ cellpb = gtk.CellRendererPixbuf()
+ cell = gtk.CellRendererText()
+
+ self.col_filename = gtk.TreeViewColumn(_i18n('Filename'))
+ self.col_filename.pack_start(cellpb, False)
+ self.col_filename.pack_start(cell, True)
+ self.col_filename.set_attributes(cellpb, stock_id=0)
+ self.col_filename.add_attribute(cell, 'text', 2)
+ self.col_filename.set_resizable(True)
+ self.treeview_right.append_column(self.col_filename)
+
+ self.col_status = gtk.TreeViewColumn(_i18n('Status'))
+ self.col_status.pack_start(cell, True)
+ self.col_status.add_attribute(cell, 'text', 3)
+ self.col_status.set_resizable(True)
+ self.treeview_right.append_column(self.col_status)
+
+ self.col_size = gtk.TreeViewColumn(_i18n('Size'))
+ self.col_size.pack_start(cell, True)
+ self.col_size.add_attribute(cell, 'text', 6)
+ self.col_size.set_resizable(True)
+ self.treeview_right.append_column(self.col_size)
+
+ self.col_mtime = gtk.TreeViewColumn(_i18n('Last modified'))
+ self.col_mtime.pack_start(cell, True)
+ self.col_mtime.add_attribute(cell, 'text', 8)
+ self.col_mtime.set_resizable(True)
+ self.treeview_right.append_column(self.col_mtime)
+
+ # Set up the properties of the TreeView
+ self.treeview_right.set_headers_visible(True)
+ self.treeview_right.set_headers_clickable(True)
+ self.treeview_right.set_search_column(1)
+
+ # Set up sorting
+ self.filelist.set_sort_func(13, self.signal._sort_filelist_callback, None)
+ self.filelist.set_sort_column_id(13, gtk.SORT_ASCENDING)
+ self.col_filename.set_sort_column_id(13)
+ self.col_status.set_sort_column_id(3)
+ self.col_size.set_sort_column_id(5)
+ self.col_mtime.set_sort_column_id(7)
def set_view_to_localbranch(self, notbranch=False):
""" Change the sensitivity of gui items to reflect the fact that the path is a branch or not"""
More information about the Pkg-bazaar-commits
mailing list