def get_background_items( # pylint: disable=arguments-differ self, _, folder: GObject) -> list[Nemo.MenuItem]|None: ''' Called when context menu is called with no file objects selected. :param folder: Nemo's current working directory. ''' folder = urlparse(folder.get_uri()).path files = [uqp(os.path.join(folder, f)) for f in os.listdir(uqp(folder)) if os.path.isfile(uqp(os.path.join(folder, f))) and f.lower().endswith(EXTENSIONS)] if all(file.endswith('png') for file in files): crush = Nemo.MenuItem( name='CrushImages', label='Optimize image(s) with pngcrush', tip='Optimize image filesizes with pngcrush' ) crush.connect('activate', crush_images, files) return [crush] if any(file.endswith(EXTENSIONS) for file in files): convert = Nemo.MenuItem( name="ConvertAllImagestoPNG", label="Convert all images to PNG", tip="Convert all images to PNG" ) convert.connect('activate', convert_images, files) crush = Nemo.MenuItem( name='ConvertandCrush', label="Convert images to PNG and optimize", tip="Convert images to PNG and optimize filesizes with pngcrush" ) crush.connect('activate', convert_and_crush, files) return [convert, crush]