~mvo/software-center/small-sso-fixes

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/widgets/containers.py

minor cleanup from lp:~gary-lasker/software-center/recommends-ui-lobby

Show diffs side-by-side

added added

removed removed

Lines of Context:
495
495
class FramedHeaderBox(FramedBox):
496
496
 
497
497
    MARKUP = '<b>%s</b>'
 
498
    
 
499
    # pages for the spinner notebook
 
500
    (CONTENT,
 
501
     SPINNER) = range(2)
498
502
 
499
 
    def __init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=0, padding=0):
 
503
    def __init__(self, orientation=Gtk.Orientation.VERTICAL,
 
504
                 spacing=0,
 
505
                 padding=0,
 
506
                 show_spinner=False):
500
507
        FramedBox.__init__(self, Gtk.Orientation.VERTICAL, spacing, padding)
 
508
        # make the header
501
509
        self.header = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, spacing)
502
510
        self.header_alignment = Gtk.Alignment()
503
511
        self.header_alignment.add(self.header)
504
512
        self.box.pack_start(self.header_alignment, False, False, 0)
 
513
        # make the content box
505
514
        self.content_box = Gtk.Box.new(orientation, spacing)
506
 
        self.box.add(self.content_box)
 
515
        # and a spinner (to be used only if needed)
 
516
        # TODO: cosmetic tweak needed - draw a line at the top of the spinner
 
517
        #       area so that the header has a proper border
 
518
        self.spinner = Gtk.Spinner()
 
519
        self.spinner.set_size_request(32, 32)
 
520
        self.spinner.set_valign(Gtk.Align.CENTER)
 
521
        self.spinner.set_halign(Gtk.Align.CENTER)
 
522
        # finally, a notebook for the spinner and the content box to share
 
523
        self.spinner_notebook = Gtk.Notebook()
 
524
        self.spinner_notebook.set_show_tabs(False)
 
525
        self.spinner_notebook.set_show_border(False)
 
526
        self.spinner_notebook.append_page(self.content_box, None)
 
527
        self.spinner_notebook.append_page(self.spinner, None)
 
528
        self.box.add(self.spinner_notebook)
507
529
        return
508
530
 
509
531
    def on_draw(self, cr):
523
545
 
524
546
    def pack_end(self, *args, **kwargs):
525
547
        return self.content_box.pack_end(*args, **kwargs)
 
548
        
 
549
    def show_spinner(self):
 
550
        self.spinner.start()
 
551
        self.spinner.show()
 
552
        self.spinner_notebook.set_current_page(self.SPINNER)
 
553
            
 
554
    def hide_spinner(self):
 
555
        self.spinner.stop()
 
556
        self.spinner.hide()
 
557
        self.spinner_notebook.set_current_page(self.CONTENT)
526
558
 
527
559
    # XXX: non-functional with current code...
528
560
    #~ def set_header_expand(self, expand):
553
585
        self.title.set_markup(self.MARKUP % label)
554
586
        return
555
587
 
556
 
    def header_implements_more_button(self, callback=None):
 
588
    def header_implements_more_button(self):
557
589
        if not hasattr(self, "more"):
558
590
            self.more = MoreLink()
559
591
            self.header.pack_end(self.more, False, False, 0)