JBrowser Source Docs
You are reading the documentation for JBrowser 2.0.1. The newest release is 2.0.3. Go to the latest documentation

jbrowser.models.state

Generated from the source code of JBrowser 2.0.1.

jbrowser/models/state.py · 440 lines

BrowserState: the single, centralised store of spaces, cards, focus and selection.

Every UI surface (sidebar, canvases, title bar, Lazy Toolbar) and every engine service observes this object through signals; none of them talk to each other directly.

Constants#

Name Value
MAX_STACK 3

BrowserState#

class BrowserState(QObject)source
BrowserState(parent: QObject | None=None)

Signals

Signal Arguments
spaceAdded (object, int)
spaceRemoved (object)
spaceUpdated (object)
spacesReordered ()
activeSpaceChanged (object, object)
tabAdded (object, int, bool)
tabRemoved (object, object)
tabMoved (object, int, int)
activeTabChanged (object, object)
selectionChanged (object)
tabArchived (dict)
dirty ()

BrowserState.space#

space(space_id: str) -> Space | Nonesource

BrowserState.active_space#

property active_spacesource

BrowserState.active_tab#

property active_tabsource

BrowserState.tab#

tab(tab_id: str) -> Tab | Nonesource

BrowserState.space_of#

space_of(tab: Tab | str) -> Space | Nonesource

BrowserState.all_tabs#

all_tabs() -> list[Tab]source

BrowserState.pinned_count#

static pinned_count(space: Space) -> intsource

BrowserState.selected_tabs#

selected_tabs(space: Space | None=None) -> list[Tab]source

BrowserState.add_space#

add_space(name: str, icon: str='🏠', color: str | None=None, incognito: bool=False, index: int | None=None, activate: bool=True, space_id: str | None=None, proxy: dict | None=None) -> Spacesource

BrowserState.remove_space#

remove_space(space_id: str) -> Nonesource

BrowserState.update_space#

update_space(space_id: str, **fields) -> Nonesource

BrowserState.move_space#

move_space(space_id: str, new_index: int) -> Nonesource

BrowserState.set_active_space#

set_active_space(space_id: str) -> Nonesource

BrowserState.cycle_space#

cycle_space(delta: int) -> Nonesource

BrowserState.add_tab#

add_tab(space_id: str, url: str='', *, index: int | None=None, activate: bool=True, width: float | None=None, title: str='', tab_id: str | None=None, sleeping: bool=False, history: bytes | None=None, zoom: float=1.0, muted: bool=False, pinned: bool=False, favourite_id: str='', stack: str='', stack_onto: str='') -> Tab | Nonesource

Add a card. stack restores a saved column; stack_onto puts the new card just below that card, in its column (when there is room).

BrowserState.remove_tab#

remove_tab(tab_id: str, remember: bool=True, history: bytes | None=None) -> Nonesource

BrowserState.move_tab#

move_tab(tab_id: str, new_index: int) -> Nonesource

BrowserState.set_pinned#

set_pinned(tab_id: str, pinned: bool) -> Nonesource

Pin (move to the end of the pinned block) or unpin (move just after it).

BrowserState.move_tab_to_space#

move_tab_to_space(tab_id: str, space_id: str) -> Tab | Nonesource

Cards cannot share engine state across spaces, so moving re-creates the card.

BrowserState.set_active_tab#

set_active_tab(tab_id: str, collapse_selection: bool=True) -> Nonesource

BrowserState.select_tab#

select_tab(tab_id: str, mode: str='single') -> Nonesource

mode: single | toggle (Ctrl+Click) | range (Shift+Click).

BrowserState.select_all#

select_all(space: Space | None=None) -> Nonesource

BrowserState.columns#

columns(space: Space) -> list[list[Tab]]source

The space's cards grouped into columns, left to right (a single card is a column of one).

BrowserState.column_of#

column_of(tab: Tab | str) -> list[Tab]source

BrowserState.can_stack_onto#

can_stack_onto(tab_id: str) -> boolsource

BrowserState.stack_tab#

stack_tab(tab_id: str, onto_id: str, above: bool=False) -> boolsource

Put a card into another card's column, just below it (or above it). Returns False when the column is full or either card is pinned.

BrowserState.unstack#

unstack(tab_id: str) -> Nonesource

Take a card out of its column; it becomes a column of its own just to the right.

BrowserState.normalize_stacks#

normalize_stacks(space: Space) -> Nonesource

Keep columns tidy after cards move or close: a stack id only counts for its first run of neighbouring cards, a column of one is no stack, and a column holds at most MAX_STACK cards.