Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qui-devices refactor #55

Merged
merged 2 commits into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions qui/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def memory(self, memory=0) -> Gtk.Label:
def icon(self) -> Gtk.Image:
''' Returns a `Gtk.Image` containing the colored lock icon '''
icon_vm = Gtk.IconTheme.get_default().load_icon(
self.vm.label.icon, 16, 0)
self.vm.icon, 16, 0)
icon_img = Gtk.Image.new_from_pixbuf(icon_vm)
return icon_img

Expand All @@ -65,7 +65,7 @@ def netvm(self) -> Gtk.Label:
return label


def device_hbox(device, frontend_domains=None) -> Gtk.Box:
def device_hbox(device) -> Gtk.Box:
''' Returns a :class:`Gtk.Box` containing the device name & icon.. '''
if device.devclass == 'block':
icon = 'drive-removable-media'
Expand All @@ -78,11 +78,11 @@ def device_hbox(device, frontend_domains=None) -> Gtk.Box:
dev_icon = create_icon(icon)

name_label = Gtk.Label(xalign=0)
name = "{}:{} - {}".format(device.backend_domain.name, device.ident,
name = "{}:{} - {}".format(device.backend_domain, device.ident,
device.description)
if frontend_domains:
if device.attachments:
name_label.set_markup('<b>{} ({})</b>'.format(
name, ", ".join([vm.name for vm in frontend_domains])))
name, ", ".join([vm for vm in device.attachments])))
else:
name_label.set_text(name)
name_label.set_max_width_chars(64)
Expand All @@ -106,7 +106,12 @@ def device_domain_hbox(vm, attached: bool) -> Gtk.Box:
add_icon = create_icon('list-add')
hbox.pack_start(add_icon, False, False, 5)

name = Gtk.Label(vm.name, xalign=0)
name = Gtk.Label(xalign=0)
if attached:
name.set_markup('<b>{}</b>'.format(vm.vm_name))
else:
name.set_text(vm.vm_name)

hbox.pack_start(name, True, True, 5)
return hbox

Expand Down
Loading