67
69
__gproperties__ = {
68
'pixbuf' : (gtk.gdk.Pixbuf, "Pixbuf",
69
"Application icon pixbuf image", gobject.PARAM_READWRITE),
71
'expanded': (bool, 'IsExpanded', 'Is expanded?', False,
72
gobject.PARAM_READWRITE),
74
'short_desc': (str, 'short_desc', 'The short description', '',
75
gobject.PARAM_READWRITE),
77
'long_desc': (str, 'long_desc', 'The long description', '',
70
#'pixbuf' : (gtk.gdk.Pixbuf, "Pixbuf",
71
#"Application icon pixbuf image", gobject.PARAM_READWRITE),
73
#'expanded': (bool, 'IsExpanded', 'Is expanded?', False,
74
#gobject.PARAM_READWRITE),
76
'markup': (str, 'short_desc', 'The short description', '',
78
77
gobject.PARAM_READWRITE)
79
# 'long_desc': (str, 'long_desc', 'The long description', '',
80
# gobject.PARAM_READWRITE)
83
def __init__(self, icons):
82
84
gtk.CellRendererText.__init__(self)
83
85
# geometry-state values
84
86
self.pixbuf_width = 0
85
self.normal_height = 0
86
self.selected_height = 0
87
self.normal_height = 40
88
self.selected_height = 40
92
self.fb_icon = self.icons.load_icon(MISSING_APP_ICON, 24, 0)
91
95
self.long_desc = ''
92
96
self.expanded = False
108
112
return layout.get_pixel_extents()[1][3]
110
114
def _render_icon(self, window, widget, cell_area, state, xpad, ypad, direction):
115
if self.markup in _pixbuf_cache:
116
pixbuf = _pixbuf_cache[self.markup]
119
pixbuf = self.icons.load_icon(self.markup, 24, 0)
120
_pixbuf_cache[self.markup] = pixbuf
122
_pixbuf_cache[self.markup] = pixbuf = self.fb_icon
111
124
# calc offsets so icon is nicely centered
112
xo = (self.pixbuf_width - self.pixbuf.get_width())/2
125
xo = (self.pixbuf_width - pixbuf.get_width())/2
114
127
if direction != gtk.TEXT_DIR_RTL:
117
130
x = cell_area.width+xo-self.pixbuf_width
119
133
# draw appicon pixbuf
120
134
window.draw_pixbuf(None,
122
136
0, 0, # src pixbuf
123
137
x, cell_area.y+ypad, # dest in window
125
139
0, 0, 0) # dither
127
# draw overlay if application is installed
129
if direction != gtk.TEXT_DIR_RTL:
132
x = cell_area.width - self.OVERLAY_SIZE
134
y = cell_area.y + self.OFFSET_Y
135
window.draw_pixbuf(None,
136
self._installed, # icon
138
x, y, # dest in window
143
def _render_appsummary(self, window, widget, cell_area, state, layout, xpad, ypad, direction):
142
def _render_description(self, window, widget, cell_area, state, layout, xpad, ypad, direction):
144
143
# adjust cell_area
146
145
# work out max allowable layout width
147
146
lw = self._layout_get_pixel_width(layout)
148
147
max_layout_width = cell_area.width - self.pixbuf_width - 3*xpad
150
if self.isactive and self.props.action_in_progress > 0:
151
action_btn = self.get_button_by_name('action0')
153
logging.warn("No action button? This doesn't make sense!")
155
max_layout_width -= (xpad + action_btn.allocation.width)
157
149
if lw >= max_layout_width:
158
150
layout.set_width((max_layout_width)*pango.SCALE)
159
151
layout.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
234
226
state = gtk.STATE_NORMAL
237
self._layout = widget.get_pango_layout('')
238
self._layout.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
228
self._layout.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
240
230
self._render_icon(window, widget,
241
231
cell_area, state,
245
self._layout.set_markup(self.short_desc)
235
self._layout.set_markup(self.markup)
246
236
self._render_description(window, widget,
247
237
cell_area, state,
282
272
def do_get_size(self, widget, cell_area):
283
if not self.isactive:
284
return -1, -1, -1, self.normal_height
273
if not self.expanded:
275
self._layout = widget.create_pango_layout('')
276
self._layout.set_markup('T\n<small>T</small>')
277
h = self._layout_get_pixel_height(self._layout)
285
279
return -1, -1, -1, self.selected_height
287
281
gobject.type_register(CellRendererMaintenanceView)
426
420
def _create_listview(self, treeview, filter_func):
427
421
"""Set up a column in the named TreeView."""
428
# XXX 2010-03-04 barry: This is a bit of an abuse because it's
429
# supposed to specify whether users are to read across the rows. As a
430
# side effect it renders the columns with alternating row colors, but
431
# that's not it's primary function.
432
#treeview.set_rules_hint(True)
433
# Each TreeView contains two columns. The leftmost one is a toggle
434
# that when select tells c-j to act on that cruft. Deselecting the
435
# toggle ignores the package for next time.
436
toggle_cr = gtk.CellRendererToggle()
437
#toggle_cr.connect('toggled', self._toggled, treeview)
438
toggle_cr.set_property('yalign', 0)
439
toggle_col = gtk.TreeViewColumn()
440
toggle_col.pack_start(toggle_cr)
441
toggle_col.add_attribute(toggle_cr, 'active', ListStoreColumns.active)
442
treeview.append_column(toggle_col)
443
# The rightmost column contains the details of the cruft. It will
444
# always contain the cruft name and can be expanded to display cruft
445
# details. Tell the column to get its toggle's active state from the
447
name_cr = gtk.CellRendererText()
448
name_cr.set_property('yalign', 0)
449
name_cr.set_property('wrap-mode', pango.WRAP_WORD)
450
name_col = gtk.TreeViewColumn()
451
name_col.pack_start(name_cr)
452
name_col.add_attribute(name_cr, 'markup', ListStoreColumns.text)
453
treeview.append_column(name_col)
454
#self.cruft_name_columns.add(name_col)
423
cr = CellRendererMaintenanceView(self.icons)
424
cr.set_pixbuf_width(32)
425
cr.set_button_spacing(3)
426
column = gtk.TreeViewColumn("Cruft", cr,
427
markup=ListStoreColumns.short_name)
428
treeview.append_column(column)
455
429
# The individual crufts may or may not be visible in this TreeView.
456
430
# It's the filter function that controls this, so set that now.
457
431
filter_store = self.store.filter_new()
458
432
filter_store.set_visible_func(filter_func)
459
433
treeview.set_model(filter_store)
460
treeview.connect('button-press-event', self.treeview_button_press_event)
434
#treeview.connect('button-press-event', self.treeview_button_press_event)
463
436
def toggle_long_description(self, treeview):
464
437
"""Toggle the currently selected cruft's long description.
493
466
model.set_value(iter, ListStoreColumns.text, value)
494
467
model.set_value(iter, ListStoreColumns.expanded, not expanded)
497
469
def treeview_button_press_event(self, treeview, event):
498
470
"""Handle mouse button press events on the TreeView ourselves.