diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-18 19:01:28 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-21 16:21:32 +0100 |
commit | 7ffd3d4f7e513cb729264d545a6ffb66560f74bc (patch) | |
tree | 38bc508f6fbf71d90811e40628dde43eacf69f22 | |
parent | cf8e5b029c59bb8ebc737e184c67574b8d745769 (diff) |
Display correct key bindings to release cursor
If the accels are enabled (with Spice controller custom bindings),
show the configured keybinding in the title bar.
-rw-r--r-- | src/virt-viewer-display-spice.c | 18 | ||||
-rw-r--r-- | src/virt-viewer-window.c | 19 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c index a5aa075..981fb57 100644 --- a/src/virt-viewer-display-spice.c +++ b/src/virt-viewer-display-spice.c @@ -181,6 +181,19 @@ virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self, 0, 0, dw, dh); } +static void +enable_accel_changed(VirtViewerApp *app, + GParamSpec *pspec G_GNUC_UNUSED, + VirtViewerDisplaySpice *self) +{ + if (virt_viewer_app_get_enable_accel(app)) { + /* disable default grab sequence */ + spice_display_set_grab_keys(self->priv->display, + spice_grab_sequence_new(0, NULL)); + } else { + spice_display_set_grab_keys(self->priv->display, NULL); + } +} GtkWidget * virt_viewer_display_spice_new(VirtViewerSessionSpice *session, @@ -188,6 +201,7 @@ virt_viewer_display_spice_new(VirtViewerSessionSpice *session, SpiceDisplay *display) { VirtViewerDisplaySpice *self; + VirtViewerApp *app; gint channelid; g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), NULL); @@ -227,6 +241,10 @@ virt_viewer_display_spice_new(VirtViewerSessionSpice *session, G_CALLBACK(virt_viewer_display_spice_size_allocate), self); + app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(session)); + g_signal_connect(app, "notify::enable-accel", G_CALLBACK(enable_accel_changed), self); + enable_accel_changed(app, NULL, self); + return GTK_WIDGET(self); } diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 62b6052..ec96532 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -943,10 +943,22 @@ virt_viewer_window_update_title(VirtViewerWindow *self) { VirtViewerWindowPrivate *priv = self->priv; char *title; - const char *ungrab = NULL; + gchar *ungrab = NULL; - if (priv->grabbed) - ungrab = _("(Press Ctrl+Alt to release pointer)"); + if (priv->grabbed) { + gchar *label; + + if (virt_viewer_app_get_enable_accel(priv->app)) { + GtkAccelKey key; + gtk_accel_map_lookup_entry("<virt-viewer>/view/release-cursor", &key); + label = gtk_accelerator_get_label(key.accel_key, key.accel_mods); + } else { + label = g_strdup(_("Ctrl+Alt")); + } + + ungrab = g_strdup_printf(_("(Press %s to release pointer)"), label); + g_free(label); + } if (!ungrab && !priv->subtitle) title = g_strdup(g_get_application_name()); @@ -966,6 +978,7 @@ virt_viewer_window_update_title(VirtViewerWindow *self) gtk_window_set_title(GTK_WINDOW(priv->window), title); g_free(title); + g_free(ungrab); } void |