[meld: 10/12] set pane inside unsafe_set



commit c39bb7def99c72018343d5c4b20074c9b0895825
Author: hugosenari <hugosenari gmail com>
Date:   Sun Aug 5 08:12:24 2018 -0300

    set pane inside unsafe_set

 meld/dirdiff.py | 13 ++++++-------
 meld/tree.py    | 33 +++++++++++++++------------------
 2 files changed, 21 insertions(+), 25 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index d057be4b..97af3df6 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1394,18 +1394,17 @@ class DirDiff(MeldDoc, Component):
 
         isdir = [os.path.isdir(files[j]) for j in range(self.model.ntree)]
         for j in range(self.model.ntree):
-            column = functools.partial(self.model.column_index, pane=j)
             if stats[j]:
                 self.model.set_path_state(
                     it, j, state, isdir[j], display_text=name_overrides[j])
                 emblem = EMBLEM_NEW if j in newest else None
                 link_emblem = EMBLEM_SYMLINK if j in symlinks else None
-                self.model.unsafe_set(it, {
-                    column(COL_EMBLEM): emblem,
-                    column(COL_EMBLEM_SECONDARY): link_emblem,
-                    column(COL_TIME): times[j],
-                    column(COL_SIZE): sizes[j],
-                    column(COL_PERMS): perms[j],
+                self.model.unsafe_set(it, j, {
+                    COL_EMBLEM: emblem,
+                    COL_EMBLEM_SECONDARY: link_emblem,
+                    COL_TIME: times[j],
+                    COL_SIZE: sizes[j],
+                    COL_PERMS: perms[j]
                 })
             else:
                 # TODO: More consistent state setting here would let us avoid
diff --git a/meld/tree.py b/meld/tree.py
index 75d9cec5..349ae32b 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -129,23 +129,19 @@ class DiffTreeStore(SearchableTreeStore):
     def add_entries(self, parent, names):
         it = self.append(parent)
         for pane, path in enumerate(names):
-            column = self.column_index(COL_PATH, pane)
-            self.unsafe_set(it, {column: path})
+            self.unsafe_set(it, pane, {COL_PATH: path})
         return it
 
     def add_empty(self, parent, text="empty folder"):
         it = self.append(parent)
         for pane in range(self.ntree):
-            column = self.column_index(COL_PATH, pane)
-            self.unsafe_set(it, {column: None})
             self.set_state(it, pane, STATE_EMPTY, text)
         return it
 
     def add_error(self, parent, msg, pane):
         it = self.append(parent)
         for i in range(self.ntree):
-            column = self.column_index(COL_STATE, i)
-            self.unsafe_set(it, {column: str(STATE_ERROR)})
+            self.unsafe_set(it, i, {COL_STATE: str(STATE_ERROR)})
         self.set_state(it, pane, STATE_ERROR, msg)
 
     def set_path_state(self, it, pane, state, isdir=0, display_text=None):
@@ -155,19 +151,18 @@ class DiffTreeStore(SearchableTreeStore):
         self.set_state(it, pane, state, display_text, isdir)
 
     def set_state(self, it, pane, state, label, isdir=0):
-        col_idx = self.column_index
         icon = self.icon_details[state][1 if isdir else 0]
         tint = self.icon_details[state][3 if isdir else 2]
         fg, style, weight, strike = self.text_attributes[state]
-        self.unsafe_set(it, {
-            col_idx(COL_STATE, pane): str(state),
-            col_idx(COL_TEXT,  pane): label,
-            col_idx(COL_ICON,  pane): icon,
-            col_idx(COL_TINT, pane): tint,
-            col_idx(COL_FG, pane): fg,
-            col_idx(COL_STYLE, pane): style,
-            col_idx(COL_WEIGHT, pane): weight,
-            col_idx(COL_STRIKE, pane): strike,
+        self.unsafe_set(it, pane, {
+            COL_STATE: str(state),
+            COL_TEXT: label,
+            COL_ICON: icon,
+            COL_TINT: tint,
+            COL_FG: fg,
+            COL_STYLE: style,
+            COL_WEIGHT: weight,
+            COL_STRIKE: strike
         })
 
     def get_state(self, it, pane):
@@ -195,7 +190,7 @@ class DiffTreeStore(SearchableTreeStore):
             if state in states:
                 yield it
 
-    def unsafe_set(self, treeiter, keys_values):
+    def unsafe_set(self, treeiter, pane, keys_values):
         """ This must be fastest than super.set,
         at the cost that may crash the application if you don't
         know what your're passing here.
@@ -209,7 +204,9 @@ class DiffTreeStore(SearchableTreeStore):
         return None
         """
         safe_keys_values = {
-            col: val if val is not None else self._none_of_cols.get(col)
+            self.column_index(col, pane):
+            val if val is not None
+            else self._none_of_cols.get(self.column_index(col, pane))
             for col, val in keys_values.items()
         }
         if _GIGtk and treeiter:


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