Example #1
0
def _getEngineIcon(engine):
    engineIconPath = resources.path('images/search_icon_%s.png' % engine.name)
    if app.config.get(prefs.THEME_NAME) and engine.filename:
        if engine.filename.startswith(resources.theme_path(
            app.config.get(prefs.THEME_NAME), 'searchengines')):
                # this search engine came from a theme; look up the icon in the
                # theme directory instead
                engineIconPath = resources.theme_path(
                    app.config.get(prefs.THEME_NAME),
                    'images/search_icon_%s.png' % engine.name)
    if not os.path.exists(engineIconPath):
        return nil
    return NSImage.alloc().initByReferencingFile_(engineIconPath)
Example #2
0
def _getEngineIcon(engine):
    engineIconPath = resources.path('images/search_icon_%s.png' % engine.name)
    if app.config.get(prefs.THEME_NAME) and engine.filename:
        if engine.filename.startswith(
                resources.theme_path(app.config.get(prefs.THEME_NAME),
                                     'searchengines')):
            # this search engine came from a theme; look up the icon in the
            # theme directory instead
            engineIconPath = resources.theme_path(
                app.config.get(prefs.THEME_NAME),
                'images/search_icon_%s.png' % engine.name)
    if not os.path.exists(engineIconPath):
        return nil
    return NSImage.alloc().initByReferencingFile_(engineIconPath)
Example #3
0
 def load_theme(self, theme):
     if theme is not None:
         logging.info("Using theme %s", theme)
         theme_app_config = resources.theme_path(theme, 'app.config')
         try:
             self.theme_vars = util.read_simple_config_file(theme_app_config)
         except EnvironmentError:
             logging.warn("Error loading theme: %s\n%s", 
                     theme_app_config, traceback.format_exc())
Example #4
0
 def load_theme(self, theme):
     if theme is not None:
         logging.info("Using theme %s", theme)
         theme_app_config = resources.theme_path(theme, 'app.config')
         try:
             self.theme_vars = buildutils.read_simple_config_file(
                 theme_app_config)
         except EnvironmentError:
             logging.warn("Error loading theme: %s\n%s", theme_app_config,
                          traceback.format_exc())
Example #5
0
 def _get_icon_location(self):
     # we set the icon first (if available) so that it doesn't flash
     # on when the window is realized in Application.build_window()
     icopath = os.path.join(resources.app_root(), "Miro.ico")
     if app.config.get(prefs.THEME_NAME) and app.config.get(options.WINDOWS_ICON):
         themeIcoPath = resources.theme_path(app.config.get(prefs.THEME_NAME),
                                             app.config.get(options.WINDOWS_ICON))
         if os.path.exists(themeIcoPath):
             icopath = themeIcoPath
     gtk.window_set_default_icon_from_file(icopath)
     return icopath
Example #6
0
def icon_path_for_engine(engine):
    engine_name = unicode_to_filename(engine.name)
    icon_path = resources.path('images/search_icon_%s.png' % engine_name)
    if app.config.get(prefs.THEME_NAME):
        logging.debug('engine %s filename: %s' % (engine.name, engine.filename))
        test_icon_path = resources.theme_path(app.config.get(prefs.THEME_NAME),
                                              'images/search_icon_%s.png' %
                                              engine_name)
        if os.path.exists(test_icon_path):
            # this search engine came from a theme; look up the icon in the
            # theme directory instead
            icon_path = test_icon_path
    return icon_path
Example #7
0
    def _set_default_icon(self):
        # set the icon so that it doesn't flash when the window is
        # realized in Application.build_window().
        # if this isn't a themed Miro, then we use the default icon set
        ico_path = resources.share_path("icons/hicolor/24x24/apps/miro.png")
        if app.config.get(prefs.THEME_NAME) != prefs.THEME_NAME.default and app.config.get(options.WINDOWS_ICON):
            theme_ico_path = resources.theme_path(
                app.config.get(prefs.THEME_NAME), app.config.get(options.WINDOWS_ICON)
            )
            if os.path.exists(theme_ico_path):
                ico_path = theme_ico_path
                gtk.window_set_default_icon_from_file(ico_path)
        else:
            gtk.icon_theme_get_default().append_search_path(resources.share_path("icons"))
            gtk.window_set_default_icon_name("miro")

        return ico_path
Example #8
0
    def _set_default_icon(self):
        # set the icon so that it doesn't flash when the window is
        # realized in Application.build_window().
        # if this isn't a themed Miro, then we use the default icon set
        ico_path = resources.share_path("icons/hicolor/24x24/apps/miro.png")
        if ((app.config.get(prefs.THEME_NAME) != prefs.THEME_NAME.default
             and app.config.get(options.WINDOWS_ICON))):
            theme_ico_path = resources.theme_path(
                app.config.get(prefs.THEME_NAME),
                app.config.get(options.WINDOWS_ICON))
            if os.path.exists(theme_ico_path):
                ico_path = theme_ico_path
                gtk.window_set_default_icon_from_file(ico_path)
        else:
            gtk.icon_theme_get_default().append_search_path(
                resources.share_path('icons'))
            gtk.window_set_default_icon_name("miro")

        return ico_path
Example #9
0
    def on_first_run(self):
        logging.info("Spawning Miro Guide...")
        guide_url = unicode(app.config.get(prefs.CHANNEL_GUIDE_URL))
        if guide.get_guide_by_url(guide_url) is None:
            allowed_urls = app.config.get(prefs.CHANNEL_GUIDE_ALLOWED_URLS)
            guide.ChannelGuide(guide_url, unicode(allowed_urls).split())

        if self.theme is not None:
            # we have a theme
            new_guides = unicode(
                app.config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split()
            for temp_guide in new_guides:
                if guide.get_guide_by_url(temp_guide) is None:
                    guide.ChannelGuide(temp_guide)
            if (((app.config.get(prefs.DEFAULT_CHANNELS_FILE) is not None)
                 and (app.config.get(prefs.THEME_NAME) is not None))):
                importer = opml.Importer()
                filepath = resources.theme_path(
                    app.config.get(prefs.THEME_NAME),
                    app.config.get(prefs.DEFAULT_CHANNELS_FILE))
                if os.path.exists(filepath):
                    importer.import_subscriptions(filepath, show_summary=False)
                else:
                    logging.warn("Theme subscription file doesn't exist: %s",
                                 filepath)
            elif None not in self.pastThemes:
                # We pretend to have run the default theme, and then
                # install the default channels.  XXX: If Miro Guide isn't
                # installed by the theme and it doesn't provide a default
                # set of channels, we'll never install the Miro Guide.

                # This code would install the Miro Guide if it isn't
                # already installed
                # if guide.get_guide_by_url(prefs.CHANNEL_GUIDE_URL.default) is None:
                #     guide.ChannelGuide(prefs.CHANNEL_GUIDE_URL.default)
                self.pastThemes.append(None)
                self._install_default_feeds()
        else:
            # no theme
            self._install_default_feeds()
        signals.system.theme_first_run(self.theme)
Example #10
0
    def on_first_run(self):
        logging.info("Spawning Miro Guide...")
        guide_url = unicode(app.config.get(prefs.CHANNEL_GUIDE_URL))
        if guide.get_guide_by_url(guide_url) is None:
            allowed_urls = app.config.get(prefs.CHANNEL_GUIDE_ALLOWED_URLS)
            guide.ChannelGuide(guide_url, unicode(allowed_urls).split())

        if self.theme is not None:
            # we have a theme
            new_guides = unicode(app.config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split()
            for temp_guide in new_guides:
                if guide.get_guide_by_url(temp_guide) is None:
                    guide.ChannelGuide(temp_guide)
            if (((app.config.get(prefs.DEFAULT_CHANNELS_FILE) is not None)
                 and (app.config.get(prefs.THEME_NAME) is not None))):
                importer = opml.Importer()
                filepath = resources.theme_path(app.config.get(prefs.THEME_NAME), 
                    app.config.get(prefs.DEFAULT_CHANNELS_FILE))
                if os.path.exists(filepath):
                    importer.import_subscriptions(filepath,
                                                  show_summary=False)
                else:
                    logging.warn("Theme subscription file doesn't exist: %s",
                                 filepath)
            elif None not in self.pastThemes:
                # We pretend to have run the default theme, and then
                # install the default channels.  XXX: If Miro Guide isn't
                # installed by the theme and it doesn't provide a default
                # set of channels, we'll never install the Miro Guide.

                # This code would install the Miro Guide if it isn't
                # already installed
                # if guide.get_guide_by_url(prefs.CHANNEL_GUIDE_URL.default) is None:
                #     guide.ChannelGuide(prefs.CHANNEL_GUIDE_URL.default)
                self.pastThemes.append(None)
                self._install_default_feeds()
        else:
            # no theme
            self._install_default_feeds()
        signals.system.theme_first_run(self.theme)
Example #11
0
def create_engines():
    """Creates all the search engines specified in the
    ``resources/searchengines/`` directory and the theme searchengines
    directory.  After doing that, it adds an additional "Search All"
    engine.
    """
    global _engines
    _delete_engines()
    engines = _search_for_search_engines(resources.path("searchengines"))
    engines_dir = os.path.join(
        app.config.get(prefs.SUPPORT_DIRECTORY), "searchengines")
    engines.update(_search_for_search_engines(engines_dir))
    if app.config.get(prefs.THEME_NAME):
        theme_engines_dir = resources.theme_path(app.config.get(prefs.THEME_NAME),
                                                 'searchengines')
        engines.update(_search_for_search_engines(theme_engines_dir))
    for fn in engines.itervalues():
        _load_search_engine(fn)

    _engines.append(SearchEngineInfo(u"all", _("Search All"), u"", -1))
    _engines.sort(key=lambda x: (x.sort_order, x.name, x.title))

    # SEARCH_ORDERING is a comma-separated list of search engine names to
    # include.  An * as the last engine includes the rest of the engines.
    if app.config.get(prefs.SEARCH_ORDERING):
        search_names = app.config.get(prefs.SEARCH_ORDERING).split(',')
        new_engines = []
        if '*' in search_names and '*' in search_names[:-1]:
            raise RuntimeError('wildcard search ordering must be at the end')
        for name in search_names:
            if name != '*':
                engine = get_engine_for_name(name)
                if not engine:
                    warn(__file__, 'Invalid search name: %r' % name)
                else:
                    new_engines.append(engine)
                    _engines.remove(engine)
            else:
                new_engines.extend(_engines)
        _engines = new_engines