File: bold-unread.py

package info (click to toggle)
liferea 1.15.8-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,652 kB
  • sloc: ansic: 27,425; javascript: 1,646; python: 1,123; makefile: 657; sh: 115; xml: 13
file content (44 lines) | stat: -rw-r--r-- 1,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
bold unread plugin

Copyright (C) 2017 Yanko Kaneti <yaneti@declera.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
"""

from gi.repository import GObject, Liferea, Pango

def cell_func_bold_unread(column, cell, model, iterator, data):
    unread_count = model.get(iterator, 3)
    cell.set_property("weight", Pango.Weight.BOLD if (unread_count[0] > 0) else Pango.Weight.NORMAL)

class NrBoldUnreadPlugin(GObject.Object, Liferea.ShellActivatable):
    __gtype_name__ = 'NrBoldUnreadPlugin'
    treeview = None
    ticol = None
    layout = None
    shell = GObject.property(type=Liferea.Shell)

    def do_activate(self):
        self.treeview = self.shell.lookup("feedlist")
        self.ticol = self.treeview.get_column(0)
        area = self.ticol.get_property("cell-area")
        self.layout = area.get_cells()
        self.ticol.set_cell_data_func(self.layout[1], cell_func_bold_unread)
        self.treeview.queue_draw()

    def do_deactivate(self):
        self.ticol.set_cell_data_func(self.layout[1], None)
        self.layout[1].set_property("weight", Pango.Weight.NORMAL)
        self.treeview.queue_draw()