Skip to content

Commit

Permalink
Modify submenu for internal qubes in qui-domains
Browse files Browse the repository at this point in the history
Now internal qubes get a title and a tooltip explanation,
plus the menu has only the shutdown and log options.

references QubesOS/qubes-issues#8064
  • Loading branch information
marmarta committed Mar 21, 2023
1 parent 7471a71 commit a944aee
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ install-icons:
cp icons/scalable/check_yes.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/check_yes.svg
cp icons/scalable/check_maybe.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/check_maybe.svg
cp icons/scalable/qubes_policy_editor.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/qubes-policy-editor.svg
cp icons/scalable/qui-domains-scalable.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/qui-domains-scalable.svg

install-autostart:
mkdir -p $(DESTDIR)/etc/xdg/autostart
Expand Down
16 changes: 16 additions & 0 deletions icons/scalable/qui-domains-scalable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 56 additions & 3 deletions qui/tray/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,23 @@ def open_file_manager(self, _item):
self.vm.name, str(ex)))


class InternalInfoItem(Gtk.MenuItem):
''' Restart menu Item. When activated shutdowns the domain and
then starts it again. '''

def __init__(self):
super().__init__()
self.label = Gtk.Label(xalign=0)
self.label.set_markup(_(
'<b>Internal qube</b>'))
self.set_tooltip_text(
'Internal qubes are used by the operating system. Do not modify'
' them or run programs in them unless you really '
'know what you are doing.')
self.add(self.label)
self.set_sensitive(False)


class StartedMenu(Gtk.Menu):
''' The sub-menu for a started domain'''

Expand Down Expand Up @@ -329,6 +346,39 @@ def __init__(self, vm, icon_cache):
self.show_all()


class InternalMenu(Gtk.Menu):
"""Sub-menu for Internal qubes"""
def __init__(self, vm, icon_cache, working_correctly=True):
"""
:param vm: relevant Internal qube
:param icon_cache: IconCache object
:param working_correctly: if True, the VM should have a Shutdown
option; otherwise, have a Kill option
"""
super().__init__()
self.vm = vm

self.add(InternalInfoItem())

logs = [
(_("Console Log"),
"/var/log/xen/console/guest-" + vm.name + ".log"),
(_("QEMU Console Log"),
"/var/log/xen/console/guest-" + vm.name + "-dm.log"),
]

for name, path in logs:
if os.path.isfile(path):
self.add(LogItem(name, path))

if working_correctly:
self.add(ShutdownItem(self.vm, icon_cache))
else:
self.add(KillItem(self.vm, icon_cache))

self.show_all()


def run_manager(_item):
# pylint: disable=consider-using-with
subprocess.Popen(['qubes-qube-manager'])
Expand Down Expand Up @@ -400,7 +450,10 @@ def set_label_icon(self):
self.set_image(self.decorator.icon())

def _set_submenu(self, state):
if state == 'Running':
if self.vm.features.get('internal', False):
submenu = InternalMenu(self.vm, self.icon_cache,
working_correctly=(state == 'Running'))
elif state == 'Running':
submenu = StartedMenu(self.vm, self.app, self.icon_cache)
elif state == 'Paused':
submenu = PausedMenu(self.vm, self.icon_cache)
Expand Down Expand Up @@ -470,8 +523,8 @@ def __init__(self, app_name, qapp, dispatcher, stats_dispatcher):
self.dispatcher = dispatcher
self.stats_dispatcher = stats_dispatcher

self.widget_icon = Gtk.StatusIcon()
self.widget_icon.set_from_icon_name('qui-domains')
self.widget_icon: Gtk.StatusIcon = Gtk.StatusIcon()
self.widget_icon.set_from_icon_name('qui-domains-scalable')
self.widget_icon.connect('button-press-event', self.show_menu)
self.widget_icon.set_tooltip_markup(
_('<b>Qubes Domains</b>\nView and manage running domains.'))
Expand Down
1 change: 1 addition & 0 deletions rpm_spec/qubes-desktop-linux-manager.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ gtk-update-icon-cache %{_datadir}/icons/Adwaita &>/dev/null || :
/usr/share/icons/hicolor/scalable/apps/check_maybe.svg
/usr/share/icons/hicolor/scalable/apps/check_yes.svg
/usr/share/icons/hicolor/scalable/apps/qubes-policy-editor.svg
/usr/share/icons/hicolor/scalable/apps/qui-domains-scalable.svg

/usr/share/gtksourceview-4/language-specs/qubes-rpc.lang

Expand Down

0 comments on commit a944aee

Please sign in to comment.