diff --git a/qui/devices/actionable_widgets.py b/qui/devices/actionable_widgets.py index 34c69f0e..266bd8a1 100644 --- a/qui/devices/actionable_widgets.py +++ b/qui/devices/actionable_widgets.py @@ -34,6 +34,7 @@ from gi.repository import Gtk, GdkPixbuf, GLib # isort:skip from . import backend +import time def load_icon(icon_name: str, backup_name: str, size: int = 24): @@ -393,6 +394,11 @@ def __init__(self, device: backend.Device, variant: str = 'dark'): self.device = device self.variant = variant + # add NEW! label for new devices for 10 minutes on 1st view + self._new_device_label_timout = 10 * 60 + # reduce NEW! label timeout to 2 minutes after 1st view + self._new_device_label_afterview = 2 * 60 + self.get_style_context().add_class('main_device_item') # the part that is common to all devices @@ -401,7 +407,13 @@ def __init__(self, device: backend.Device, variant: str = 'dark'): self.device_icon.set_valign(Gtk.Align.CENTER) self.device_label = Gtk.Label(xalign=0) - self.device_label.set_markup(device.name) + + label_markup = device.name + if (device.connection_timestamp and + int(time.monotonic() - device.connection_timestamp) < 120): + label_markup += ' NEW' + self.device_label.set_markup(label_markup) + if self.device.attachments: self.device_label.get_style_context().add_class("dev_attached") diff --git a/qui/devices/backend.py b/qui/devices/backend.py index 1dfaacd9..449f7d21 100644 --- a/qui/devices/backend.py +++ b/qui/devices/backend.py @@ -100,6 +100,8 @@ def __init__(self, dev: qubesadmin.devices.DeviceInfo, self._dev: qubesadmin.devices.DeviceInfo = dev self.__hash = hash(dev) self._port: str = '' + # Monotonic connection timestamp only for new devices + self.connection_timestamp: float = None self._dev_name: str = getattr(dev, 'description', 'unknown') if dev.devclass == 'block' and 'size' in dev.data: diff --git a/qui/devices/device_widget.py b/qui/devices/device_widget.py index 386b282d..44d0fd9a 100644 --- a/qui/devices/device_widget.py +++ b/qui/devices/device_widget.py @@ -20,6 +20,7 @@ from typing import Set, List, Dict import asyncio import sys +import time import importlib.resources @@ -130,6 +131,7 @@ def device_list_update(self, vm, _event, **_kwargs): for dev_name, dev in changed_devices.items(): if dev_name not in self.devices: + dev.connection_timestamp = time.monotonic() self.devices[dev_name] = dev self.emit_notification( _("Device available"),