Commit Graph

1160 Commits

Author SHA1 Message Date
Eduardo Lima (Etrunko)
40eec08817 iso-dialog: Use GtkHeaderBar
We now display the current ISO as subtitle on the HeaderBar. On the
glade UI file, we get rid of the GtkAlignment object that was used to
put some space between the tree view and dialog buttons. The "Select
ISO" label is gone too.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2021-09-15 11:28:45 -03:00
Eduardo Lima (Etrunko)
d451d6e4a4 Add Change CD button to toolbar
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2021-09-15 11:28:45 -03:00
Eduardo Lima (Etrunko)
c3c3a1faf6 ovirt-foreign-menu: Support changing ISO from Data StorageDomain
With the possibility of having ISO images in storage domains of DATA
type, we need to store the id of the object as well as its name. This is
not the case with ISO storage domains, which only hold the name of the
image. This patch makes it possible to use deal with both types
transparently for the user.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1835640

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2021-09-15 11:18:03 -03:00
Eduardo Lima (Etrunko)
24ce0d9c3b ovirt-foreign-menu: Remove unecessary strv_contains() function
This function only existed to make use of glib compat, now that we
require a version of glib that already exports the symbol, the call is
not required anymore.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2021-09-15 11:18:03 -03:00
Eduardo Lima (Etrunko)
be0dd059ac Update libgovirt requirements
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2021-09-15 11:18:03 -03:00
Daniel P. Berrangé
a8c781e85c Delete '-r' shortcut for --auto-resize
The '-r' shortcut was alread used for '--reconnect' in virt-viewer.
The --auto-resize arg is a fairly niche use case so doesn't really
need a shortcut.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-07 13:01:04 +01:00
Paul Donohue
f0cc7103be src: Support modifier-only hotkey for release-cursor
This is implemented by switching from GTK accelerators to using the
display's grab sequence handling when a modifier-only hotkey is
configured.

Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Paul Donohue
26f5f2a3f2 src: Fix smartcard and USB dynamic hotkey configuration
Previously, virt_viewer_update_smartcard_accels() and
virt_viewer_update_usbredir_accels() needed to be called after
configuring hotkeys and before any smartcard/usbredir devices were
connected in order to properly configure the hotkeys.  However, those
were not called if hotkeys were configured via the config file.

In addition, the code did not support reconfiguring hotkeys after
devices were connected, which could cause future problems, eg. if a GUI
is added to support reconfiguring hotkeys.

Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Paul Donohue
0a997601ab src: Unify hotkey setup from command line and config file
This is mostly just code de-duplication and cleanup.  The only
functional change is that the case-sensitive accel support from the
command-line hotkey handling now also applies to the config file.

Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Paul Donohue
af644ec423 src: Move virt_viewer_app_get_enable_accel() and virt_viewer_app_set_enable_accel()
No functional changes.  This is only to reduce clutter in the next few
commits.

Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Paul Donohue
87d8c80ba2 src: Add usb-device-reset hotkey support to config file
Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Paul Donohue
dde79e637a src: Fix hotkey GTK actions
"win.<action>" and "app.<action>" were mixed up in a few places.
Smartcard actions use "app" and other actions use "win".

Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Paul Donohue
4175930194 src: Release keyboard grab in addition to mouse grab when using spice
This requires spice-gtk 0.40 or later:
ea81b97f74

Signed-off-by: Paul Donohue <git@PaulSD.com>
2021-07-30 10:03:02 +00:00
Daniel P. Berrangé
2e6adf9b85 src: avoid warnings from use of G_GNUC_FALLTHROUGH
Since glib >= 2.69 we get warnings:

../src/ovirt-foreign-menu.c: In function 'ovirt_foreign_menu_next_async_step':
../src/ovirt-foreign-menu.c:319:13: error: Not available before 2.60 [-Werror]
  319 |         G_GNUC_FALLTHROUGH;
      |             ^~~~~~~~~~~~~~~
../src/ovirt-foreign-menu.c:345:13: error: Not available before 2.60 [-Werror]
  345 |         G_GNUC_FALLTHROUGH;
      |             ^~~~~~~~~~~~~~~
../src/ovirt-foreign-menu.c:351:13: error: Not available before 2.60 [-Werror]
  351 |         G_GNUC_FALLTHROUGH;
      |             ^~~~~~~~~~~~~~~
../src/ovirt-foreign-menu.c:357:13: error: Not available before 2.60 [-Werror]
  357 |         G_GNUC_FALLTHROUGH;
      |             ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

GLib is right to warn about this, since it does not know that we
provided our own back-compat definition of the macro. For now we have to
temporarily purge glib's macro entirely in order to get rid of the
warning that is bogus for our usage.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-07-27 16:50:04 +01:00
Daniel P. Berrangé
70fe65f188 Fix creation of window when using single QXL card with 2 heads
With a single QXL card with > 1 head, initially only the first head
is active. As a result virt-viewer will not create the windows when
it first connects. They have to be created explicitly when user
requests to activate the window.

Fixes: https://gitlab.com/virt-viewer/virt-viewer/-/issues/46
Fixes: https://gitlab.com/virt-viewer/virt-viewer/-/issues/37
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-06-28 18:47:02 +01:00
Daniel P. Berrangé
5367a7b123 src: relax minimum desktop width/height
The desktop-width / desktop-height properties are set to have a min
valid value of 320x200, and this also matches the minimum window
dimensions reported to GTK.

In practice when a guest restarts, spice can report width/height
values smaller than this

(virt-viewer:9359): GLib-GObject-WARNING **: 12:57:05.556: value "64" of type 'gint' is invalid or out of range for property 'desktop-width' of type 'gint'

(virt-viewer:9359): GLib-GObject-WARNING **: 12:57:05.556: value "64" of type 'gint' is invalid or out of range for property 'desktop-height' of type 'gint'

There is not an obvious need to enforce this minimum on the properties,
as the window dimension sizing will do the right thing regardless.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-05-26 17:32:19 +01:00
Daniel P. Berrangé
aa6b4b40b8 src: update action sensitivity when creating window
If we don't explicitly set action sensitivity after associating a
display with the window, the actions will end up with the wrong
state. This exhibits itself as send key actions being marked
disabled despite being connected,

Related: https://gitlab.com/virt-viewer/virt-viewer/-/issues/37
Closes: https://gitlab.com/virt-viewer/virt-viewer/-/issues/41
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-05-26 17:32:08 +01:00
Daniel P. Berrangé
4820d05c82 src: correctly set display state when cancelling quit request
When the last window is closed we optionally show a confirmation dialog
to check if user wants to quit. If the user cancels, we need to ensure
the display menu state gets set back to checked.

We called g_action_change_state correctly, but a later call to
g_simple_action_set_state used the "visible" variable which was not
correctly reset back to TRUE upon cancel.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-05-05 12:40:52 +00:00
Daniel P. Berrangé
73f567ea94 src: ensure auth entry fields are cleared
If authentication fails we reshow the same authentication dialog box
again. Rather than leaving the previous incorrect information in the
text entry boxes we need to clear them.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-05-05 12:00:29 +01:00
Ján Tomko
9e36a59c80 src: initialize keymaps variable
My clang version 11.0.0 (Fedora 11.0.0-2.fc33) complains:
../src/virt-viewer-app.c:610:9: error: variable 'keymaps' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
    if (keymap_string) {
        ^~~~~~~~~~~~~
../src/virt-viewer-app.c:614:10: note: uninitialized use occurs here
    if (!keymaps || g_strv_length(keymaps) == 0) {
         ^~~~~~~
../src/virt-viewer-app.c:610:5: note: remove the 'if' if its condition is always true
    if (keymap_string) {
    ^~~~~~~~~~~~~~~~~~~
../src/virt-viewer-app.c:595:27: note: initialize the variable 'keymaps' to silence this warning
    gchar **key, **keymaps, **valkey, **valuekeys = NULL;
                          ^
                           = NULL
1 error generated.

Initialize the variable to fix the uninitialized use.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-04-23 15:59:49 +02:00
Daniel P. Berrangé
16714e97a5 src: fix case sensitive accelerator parsing
The gtk_accelerator_parse code is case sensitive when resolving key
names, however, the spice_hotkey_to_gtk_accelerator method converts
everything to uppercase. The latter allows the user to provide "f"
as the key and get it converted to "F" which matches a GDK key name.
The latter breaks for most other keys though, eg "comma" is required
to be all lowercase and "Menu" must have the initial capital.

To cope with this we try the gtk_accelerator_parse call twice, once
with the spice munged key name for back compat, and once with the
exact user specified key name.

https://gitlab.com/virt-viewer/virt-viewer/-/issues/30
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-19 14:54:37 +01:00
Daniel P. Berrangé
30e6f4cd03 src: update for renamed GTK-VNC zoom API
The API was renamed before GTK-VNC 1.2.0 release.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-14 11:39:26 +01:00
Daniel P. Berrangé
47c22dc23b src: enable remote desktop resize with VNC
GTK-VNC has native support for remote desktop resize, provided that we
always give the widget the full available allocation. This requires that
we turn off VirtViewerDisplay's code for keeping aspect ratio, and
instead enable GTK-VNC's equivalent.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:08:07 +01:00
Daniel P. Berrangé
20f5b18b6a src: add prop to control forced aspect ratio
When the VirtViewerDisplay class resizes the child display widget, it
attempts to preserve the remote desktop aspect ratio. This is useful in
general, if the display widget can't do this itself. The implication,
however, is that VirtViewerDisplay also has to take ownership of the
remote framebuffer resize functionality.

It is thus useful to disable VirtViewerDisplay's aspect ratio
preservation when the display widget can do this natively, as it can
then also do desktop resizes natively.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:08:07 +01:00
Daniel P. Berrangé
e9e2ebb796 src: add --auto-resize <always|never> CLI arg
This is used to control whether resizing of the remote framebuffer
is permitted.

Fixes: https://gitlab.com/virt-viewer/virt-viewer/-/issues/20
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:08:06 +01:00
Daniel P. Berrangé
707f74b9c4 src: add menu to control whether framebuffer resize is attempted
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:07:08 +01:00
Daniel P. Berrangé
512efe70c6 src: initialize actions during instance init
Currently the GActionMap is registered during the application
startup. This takes place after the command line args are processed,
so prevents the CLI processing from using actions.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:07:08 +01:00
Daniel P. Berrangé
83db5b3c64 src: remove unused property constant
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:07:08 +01:00
Daniel P. Berrangé
3125e8f507 src: fix version check for power control
The next gtk-vnc will be 1.2.0, not 2.0.0

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 15:07:08 +01:00
Daniel P. Berrangé
15fbaa3fb4 src: introduce "--cursor auto|local" command line
Normally we will honour the server requested behaviour for cursor,
either letting the server render it directly, or locally rendering
a cursor that the server provided us.

There are times, however, where the server does the wrong thing. For
example it might tell us to render an empty cursor, leaving the user
with no visible cursor at all. In this case it can be helpful to ignore
what the server requests, and always display the default local cursor.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-04-08 12:52:59 +00:00
Daniel P. Berrangé
ada810c088 src: support power control actions with VNC
VNC can support graceful shutdown, hard reset and hard power off.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-23 17:59:29 +00:00
Daniel P. Berrangé
f42a1a7eaa src: conditionally enable VM action UIs
We only want to enable VM actions that are supported by
the session.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-23 17:59:29 +00:00
Daniel P. Berrangé
897543880c src: wire up reporting of whether VM actions are supported in SPICE
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-23 17:59:29 +00:00
Daniel P. Berrangé
27aa853981 src: add method to test whether a VM action is supported
SPICE provides a number of VM actions, but they are only supported if
the QMP tunnel is available. VNC doesn't currently support any, but
in future it will support some.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-23 17:59:29 +00:00
Daniel P. Berrangé
6db5b71419 src: hide password/username auth widgets if not required
When a password is sufficiently, we should not even show the username
field, and vica-verca.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Daniel P. Berrangé
1d11dd55da src: cancel auth dialog when closing session
This ensures that the application exits when the user presses Ctrl-C
while an auth dialog is open.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Daniel P. Berrangé
247d91d889 src: switch auth dialog to use a GTK UI template
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Daniel P. Berrangé
d59f550d21 src: improve spacing between password box and buttons in auth dialog
The standard layout uses 6 pixels spacing between controls.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Daniel P. Berrangé
abbd076fdb src: use embedded eye icon in password entry box
This improves the UI for the password auth box by using an inline icon
for showing/hiding the password text. This is the UI pattern uses by
GNOME shell and other GTK applications.

The two svg files added here are copied from the GTK4 codebase which
is under the LGPLv2+.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Daniel P. Berrangé
c6f429627c src: remove SIGINT handler after first firing
If you press Ctrl-C while the auth dialog is active it gets ignored
because calling g_application_quit() won't break out of the model
g_dialog_run() call.

By removing the SIGINT handler after first firing, we can at least let
the user press Ctrl-C a second time to force quit.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Daniel P. Berrangé
5b44064b35 src: use the same application ID for remote-viewer and virt-viewer
Gtk uses the application ID to lookup resource entries compiled into the
application. The application ID must match the path in the gresource.xml
file for this to work correctly.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-18 11:26:37 +00:00
Victor Toso
81129f8eb1 build: fix build without gtk-vnc
Without gtk-vnc we get implicit function declaration for
VIRT_VIEWER_IS_SESSION_VNC. Introduced at 8bc91ac "session: remove
"session-error" signal" in 2021-02-18

As we are already using #ifdef here, I've also changed the ternary to
an if for clarity.

Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-03-08 17:05:42 +01:00
Daniel P. Berrangé
7040dded11 icons: remove obsolete usb icon
We are now using a standard symbolic icon so don't need the custom USB
icon.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-03-08 12:33:06 +00:00
Daniel P. Berrangé
febf72fe26 src: switch to preferring gtk dark theme
This enables the app to use the dark theme when running in environments
where a dark theme is available.

This is not done in Windows because the dark theme looks quite odd when
run on older versions of Windows where GTK can't replace the titlebars
by default.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00
Daniel P. Berrangé
0f1c12dc38 src: add help window showing keyboard shortcuts
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00
Daniel P. Berrangé
49a67971af src: make use of header bar subtitle for ungrab hint
The header bar includes space for both a title and subtitle. By using
the latter for the ungrab hint, we avoid having such a long title.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00
Daniel P. Berrangé
c43eb057bd src: convert full screen toolbar to GtkHeaderBar
The user interface for the fullscreen toolbar is now identical to that
seen when non-fullscreen. All that differs is that the toolbar autohides
in fullscreen mode and doesn't expand to fill the window width.

There is a complication with the timed revealer and menus. With
traditional GtkMenus, it appears a grab is held as long as the menu is
open, so the revealer won't hide the toolbar. With modern GtkPopover
based menus, however, the revealer hides the toolbar despite the menu
being open, and thus in turn hides the menu.

This hacks around the problem by setting the header buttons to force use
of a traditional GtkMenu instead of a GtkPopover. It is not quite as
visually pretty, but at least it works.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00
Daniel P. Berrangé
bb9664de38 src: switch main window to use GtkHeaderBar
This removes the main menu bar in favour of using the GtkHeaderBar with
integrated bars. This reduces the amount of vertical screen real estate
consumed by the application, leaving more for the guest display. The new
buttons are laid out to make the more common actions available with a
single click.

The buttons are grouped into two sets. On the left hand side of the
header are buttons that are interacting with the server

 - Send key
 - USB device selection
 - Monitor selection and VM pause/shutdown

whle on the right hand side are buttons interacting with the local user
interface

 - Fullscreen
 - Preferences / About / Guest detail / zoom level

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00
Daniel P. Berrangé
2f11e0a407 src: convert accelerator handling over to actions
This better decouples the accelerator handling from the current user
interface design.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00
Daniel P. Berrangé
407836ecee src: convert displays menu to use actions
This better decouples the user interface from the implementation.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-02-19 12:36:07 +00:00