Commit 978df6a1 authored by Hugo Sena Ribeiro's avatar Hugo Sena Ribeiro

single set() call instead of the multiple set_values()

parent 948aa39e
......@@ -1399,13 +1399,14 @@ class DirDiff(MeldDoc, Component):
it, j, state, isdir[j], display_text=name_overrides[j])
emblem = EMBLEM_NEW if j in newest else None
self.model.unsafe_set_value(it, column(COL_EMBLEM), emblem)
link_emblem = EMBLEM_SYMLINK if j in symlinks else None
it, column(COL_EMBLEM_SECONDARY), link_emblem)
self.model.unsafe_set_value(it, column(COL_TIME), times[j])
self.model.unsafe_set_value(it, column(COL_SIZE), sizes[j])
self.model.unsafe_set_value(it, column(COL_PERMS), perms[j])
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],
# TODO: More consistent state setting here would let us avoid
# pyobjects for column types by avoiding None use.
......@@ -115,25 +115,25 @@ class DiffTreeStore(SearchableTreeStore):
return self.ntree * col + pane
def add_entries(self, parent, names):
child = self.append(parent)
it = self.append(parent)
for pane, path in enumerate(names):
column = self.column_index(COL_PATH, pane)
self.unsafe_set_value(child, column, path)
return child
self.unsafe_set(it, { column: 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.set_value(it, column, None)
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):
self.set_value(it, self.column_index(COL_STATE, i),
column = self.column_index(COL_STATE, i)
self.unsafe_set(it, { column: str(STATE_ERROR) })
self.set_state(it, pane, STATE_ERROR, msg)
def set_path_state(self, it, pane, state, isdir=0, display_text=None):
......@@ -146,16 +146,17 @@ class DiffTreeStore(SearchableTreeStore):
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]
self.unsafe_set_value(it, col_idx(COL_STATE, pane), str(state))
self.unsafe_set_value(it, col_idx(COL_TEXT, pane), label)
self.unsafe_set_value(it, col_idx(COL_ICON, pane), icon)
self.unsafe_set_value(it, col_idx(COL_TINT, pane), tint)
fg, style, weight, strike = self.text_attributes[state]
self.unsafe_set_value(it, col_idx(COL_FG, pane), fg)
self.unsafe_set_value(it, col_idx(COL_STYLE, pane), style)
self.unsafe_set_value(it, col_idx(COL_WEIGHT, pane), weight)
self.unsafe_set_value(it, col_idx(COL_STRIKE, pane), strike)
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,
def get_state(self, it, pane):
state_idx = self.column_index(COL_STATE, pane)
......@@ -147,21 +147,26 @@ class SearchableTreeStore(Gtk.TreeStore):
return prev_path, next_path
def unsafe_set_value(self, treeiter, column, value):
""" This must be fastest than super.set_value,
def unsafe_set(self, treeiter, 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.
ie: pass treeiter or column as None crash meld
treeiter: Gtk.TreeIter
column: Int col index
value: Str (UTF-8), Int, Float, Double, Boolean or GObject
keys_values: dict<column, value>
column: Int col index
value: Str (UTF-8), Int, Float, Double, Boolean, None or GObject
return None
if value is None and hasattr(self, '_none_of_cols'):
value = self._none_of_cols.get(column)
if value is not None and _GIGtk and treeiter:
_GIGtk.TreeStore.set_value(self, treeiter, column, value)
safe_keys_values = {
col: val if val is not None else self._none_of_cols.get(col)
for col, val in keys_values.items()
if _GIGtk and treeiter:
columns = [col for col in safe_keys_values.keys()]
values = [val for val in safe_keys_values.values()]
_GIGtk.TreeStore.set(self, treeiter, columns, values)
self.set_value(treeiter, column, value)
self.set(treeiter, safe_keys_values)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment