[meld] Update column preferences to handle missing columns in the pref store



commit 2776aa48740e3d97e6f4ea452cfd865e07fbf107
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Jan 12 07:30:49 2013 +1000

    Update column preferences to handle missing columns in the pref store
    
    The existing code did not let us actually add new columns to the prefs
    store, as it only added columns already present in prefs to the column
    selector. This commit adds a field for storing all columns that Meld
    currently knows about, so that any missing columns can then be shown
    to the user by the preferences UI.

 meld/preferences.py |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/meld/preferences.py b/meld/preferences.py
index 353de01..92b6cec 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -90,6 +90,11 @@ class FilterList(listwidget.ListWidget):
 
 class ColumnList(listwidget.ListWidget):
 
+    available_columns = set((
+        "size",
+        "modification time",
+    ))
+
     def __init__(self, prefs, key):
         listwidget.ListWidget.__init__(self, "EditableList.ui",
                                "columns_ta", ["ColumnsListStore"],
@@ -97,9 +102,15 @@ class ColumnList(listwidget.ListWidget):
         self.prefs = prefs
         self.key = key
 
+        prefs_columns = []
         for column in getattr(self.prefs, self.key):
             column_name, visibility = column.rsplit(" ", 1)
             visibility = bool(int(visibility))
+            prefs_columns.append((column_name, visibility))
+
+        missing = self.available_columns - set([c[0] for c in prefs_columns])
+        prefs_columns.extend([(m, False) for m in missing])
+        for column_name, visibility in prefs_columns:
             self.model.append([visibility, _(column_name.capitalize())])
 
         for signal in ('row-changed', 'row-deleted', 'row-inserted',



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]