~didrocks/software-center/smarter-app-filtering-level

« back to all changes in this revision

Viewing changes to softwarecenter/view/appdetailsview_gtk.py

  • Committer: Matthew McGowan
  • Date: 2010-09-21 09:50:20 UTC
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20100921095020-iyx3lps258vyffkb
first draft of a gtk widget allowing for selectable formatted text + integration work wrt AppDetailsViewGtk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
from appdetailsview import AppDetailsViewBase
46
46
 
47
47
from widgets import mkit
 
48
from widgets.label import FormattedLabel
48
49
from widgets.imagedialog import ShowImageDialog, GnomeProxyURLopener, Url404Error, Url403Error
49
50
 
50
51
if os.path.exists("./softwarecenter/enums.py"):
316
317
    def __init__(self):
317
318
        gtk.VBox.__init__(self, spacing=mkit.SPACING_LARGE)
318
319
 
319
 
        self.body = gtk.VBox()
 
320
        self.description = FormattedLabel()
320
321
        self.footer = gtk.HBox(spacing=mkit.SPACING_MED)
321
322
 
322
 
        self.pack_start(self.body, False)
 
323
        self.pack_start(self.description, False)
323
324
        self.pack_start(self.footer, False)
324
325
        self.show_all()
325
 
 
326
 
        self.paragraphs = []
327
 
        self.points = []
328
326
        return
329
327
 
330
328
    def clear(self):
331
 
        for child in self.body.get_children():
332
 
            self.body.remove(child)
333
 
            child.destroy()
334
 
 
335
 
        self.paragraphs = []
336
 
        self.points = []
337
 
        return
338
 
 
339
 
    def append_paragraph(self, fragment):
340
 
        p = gtk.Label()
341
 
        p.set_markup(fragment)
342
 
        p.set_line_wrap(True)
343
 
        p.set_selectable(True)
344
 
 
345
 
        hb = gtk.HBox()
346
 
        hb.pack_start(p, False)
347
 
 
348
 
        self.body.pack_start(hb, False)
349
 
        self.paragraphs.append(p)
350
 
        return
351
 
 
352
 
    def append_bullet_point(self, fragment):
353
 
        for bullet in self.BULLETS:
354
 
            fragment = fragment.replace(bullet, '')
355
 
 
356
 
        bullet = gtk.Label()
357
 
        bullet.set_markup(u"  <b>\u2022</b>")
358
 
 
359
 
        a = gtk.Alignment(0.5, 0.0)
360
 
        a.add(bullet)
361
 
 
362
 
        point = gtk.Label()
363
 
        point.set_markup(fragment)
364
 
        point.set_line_wrap(True)
365
 
        point.set_selectable(True)
366
 
 
367
 
        hb = gtk.HBox(spacing=mkit.EM)
368
 
        hb.pack_start(a, False)
369
 
        hb.pack_start(point, False)
370
 
 
371
 
        a = gtk.Alignment(xscale=1.0, yscale=1.0)
372
 
        a.set_padding(4,4,0,0)
373
 
        a.add(hb)
374
 
 
375
 
        self.body.pack_start(a, False)
376
 
        self.points.append(point)
 
329
        self.description.clear()
 
330
        return
 
331
 
 
332
    def append_paragraph(self, p):
 
333
        self.description.append_paragraph(p.strip())
 
334
        return
 
335
 
 
336
    def append_bullet(self, point):
 
337
        self.description.append_bullet(point[2:].strip())
377
338
        return
378
339
 
379
340
    def set_description(self, desc, appname):
403
364
                if part[:2] in self.BULLETS:
404
365
                    # if there's an existing bullet, append it and start anew
405
366
                    if in_blist:
406
 
                        self.append_bullet_point(processed_frag)
 
367
                        self.append_bullet(processed_frag)
407
368
                        processed_frag = ''
408
369
 
409
370
                    in_blist = True
435
396
                            processed_frag += '\n'
436
397
 
437
398
                        # append a bullet point
438
 
                        self.append_bullet_point(processed_frag)
 
399
                        self.append_bullet(processed_frag)
439
400
                        # reset
440
401
                        processed_frag = ''
441
402
                        in_blist = False
445
406
 
446
407
        if processed_frag:
447
408
            if processed_frag[:2] in self.BULLETS:
448
 
                self.append_bullet_point(processed_frag)
 
409
                self.append_bullet(processed_frag)
449
410
            else:
450
411
                self.append_paragraph(processed_frag)
451
412
 
1077
1038
        else:
1078
1039
            self.app_info.label.set_size_request(-1, -1)
1079
1040
 
1080
 
        for p in self.app_desc.paragraphs:
1081
 
            p.set_size_request(w-5*mkit.EM-166, -1)
1082
 
            
1083
 
        for pt in self.app_desc.points:
1084
 
            pt.set_size_request(w-7*mkit.EM-166, -1)
 
1041
        desc = self.app_desc.description
 
1042
        size = desc.height_from_width(w-5*mkit.EM-166)
 
1043
        if size:
 
1044
            desc.set_size_request(*size)
1085
1045
 
1086
1046
        self.version_info.set_width(w-6*mkit.EM)
1087
1047
        self.license_info.set_width(w-6*mkit.EM)
1116
1076
            # draw icon frame as well...
1117
1077
            self._draw_icon_frame(cr)
1118
1078
 
 
1079
        self.app_desc.description.draw(widget, event)
 
1080
 
1119
1081
        if self.action_bar.get_property('visible'):
1120
1082
            self.action_bar.draw(cr,
1121
1083
                                 self.action_bar.allocation,
1122
1084
                                 event.area)
1123
 
        
 
1085
 
1124
1086
        if self.addons_bar.get_property('visible'):
1125
1087
            self.addons_bar.draw(cr,
1126
1088
                                 self.addons_bar.allocation,
1243
1205
        app_desc_hb.pack_start(self.app_desc, False)
1244
1206
 
1245
1207
        # a11y for description
1246
 
        self.app_desc.body.set_property("can-focus", True)
1247
 
        self.app_desc.body.a11y = self.app_desc.body.get_accessible()
 
1208
        self.app_desc.description.set_property("can-focus", True)
 
1209
        self.app_desc.description.a11y = self.app_desc.description.get_accessible()
1248
1210
 
1249
1211
        # screenshot
1250
1212
        self.screenshot = ScreenshotView(self.distro, self.icons)
1352
1314
            description = " "
1353
1315
        self.app_desc.set_description(description, appname)
1354
1316
        # a11y for description
1355
 
        self.app_desc.body.a11y.set_name("Description: " + description)
 
1317
        #self.app_desc.body.a11y.set_name("Description: " + description)
1356
1318
 
1357
1319
        # show or hide the homepage button and set uri if homepage specified
1358
1320
        if app_details.website: