Beispiel #1
0
    for icon_name in icon_names:
        for type, size in (('icon', '32'), ('logo', '75')):
            key = '%s_%s' % (icon_name, type)
            # Look for a usable image file.
            for file_name in get_pixmap_file_names(icon_name, size):
                file_path = os.path.join(pixmap_path, file_name)
                try:
                    pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
                    break
                except gobject.GError:
                    # Try again.
                    pass
            else:
                log.warn('Could not find the icon for %s at '
                        'any of (%s) in %s' % (
                            icon_name,
                            ', '.join(get_pixmap_file_names(icon_name, size)),
                            pixmap_path))
                continue
            iconset = gtk.IconSet(pixbuf)
            iconfactory.add(key, iconset)
            log.debug('Register %s icon name for file %s' % (key, file_path))
    iconfactory.add_default()


def get_os_icon(host):
    osmatch = host.get_best_osmatch()
    if osmatch and osmatch['osclasses']:
        osclass = osmatch['osclasses'][0]
    else:
        osclass = None
Beispiel #2
0
    for icon_name in icon_names:
        for type, size in (('icon', '32'), ('logo', '75')):
            key = '%s_%s' % (icon_name, type)
            # Look for a usable image file.
            for file_name in get_pixmap_file_names(icon_name, size):
                file_path = os.path.join(pixmap_path, file_name)
                try:
                    pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
                    break
                except gobject.GError:
                    # Try again.
                    pass
            else:
                log.warn('Could not find the icon for %s at '
                        'any of (%s) in %s' % (
                            icon_name,
                            ', '.join(get_pixmap_file_names(icon_name, size)),
                            pixmap_path))
                continue
            iconset = gtk.IconSet(pixbuf)
            iconfactory.add(key, iconset)
            log.debug('Register %s icon name for file %s' % (key, file_path))
    iconfactory.add_default()


def get_os_icon(host):
    osmatch = host.get_best_osmatch()
    if osmatch and osmatch['osclasses']:
        osclass = osmatch['osclasses'][0]
    else:
        osclass = None