def change_bookmarks(self, should_add):
        """Add/remove current directory from bookmarks."""
        ### retrieve the directory currently loaded in the
        ### directory panel
        current_dir = self.dir_panel.current_dir

        ### retrieve the bookmarks saved on file
        bookmarks = load_pyl(BOOKMARKS_FILE)

        ### if we mean to add the current directory as
        ### a bookmark...

        if should_add:

            ## if the directory is not present in the
            ## bookmarks, add it and sort the bookmarks
            ## by the name of the directory

            if str(current_dir) not in bookmarks:

                bookmarks.append(str(current_dir))
                bookmarks.sort(key=lambda path: Path(path).name)

            ## otherwise there's no need to add what is
            ## already there, so we just notify the user
            ## and leave this method by returning

            else:

                create_and_show_dialog(
                    "Current directory is already bookmarked.",
                    level_name='info',
                    unhighlighter_obj=self.semitransp_obj,
                )

                return

        ### otherwise, if we mean to remove the current
        ### directory from the bookmarks...

        else:

            ## if the directory is present in the
            ## bookmarks, remove it

            if str(current_dir) in bookmarks:
                bookmarks.remove(str(current_dir))

            ## otherwise there's no need to remove what
            ## isn't even there, so we just notify the user
            ## and leave this method by returning

            else:

                create_and_show_dialog(
                    (
                        "Current directory isn't bookmarked, so"
                        " there's no point in removing it from"
                        " bookmarks."
                    ),
                    level_name='info',
                    unhighlighter_obj=self.semitransp_obj,
                )

                return

        ### now that the bookmars were changed, override
        ### the bookmarks file, then update the bookmarks
        ### show on this bookmark panel

        save_pyl(bookmarks, BOOKMARKS_FILE)
        self.update_bookmarks()
Add/remove current directory from bookmarks.
nodezator/fileman/bookmarkpanel/main.py