コード例 #1
0
    def __init__(self, todo_filename, text_editor=None, invert_icon=False):
        """Sets the filename, loads the list of items from the file, builds the
        indicator, &c."""
        if text_editor:
            self.text_editor = text_editor
        else:
            self.text_editor = DEFAULT_EDITOR

        if invert_icon:
            self.icon_path = DARK_ICON
        else:
            # Default to light icon, assuming dark panel background:
            self.icon_path = LIGHT_ICON

        # Initialize the main list object:
        self.todo_list = TodoTxtList(todo_filename)

        # Non-list menu items:
        self._setup_menu_items()

        # Necessary for threaded notifications:
        GObject.threads_init()

        # Does the GUI need to catch up with our list file?
        self.list_updated_flag = False

        # Creates self.ind, the main indicator object:
        self._build_indicator()

        # Starts up inotify, watches our list file:
        self._setup_inotify()

        # Add timeout function, allows threading to not fart all over itself.
        # Can't use Gobject.idle_add() since it rudely 100%s the CPU.
        GObject.timeout_add(500, self._update_if_todo_file_changed)