Beispiel #1
0
    def adjustContent(self, videoWindow, animate):
        if videoWindow.is_fullscreen:
            self.popInOutButton.setHidden_(YES)
            self.popInOutLabel.setHidden_(YES)
            self.fsButton.setImage_(NSImage.imageNamed_('fs-button-exitfullscreen'))
            self.fsButton.setAlternateImage_(NSImage.imageNamed_('fs-button-exitfullscreen-alt'))
        else:
            if app.playback_manager.detached_window is None:
                image_path = resources.path('images/popout.png')
                label = _('Pop Out')
            else:
                image_path = resources.path('images/popin.png')
                label = _('Pop In')
            self.popInOutButton.setImage_(NSImage.alloc().initWithContentsOfFile_(image_path))
            self.popInOutButton.setHidden_(NO)
            self.popInOutLabel.setHidden_(NO)
            self.popInOutLabel.setStringValue_(label)
            self.fsButton.setImage_(NSImage.imageNamed_('fs-button-enterfullscreen'))
            self.fsButton.setAlternateImage_(NSImage.imageNamed_('fs-button-enterfullscreen-alt'))

        newFrame = self.window().frame() 
        if videoWindow.is_fullscreen or app.playback_manager.detached_window is not None: 
            self.titleLabel.setHidden_(NO)
            self.feedLabel.setHidden_(NO)
            newFrame.size.height = 198 
        else: 
            self.titleLabel.setHidden_(YES)
            self.feedLabel.setHidden_(YES)
            newFrame.size.height = 144
        newFrame.origin.x = self.getHorizontalPosition(videoWindow, newFrame.size.width)
        self.window().setFrame_display_animate_(newFrame, YES, animate)
        self.playbackControls.setNeedsDisplay_(YES)
Beispiel #2
0
    def _fake_info(self, info, typ, name):
        new_data = {
            'fake':
            True,
            'tab_type':
            typ,
            'id':
            u'%s-%s' % (info.id, typ),
            'name':
            name,
            'device_name':
            info.name,
            'icon':
            imagepool.get_surface(
                resources.path('images/icon-device-%s.png' % typ)),
            'active_icon':
            imagepool.get_surface(
                resources.path('images/icon-device-%s_active.png' % typ))
        }

        # hack to create a DeviceInfo without dealing with __init__
        di = messages.DeviceInfo.__new__(messages.DeviceInfo)
        di.__dict__ = info.__dict__.copy()
        di.__dict__.update(new_data)
        return di
Beispiel #3
0
 def init_info(self, info):
     if info.is_folder:
         thumb_path = resources.path("images/icon-folder.png")
     else:
         thumb_path = resources.path("images/icon-playlist.png")
     info.icon = imagepool.get_surface(thumb_path)
     info.unwatched = info.available = 0
Beispiel #4
0
    def adjustContent(self, videoWindow, animate):
        if videoWindow.is_fullscreen:
            self.popInOutButton.setHidden_(YES)
            self.popInOutLabel.setHidden_(YES)
            image_path = resources.path('images/fullscreen_exit.png')
            self.fsButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))
        else:
            if app.playback_manager.detached_window is None:
                image_path = resources.path('images/popout.png')
                label = _('Pop Out')
            else:
                image_path = resources.path('images/popin.png')
                label = _('Pop In')
            self.popInOutButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))
            self.popInOutButton.setHidden_(NO)
            self.popInOutLabel.setHidden_(NO)
            self.popInOutLabel.setStringValue_(label)
            image_path = resources.path('images/fullscreen_enter.png')
            self.fsButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))

        newFrame = self.window().frame() 
        if videoWindow.is_fullscreen or app.playback_manager.detached_window is not None: 
            self.titleLabel.setHidden_(NO)
            self.feedLabel.setHidden_(NO)
            newFrame.size.height = 198 
        else: 
            self.titleLabel.setHidden_(YES)
            self.feedLabel.setHidden_(YES)
            newFrame.size.height = 144
        newFrame.origin.x = self.getHorizontalPosition(videoWindow, newFrame.size.width)
        self.window().setFrame_display_animate_(newFrame, YES, animate)
        self.playbackControls.setNeedsDisplay_(YES)
class GuideSidebarExpander(widgetset.CustomButton):
    SIDEBAR_BG = imagepool.get_surface(
        resources.path('images/guide-sidebar.png'))
    SIDEBAR_ARROW_OPEN = imagepool.get_surface(
        resources.path('images/guide-sidebar-arrow-open.png'))
    SIDEBAR_ARROW_CLOSE = imagepool.get_surface(
        resources.path('images/guide-sidebar-arrow-close.png'))

    def __init__(self):
        widgetset.CustomButton.__init__(self)
        self.expanded = True

    def size_request(self, layout):
        return 8, -1

    def set_expanded(self, value):
        if value != self.expanded:
            self.expanded = value
            self.queue_redraw()

    def draw(self, context, layout):
        self.SIDEBAR_BG.draw(context, 0, 0, 8, context.height)
        if self.expanded:
            image = self.SIDEBAR_ARROW_CLOSE
        else:
            image = self.SIDEBAR_ARROW_OPEN
        vpos = int((context.height - image.height) / 2)
        hpos = int((8 - image.width) / 2)
        image.draw(context, hpos, vpos, image.width, image.height)
Beispiel #6
0
 def __init__(self):
     ListViewRenderer.__init__(self)
     self.button = {}
     for button in self.BUTTONS:
         path = resources.path('images/%s-button.png' % button)
         self.button[button] = imagepool.get_surface(path)
     path = resources.path('images/download-arrow.png')
     self.download_icon = imagepool.get_surface(path)
Beispiel #7
0
 def __init__(self):
     ListViewRenderer.__init__(self)
     self.button = {}
     for button in self.BUTTONS:
         path = resources.path('images/%s-button.png' % button)
         self.button[button] = imagepool.get_surface(path)
     path = resources.path('images/download-arrow.png')
     self.download_icon = imagepool.get_surface(path)
Beispiel #8
0
 def __init__(self):
     widgetset.DrawingArea.__init__(self)
     self.video_icon = imagepool.get_surface(resources.path('images/mini-icon-video.png'))
     self.audio_icon = imagepool.get_surface(resources.path('images/mini-icon-audio.png'))
     self.reset()
     app.playback_manager.connect('selecting-file', self.handle_selecting)
     app.playback_manager.connect('will-play', self.handle_play)
     app.playback_manager.connect('will-stop', self.handle_stop)
Beispiel #9
0
 def __init__(self):
     widgetset.DragableCustomButton.__init__(self)
     self.value = False
     self.background = imagepool.get_surface(
         resources.path('images/connect-toggle-bg.png'))
     self.on = imagepool.get_surface(
         resources.path('images/connect-toggle-on.png'))
     self.off = imagepool.get_surface(
         resources.path('images/connect-toggle-off.png'))
Beispiel #10
0
 def get_thumbnail(self):
     if self.cover_art:
         return os.path.join(self.device.mount, self.cover_art)
     elif self.screenshot:
         return os.path.join(self.device.mount, self.screenshot)
     elif self.file_type == 'audio':
         return resources.path("images/thumb-default-audio.png")
     else:
         return resources.path("images/thumb-default-video.png")
Beispiel #11
0
 def __init__(self):
     widgetset.DragableCustomButton.__init__(self)
     self.value = False
     self.background = imagepool.get_surface(
         resources.path('images/connect-toggle-bg.png'))
     self.on = imagepool.get_surface(
         resources.path('images/connect-toggle-on.png'))
     self.off = imagepool.get_surface(
         resources.path('images/connect-toggle-off.png'))
Beispiel #12
0
 def init_playlist_info(self, info):
     info.type = u'sharing-playlist'
     if info.podcast:
         thumb_path = resources.path('images/icon-podcast-small.png')
         active = resources.path('images/icon-podcast-small_active.png')
     else:
         thumb_path = resources.path('images/icon-playlist-small.png')
         active = resources.path('images/icon-playlist-small_active.png')
     info.icon = imagepool.get_surface(thumb_path)
     info.active_icon = imagepool.get_surface(active)
Beispiel #13
0
 def init_playlist_info(self, info):
     info.type = u'sharing-playlist'
     if info.podcast:
         thumb_path = resources.path('images/icon-podcast-small.png')
         active = resources.path('images/icon-podcast-small_active.png')
     else:
         thumb_path = resources.path('images/icon-playlist-small.png')
         active = resources.path('images/icon-playlist-small_active.png')
     info.icon = imagepool.get_surface(thumb_path)
     info.active_icon = imagepool.get_surface(active)
Beispiel #14
0
    def set_image(self, image_name):
        path = resources.path('images/%s.png' % image_name)
        self.image = imagepool.get_surface(path)
        pressed_path = resources.path('images/%s_active.png' % image_name)
        self.pressed_image = imagepool.get_surface(pressed_path)

        disabled_path = resources.path('images/%s_disabled.png' % image_name)
        if os.path.exists(disabled_path):
            self.disabled_image = imagepool.get_surface(disabled_path)
        else:
            self.disabled_image = None
Beispiel #15
0
 def __init__(self):
     widgetset.CustomButton.__init__(self)
     self.set_can_focus(False)
     self.video_icon = imagepool.get_surface(resources.path('images/mini-icon-video.png'))
     self.audio_icon = imagepool.get_surface(resources.path('images/mini-icon-audio.png'))
     self.reset()
     app.playback_manager.connect('selecting-file', self.on_info_change)
     app.playback_manager.connect('playing-info-changed',
             self.on_info_change)
     app.playback_manager.connect('will-play', self.handle_play)
     app.playback_manager.connect('will-stop', self.handle_stop)
Beispiel #16
0
    def setUp(self):
        app.testing_mdp = True # hack to override moviedata's in_unit_tests hack
        MiroTestCase.setUp(self)
        self.feed = models.Feed(u'dtv:manualFeed')
        mp3_path = resources.path("testdata/metadata/mp3-0.mp3")
        webm_path = resources.path("testdata/metadata/webm-0.webm")
        jpg_path = resources.path("testdata/dean.jpg")

        self.audio_item = models.FileItem(mp3_path, self.feed.id)
        self.video_item = models.FileItem(webm_path, self.feed.id)
        self.other_item = models.FileItem(jpg_path, self.feed.id)
Beispiel #17
0
 def __init__(self):
     widgetset.CustomButton.__init__(self)
     self.set_can_focus(False)
     self.video_icon = imagepool.get_surface(resources.path('images/mini-icon-video.png'))
     self.audio_icon = imagepool.get_surface(resources.path('images/mini-icon-audio.png'))
     self.reset()
     app.playback_manager.connect('selecting-file', self.on_info_change)
     app.playback_manager.connect('playing-info-changed',
             self.on_info_change)
     app.playback_manager.connect('will-play', self.handle_play)
     app.playback_manager.connect('will-stop', self.handle_stop)
Beispiel #18
0
 def get_thumbnail(self):
     if self.cover_art:
         return os.path.join(self.device.mount,
                             self.cover_art)
     elif self.screenshot:
         return os.path.join(self.device.mount,
                             self.screenshot)
     elif self.file_type == 'audio':
         return resources.path("images/thumb-default-audio.png")
     else:
         return resources.path("images/thumb-default-video.png")
Beispiel #19
0
    def set_image(self, image_name):
        path = resources.path('images/%s.png' % image_name)
        self.image = imagepool.get_surface(path)
        pressed_path = resources.path('images/%s_active.png' % image_name)
        self.pressed_image = imagepool.get_surface(pressed_path)

        disabled_path = resources.path('images/%s_disabled.png' % image_name)
        if os.path.exists(disabled_path):
            self.disabled_image = imagepool.get_surface(disabled_path)
        else:
            self.disabled_image = None
Beispiel #20
0
 def init_info(self, info):
     if info is self.info:
         return
     if info.is_folder:
         info.icon = imagepool.get_surface(
             resources.path('images/icon-folder.png'))
     else:
         info.icon = imagepool.get_surface(
             resources.path('images/icon-playlist-small.png'))
         info.active_icon = imagepool.get_surface(
             resources.path('images/icon-playlist-small_active.png'))
     info.type = self.type
     info.unwatched = info.available = 0
Beispiel #21
0
 def init_info(self, info):
     if info is self.info:
         return
     if info.is_folder:
         info.icon = imagepool.get_surface(
             resources.path('images/icon-folder.png'))
     else:
         info.icon = imagepool.get_surface(
             resources.path('images/icon-playlist-small.png'))
         info.active_icon = imagepool.get_surface(
             resources.path('images/icon-playlist-small_active.png'))
     info.type = self.type
     info.unwatched = info.available = 0
Beispiel #22
0
    def __init__(self, theme=None):
        self.theme_vars = {}

        app_config_path = resources.path('app.config')
        self.default_vars = buildutils.read_simple_config_file(app_config_path)

        self.load_theme(theme)
Beispiel #23
0
def get(descriptor):
    if descriptor == prefs.MOVIES_DIRECTORY:
        return os.path.join(MOVIES_DIRECTORY_PARENT, "Miro")

    elif descriptor == prefs.NON_VIDEO_DIRECTORY:
        return os.path.expanduser('~/Desktop')

    elif descriptor == prefs.GETTEXT_PATHNAME:
        return os.path.abspath(resources.path("../locale"))

    elif descriptor == prefs.RUN_AT_STARTUP:
        # On Mac, don't mark as run at startup by default.
        return False

    elif descriptor == prefs.SUPPORT_DIRECTORY:
        path = os.path.join(SUPPORT_DIRECTORY_PARENT, "Miro")
        os.environ['APPDATA'] = path  # This is for the Bittorent module
        try:
            os.makedirs(path)
        except:
            pass
        return path

    elif descriptor == prefs.ICON_CACHE_DIRECTORY:
        return _makeSupportFilePath('icon-cache')

    elif descriptor == prefs.COVER_ART_DIRECTORY:
        return _makeSupportFilePath('cover-art')

    elif descriptor == prefs.SQLITE_PATHNAME:
        return _makeSupportFilePath('sqlitedb')

    elif descriptor == prefs.CRASH_PATHNAME:
        return _makeSupportFilePath('crashes')

    elif descriptor == prefs.LOG_PATHNAME:
        return _makeSupportFilePath('dtv-log')

    elif descriptor == prefs.DOWNLOADER_LOG_PATHNAME:
        return _makeSupportFilePath('dtv-downloader-log')

    elif descriptor == prefs.HTTP_PROXY_ACTIVE:
        return _getProxyInfo('HTTPEnable', 0) == 1

    elif descriptor == prefs.HTTP_PROXY_HOST:
        return _getProxyInfo('HTTPProxy')

    elif descriptor == prefs.HTTP_PROXY_PORT:
        return _getProxyInfo('HTTPPort', 0)

    elif descriptor == prefs.HTTP_PROXY_IGNORE_HOSTS:
        return _getProxyInfo('ExceptionsList', list())

    elif descriptor == prefs.HTTP_PROXY_AUTHORIZATION_USERNAME:
        return _getProxyAuthInfo('username')

    elif descriptor == prefs.HTTP_PROXY_AUTHORIZATION_PASSWORD:
        return _getProxyAuthInfo('password')

    return descriptor.default
Beispiel #24
0
    def test_shared_cover_art(self):
        # test what happens when 2 files with coverart share the same album.
        # In this case the first one we process should create the cover art
        # file and the next one should just skip cover art processing.
        src_path = resources.path(path.join('testdata', 'metadata',
                                            'drm.m4v'))
        dest_paths = []
        for x in range(3):
            new_filename = 'drm-%s.m4v' % x
            dest_path = path.join(self.tempdir, new_filename)
            shutil.copyfile(src_path, dest_path)
            dest_paths.append(dest_path)

        # process the first file
        result_1 = process_file(dest_paths[0], self.tempdir)
        self.assertEquals(result_1['cover_art'],
                          path.join(self.tempdir, result_1['album']))
        self.assert_(path.exists(result_1['cover_art']))
        org_mtime = stat(result_1['cover_art']).st_mtime

        # process the rest, they should fill in the cover_art value, but
        # not rewrite the file
        for dup_path in dest_paths[1:]:
            results = process_file(dup_path, self.tempdir)
            self.assertEquals(results['cover_art'],
                              result_1['cover_art'])
            self.assert_(path.exists(results['cover_art']))
            self.assertEquals(stat(results['cover_art']).st_mtime,
                              org_mtime)
Beispiel #25
0
 def get_image_path(self, item_info):
     try:
         feed_info = widgetutil.get_feed_info(item_info.feed_id)
         return feed_info.thumbnail
     except KeyError:
         # use placeholder image until we get one from a designer
         return resources.path('images/album-art-placeholder.gif')
Beispiel #26
0
 def get_image_path(self):
     if self.feed_mode:
         feed_info = widgetutil.get_feed_info(self.info.feed_id)
         return feed_info.thumbnail
     else:
         # use placeholder image until the metadata changes happen
         return resources.path('images/album-art-placeholder.gif')
Beispiel #27
0
    def awakeFromNib(self):
        image_path = resources.path('images/subtitles_down.png')
        self.subtitlesButton.setImage_(NSImage.alloc().initWithContentsOfFile_(filename_to_unicode(image_path)))
        self.subtitlesLabel.setTitleWithMnemonic_(_("Subtitles"))
        self.fsLabel.setTitleWithMnemonic_(_("Fullscreen"))
        self.shareButton.setImage_(getOverlayButtonImage(self.shareButton.bounds().size))
        self.shareButton.setAlternateImage_(getOverlayButtonAlternateImage(self.shareButton.bounds().size))
        self.shareButton.setTitle_(_("Share"))

        self.keepButton.setImage_(getOverlayButtonImage(self.keepButton.bounds().size))
        self.keepButton.setAlternateImage_(getOverlayButtonAlternateImage(self.keepButton.bounds().size))
        self.keepButton.setTitle_(_("Keep"))

        self.deleteButton.setImage_(getOverlayButtonImage(self.deleteButton.bounds().size))
        self.deleteButton.setAlternateImage_(getOverlayButtonAlternateImage(self.deleteButton.bounds().size))
        self.deleteButton.setTitle_(_("Delete"))

        self.seekForwardButton.setCell_(SkipSeekButtonCell.cellFromButtonCell_direction_delay_(self.seekForwardButton.cell(), 1, 0.0))
        self.seekForwardButton.cell().setAllowsSkipping(False)
        self.seekBackwardButton.setCell_(SkipSeekButtonCell.cellFromButtonCell_direction_delay_(self.seekBackwardButton.cell(), -1, 0.0))
        self.seekBackwardButton.cell().setAllowsSkipping(False)

        self.progressSlider.cursor = NSImage.imageNamed_(u'fs-progress-slider')
        self.progressSlider.sliderWasClicked = self.progressSliderWasClicked
        self.progressSlider.sliderWasDragged = self.progressSliderWasDragged
        self.progressSlider.sliderWasReleased = self.progressSliderWasReleased
        self.progressSlider.setShowCursor_(True)

        self.volumeSlider.cursor = NSImage.imageNamed_(u'fs-volume-slider')
        self.volumeSlider.sliderWasClicked = self.volumeSliderWasClicked
        self.volumeSlider.sliderWasDragged = self.volumeSliderWasDragged
        self.volumeSlider.sliderWasReleased = self.volumeSliderWasReleased
        self.volumeSlider.setShowCursor_(True)
Beispiel #28
0
 def get_image_path(self, item_info):
     try:
         feed_info = widgetutil.get_feed_info(item_info.feed_id)
         return feed_info.thumbnail
     except KeyError:
         # use placeholder image until we get one from a designer
         return resources.path('images/album-art-placeholder.gif')
Beispiel #29
0
def _makeSearchIcon(engine):
    popupRectangle = NSImage.imageNamed_(u'search_popup_triangle')
    popupRectangleSize = popupRectangle.size()

    engineIconPath = resources.path('images/search_icon_%s.png' % engine.name)
    if not os.path.exists(engineIconPath):
        return nil
    engineIcon = NSImage.alloc().initByReferencingFile_(
      filename_to_unicode(engineIconPath))
    engineIconSize = engineIcon.size()

    searchIconSize = (engineIconSize.width + popupRectangleSize.width + 2, engineIconSize.height)
    searchIcon = NSImage.alloc().initWithSize_(searchIconSize)
    
    searchIcon.lockFocus()
    try:
        engineIcon.drawAtPoint_fromRect_operation_fraction_(
          (0,0), NSZeroRect, NSCompositeSourceOver, 1.0)
        popupRectangleX = engineIconSize.width + 2
        popupRectangleY = (engineIconSize.height - popupRectangleSize.height) / 2
        popupRectangle.drawAtPoint_fromRect_operation_fraction_(
          (popupRectangleX, popupRectangleY), NSZeroRect,
          NSCompositeSourceOver, 1.0)
    finally:
        searchIcon.unlockFocus()

    return searchIcon
Beispiel #30
0
    def test_stripper_data(self):
        stripper = util.HTMLStripper()

        testdir = resources.path(os.path.join("testdata", "stripperdata"))
        tests = [m for m in os.listdir(testdir) if m.endswith(".in")]

        for mem in tests:
            mem = os.path.join(testdir, mem)
            if not os.path.isfile(mem):
                continue

            f = open(mem, "r")
            input_ = f.read()
            f.close()

            input_ = input_.decode("utf-8")
            output = stripper.strip(input_)

            expected = os.path.splitext(mem)[0] + ".expected"
            if not os.path.isfile(expected):
                self.assertEquals(0, 1, "%s not found." % expected)
            else:
                f = open(expected, "r")
                data = f.read().strip()
                f.close()
                self.assertEquals(
                    repr(output), data, "output: %s" % repr(output))
Beispiel #31
0
    def awakeFromNib(self):
        image_path = resources.path('images/subtitles_down.png')
        self.subtitlesButton.setImage_(NSImage.alloc().initWithContentsOfFile_(image_path))
        self.subtitlesLabel.setTitleWithMnemonic_(_("Subtitles"))
        self.fsLabel.setTitleWithMnemonic_(_("Fullscreen"))
        self.shareButton.setImage_(getOverlayButtonImage(self.shareButton.bounds().size))
        self.shareButton.setAlternateImage_(getOverlayButtonAlternateImage(self.shareButton.bounds().size))
        self.shareButton.setTitle_(_("Share"))

        self.keepButton.setImage_(getOverlayButtonImage(self.keepButton.bounds().size))
        self.keepButton.setAlternateImage_(getOverlayButtonAlternateImage(self.keepButton.bounds().size))
        self.keepButton.setTitle_(_("Keep"))

        self.deleteButton.setImage_(getOverlayButtonImage(self.deleteButton.bounds().size))
        self.deleteButton.setAlternateImage_(getOverlayButtonAlternateImage(self.deleteButton.bounds().size))
        self.deleteButton.setTitle_(_("Delete"))

        self.seekForwardButton.setCell_(SkipSeekButtonCell.cellFromButtonCell_direction_delay_(self.seekForwardButton.cell(), 1, 0.0))
        self.seekForwardButton.cell().setAllowsSkipping(False)
        self.seekBackwardButton.setCell_(SkipSeekButtonCell.cellFromButtonCell_direction_delay_(self.seekBackwardButton.cell(), -1, 0.0))
        self.seekBackwardButton.cell().setAllowsSkipping(False)

        self.progressSlider.cursor = NSImage.imageNamed_(u'fs-progress-slider')
        self.progressSlider.sliderWasClicked = self.progressSliderWasClicked
        self.progressSlider.sliderWasDragged = self.progressSliderWasDragged
        self.progressSlider.sliderWasReleased = self.progressSliderWasReleased
        self.progressSlider.setShowCursor_(True)

        self.volumeSlider.cursor = NSImage.imageNamed_(u'fs-volume-slider')
        self.volumeSlider.sliderWasClicked = self.volumeSliderWasClicked
        self.volumeSlider.sliderWasDragged = self.volumeSliderWasDragged
        self.volumeSlider.sliderWasReleased = self.volumeSliderWasReleased
        self.volumeSlider.setShowCursor_(True)
Beispiel #32
0
    def __init__(self, theme=None):
        self.theme_vars = {}

        app_config_path = resources.path('app.config')
        self.default_vars = buildutils.read_simple_config_file(app_config_path)

        self.load_theme(theme)
Beispiel #33
0
 def send_feedparser_task(self):
     # send feedparser successfully parsing a feed
     path = os.path.join(resources.path("testdata/feedparsertests/feeds"),
         "http___feeds_miroguide_com_miroguide_featured.xml")
     html = open(path).read()
     msg = workerprocess.FeedparserTask(html)
     workerprocess.send(msg, self.callback, self.errback)
Beispiel #34
0
 def init(self):
     self = super(MiroSearchTextField, self).init()
     image = NSImage.alloc().initByReferencingFile_(
         resources.path('images/search_icon_all.png'))
     self.cell().searchButtonCell().setImage_(image)
     self.cell().searchButtonCell().setAlternateImage_(image)
     return self
Beispiel #35
0
    def __init__(self):
        widgetset.VBox.__init__(self)

        if not app.sharing_manager.mdns_present:
            sharing_broken = SharingBroken()
            sharing_broken.connect('install-clicked',
                                   self.daap_install_clicked)
            self.pack_start(widgetutil.align_center(sharing_broken))

        title = widgetset.HBox()
        logo = widgetset.ImageDisplay(imagepool.get(
            resources.path('images/icon-connect_large.png')))
        title.pack_start(widgetutil.align_middle(logo))
        label = widgetset.Label(_("Connect"))
        label.set_size(widgetutil.font_scale_from_osx_points(30))
        label.set_bold(True)
        title.pack_start(widgetutil.align_middle(label, left_pad=5))
        self.pack_start(widgetutil.align_center(title, top_pad=30,
                                                bottom_pad=20))

        bottom = widgetset.VBox()

        self._build_daap_section(bottom)
        self._build_sync_section(bottom)
        self._build_app_store_section(bottom)
        self._build_android_section(bottom)

        self.pack_start(widgetutil.align_center(bottom))
Beispiel #36
0
def get(descriptor):
    if descriptor == prefs.MOVIES_DIRECTORY:
        return os.path.join(MOVIES_DIRECTORY_PARENT, "Miro")

    elif descriptor == prefs.NON_VIDEO_DIRECTORY:
        return os.path.expanduser('~/Desktop')

    elif descriptor == prefs.GETTEXT_PATHNAME:
        return os.path.abspath(resources.path("../locale"))

    elif descriptor == prefs.RUN_AT_STARTUP:
        # On Mac, don't mark as run at startup by default.
        return False

    elif descriptor == prefs.SUPPORT_DIRECTORY:
        path = os.path.join(SUPPORT_DIRECTORY_PARENT, "Miro")
        os.environ['APPDATA'] = path # This is for the Bittorent module
        try:
            os.makedirs(path)
        except:
            pass
        return path

    elif descriptor == prefs.ICON_CACHE_DIRECTORY:
        return _makeSupportFilePath('icon-cache')

    elif descriptor == prefs.COVER_ART_DIRECTORY:
        return _makeSupportFilePath('cover-art')
    
    elif descriptor == prefs.SQLITE_PATHNAME:
        return _makeSupportFilePath('sqlitedb')

    elif descriptor == prefs.CRASH_PATHNAME:
        return _makeSupportFilePath('crashes')

    elif descriptor == prefs.LOG_PATHNAME:
        return _makeSupportFilePath('dtv-log')

    elif descriptor == prefs.DOWNLOADER_LOG_PATHNAME:
        return _makeSupportFilePath('dtv-downloader-log')

    elif descriptor == prefs.HTTP_PROXY_ACTIVE:
        return _getProxyInfo('HTTPEnable', 0) == 1
        
    elif descriptor == prefs.HTTP_PROXY_HOST:
        return _getProxyInfo('HTTPProxy')
        
    elif descriptor == prefs.HTTP_PROXY_PORT:
        return _getProxyInfo('HTTPPort', 0)
        
    elif descriptor == prefs.HTTP_PROXY_IGNORE_HOSTS:
        return _getProxyInfo('ExceptionsList', list())
    
    elif descriptor == prefs.HTTP_PROXY_AUTHORIZATION_USERNAME:
        return _getProxyAuthInfo('username')
    
    elif descriptor == prefs.HTTP_PROXY_AUTHORIZATION_PASSWORD:
        return _getProxyAuthInfo('password')
    
    return descriptor.default
Beispiel #37
0
    def __init__(self):
        widgetset.SolidBackground.__init__(self, itemlistwidgets.StandardView.BACKGROUND_COLOR)
        bg = widgetutil.RoundedSolidBackground(widgetutil.WHITE)
        vbox = widgetset.VBox()
        title = widgetset.HBox()
        logo = imagepool.get_image_display(resources.path("images/icon-search_large.png"))
        title.pack_start(widgetutil.align_middle(logo))
        label = widgetset.Label(self.TITLE)
        label.set_bold(True)
        label.set_size(widgetutil.font_scale_from_osx_points(30))
        title.pack_start(widgetutil.align_middle(label, left_pad=5))
        vbox.pack_start(widgetutil.align_center(title, bottom_pad=20))
        desc = widgetset.Label(self.DESC)
        vbox.pack_start(widgetutil.align_center(desc, bottom_pad=40))

        engine_width = int((desc.get_width() - 30) / 2)

        engine_widgets = self.build_engine_widgets()
        for widgets in engine_widgets[:-1]:  # widgets with borders
            hbox = widgetset.HBox(spacing=30)
            for widget in widgets:
                widget.set_size_request(engine_width, 45)
                hbox.pack_start(widget, expand=True)
            vbox.pack_start(hbox)

        hbox = widgetset.HBox(spacing=30)
        for widget in engine_widgets[-1]:  # has no border
            widget.set_has_border(False)
            widget.set_size_request(engine_width, 45)
            hbox.pack_start(widget, expand=True)

        vbox.pack_start(hbox)

        bg.add(widgetutil.pad(vbox, 45, 45, 45, 45))
        self.add(widgetutil.align(bg, xalign=0.5, top_pad=50))
Beispiel #38
0
 def test_info(self):
     self.httpserver.add_header('x-foo', 'bar')
     self.grab_url(self.httpserver.build_url('test.txt'))
     self.assertEquals(self.grab_url_info['x-foo'], 'bar')
     path = resources.path("testdata/httpserver/test.txt")
     self.assertEquals(self.grab_url_info['content-length'],
             len(open(path).read()))
Beispiel #39
0
    def __init__(self):
        widgetset.VBox.__init__(self)
        label = widgetset.Label()
        label.set_text(
            _("Your device isn't telling us its exact model number."))
        self.pack_start(widgetutil.align_center(label, left_pad=20, top_pad=50,
                                              bottom_pad=20))
        label = widgetset.Label()
        label.set_text(
            _('For optimal video conversion, select the device model.'))
        label.set_bold(True)
        self.pack_start(widgetutil.align_center(label, left_pad=20,
                                                bottom_pad=20)),

        self.device_choices = widgetset.VBox()
        self.pack_start(widgetutil.align_center(self.device_choices,
                                                left_pad=20, top_pad=20,
                                                bottom_pad=20))

        image = widgetset.ImageDisplay(
            imagepool.get(resources.path('images/sync-unknown.png')))
        self.pack_start(widgetutil.align_center(image, left_pad=20,
                                                bottom_pad=20))

        label = widgetset.Label()
        label.set_text(_("If you don't know the model or it doesn't appear "
                         "in the list, it's fine to choose the 'Generic' "
                         "device option."))
        label.set_bold(True)
        self.pack_start(widgetutil.align_center(label, left_pad=20,
                                                bottom_pad=20))
Beispiel #40
0
    def __init__(self):
        widgetset.VBox.__init__(self)

        if not app.sharing_manager.mdns_present:
            sharing_broken = SharingBroken()
            sharing_broken.connect('install-clicked',
                                   self.daap_install_clicked)
            self.pack_start(widgetutil.align_center(sharing_broken))

        title = widgetset.HBox()
        logo = widgetset.ImageDisplay(
            imagepool.get(resources.path('images/icon-connect_large.png')))
        title.pack_start(widgetutil.align_middle(logo))
        label = widgetset.Label(_("Connect"))
        label.set_size(widgetutil.font_scale_from_osx_points(30))
        label.set_bold(True)
        title.pack_start(widgetutil.align_middle(label, left_pad=5))
        self.pack_start(
            widgetutil.align_center(title, top_pad=30, bottom_pad=20))

        bottom = widgetset.VBox()

        self._build_daap_section(bottom)
        self._build_sync_section(bottom)
        self._build_app_store_section(bottom)
        self._build_android_section(bottom)

        self.pack_start(widgetutil.align_center(bottom))

        self.callback_handle = app.backend_config_watcher.connect_weak(
            'changed', self.on_config_changed)
Beispiel #41
0
 def send_feedparser_task(self):
     # send feedparser successfully parsing a feed
     path = os.path.join(
         resources.path("testdata/feedparsertests/feeds"),
         "http___feeds_miroguide_com_miroguide_featured.xml")
     html = open(path).read()
     workerprocess.run_feedparser(html, self.callback, self.errback)
Beispiel #42
0
    def test_shared_cover_art(self):
        # test what happens when 2 files with coverart share the same album.
        # In this case the first one we process should create the cover art
        # file and the next one should just skip cover art processing.
        src_path = resources.path(path.join('testdata', 'metadata', 'drm.m4v'))
        dest_paths = []
        for x in range(3):
            new_filename = 'drm-%s.m4v' % x
            dest_path = path.join(self.tempdir, new_filename)
            shutil.copyfile(src_path, dest_path)
            dest_paths.append(dest_path)

        # process the first file
        result_1 = process_file(dest_paths[0], self.tempdir)
        self.assertEquals(result_1['cover_art'],
                          path.join(self.tempdir, result_1['album']))
        self.assert_(path.exists(result_1['cover_art']))
        org_mtime = stat(result_1['cover_art']).st_mtime

        # process the rest, they should fill in the cover_art value, but
        # not rewrite the file
        for dup_path in dest_paths[1:]:
            results = process_file(dup_path, self.tempdir)
            self.assertEquals(results['cover_art'], result_1['cover_art'])
            self.assert_(path.exists(results['cover_art']))
            self.assertEquals(stat(results['cover_art']).st_mtime, org_mtime)
Beispiel #43
0
def _makeSearchIcon(engine):
    popupRectangle = NSImage.imageNamed_(u'search_popup_triangle')
    popupRectangleSize = popupRectangle.size()

    engineIconPath = resources.path('images/search_icon_%s.png' % engine.name)
    if not os.path.exists(engineIconPath):
        return nil
    engineIcon = NSImage.alloc().initByReferencingFile_(
        filename_to_unicode(engineIconPath))
    engineIconSize = engineIcon.size()

    searchIconSize = (engineIconSize.width + popupRectangleSize.width + 2,
                      engineIconSize.height)
    searchIcon = NSImage.alloc().initWithSize_(searchIconSize)

    searchIcon.lockFocus()
    try:
        engineIcon.drawAtPoint_fromRect_operation_fraction_(
            (0, 0), NSZeroRect, NSCompositeSourceOver, 1.0)
        popupRectangleX = engineIconSize.width + 2
        popupRectangleY = (engineIconSize.height -
                           popupRectangleSize.height) / 2
        popupRectangle.drawAtPoint_fromRect_operation_fraction_(
            (popupRectangleX, popupRectangleY), NSZeroRect,
            NSCompositeSourceOver, 1.0)
    finally:
        searchIcon.unlockFocus()

    return searchIcon
Beispiel #44
0
 def get_favicon_path(self):
     """Returns the path to the favicon file.  It's either the favicon of
     the site or the default icon image.
     """
     if self.icon_cache and self.icon_cache.get_filename():
         return fileutil.expand_filename(self.icon_cache.get_filename())
     return resources.path("images/icon-site.png")
Beispiel #45
0
 def test_upgrade_from_5x(self):
     # Test the upgrade from devices from Miro 5.x.  These have an sqlite
     # database, but only metadata on it, not the device_item table
     self.setup_json_db('testdata/device-dbs/5.x-json')
     device_sqlite = os.path.join(self.device.mount, '.miro', 'sqlite')
     shutil.copyfile(resources.path('testdata/5.x-device-database.sqlite'),
                     device_sqlite)
     self.check_json_import(self.device.db[u'audio'])
Beispiel #46
0
 def __init__(self, filename):
     Namespace.__init__(self)
     metadata.Source.__init__(self)
     filename = resources.path(path.join('testdata', 'metadata', filename))
     self.__dict__['_filename'] = filename
     self.__dict__['id'] = 9999
     self.mdp_state = None
     self.file_type = None
Beispiel #47
0
 def test_upgrade_from_5x(self):
     # Test the upgrade from devices from Miro 5.x.  These have an sqlite
     # database, but only metadata on it, not the device_item table
     self.setup_json_db('testdata/device-dbs/5.x-json')
     device_sqlite = os.path.join(self.device.mount, '.miro', 'sqlite')
     shutil.copyfile(resources.path('testdata/5.x-device-database.sqlite'),
                     device_sqlite)
     self.check_json_import(self.device.db[u'audio'])
Beispiel #48
0
 def __init__(self):
     widgetset.HBox.__init__(self)
     self.download = imagepool.get_image_display(
         resources.path('images/download-started.png'))
     self.throbber_shown = False
     self.download_shown = False
     self._width = None
     self.set_size_request(62, 37)
Beispiel #49
0
 def __init__(self):
     widgetset.HBox.__init__(self)
     self.download = imagepool.get_image_display(
         resources.path('images/download-started.png'))
     self.throbber_shown = False
     self.download_shown = False
     self._width = None
     self.set_size_request(62, 37)
Beispiel #50
0
 def init(self):
     self = super(MiroSearchTextField, self).init()
     imagepath = filename_to_unicode(
                 resources.path('images/search_icon_all.png'))
     image = NSImage.alloc().initByReferencingFile_(imagepath)
     self.cell().searchButtonCell().setImage_(image)
     self.cell().searchButtonCell().setAlternateImage_(image)
     return self
Beispiel #51
0
 def setUp(self):
     EventLoopTest.setUp(self)
     self.start_http_server()
     self.grab_url_info = self.grab_url_error = None
     self.expecting_errback = False
     self.event_loop_timeout = 1.0
     test_txt_path = resources.path("testdata/httpserver/test.txt")
     self.test_response_data = open(test_txt_path).read()
Beispiel #52
0
 def init_info(self, info):
     info.type = u'device'
     info.unwatched = info.available = 0
     if not getattr(info, 'fake', False):
         if getattr(info.info, 'generic', False):
             info.icon = imagepool.get_surface(
                 resources.path('images/icon-device-hd.png'))
             info.active_icon = imagepool.get_surface(
                 resources.path('images/icon-device-hd_active.png'))
         else:
             info.icon = imagepool.get_surface(
                 resources.path('images/icon-device.png'))
             info.active_icon = imagepool.get_surface(
                 resources.path('images/icon-device_active.png'))
         if getattr(info, 'is_updating', False):
             self.tablist.start_updating(info.id)
         else:
             self.tablist.stop_updating(info.id)
Beispiel #53
0
    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)
Beispiel #54
0
 def __init__(self, tab_class, name, icon_name):
     # "type" is overused, so tab_class refers to the type class
     # attribute of the tab.  e.g. "connect", "feed", ...
     self.tab_class = tab_class
     self.name = name
     self.id = u'%s-base-tab' % tab_class
     self.icon_name = icon_name
     self.thumbnail = resources.path('images/%s.png' % icon_name)
     self.icon = widgetutil.make_surface(self.icon_name)
     self.active_icon = widgetutil.make_surface(self.icon_name + '_active')
Beispiel #55
0
    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