Ejemplo n.º 1
0
 def _on_apply1(self):
     it = self._treemodel.get_iter_first()
     just_modified = []
     while it is not None:
         nextit = self._treemodel.iter_next(it)
         if nextit is None:
             it = nextit
             continue
         if self._treemodel[it][1] is not None:
             # if there are some changes, self._treemodel[it][1] is a list of the names
             # of the affected fields.
             new_just_modified = []
             # now go through the affected fields, ignoring those which were modified
             # only during the previous iteration.
             for fn in [x for x in self._treemodel[it][1] if x not in just_modified]:
                 if (self._treemodel[nextit][1] is None) or (fn not in self._treemodel[nextit][1]):
                     # if this field is not yet changed in the next row, add this fieldname to the skip list
                     # of the next iteration. We thus avoid to propagate the change more than one times.
                     new_just_modified.append(fn)
                 # get the treeview column.
                 self._on_cell_edited([c for c in self._treeview.get_columns() if c.get_title() == fn][0].get_cells()[0],
                                      self._treemodel.get_path(nextit),
                                      SASHeaderField.get_instance(fn).tostring(self._treemodel[it][0][fn]), fn, True)
         just_modified = new_just_modified
         it = nextit
Ejemplo n.º 2
0
 def _on_cell_edited(self, cellrenderer, path, newtext, fieldname, force_edit=False):
     shf = SASHeaderField.get_instance(fieldname)
     newvalue = shf.fromstring(newtext)
     if (self._treemodel[path][0][fieldname] == newvalue) and not force_edit:
         return True
     self._treemodel[path][0][fieldname] = newvalue
     if self._treemodel[path][1] is None:
         self._treemodel[path][1] = []
     self._treemodel[path][1].append(fieldname)
     self._cell_datafunction([c for c in self._treeview.get_columns() if c.get_title() == fieldname][0], cellrenderer, self._treemodel, self._treemodel.get_iter(path), shf)
     self._apply1_button.set_sensitive(True)
     self._applyall_button.set_sensitive(True)
     self._commit_button.set_sensitive(True)
     self._forget_button.set_sensitive(True)
Ejemplo n.º 3
0
 def _update_treeview(self):
     for col in self._treeview.get_columns()[:]:
         self._treeview.remove_column(col)
     if hasattr(self, '_renderer_connections'):
         for cr, conn in self._renderer_connections:
             cr.disconnect(conn)
         del self._renderer_connections
     self._renderer_connections = []
     for fn in self._fieldnames:
         cr = Gtk.CellRendererText()
         cr.set_property('editable', True)
         self._renderer_connections.append((cr, cr.connect('edited', self._on_cell_edited, fn)))
         shf = SASHeaderField.get_instance(fn)
         tvc = Gtk.TreeViewColumn(shf.fieldname, cr)
         tvc.set_cell_data_func(cr, self._cell_datafunction, shf)
         self._treeview.append_column(tvc)
Ejemplo n.º 4
0
 def set_visible_fields(self, fieldslist):
     self._treemodel.clear()
     for shf in [SASHeaderField.get_instance(fn) for fn in fieldslist]:
         self._treemodel.append((True, shf.fieldname, shf.mnemonic))
     for shf in [shf for shf in SASHeaderField._allknownfields if shf.fieldname not in fieldslist]:
         self._treemodel.append((False, shf.fieldname, shf.mnemonic))
Ejemplo n.º 5
0
 def _validate_column_names(self, *names):
     try:
         [SASHeaderField.get_instance(n) for n in names]
     except ValueError as ve:
         raise ve
Ejemplo n.º 6
0
 def _on_applyall(self):
     it = self._treemodel.get_iter_first()
     alreadydone = []
     while it is not None:
         nextit = self._treemodel.iter_next(it)
         if nextit is None:
             it = nextit
             continue
         if self._treemodel[it][1] is not None:
             for fn in [n for n in self._treemodel[it][1] if n not in alreadydone]:
                 ni = nextit
                 while ni is not None:
                     tvc = [c for c in self._treeview.get_columns() if c.get_title() == fn][0]
                     self._on_cell_edited(tvc.get_cells()[0], self._treemodel.get_path(ni), SASHeaderField.get_instance(fn).tostring(self._treemodel[it][0][fn]), fn, True)
                     ni = self._treemodel.iter_next(ni)
                 alreadydone.append(fn)
         it = nextit