def fill_tree_store(self, store): """ Fill TreeStore object """ it = None font = config.font fg_color = config.font_color icontheme = Gtk.IconTheme.get_default() bg_dark = False ch_dark = False for wd in range(7): for item in self._sched_week[wd]: # Get pixbuf if item["icon"]: icon = GdkPixbuf.Pixbuf.new_from_file(item["icon"]) else: # Load default icon instead icon = icontheme.load_icon(ICON, 256, 0) # Scale sz = 80 if not item["is_main"]: sz = 60 icon = icon.scale_simple(sz, sz, GdkPixbuf.InterpType.BILINEAR) # Join hosts host = parse_hosts(item["host"]) # Insert program if item["is_main"]: # Main event bg_color = hex_to_rgba(config.bg_colors[bg_dark]) bg_color.alpha = config.bg_alpha[bg_dark] # Insert item it = store.append(None, [item["weekday"], item["is_main"], item["time"], item["title"], item["url"], host, icon, bg_color, fg_color, font, bg_dark, item["record"], item["play"], item["is_merged"]]) # Alternate row color bg_dark = not bg_dark ch_dark = bg_dark else: # Child event bg_color = hex_to_rgba(config.bg_colors[ch_dark]) bg_color.alpha = config.bg_alpha[ch_dark] # Insert item store.append(it, [item["weekday"], item["is_main"], item["time"], item["title"], item["url"], host, icon, bg_color, fg_color, font, ch_dark, False, False, False]) # Alternate row color ch_dark = not ch_dark
def reset_marked(self): """ Reset marked row """ if not self._marked: # Nothing to reset return # Get current position path = Gtk.TreePath(self._marked_pos) iter = self._model.get_iter(path) # Set original colors and font dark = self._model[iter][10] bg_color = hex_to_rgba(config.bg_colors[dark]) bg_color.alpha = config.bg_alpha[dark] self._model[iter][7] = bg_color self._model[iter][8] = config.font_color self._model[iter][9] = config.font self._marked = False
def mark_current(self): """ Mark current event """ # Get current position pos = self._sched.get_event_position() path = Gtk.TreePath(pos) iter = self._model.get_iter(path) # Set current row color marked_color = hex_to_rgba(config.selected_bg_color) marked_color.alpha = config.selected_alpha self._model[iter][7] = marked_color self._model[iter][8] = config.selected_font_color self._model[iter][9] = config.selected_font # Scroll to current cell self.scroll_to_cell(path, use_align=True, row_align=0.5) # Backup position self._marked = True self._marked_pos = pos