Skip to content

Commit

Permalink
Add emblem for connected state
Browse files Browse the repository at this point in the history
  • Loading branch information
cschramm committed Oct 20, 2022
1 parent 6014065 commit 803e9b7
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 8 deletions.
14 changes: 8 additions & 6 deletions blueman/gui/manager/ManagerDeviceList.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@ def get_icon_info(self, icon_name: str, size: int = 48, fallback: bool = True) -

return icon_info

def make_device_icon(self, icon_info: Gtk.IconInfo, is_paired: bool = False, is_trusted: bool = False,
is_blocked: bool = False) -> cairo.Surface:
def _make_device_icon(self, icon_info: Gtk.IconInfo, is_paired: bool, is_connected: bool, is_trusted: bool,
is_blocked: bool) -> cairo.Surface:
window = self.get_window()
scale = self.get_scale_factor()
target = icon_info.load_surface(window)
ctx = cairo.Context(target)

if is_paired:
_icon_info = self.get_icon_info("blueman-paired-emblem", 16, False)
if is_connected or is_paired:
icon = "blueman-connected-emblem" if is_connected else "blueman-paired-emblem"
_icon_info = self.get_icon_info(icon, 16, False)
assert _icon_info is not None
paired_surface = _icon_info.load_surface(window)
ctx.set_source_surface(paired_surface, 1 / scale, 1 / scale)
Expand Down Expand Up @@ -628,8 +629,9 @@ def _set_cell_data(self, _col: Gtk.TreeViewColumn, cell: Gtk.CellRenderer, model
tree_iter: Gtk.TreeIter, data: Optional[str]) -> None:
tree_iter = model.convert_iter_to_child_iter(tree_iter)
if data is None:
row = self.get(tree_iter, "icon_info", "trusted", "paired", "blocked")
surface = self.make_device_icon(row["icon_info"], row["paired"], row["trusted"], row["blocked"])
row = self.get(tree_iter, "icon_info", "paired", "connected", "trusted", "blocked")
surface = self._make_device_icon(row["icon_info"], row["paired"],
row["connected"], row["trusted"], row["blocked"])
cell.set_property("surface", surface)
else:
window = self.get_window()
Expand Down
5 changes: 3 additions & 2 deletions data/icons/hicolor/scalable/emblems/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ context = emblems
iconsdir = $(themedir)/$(size)/$(context)

icons_DATA = \
blueman-blocked-emblem.svg \
blueman-paired-emblem.svg \
blueman-blocked-emblem.svg \
blueman-connected-emblem.svg \
blueman-paired-emblem.svg \
blueman-trusted-emblem.svg

EXTRA_DIST = $(icons_DATA)
85 changes: 85 additions & 0 deletions data/icons/hicolor/scalable/emblems/blueman-connected-emblem.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 803e9b7

Please sign in to comment.