コード例 #1
0
ファイル: signalfilter.py プロジェクト: AdaJass/qutebrowser
    def _filter_signals(self, signal, tab, *args):
        """Filter signals and trigger TabbedBrowser signals if needed.

        Triggers signal if the original signal was sent from the _current_ tab
        and not from any other one.

        The original signal does not matter, since we get the new signal and
        all args.

        Args:
            signal: The signal to emit if the sender was the current widget.
            tab: The WebView which the filter belongs to.
            *args: The args to pass to the signal.
        """
        log_signal = debug.signal_name(signal) not in self.BLACKLIST
        tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                    window=self._win_id)
        try:
            tabidx = tabbed_browser.indexOf(tab)
        except RuntimeError:
            # The tab has been deleted already
            return
        if tabidx == tabbed_browser.currentIndex():
            if log_signal:
                log.signals.debug("emitting: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
            signal.emit(*args)
        else:
            if log_signal:
                log.signals.debug("ignoring: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
コード例 #2
0
ファイル: signalfilter.py プロジェクト: xManusx/qutebrowser
    def _filter_signals(self, signal, tab, *args):
        """Filter signals and trigger TabbedBrowser signals if needed.

        Triggers signal if the original signal was sent from the _current_ tab
        and not from any other one.

        The original signal does not matter, since we get the new signal and
        all args.

        Args:
            signal: The signal to emit if the sender was the current widget.
            tab: The WebView which the filter belongs to.
            *args: The args to pass to the signal.
        """
        log_signal = debug.signal_name(signal) not in self.BLACKLIST
        tabbed_browser = objreg.get('tabbed-browser',
                                    scope='window',
                                    window=self._win_id)
        try:
            tabidx = tabbed_browser.indexOf(tab)
        except RuntimeError:
            # The tab has been deleted already
            return
        if tabidx == tabbed_browser.currentIndex():
            if log_signal:
                log.signals.debug("emitting: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
            signal.emit(*args)
        else:
            if log_signal:
                log.signals.debug("ignoring: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
コード例 #3
0
ファイル: signalfilter.py プロジェクト: mkonig/qutebrowser
    def create(self, signal, tab):
        """Factory for partial _filter_signals functions.

        Args:
            signal: The pyqtBoundSignal to filter.
            tab: The WebView to create filters for.

        Return:
            A partial function calling _filter_signals with a signal.
        """
        log_signal = debug.signal_name(signal) not in self.BLACKLIST
        return functools.partial(
            self._filter_signals, signal=signal,
            log_signal=log_signal, tab=tab)
コード例 #4
0
def test_signal_name(signal, expected):
    assert debug.signal_name(signal) == expected
コード例 #5
0
ファイル: test_debug.py プロジェクト: vyp/qutebrowser
def test_signal_name(signal, expected):
    assert debug.signal_name(signal) == expected
コード例 #6
0
ファイル: test_debug.py プロジェクト: peterlvilim/qutebrowser
 def test_signal_name(self):
     """Test signal_name()."""
     self.assertEqual(debug.signal_name(self.signal), 'fake')
コード例 #7
0
ファイル: test_debug.py プロジェクト: HalosGhost/qutebrowser
 def test_signal_name(self):
     """Test signal_name()."""
     self.assertEqual(debug.signal_name(self.signal), 'fake')
コード例 #8
0
def test_signal_name(cls, signal, bound):
    base = cls() if bound else cls
    sig = getattr(base, signal)
    assert debug.signal_name(sig) == signal
コード例 #9
0
ファイル: test_signal.py プロジェクト: JIVS/qutebrowser
def test_signal_name(signal):
    """Test signal_name()."""
    assert debug.signal_name(signal) == 'fake'
コード例 #10
0
ファイル: test_signal.py プロジェクト: andor44/qutebrowser
def test_signal_name(signal):
    """Test signal_name()."""
    assert debug.signal_name(signal) == 'fake'