コード例 #1
0
class SyncProgressBar(widgetset.Background):
    PROGRESS_GRADIENT_TOP = (1, 1, 1)
    PROGRESS_GRADIENT_BOTTOM = widgetutil.css_to_color('#a0a0a0')

    BACKGROUND_GRADIENT_TOP = widgetutil.css_to_color('#0c0c0e')
    BACKGROUND_GRADIENT_BOTTOM = widgetutil.css_to_color('#3f4346')

    def __init__(self):
        widgetset.Background.__init__(self)
        self.progress_ratio = 0.0

    def set_progress(self, progress):
        self.progress_ratio = progress
        self.queue_redraw()

    def draw(self, context, layout):
        widgetutil.circular_rect(context, 0, 0, context.width, context.height)
        gradient = widgetset.Gradient(0, 0, 0, context.height)
        gradient.set_start_color(self.BACKGROUND_GRADIENT_TOP)
        gradient.set_end_color(self.BACKGROUND_GRADIENT_BOTTOM)
        context.gradient_fill(gradient)
        progress_width = (
            (context.width - context.height) * self.progress_ratio +
            context.height)
        widgetutil.circular_rect_negative(context, 1, 1, progress_width - 2,
                                          context.height - 2)
        gradient = widgetset.Gradient(1, 1, 1, context.height - 2)
        gradient.set_start_color(self.PROGRESS_GRADIENT_TOP)
        gradient.set_end_color(self.PROGRESS_GRADIENT_BOTTOM)
        context.gradient_fill(gradient)
コード例 #2
0
ファイル: browser.py プロジェクト: kmshi/miro
    def __init__(self, guide_info):
        widgetset.VBox.__init__(self)
        self.browser = Browser(guide_info)
        self.toolbar = BrowserToolbar()
        self.guide_info = guide_info
        self.home_url = guide_info.url
        self.pack_start(self.toolbar)
        color1 = widgetutil.css_to_color('#bcbcbc')
        color2 = widgetutil.css_to_color('#020202')
        self.pack_start(separator.HSeparator(color1, color2))
        self.pack_start(self.browser, expand=True)

        self.toolbar.connect_weak('browser-back', self._on_browser_back)
        self.toolbar.connect_weak('browser-forward', self._on_browser_forward)
        self.toolbar.connect_weak('browser-reload', self._on_browser_reload)
        self.toolbar.connect_weak('browser-stop', self._on_browser_stop)
        self.toolbar.connect_weak('browser-home', self._on_browser_home)
        self.toolbar.connect_weak('browser-download',
                                  self._on_browser_download)
        self.toolbar.connect_weak('browser-open', self._on_browser_open)

        self.browser.connect_weak('net-start', self._on_net_start)
        self.browser.connect_weak('net-stop', self._on_net_stop)
        self.browser.connect_weak('download-started',
                                  self._on_download_started)

        self.browser.navigate(self.guide_info.url)
コード例 #3
0
class TabButtonContainer(widgetset.Background):
    TOP_BORDER = widgetutil.css_to_color('#e2e2e2')
    TOP_GRADIENT = widgetutil.css_to_color('#cfcfcf')
    BOTTOM_GRADIENT = widgetutil.css_to_color('#a4a4a4')
    BOTTOM_BORDER1 = widgetutil.css_to_color('#bbbbbb')
    BOTTOM_BORDER2 = widgetutil.css_to_color('#303030')

    def __init__(self):
        widgetset.Background.__init__(self)
        self.set_size_request(-1, 45)

    def draw(self, context, layout):
        context.set_line_width(1)
        context.move_to(0, 0.5)
        context.line_to(context.width, 0.5)
        context.set_color(self.TOP_BORDER)
        context.stroke()
        gradient = widgetset.Gradient(0, 1, context.width, context.height - 2)
        gradient.set_start_color(self.TOP_GRADIENT)
        gradient.set_end_color(self.BOTTOM_GRADIENT)
        context.rectangle(0, 1, context.width, context.height - 2)
        context.gradient_fill(gradient)
        context.move_to(0, context.height - 1.5)
        context.line_to(context.width, context.height - 1.5)
        context.set_color(self.BOTTOM_BORDER1)
        context.stroke()
        context.move_to(0, context.height - 0.5)
        context.line_to(context.width, context.height - 0.5)
        context.set_color(self.BOTTOM_BORDER2)
        context.stroke()
コード例 #4
0
ファイル: browser.py プロジェクト: codito/miro
    def __init__(self, guide_info):
        widgetset.VBox.__init__(self)
        self.browser = Browser(guide_info)
        self.toolbar = BrowserToolbar()
        self.guide_info = guide_info
        self.home_url = guide_info.url
        self.pack_start(self.toolbar)
        color1 = widgetutil.css_to_color('#bcbcbc')
        color2 = widgetutil.css_to_color('#020202')
        self.pack_start(separator.HSeparator(color1, color2))
        self.pack_start(self.browser, expand=True)

        self.toolbar.connect_weak('browser-back', self._on_browser_back)
        self.toolbar.connect_weak('browser-forward', self._on_browser_forward)
        self.toolbar.connect_weak('browser-reload', self._on_browser_reload)
        self.toolbar.connect_weak('browser-stop', self._on_browser_stop)
        self.toolbar.connect_weak('browser-home', self._on_browser_home)
        self.toolbar.connect_weak('browser-download',
                                  self._on_browser_download)
        self.toolbar.connect_weak('browser-open', self._on_browser_open)

        self.browser.connect_weak('net-start', self._on_net_start)
        self.browser.connect_weak('net-stop', self._on_net_stop)
        self.browser.connect_weak('download-started',
                                  self._on_download_started)

        self.browser.navigate(self.guide_info.url)
コード例 #5
0
ファイル: tabcontroller.py プロジェクト: kmshi/miro
 def draw(self, context, layout):
     gradient = widgetset.Gradient(0, 0, 0, context.height - 1)
     gradient.set_start_color(widgetutil.css_to_color('#a92928'))
     gradient.set_end_color(widgetutil.css_to_color('#7e1c1b'))
     context.rectangle(0, 0, context.width, context.height - 1)
     context.gradient_fill(gradient)
     context.rectangle(0, context.height - 1, context.width, context.height)
     context.set_color((0, 0, 0))
     context.fill()
コード例 #6
0
 def draw(self, context, layout):
     gradient = widgetset.Gradient(0, 0, 0, context.height - 1)
     gradient.set_start_color(widgetutil.css_to_color('#a92928'))
     gradient.set_end_color(widgetutil.css_to_color('#7e1c1b'))
     context.rectangle(0, 0, context.width, context.height - 1)
     context.gradient_fill(gradient)
     context.rectangle(0, context.height -1, context.width, context.height)
     context.set_color((0, 0, 0))
     context.fill()
コード例 #7
0
 def draw(self, context, layout):
     context.set_line_width(1)
     context.set_color(widgetutil.css_to_color('#d8d8d8'))
     context.move_to(0, 0.5)
     context.line_to(context.width, 0.5)
     context.stroke()
     gradient = widgetset.Gradient(0, 1, 0, context.height)
     gradient.set_start_color(widgetutil.css_to_color('#f7f7f7'))
     gradient.set_end_color(widgetutil.css_to_color('#cacaca'))
     context.rectangle(0, 1, context.width, context.height)
     context.gradient_fill(gradient)
コード例 #8
0
 def draw(self, context, layout):
     context.set_line_width(1)
     context.set_color(widgetutil.css_to_color('#d8d8d8'))
     context.move_to(0, 0.5)
     context.line_to(context.width, 0.5)
     context.stroke()
     gradient = widgetset.Gradient(0, 1, 0, context.height)
     gradient.set_start_color(widgetutil.css_to_color('#f7f7f7'))
     gradient.set_end_color(widgetutil.css_to_color('#cacaca'))
     context.rectangle(0, 1, context.width, context.height)
     context.gradient_fill(gradient)
コード例 #9
0
ファイル: devicecontroller.py プロジェクト: kmshi/miro
    def draw(self, context, layout):
        # we draw the rectangle off the bottom so that it's flat
        widgetutil.round_rect(context, 0, 0, context.width,
                              context.height + 10, 10)

        context.set_color(widgetutil.css_to_color('#9199bd'))
        context.fill()
        widgetutil.round_rect_reverse(context, 1, 1, context.width - 2,
                                      context.height + 10, 10)
        context.set_color(widgetutil.css_to_color('#bec1d0'))
        context.fill()
コード例 #10
0
    def draw(self, context, layout):
        # we draw the rectangle off the bottom so that it's flat
        widgetutil.round_rect(context, 0, 0, context.width,
                              context.height + 10, 10)

        context.set_color(widgetutil.css_to_color('#9199bd'))
        context.fill()
        widgetutil.round_rect_reverse(context, 1, 1, context.width - 2,
                                      context.height + 10, 10)
        context.set_color(widgetutil.css_to_color('#bec1d0'))
        context.fill()
コード例 #11
0
    def draw(self, context, layout_manager):
        gradient = widgetset.Gradient(0, 2, 0, context.height)
        gradient.set_start_color(widgetutil.css_to_color('#d4d4d4'))
        gradient.set_end_color(widgetutil.css_to_color('#a8a8a8'))
        context.rectangle(0, 2, context.width, context.height)
        context.gradient_fill(gradient)

        context.set_line_width(1)
        context.move_to(0, 0.5)
        context.line_to(context.width, 0.5)
        context.set_color(widgetutil.css_to_color('#585858'))
        context.stroke()
        context.move_to(0, 1.5)
        context.line_to(context.width, 1.5)
        context.set_color(widgetutil.css_to_color('#e6e6e6'))
        context.stroke()
コード例 #12
0
ファイル: style.py プロジェクト: codito/miro
    def draw(self, context, layout_manager):  
        gradient = widgetset.Gradient(0, 2, 0, context.height)
        gradient.set_start_color(widgetutil.css_to_color('#d4d4d4'))
        gradient.set_end_color(widgetutil.css_to_color('#a8a8a8'))
        context.rectangle(0, 2, context.width, context.height)
        context.gradient_fill(gradient)

        context.set_line_width(1)
        context.move_to(0, 0.5)
        context.line_to(context.width, 0.5)
        context.set_color(widgetutil.css_to_color('#585858'))
        context.stroke()
        context.move_to(0, 1.5)
        context.line_to(context.width, 1.5)
        context.set_color(widgetutil.css_to_color('#e6e6e6'))
        context.stroke()
コード例 #13
0
ファイル: searchcontroller.py プロジェクト: zjmmjzzjm/miro
class SearchEngineDisplay(widgetset.Background):

    BORDER_COLOR = widgetutil.css_to_color('#d9d9d9')

    def __init__(self, engine):
        widgetset.Background.__init__(self)
        hbox = widgetset.HBox(spacing=15)
        self.pack(
            hbox,
            imagepool.get_image_display(
                searchengines.icon_path_for_engine(engine)))
        label = widgetset.Label(engine.title)
        label.set_size(widgetutil.font_scale_from_osx_points(14))
        label.set_bold(True)
        self.pack(hbox, widgetutil.align_left(label), expand=True)
        self.add(hbox)
        self.has_border = True

    def set_has_border(self, has_border):
        self.has_border = has_border

    def pack(self, hbox, widget, expand=False):
        hbox.pack_start(widgetutil.align_middle(widget), expand=expand)

    def draw(self, context, layout):
        if self.has_border:
            context.set_line_width(1)
            context.set_color(self.BORDER_COLOR)
            context.move_to(0, context.height)
            context.line_to(context.width, context.height)
            context.stroke()
コード例 #14
0
ファイル: tabcontroller.py プロジェクト: kmshi/miro
    def _build_sync_section(self, bottom):
        hbox = widgetset.HBox()
        vbox = widgetset.VBox()
        label_line = widgetset.HBox()
        label = self.build_header(_("Sync a Phone, Tablet, or Digital Camera"))
        label_line.pack_start(
            widgetutil.align_left(label, left_pad=20, bottom_pad=10))
        help_button = HelpButton()
        help_button.connect('clicked', self.help_button_clicked)
        label_line.pack_start(widgetutil.align_top(help_button))
        bottom.pack_start(label_line)

        label = widgetset.Label(
            _(
                "Connect the USB cable to sync your Android device with "
                "%(shortappname)s.  Be sure to set your device to 'USB Mass "
                "Storage' mode in your device settings.  Attach your digital "
                "camera, and convert your video files to be instantly "
                "web-ready.", self.trans_data))
        label.set_size(self.TEXT_SIZE)
        label.set_color(self.TEXT_COLOR)
        label.set_size_request(400, -1)
        label.set_wrap(True)
        vbox.pack_start(
            widgetutil.align_left(label, left_pad=20, bottom_pad=20))

        show_all_vbox = widgetset.VBox()
        self.show_unknown = widgetset.Checkbox(
            _("Show all attached devices and drives"))
        self.show_unknown.set_checked(
            app.config.get(prefs.SHOW_UNKNOWN_DEVICES))
        self.show_unknown.connect('toggled', self.show_all_devices_toggled)
        show_all_vbox.pack_start(self.show_unknown)
        padding = self.show_unknown.get_text_padding()
        label = widgetset.Label(
            _(
                "Use this if your phone doesn't appear in %(shortappname)s when "
                "you connect it to the computer, or if you want to sync with an "
                "external drive.", self.trans_data))
        label.set_size(self.TEXT_SIZE)
        label.set_color(self.TEXT_COLOR)
        label.set_size_request(370 - padding, -1)
        label.set_wrap(True)
        show_all_vbox.pack_start(widgetutil.pad(label, top=10, left=padding))
        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.set_size_request(400, -1)
        bg.add(widgetutil.pad(show_all_vbox, 20, 20, 20, 20))
        vbox.pack_start(widgetutil.pad(bg, left=20, right=10, bottom=50))
        hbox.pack_start(vbox)
        hbox.pack_start(
            widgetutil.align_top(
                widgetset.ImageDisplay(
                    imagepool.get(
                        resources.path('images/connect-android.png')))))
        bottom.pack_start(hbox)
コード例 #15
0
class SizeProgressBar(widgetset.Background):
    GRADIENT_COLOR_TOP = widgetutil.css_to_color('#080808')
    GRADIENT_COLOR_BOTTOM = widgetutil.css_to_color('#515151')
    SIZE_COLOR_TOP = widgetutil.css_to_color('#829ac8')
    SIZE_COLOR_BOTTOM = widgetutil.css_to_color('#697fb0')
    SIZE_BORDER = widgetutil.css_to_color('#060606')

    def __init__(self):
        widgetset.Background.__init__(self)
        self.size_ratio = 0.0
        self.bg_surface = widgetutil.ThreeImageSurface('device-size-bg')
        self.fg_surface = widgetutil.ThreeImageSurface('device-size-fg')

    def set_progress(self, progress):
        self.size_ratio = progress
        self.queue_redraw()

    def draw(self, context, layout):
        self.bg_surface.draw(context, 0, 0, context.width)
        if self.size_ratio:
            self.fg_surface.draw(context, 0, 0,
                                 int(context.width * self.size_ratio))
コード例 #16
0
ファイル: tabcontroller.py プロジェクト: kmshi/miro
    def _build_sync_section(self, bottom):
        hbox = widgetset.HBox()
        vbox = widgetset.VBox()
        label_line = widgetset.HBox()
        label = self.build_header(_("Sync a Phone, Tablet, or Digital Camera"))
        label_line.pack_start(widgetutil.align_left(label, left_pad=20,
                                              bottom_pad=10))
        help_button = HelpButton()
        help_button.connect('clicked', self.help_button_clicked)
        label_line.pack_start(widgetutil.align_top(help_button))
        bottom.pack_start(label_line)

        label = widgetset.Label(
            _("Connect the USB cable to sync your Android device with "
              "%(shortappname)s.  Be sure to set your device to 'USB Mass "
              "Storage' mode in your device settings.  Attach your digital "
              "camera, and convert your video files to be instantly "
              "web-ready.", self.trans_data))
        label.set_size(self.TEXT_SIZE)
        label.set_color(self.TEXT_COLOR)
        label.set_size_request(400, -1)
        label.set_wrap(True)
        vbox.pack_start(widgetutil.align_left(label, left_pad=20,
                                              bottom_pad=20))

        show_all_vbox = widgetset.VBox()
        self.show_unknown = widgetset.Checkbox(
            _("Show all attached devices and drives"))
        self.show_unknown.set_checked(
            app.config.get(prefs.SHOW_UNKNOWN_DEVICES))
        self.show_unknown.connect('toggled', self.show_all_devices_toggled)
        show_all_vbox.pack_start(self.show_unknown)
        padding = self.show_unknown.get_text_padding()
        label = widgetset.Label(
            _("Use this if your phone doesn't appear in %(shortappname)s when "
              "you connect it to the computer, or if you want to sync with an "
              "external drive.", self.trans_data))
        label.set_size(self.TEXT_SIZE)
        label.set_color(self.TEXT_COLOR)
        label.set_size_request(370 - padding, -1)
        label.set_wrap(True)
        show_all_vbox.pack_start(widgetutil.pad(label, top=10, left=padding))
        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.set_size_request(400, -1)
        bg.add(widgetutil.pad(show_all_vbox, 20, 20, 20, 20))
        vbox.pack_start(widgetutil.pad(bg, left=20, right=10, bottom=50))
        hbox.pack_start(vbox)
        hbox.pack_start(widgetutil.align_top(widgetset.ImageDisplay(
            imagepool.get(resources.path('images/connect-android.png')))))
        bottom.pack_start(hbox)
コード例 #17
0
class RoundedVBox(widgetset.Background):
    BORDER_COLOR = widgetutil.css_to_color('#c8c8c8')
    BG_COLOR = widgetutil.css_to_color('#e4e4e4')

    def __init__(self):
        widgetset.Background.__init__(self)
        self._vbox = widgetset.VBox()
        self.add(self._vbox)
        self.children_start = []

    def pack_start(self, widget, **kwargs):
        self._vbox.pack_start(widget, **kwargs)
        self.children_start.append(widget)

    def set_size_request(self, width, height):
        self._vbox.set_size_request(width, height)

    def size_request(self, layout):
        return self._vbox.get_size_request()

    def draw(self, context, layout):
        width, height = self.get_width(), self.get_height()
        x, y = (context.width - width) / 2, (context.height - height) / 2
        widgetutil.round_rect(context, x, y, width, height, 20)
        context.set_color(self.BG_COLOR)
        context.fill()
        widgetutil.round_rect(context, x, y, width, height, 20)
        widgetutil.round_rect_reverse(context, x + 1, y + 1, width - 2,
                                      height - 2, 20)
        context.set_color(self.BORDER_COLOR)
        context.fill()
        total = y
        for child in self.children_start[:-1]:
            total += child.get_height()
            context.rectangle(x, total, width, 1)
            context.fill()

        widgetset.Background.draw(self, context, layout)
コード例 #18
0
    def _build_stores_section(self, bottom):
        vbox = widgetset.VBox()
        from miro.frontends.widgets import prefpanel
        self.store_helper = prefpanel.StoreHelper(height=200)
        self.store_helper.store_list.set_size_request(550, -1)
        vbox.pack_start(widgetutil.align_middle(
                self.store_helper.store_list, top_pad=20, bottom_pad=15,
                left_pad=15, right_pad=15))

        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.add(widgetutil.pad(vbox, 00, 10, 10, 10))

        bottom.pack_start(bg)
コード例 #19
0
ファイル: tabcontroller.py プロジェクト: kmshi/miro
    def _build_stores_section(self, bottom):
        vbox = widgetset.VBox()
        from miro.frontends.widgets import prefpanel
        self.store_helper = prefpanel.StoreHelper(height=200)
        self.store_helper.store_list.set_size_request(550, -1)
        vbox.pack_start(
            widgetutil.align_middle(self.store_helper.store_list,
                                    top_pad=20,
                                    bottom_pad=15,
                                    left_pad=15,
                                    right_pad=15))

        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.add(widgetutil.pad(vbox, 00, 10, 10, 10))

        bottom.pack_start(bg)
コード例 #20
0
ファイル: guidecontroller.py プロジェクト: zjmmjzzjm/miro
    def __init__(self):
        widgetset.SolidBackground.__init__(self)
        self.set_background_color(widgetutil.css_to_color('#e7e7e7'))
        self.video = GuideSidebarCollection(_("Recently Watched"))
        self.audio = GuideSidebarCollection(_("Recently Listened To"))
        self.download = GuideSidebarCollection(_("Recent Downloads"))
        self.vbox = widgetset.VBox()
        self.vbox.pack_start(self.video)
        self.vbox.pack_start(self.audio)
        self.vbox.pack_start(self.download)
        self.add(widgetutil.pad(self.vbox, left=17, right=17))

        self.id_to_collection = {}

        self.changing_size = False
        self.current_height = None
        self.connect('size-allocated', self.on_size_allocated)

        self.set_size_request(172, 220)
コード例 #21
0
ファイル: guidecontroller.py プロジェクト: dankamongmen/miro
    def __init__(self):
        widgetset.SolidBackground.__init__(self)
        self.set_background_color(widgetutil.css_to_color('#e7e7e7'))
        self.video = GuideSidebarCollection(_("Recently Watched"))
        self.audio = GuideSidebarCollection(_("Recently Listened To"))
        self.download = GuideSidebarCollection(_("Recent Downloads"))
        self.vbox = widgetset.VBox()
        self.vbox.pack_start(self.video)
        self.vbox.pack_start(self.audio)
        self.vbox.pack_start(self.download)
        self.add(widgetutil.pad(self.vbox, left=17, right=17))

        self.id_to_collection = {}

        self.changing_size = False
        self.current_height = None
        self.connect('size-allocated', self.on_size_allocated)

        self.set_size_request(172, 220)
コード例 #22
0
class DeviceTabButtonSegment(segmented.TextButtonSegment):
    PARTS = {
        'off-far-left': segmented._get_image('device-off-far-left'),
        'off-middle-left': segmented._get_image('device-off-middle-left'),
        'off-center': segmented._get_image('device-off-center'),
        'off-middle-right': segmented._get_image('device-off-middle-right'),
        'off-far-right': segmented._get_image('device-off-far-right'),
        'on-far-left': segmented._get_image('device-on-far-left'),
        'on-middle-left': segmented._get_image('device-on-middle-left'),
        'on-center': segmented._get_image('device-on-center'),
        'on-middle-right': segmented._get_image('device-on-middle-right'),
        'on-far-right': segmented._get_image('device-on-far-right')
    }

    MARGIN = 20
    TEXT_COLOR = {True: (1, 1, 1), False: widgetutil.css_to_color('#424242')}

    def size_request(self, layout):
        width, _ = segmented.TextButtonSegment.size_request(self, layout)
        return width, 23
コード例 #23
0
ファイル: tabcontroller.py プロジェクト: kmshi/miro
    def _build_add_playlist_section(self, bottom):
        hbox = widgetset.HBox()
        label = widgetset.Label(_("Name"))
        hbox.pack_start(widgetutil.align_middle(label))

        self.name_entry = widgetset.TextEntry()
        self.name_entry.set_size_request(400, -1)
        self.name_entry.connect('activate', self._on_add_playlist)
        hbox.pack_start(widgetutil.align_middle(self.name_entry, left_pad=15))

        self.add_playlist_button = widgetutil.TitlebarButton(_("Add Playlist"))
        self.add_playlist_button.connect('clicked', self._on_add_playlist)
        hbox.pack_start(
            widgetutil.align_middle(self.add_playlist_button, left_pad=15))

        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.add(widgetutil.pad(hbox, 10, 10, 10, 10))

        bottom.pack_start(bg)
コード例 #24
0
class DeviceTabButtonSegment(segmented.TextButtonSegment):
    PARTS = {
        'off-far-left': segmented._get_image('toggle-button-inactive_left'),
        'off-middle-left':
        segmented._get_image('toggle-button-inactive_center'),
        'off-center': segmented._get_image('toggle-button-inactive_center'),
        'off-middle-right': segmented._get_image('toggle-button-separator'),
        'off-far-right': segmented._get_image('toggle-button-inactive_right'),
        'on-far-left': segmented._get_image('toggle-button-active_left'),
        'on-middle-left': segmented._get_image('toggle-button-active_center'),
        'on-center': segmented._get_image('toggle-button-active_center'),
        'on-middle-right': segmented._get_image('toggle-button-active_center'),
        'on-far-right': segmented._get_image('toggle-button-active_right')
    }

    MARGIN = 20
    TEXT_COLOR = {True: (1, 1, 1), False: widgetutil.css_to_color('#0e0e0e')}

    def size_request(self, layout):
        width, _ = segmented.TextButtonSegment.size_request(self, layout)
        return width, 24
コード例 #25
0
    def _build_add_playlist_section(self, bottom):
        hbox = widgetset.HBox()
        label = widgetset.Label(_("Name"))
        hbox.pack_start(widgetutil.align_middle(label))

        self.name_entry = widgetset.TextEntry()
        self.name_entry.set_size_request(400, -1)
        self.name_entry.connect('activate', self._on_add_playlist)
        hbox.pack_start(widgetutil.align_middle(
                self.name_entry, left_pad=15))

        self.add_playlist_button = widgetutil.TitlebarButton(_("Add Playlist"))
        self.add_playlist_button.connect('clicked', self._on_add_playlist)
        hbox.pack_start(widgetutil.align_middle(
                self.add_playlist_button, left_pad=15))

        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.add(widgetutil.pad(hbox, 10, 10, 10, 10))

        bottom.pack_start(bg)
コード例 #26
0
ファイル: devicecontroller.py プロジェクト: kmshi/miro
    def __init__(self):
        self.device = None
        self.bulk_change = False
        widgetset.VBox.__init__(self)
        self.create_signal('changed')
        self.sync_library = widgetset.Checkbox(self.title)
        self.sync_library.connect('toggled', self.sync_library_toggled)
        self.pack_start(widgetutil.pad(self.sync_library, top=50))
        self._pack_extra_buttons()

        self.feed_list = widgetset.VBox()
        self.feed_list.set_size_request(450, -1)
        self.info_map = {}
        feeds = self.get_feeds()
        if feeds:
            for info in feeds:
                checkbox = widgetset.Checkbox(info.name)
                checkbox.connect('toggled', self.feed_toggled, info)
                self.feed_list.pack_start(checkbox)
                self.info_map[self.info_key(info)] = checkbox
        else:
            self.sync_library.disable()
        background = widgetset.SolidBackground(
                widgetutil.css_to_color('#dddddd'))
        background.add(self.feed_list)
        scroller = widgetset.Scroller(False, True)
        scroller.set_child(background)
        self.feed_list.disable()
        self.pack_start(widgetutil.pad(scroller, top=20, bottom=5),
                        expand=True)

        line = widgetset.HBox(spacing=5)
        button = widgetutil.TitlebarButton(_("Select none"))
        button.connect('clicked', self.select_clicked, False)
        line.pack_end(button)
        button = widgetutil.TitlebarButton(_("Select all"))
        button.connect('clicked', self.select_clicked, True)
        line.pack_end(button)
        self.pack_start(widgetutil.pad(line, bottom=20))
コード例 #27
0
    def __init__(self):
        self.device = None
        self.bulk_change = False
        widgetset.VBox.__init__(self)
        self.create_signal('changed')
        self.sync_library = widgetset.Checkbox(self.title)
        self.sync_library.connect('toggled', self.sync_library_toggled)
        self.pack_start(widgetutil.pad(self.sync_library, top=50))
        self._pack_extra_buttons()

        self.feed_list = widgetset.VBox()
        self.feed_list.set_size_request(450, -1)
        self.info_map = {}
        feeds = self.get_feeds()
        if feeds:
            for info in feeds:
                checkbox = widgetset.Checkbox(info.name)
                checkbox.connect('toggled', self.feed_toggled, info)
                self.feed_list.pack_start(checkbox)
                self.info_map[self.info_key(info)] = checkbox
        else:
            self.sync_library.disable()
        background = widgetset.SolidBackground(
            widgetutil.css_to_color('#dddddd'))
        background.add(self.feed_list)
        scroller = widgetset.Scroller(False, True)
        scroller.set_child(background)
        self.feed_list.disable()
        self.pack_start(widgetutil.pad(scroller, top=20, bottom=5),
                        expand=True)

        line = widgetset.HBox(spacing=5)
        button = widgetutil.TitlebarButton(_("Select none"))
        button.connect('clicked', self.select_clicked, False)
        line.pack_end(button)
        button = widgetutil.TitlebarButton(_("Select all"))
        button.connect('clicked', self.select_clicked, True)
        line.pack_end(button)
        self.pack_start(widgetutil.pad(line, bottom=20))
コード例 #28
0
ファイル: itemedit.py プロジェクト: bluezone/miro
    def __init__(self, items, label):
        Field.__init__(self, 'cover_art', items, label)
        DialogOwnerMixin.__init__(self, self.DIALOG, self.TITLE)
        path = self.common_value

        vbox = widgetset.VBox(spacing=5)
        label = widgetset.Label()
        label.set_text(_('Click to choose image.'))
        label.set_color(widgetutil.css_to_color('#a9a9a9'))
        try:
            widget = widgetset.ClickableImageButton(path, 134, 134)
        except ValueError:
            # ValueError can happen if the image isn't valid and can't
            # be loaded
            path = resources.path('images/broken-image.gif')
            widget = widgetset.ClickableImageButton(path, 134, 134)

        widget.connect('clicked', self.show_dialog)

        vbox.pack_start(widget)
        vbox.pack_start(label)

        self.thumb_widget = widget
        self.widget = vbox
コード例 #29
0
    def __init__(self, items, label):
        Field.__init__(self, 'cover_art', items, label)
        DialogOwnerMixin.__init__(self, self.DIALOG, self.TITLE)
        path = self.common_value

        vbox = widgetset.VBox(spacing=5)
        label = widgetset.Label()
        label.set_text(_('Click to choose image.'))
        label.set_color(widgetutil.css_to_color('#a9a9a9'))
        try:
            widget = widgetset.ClickableImageButton(path, 134, 134)
        except ValueError:
            # ValueError can happen if the image isn't valid and can't
            # be loaded
            path = resources.path('images/broken-image.gif')
            widget = widgetset.ClickableImageButton(path, 134, 134)

        widget.connect('clicked', self.show_dialog)

        vbox.pack_start(widget)
        vbox.pack_start(label)

        self.thumb_widget = widget
        self.widget = vbox
コード例 #30
0
ファイル: devicecontroller.py プロジェクト: kmshi/miro
 def draw(self, context, layout):
     gradient = widgetset.Gradient(0, 0, 0, context.height)
     gradient.set_start_color(widgetutil.css_to_color('#c2c2c2'))
     gradient.set_end_color(widgetutil.css_to_color('#a3a3a3'))
     context.rectangle(0, 0, context.width, context.height)
     context.gradient_fill(gradient)
コード例 #31
0
ファイル: style.py プロジェクト: codito/miro
from miro.frontends.widgets import widgetutil
from miro.frontends.widgets.itemrenderer import (DOWNLOAD_TEXT,
                                                 DOWNLOAD_TO_MY_MIRO_TEXT)
from miro.plat import PLATFORMNAME
from miro.plat import resources
from miro.plat.frontends.widgets import use_custom_tablist_font
from miro.plat.frontends.widgets import widgetset

PI = math.pi

AVAILABLE_COLOR = (38/255.0, 140/255.0, 250/255.0) # blue
UNPLAYED_COLOR = (0.31, 0.75, 0.12) # green
DOWNLOADING_COLOR = (0.90, 0.45, 0.08) # orange
WATCHED_COLOR = (0.33, 0.33, 0.33) # dark grey
EXPIRING_COLOR = (0.95, 0.82, 0.11) # yellow-ish
EXPIRING_TEXT_COLOR = widgetutil.css_to_color('#7b949d')

TAB_LIST_BACKGROUND_COLOR = widgetutil.css_to_color('#e1edf7')

ERROR_COLOR = (0.90, 0.0, 0.0)
BLINK_COLOR = widgetutil.css_to_color('#fffb83')

class LowerBox(widgetset.Background):
    def size_request(self, layout_manager):
        return (0, 63)

    def draw(self, context, layout_manager):  
        gradient = widgetset.Gradient(0, 2, 0, context.height)
        gradient.set_start_color(widgetutil.css_to_color('#d4d4d4'))
        gradient.set_end_color(widgetutil.css_to_color('#a8a8a8'))
        context.rectangle(0, 2, context.width, context.height)
コード例 #32
0
ファイル: tabcontroller.py プロジェクト: kmshi/miro
    def _build_daap_section(self, bottom):
        label = self.build_header(
            _("%(shortappname)s Sharing", self.trans_data))
        bottom.pack_start(
            widgetutil.align_left(label, left_pad=20, bottom_pad=10))
        # Note: "Miro iPad app" is the name of a piece of software--
        # don't substitute Miro for %(appname)s here.
        label = widgetset.Label(
            _(
                "%(shortappname)s can stream and download files to and from "
                "other %(shortappname)ss on your local network and to the "
                "Miro iPad app.  It's awesome!", self.trans_data))
        label.set_size(self.TEXT_SIZE)
        label.set_color(self.TEXT_COLOR)
        label.set_wrap(True)
        label.set_size_request(550, -1)
        bottom.pack_start(
            widgetutil.align_left(label, left_pad=20, bottom_pad=20))

        if not app.sharing_manager.mdns_present:
            label = widgetset.Label(_("Disabled: Needs Bonjour"))
            label.set_bold(True)
            bottom.pack_start(
                widgetutil.align_left(label,
                                      left_pad=20,
                                      bottom_pad=20,
                                      top_pad=10))
            return

        container = widgetset.HBox()
        self.share_button = PrettyToggleButton()
        self.share_button.connect('clicked', self.daap_changed)
        self.share_button.connect('dragged-left', self.daap_changed)
        self.share_button.connect('dragged-right', self.daap_changed)
        self.share_button.set_value(app.config.get(prefs.SHARE_MEDIA))
        container.pack_start(widgetutil.pad(self.share_button, right=20))

        vbox = widgetset.VBox()
        hbox = widgetset.HBox(spacing=30)
        self.share_audio_cbx = widgetset.Checkbox(_("Share Music"), bold=True)
        self.share_video_cbx = widgetset.Checkbox(_("Share Videos"), bold=True)
        self.share_warnonquit_cbx = widgetset.Checkbox(
            _('Warn on quit when others are connected to my media library.'))
        hbox.pack_start(widgetutil.align_top(self.share_video_cbx))
        hbox.pack_start(widgetutil.align_top(self.share_audio_cbx))
        prefpanel.attach_boolean(self.share_audio_cbx, prefs.SHARE_AUDIO)
        prefpanel.attach_boolean(self.share_video_cbx, prefs.SHARE_VIDEO)
        vbox.pack_start(hbox)

        label = widgetset.Label(
            _("My %(shortappname)s Share Name", self.trans_data))
        label.set_bold(True)
        vbox.pack_start(widgetutil.align_left(label, top_pad=15, bottom_pad=5))

        hbox = widgetset.HBox()
        self.share_entry = widgetset.TextEntry()
        self.share_entry.set_size_request(230, -1)
        share_error = prefpanel.build_error_image()
        prefpanel.attach_text(self.share_entry,
                              prefs.SHARE_NAME,
                              share_error,
                              check_function=prefpanel.text_is_not_blank)

        if not self.share_button.get_value():
            self.share_entry.disable()
            self.share_video_cbx.disable()
            self.share_audio_cbx.disable()
            self.share_warnonquit_cbx.disable()

        hbox.pack_start(self.share_entry)
        hbox.pack_start(share_error)
        vbox.pack_start(hbox)
        vbox.pack_start(widgetutil.pad(self.share_warnonquit_cbx, top=15))

        container.pack_start(vbox)

        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.add(widgetutil.pad(container, 20, 20, 20, 20))
        bottom.pack_start(widgetutil.align_left(bg, left_pad=20,
                                                bottom_pad=50))
コード例 #33
0
from miro.frontends.widgets import widgetutil
from miro.frontends.widgets.itemrenderer import (DOWNLOAD_TEXT,
                                                 DOWNLOAD_TO_MY_MIRO_TEXT)
from miro.plat import PLATFORMNAME
from miro.plat import resources
from miro.plat.frontends.widgets import use_custom_tablist_font
from miro.plat.frontends.widgets import widgetset

PI = math.pi

AVAILABLE_COLOR = (38 / 255.0, 140 / 255.0, 250 / 255.0)  # blue
UNPLAYED_COLOR = (0.31, 0.75, 0.12)  # green
DOWNLOADING_COLOR = (0.90, 0.45, 0.08)  # orange
WATCHED_COLOR = (0.33, 0.33, 0.33)  # dark grey
EXPIRING_COLOR = (0.95, 0.82, 0.11)  # yellow-ish
EXPIRING_TEXT_COLOR = widgetutil.css_to_color('#7b949d')

TAB_LIST_BACKGROUND_COLOR = widgetutil.css_to_color('#e1edf7')

ERROR_COLOR = (0.90, 0.0, 0.0)
BLINK_COLOR = widgetutil.css_to_color('#fffb83')


class LowerBox(widgetset.Background):
    def size_request(self, layout_manager):
        return (0, 63)

    def draw(self, context, layout_manager):
        gradient = widgetset.Gradient(0, 2, 0, context.height)
        gradient.set_start_color(widgetutil.css_to_color('#d4d4d4'))
        gradient.set_end_color(widgetutil.css_to_color('#a8a8a8'))
コード例 #34
0
    def _build_daap_section(self, bottom):
        label = self.build_header(_("%(shortappname)s Sharing",
                                    self.trans_data))
        bottom.pack_start(widgetutil.align_left(label, left_pad=20,
                                              bottom_pad=10))
        # Note: "Miro iPad app" is the name of a piece of software--
        # don't substitute Miro for %(appname)s here.
        label = self.build_text(
            _("%(shortappname)s can stream and download files to and from "
              "other %(shortappname)ss on your local network and to the "
              "Miro iPad app.  It's awesome!", self.trans_data))
        label.set_wrap(True)
        label.set_size_request(550, -1)
        bottom.pack_start(widgetutil.align_left(label, left_pad=20,
                                              bottom_pad=20))

        if not app.sharing_manager.mdns_present:
            label = widgetset.Label(_("Disabled: Needs Bonjour"))
            label.set_bold(True)
            bottom.pack_start(widgetutil.align_left(
                    label, left_pad=20, bottom_pad=20, top_pad=10))
            return

        container = widgetset.HBox()
        self.share_button = PrettyToggleButton()
        self.share_button.connect('clicked', self.daap_changed)
        self.share_button.connect('dragged-left', self.daap_changed)
        self.share_button.connect('dragged-right', self.daap_changed)
        self.share_button.set_value(app.config.get(prefs.SHARE_MEDIA))
        container.pack_start(widgetutil.pad(self.share_button, right=20))

        vbox = widgetset.VBox()
        hbox = widgetset.HBox(spacing=30)
        self.share_audio_cbx = widgetset.Checkbox(_("Share Music"), bold=True)
        self.share_video_cbx = widgetset.Checkbox(_("Share Videos"), bold=True)
        self.share_feed_cbx = widgetset.Checkbox(_("Share Podcasts"), bold=True)
        self.share_warnonquit_cbx = widgetset.Checkbox(
            _('Warn on quit when others are connected to my media library.'))
        hbox.pack_start(widgetutil.align_top(self.share_video_cbx))
        hbox.pack_start(widgetutil.align_top(self.share_audio_cbx))
        hbox.pack_start(widgetutil.align_top(self.share_feed_cbx))
        prefpanel.attach_boolean(self.share_audio_cbx, prefs.SHARE_AUDIO)
        prefpanel.attach_boolean(self.share_video_cbx, prefs.SHARE_VIDEO)
        prefpanel.attach_boolean(self.share_feed_cbx, prefs.SHARE_FEED)
        prefpanel.attach_boolean(self.share_warnonquit_cbx,
                                 prefs.SHARE_WARN_ON_QUIT)
        vbox.pack_start(hbox)

        label = widgetset.Label(
                    _("My %(shortappname)s Share Name", self.trans_data))
        label.set_bold(True)
        vbox.pack_start(widgetutil.align_left(label,
                                              top_pad=15, bottom_pad=5))

        hbox = widgetset.HBox()
        self.share_entry = widgetset.TextEntry()
        self.share_entry.set_size_request(230, -1)
        share_error = prefpanel.build_error_image()
        prefpanel.attach_text(self.share_entry,
                              prefs.SHARE_NAME,
                              share_error,
                              check_function=prefpanel.text_is_not_blank)

        if not self.share_button.get_value():
            self.share_entry.disable()
            self.share_feed_cbx.disable()
            self.share_video_cbx.disable()
            self.share_audio_cbx.disable()
            self.share_warnonquit_cbx.disable()

        hbox.pack_start(self.share_entry)
        hbox.pack_start(share_error)
        vbox.pack_start(hbox)
        vbox.pack_start(widgetutil.pad(self.share_warnonquit_cbx, top=15))

        container.pack_start(vbox)

        bg = widgetutil.RoundedSolidBackground(
            widgetutil.css_to_color('#e4e4e4'))
        bg.add(widgetutil.pad(container, 20, 20, 20, 20))
        bottom.pack_start(widgetutil.align_left(bg, left_pad=20,
                                                bottom_pad=50))

        widgets = [self.share_button, self.share_entry, self.share_audio_cbx,
                   self.share_video_cbx, self.share_feed_cbx,
                   self.share_warnonquit_cbx]
        callbacks = (self.sharing_start_volatile, self.sharing_end_volatile)
        app.sharing_manager.register_interest(self, callbacks, widgets)
コード例 #35
0
class MultiRowAlbumRenderer(widgetset.ItemListRenderer):
    """Renderer for album view."""

    IGNORE_PADDING = True
    DRAW_BACKGROUND = False

    IMAGE_MARGIN_TOP = 4
    IMAGE_MARGIN_BOTTOM = 3
    IMAGE_MARGIN_LEFT = 7
    IMAGE_MARGIN_RIGHT = 6

    MIN_TEXT_WIDTH = 78
    TEXT_PADDING_RIGHT = 6
    TRACK_NUMBER_MARGIN_RIGHT = 13

    BACKGROUND_COLOR = widgetutil.WHITE
    TEXT_COLOR = widgetutil.BLACK
    TRACK_TEXT_COLOR = widgetutil.css_to_color('#969696')
    BOTTOM_LINE_COLOR = widgetutil.css_to_color('#dddddd')
    FONT_SIZE = widgetutil.font_scale_from_osx_points(11)

    min_width = 260

    def __init__(self):
        widgetset.ItemListRenderer.__init__(self)
        self._render_strategy = _StandardRenderStrategy()
        self._setup_default_image_map()

    def _setup_default_image_map(self):
        """Setup the _default_image_map attribute.

        _default_image_map maps the default images for things to a default
        image that looks better in album view.
        """
        # check if we're using one of the default image files and switch to an
        # album-view-specific default file in that case
        mappings = [
            ('thumb-default-audio.png', 'album-view-default-audio.png'),
            ('thumb-default-video.png', 'album-view-default-video.png'),
            ('icon-podcast-small.png', 'album-view-default-podcast.png'),
            ('icon-watched-folder.png', 'album-view-watched-folder.png'),
        ]
        self._default_image_map = {}
        for src, dest in mappings:
            src_path = resources.path('images/%s' % src)
            dest_path = resources.path('images/%s' % dest)
            self._default_image_map[src_path] = dest_path

    def get_image_path(self):
        image_path = self._render_strategy.get_image_path(
            self.info, self.get_first_info())
        if image_path in self._default_image_map:
            return self._default_image_map[image_path]
        else:
            return image_path

    def get_album(self):
        return self._render_strategy.get_album(self.info,
                                               self.get_first_info())

    def get_artist(self):
        return self._render_strategy.get_artist(self.info,
                                                self.get_first_info())

    def get_track_number(self):
        return self._render_strategy.get_track_number(self.info,
                                                      self.get_first_info())

    def get_current_row(self):
        return self.group_info[0]

    def get_total_rows(self):
        return self.group_info[1]

    def get_first_info(self):
        return self.group_info[2]

    def switch_mode(self, new_mode):
        """Switch which mode we use to render the album art.

        Currently there are 3 modes:

        - 'standard' -- standard view of the data
        - 'feed' -- use feed info instead of album info
        - 'video' -- mode for the all videos tab
        """
        if new_mode == 'standard':
            self._render_strategy = _StandardRenderStrategy()
        elif new_mode == 'feed':
            self._render_strategy = _FeedRenderStrategy()
        elif new_mode == 'video':
            self._render_strategy = _VideoRenderStrategy()
        else:
            raise ValueError("Unknown mode: %s" % new_mode)

    def get_size(self, style, layout_manager):
        # return 0 for height because we render to multiple columns.  We let
        # the other columns determin the row height
        return self.min_width, 0

    def hotspot_test(self, style, layout_manager, x, y, width, height):
        return 'album-click'

    def render(self, context, layout_manager, selected, hotspot, hover):
        if not self.sanity_check_before_render(context):
            return

        # draw our background color behind everything.  We need this in case
        # there's transparency in our album art
        context.set_color(self.BACKGROUND_COLOR)
        context.rectangle(0, 0, context.width, context.height)
        context.fill()

        self.calc_album_art_size(context)
        self.render_album_art(context)
        self.render_track_number(context, layout_manager)
        self.render_album_or_artist(context, layout_manager)

    def sanity_check_before_render(self, context):
        """Do some sanity checking before starting to render things.

        Returns True if we're okay to render, False if we should bail
        """
        if self.group_info is None:
            # we can't render if group_info isn't set
            logging.warn("group_info is None in MultiRowAlbumRenderer")
            return False
        if context.height == 0:
            # not sure how this would happen, but we need to avoid
            # divide-by-zero errors if it does
            logging.warn("row height is 0 in MultiRowAlbumRenderer")
            return False
        return True

    def calc_album_art_size(self, context):
        """Calculate how big we are going to draw album art.

        This is currently big enough so it fits in 6 rows with the top/bottom
        padding.
        """
        self.album_art_size = context.height * 6
        self.album_art_size -= (self.IMAGE_MARGIN_TOP +
                                self.IMAGE_MARGIN_BOTTOM)

    def make_album_art(self, context):
        """Make an image to draw as album art.

        Returns ImageSurface to draw or None if we don't have anything
        """
        if self.get_total_rows() < 6:
            # don't draw album art if we have less than 6 items in the group
            return None

        album_art_path = self.get_image_path()
        if album_art_path is None:
            return None
        return imagepool.get_surface(
            album_art_path,
            size=(self.album_art_size, self.album_art_size),
            invalidator=util.mtime_invalidator(album_art_path))

    def render_album_art(self, context):
        album_art = self.make_album_art(context)
        if (album_art is not None
                and self.cell_contains_album_art(context, album_art)):
            self.render_album_art_slice(context, album_art)

    def cell_contains_album_art(self, context, album_art):
        """Does this cell contain a portion of the album art?
        """
        album_art_bottom = album_art.height + self.IMAGE_MARGIN_TOP
        cell_top = self.get_current_row() * context.height
        cell_bottom = cell_top + context.height
        return (cell_bottom > self.IMAGE_MARGIN_TOP
                and cell_top < album_art_bottom)

    def render_album_art_slice(self, context, image):
        """Render the slice of the album art for this cell."""

        if context.width < image.width:
            # not enough width to draw
            return

        # setup variables to track where we are copying from and to

        dest_x = self.IMAGE_MARGIN_LEFT
        width = image.width

        dest_y = 0
        height = context.height

        src_x = 0
        src_y = self.get_current_row() * context.height - self.IMAGE_MARGIN_TOP

        if src_y < 0:
            # The cell is contains the top padding for our image.
            # move dest_y and src_y down
            dest_y -= src_y
            src_y = 0
            # descrease height
            height -= dest_y
        src_y_bottom = src_y + height
        if src_y_bottom > image.height:
            # The cell is contains the bottom padding for our image.
            # decrease height
            extra_space = src_y_bottom - image.height
            height -= extra_space
        # draw our image slice
        if height > 0:
            image.draw_rect(context, dest_x, dest_y, src_x, src_y, width,
                            height)

    def render_album_or_artist(self, context, layout_manager):
        x = (self.album_art_size + self.IMAGE_MARGIN_LEFT +
             self.IMAGE_MARGIN_RIGHT)
        if self.get_current_row() == 0:
            text = self.get_artist()
            bold = True
        elif self.get_current_row() == 1:
            text = self.get_album()
            bold = False
        else:
            return

        width = self.album_artist_text_end - x
        if width < 10:
            # don't try to render if we have a really small, or negative
            # amount of space
            return
        # setup a textbox for the text
        layout_manager.set_font(self.FONT_SIZE, bold=bold)
        layout_manager.set_text_color(self.TEXT_COLOR)
        textbox = layout_manager.textbox(text)
        # truncate the textbox to the area we have in a cell.
        textbox.set_wrap_style('truncated-char')
        textbox.set_width(width)
        # middle-align the text to line-up with the other cells
        line_height = textbox.font.line_height()
        y = (context.height - line_height) / 2.0
        # okay, ready to draw
        textbox.draw(context, x, y, width, line_height)

    def render_track_number(self, context, layout_manager):
        # setup a textbox for the text
        layout_manager.set_font(self.FONT_SIZE)
        layout_manager.set_text_color(self.TRACK_TEXT_COLOR)
        textbox = layout_manager.textbox(str(self.get_track_number()))
        # place the text on the right-side of the cell
        text_width, text_height = textbox.get_size()
        x = context.width - self.TEXT_PADDING_RIGHT - text_width
        # middle-align the text to line-up with the other cells
        y = (context.height - text_height) // 2
        # okay, ready to draw
        textbox.draw(context, x, y, text_width, text_height)
        self.album_artist_text_end = x - self.TEXT_PADDING_RIGHT
コード例 #36
0
 def draw(self, context, layout):
     gradient = widgetset.Gradient(0, 0, 0, context.height)
     gradient.set_start_color(widgetutil.css_to_color('#c2c2c2'))
     gradient.set_end_color(widgetutil.css_to_color('#a3a3a3'))
     context.rectangle(0, 0, context.width, context.height)
     context.gradient_fill(gradient)