def _get_background_color(self, idx, entitlement_cert=None): if entitlement_cert: date_range = entitlement_cert.validRange() now = datetime.now(GMT()) if date_range.end() < now: return EXPIRED_COLOR if date_range.end() - timedelta(days=WARNING_DAYS) < now: return WARNING_COLOR return get_cell_background_color(idx)
def _get_background_color(self, idx, entitlement_cert=None): if entitlement_cert: date_range = entitlement_cert.validRange() now = datetime.now(GMT()) if date_range.end() < now: return EXPIRED_COLOR if date_range.end() - timedelta(days=WARNING_DAYS) < now: return WARNING_COLOR return get_cell_background_color(idx)
def _add_group(self, group_idx, group): iter = None bg_color = get_cell_background_color(group_idx) if group.name: iter = self.store.add_map(iter, self._create_stacking_header_entry(group.name, bg_color)) new_parent_image = None for i, cert in enumerate(group.entitlements): image = self._get_entry_image(cert) self.store.add_map(iter, self._create_entry_map(cert, bg_color, image)) # Determine if we need to change the parent's image. We # will match the parent's image with the children if any of # the children have an image. if self.image_ranks_higher(new_parent_image, image): new_parent_image = image # Update the parent image if required. if new_parent_image and iter: self.store.set_value( iter, self.store["image"], gtk.gdk.pixbuf_new_from_file_at_size(new_parent_image, 13, 13) )
def _stripe_rows(self, column, store): """ This method repaints the row stripes when the rows are re-arranged due to the user sorting a column """ if 'background' in store: iter = store.get_iter_first() i = 0 rows = [] # Making changes to a TreeModel while you are iterating over it can lead # to weird behavior so we save all the rows that need to be recolored as # TreeRowReferences and set the color on them after the iteration is finished. while iter: bg_color = utils.get_cell_background_color(i) rows += [(ref, bg_color) for ref in utils.gather_group(store, iter, [])] i += 1 iter = store.iter_next(iter) for r in rows: model = r[0].get_model() iter = model.get_iter(r[0].get_path()) model.set_value(iter, model['background'], r[1])
def _stripe_rows(self, column, store): """ This method repaints the row stripes when the rows are re-arranged due to the user sorting a column """ if 'background' in store: iter = store.get_iter_first() i = 0 rows = [] # Making changes to a TreeModel while you are iterating over it can lead # to weird behavior so we save all the rows that need to be recolored as # TreeRowReferences and set the color on them after the iteration is finished. while iter: bg_color = utils.get_cell_background_color(i) rows += [(ref, bg_color) for ref in utils.gather_group(store, iter, [])] i += 1 iter = store.iter_next(iter) for r in rows: model = r[0].get_model() iter = model.get_iter(r[0].get_path()) model.set_value(iter, model['background'], r[1])
def _add_group(self, group_idx, group): iter = None bg_color = get_cell_background_color(group_idx) if group.name: iter = self.store.add_map( iter, self._create_stacking_header_entry(group.name, bg_color)) new_parent_image = None for i, cert in enumerate(group.entitlements): image = self._get_entry_image(cert) self.store.add_map(iter, self._create_entry_map(cert, bg_color, image)) # Determine if we need to change the parent's image. We # will match the parent's image with the children if any of # the children have an image. if self.image_ranks_higher(new_parent_image, image): new_parent_image = image # Update the parent image if required. if new_parent_image and iter: self.store.set_value( iter, self.store['image'], gtk.gdk.pixbuf_new_from_file_at_size(new_parent_image, 13, 13))