1 # Copyright (C) 2007, One Laptop Per Child
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 from gettext
import gettext
as _
24 from sugar
.graphics
import units
25 from sugar
.graphics
import style
26 from sugar
.graphics
.canvasicon
import CanvasIcon
27 from sugar
.datastore
import datastore
29 from expandedentry
import ExpandedEntry
30 from keepicon
import KeepIcon
32 class DetailView(gtk
.VBox
):
33 __gtype_name__
= 'DetailView'
36 'go-back-clicked': (gobject
.SIGNAL_RUN_FIRST
, gobject
.TYPE_NONE
, ([]))
39 def __init__(self
, model
):
40 gtk
.VBox
.__init
__(self
)
44 canvas
= hippo
.Canvas()
45 self
.pack_start(canvas
, expand
=True, fill
=True)
48 root
= hippo
.CanvasBox()
49 root
.props
.background_color
= style
.COLOR_PANEL_GREY
.get_int()
53 back_bar
.connect('button-release-event', self
._back
_bar
_release
_event
_cb
)
56 self
._hbox
= hippo
.CanvasBox(orientation
= hippo
.ORIENTATION_HORIZONTAL
,
57 spacing
=units
.points_to_pixels(5),
58 padding
=units
.points_to_pixels(5))
59 root
.append(self
._hbox
)
61 self
._expanded
_object
= ExpandedEntry(self
._jobject
)
62 self
._hbox
.append(self
._expanded
_object
, hippo
.PACK_EXPAND
)
64 def _fav_icon_activated_cb(self
, fav_icon
):
65 keep
= not self
._expanded
_object
.get_keep()
66 self
._expanded
_object
.set_keep(keep
)
67 fav_icon
.props
.keep
= keep
69 def _back_bar_release_event_cb(self
, back_bar
, event
):
70 self
.emit('go-back-clicked')
74 logging
.debug('DetailView.refresh')
75 self
._jobject
= datastore
.get(self
._jobject
.object_id
)
77 self
._hbox
.remove(self
._expanded
_object
)
78 self
._expanded
_object
= ExpandedEntry(self
._jobject
)
79 self
._hbox
.append(self
._expanded
_object
, hippo
.PACK_EXPAND
)
81 class BackBar(hippo
.CanvasBox
):
83 hippo
.CanvasBox
.__init
__(self
,
84 orientation
=hippo
.ORIENTATION_HORIZONTAL
,
85 border
=style
.LINE_WIDTH
,
86 background_color
=style
.COLOR_PANEL_GREY
.get_int(),
87 border_color
=style
.COLOR_SELECTION_GREY
.get_int(),
88 padding
=style
.DEFAULT_SPACING
,
89 spacing
=style
.DEFAULT_SPACING
)
91 icon
= CanvasIcon(icon_name
='theme:go-previous-mini',
92 scale
=units
.STANDARD_ICON_SCALE
)
95 label
= hippo
.CanvasText(text
=_('Go back'),
96 font_desc
=style
.FONT_BOLD
.get_pango_desc())
99 self
.connect('motion-notify-event', self
._motion
_notify
_event
_cb
)
101 def _motion_notify_event_cb(self
, box
, event
):
102 if event
.detail
== hippo
.MOTION_DETAIL_ENTER
:
103 self
.props
.background_color
= style
.COLOR_SELECTION_GREY
.get_int()
104 elif event
.detail
== hippo
.MOTION_DETAIL_LEAVE
:
105 self
.props
.background_color
= style
.COLOR_PANEL_GREY
.get_int()