Example #1
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.columns_to_filter = [self.URL_COLUMN, self.TEXT_COLUMN]

        self._quickmark_cat = self.new_category("Quickmarks")
        self._bookmark_cat = self.new_category("Bookmarks")
        self._history_cat = self.new_category("History")

        quickmark_manager = objreg.get('quickmark-manager')
        quickmarks = quickmark_manager.marks.items()
        for qm_name, qm_url in quickmarks:
            self.new_item(self._quickmark_cat, qm_url, qm_name)
        quickmark_manager.added.connect(
            lambda name, url: self.new_item(self._quickmark_cat, url, name))
        quickmark_manager.removed.connect(self.on_quickmark_removed)

        bookmark_manager = objreg.get('bookmark-manager')
        bookmarks = bookmark_manager.marks.items()
        for bm_url, bm_title in bookmarks:
            self.new_item(self._bookmark_cat, bm_url, bm_title)
        bookmark_manager.added.connect(
            lambda name, url: self.new_item(self._bookmark_cat, url, name))
        bookmark_manager.removed.connect(self.on_bookmark_removed)

        self._history = objreg.get('web-history')
        self._max_history = config.get('completion', 'web-history-max-items')
        history = utils.newest_slice(self._history, self._max_history)
        for entry in history:
            self._add_history_entry(entry)
        self._history.add_completion_item.connect(self.on_history_item_added)
        self._history.cleared.connect(self.on_history_cleared)

        objreg.get('config').changed.connect(self.reformat_timestamps)
Example #2
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.columns_to_filter = [self.URL_COLUMN, self.TEXT_COLUMN]

        self._quickmark_cat = self.new_category("Quickmarks")
        self._bookmark_cat = self.new_category("Bookmarks")
        self._history_cat = self.new_category("History")

        quickmark_manager = objreg.get('quickmark-manager')
        quickmarks = quickmark_manager.marks.items()
        for qm_name, qm_url in quickmarks:
            self.new_item(self._quickmark_cat, qm_url, qm_name)
        quickmark_manager.added.connect(
            lambda name, url: self.new_item(self._quickmark_cat, url, name))
        quickmark_manager.removed.connect(self.on_quickmark_removed)

        bookmark_manager = objreg.get('bookmark-manager')
        bookmarks = bookmark_manager.marks.items()
        for bm_url, bm_title in bookmarks:
            self.new_item(self._bookmark_cat, bm_url, bm_title)
        bookmark_manager.added.connect(
            lambda name, url: self.new_item(self._bookmark_cat, url, name))
        bookmark_manager.removed.connect(self.on_bookmark_removed)

        self._history = objreg.get('web-history')
        self._max_history = config.get('completion', 'web-history-max-items')
        history = utils.newest_slice(self._history, self._max_history)
        for entry in history:
            if not entry.redirect:
                self._add_history_entry(entry)
        self._history.add_completion_item.connect(self.on_history_item_added)
        self._history.cleared.connect(self.on_history_cleared)

        objreg.get('config').changed.connect(self.reformat_timestamps)
Example #3
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self._quickmark_cat = self.new_category("Quickmarks")
        self._history_cat = self.new_category("History")

        quickmark_manager = objreg.get('quickmark-manager')
        quickmarks = quickmark_manager.marks.items()
        for qm_name, qm_url in quickmarks:
            self._add_quickmark_entry(qm_name, qm_url)
        quickmark_manager.added.connect(self.on_quickmark_added)
        quickmark_manager.removed.connect(self.on_quickmark_removed)

        self._history = objreg.get('web-history')
        max_history = config.get('completion', 'web-history-max-items')
        history = utils.newest_slice(self._history, max_history)
        for entry in history:
            self._add_history_entry(entry)
        self._history.item_about_to_be_added.connect(
            self.on_history_item_added)

        objreg.get('config').changed.connect(self.reformat_timestamps)
Example #4
0
 def test_count_much_bigger(self):
     """Test with a count which is much bigger than the iterable."""
     items = range(5)
     sliced = utils.newest_slice(items, 50)
     assert list(sliced) == list(items)
Example #5
0
 def test_count_equal(self):
     """Test with a count which is just as large as the iterable."""
     items = range(5)
     sliced = utils.newest_slice(items, 5)
     assert list(sliced) == list(items)
Example #6
0
 def test_count_smaller(self):
     """Test with a count which is exactly one smaller."""
     items = range(5)
     sliced = utils.newest_slice(items, 4)
     assert list(sliced) == [1, 2, 3, 4]
Example #7
0
 def test_count_much_smaller(self):
     """Test with a count which is much smaller than the iterable."""
     items = range(20)
     sliced = utils.newest_slice(items, 5)
     assert list(sliced) == [15, 16, 17, 18, 19]
Example #8
0
 def test_count_zero(self):
     """Test with a count of 0 (no elements)."""
     items = range(20)
     sliced = utils.newest_slice(items, 0)
     assert list(sliced) == []
Example #9
0
 def test_count_minus_one(self):
     """Test with a count of -1 (all elements)."""
     items = range(20)
     sliced = utils.newest_slice(items, -1)
     assert list(sliced) == list(items)
Example #10
0
 def test_count_minus_one(self):
     """Test with a count of -1 (all elements)."""
     items = range(20)
     sliced = utils.newest_slice(items, -1)
     assert list(sliced) == list(items)
Example #11
0
 def test_count_bigger(self):
     """Test with a count which is one bigger than the iterable."""
     items = range(5)
     sliced = utils.newest_slice(items, 6)
     self.assertEqual(list(sliced), list(items))
Example #12
0
 def test_count_much_bigger(self):
     """Test with a count which is much bigger than the iterable."""
     items = range(5)
     sliced = utils.newest_slice(items, 50)
     assert list(sliced) == list(items)
Example #13
0
 def test_count_equal(self):
     """Test with a count which is just as large as the iterable."""
     items = range(5)
     sliced = utils.newest_slice(items, 5)
     assert list(sliced) == list(items)
Example #14
0
 def test_count_smaller(self):
     """Test with a count which is exactly one smaller."""
     items = range(5)
     sliced = utils.newest_slice(items, 4)
     assert list(sliced) == [1, 2, 3, 4]
Example #15
0
 def test_count_much_smaller(self):
     """Test with a count which is much smaller than the iterable."""
     items = range(20)
     sliced = utils.newest_slice(items, 5)
     assert list(sliced) == [15, 16, 17, 18, 19]
Example #16
0
 def test_count_zero(self):
     """Test with a count of 0 (no elements)."""
     items = range(20)
     sliced = utils.newest_slice(items, 0)
     assert list(sliced) == []
Example #17
0
 def test_count_minus_two(self):
     """Test with a count of -2."""
     with pytest.raises(ValueError):
         utils.newest_slice([], -2)
Example #18
0
 def test_count_minus_two(self):
     """Test with a count of -2."""
     with pytest.raises(ValueError):
         utils.newest_slice([], -2)