Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/207'
Browse files Browse the repository at this point in the history
* origin/pr/207:
  Change color from #99bfff to #63a0ff
  Update color from blue to #99bfff
  Change color and punctuation
  Update actionable_widgets.py
  Fixing Pylint error and initial value for connection_timestamp
  Devices widget: label recently-connected devices as "NEW"
  Devices widget: label recently-connected devices as "NEW"
  • Loading branch information
marmarek committed Jul 18, 2024
2 parents 18ca655 + 35de124 commit 3f2817f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion qui/devices/actionable_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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 += ' <span foreground="#63a0ff"><b>NEW</b></span>'
self.device_label.set_markup(label_markup)

if self.device.attachments:
self.device_label.get_style_context().add_class("dev_attached")

Expand Down
2 changes: 2 additions & 0 deletions qui/devices/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions qui/devices/device_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import Set, List, Dict
import asyncio
import sys
import time

import importlib.resources

Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 3f2817f

Please sign in to comment.