Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/jarabe/journal/listview.py
blob: 10728000c00ba76d13a4727a1443d11387ad88d7 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright (C) 2010, Aleksey Lim
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import gobject
import logging

from sugar.graphics import style

from jarabe.journal.homogeneview import HomogeneView
from jarabe.journal.homogeneview import Cell
from jarabe.journal.widgets import *


class _Cell(Cell):

    def __init__(self):
        Cell.__init__(self)

        row = gtk.HBox()
        row.props.spacing = style.DEFAULT_SPACING
        self.add(row)

        self._keep = KeepIcon()
        row.pack_start(self._keep, expand=False)

        self._icon = ObjectIcon(
                paint_box=False,
                pixel_size=style.STANDARD_ICON_SIZE)
        row.pack_start(self._icon, expand=False)

        self._title = Title()
        title_alignment = gtk.Alignment(
                xalign=0, yalign=0.5, xscale=1, yscale=0)
        title_alignment.add(self._title)
        row.pack_start(title_alignment)

        self._details = DetailsIcon()
        row.pack_end(self._details, expand=False)

        self._date = Timestamp()
        row.pack_end(self._date, expand=False)

        self._buddies = Buddies(buddies_max=3,
                xalign=0, yalign=0.5, xscale=1, yscale=0.15)
        row.pack_end(self._buddies, expand=False)

        self.show_all()

    def do_fill_in_cell_content(self, table, offset, metadata):
        self._keep.fill_in(metadata)
        self._icon.fill_in(metadata)
        self._title.fill_in(metadata)
        self._details.fill_in(metadata)
        self._date.fill_in(metadata)
        self._buddies.fill_in(metadata)


class ListView(HomogeneView):

    def __init__(self, selection):
        HomogeneView.__init__(self, _Cell, selection)
        self.frame_size = (None, 1)
        self.cell_size = (None, style.GRID_CELL_SIZE)