From 0128c8f569ed4adf2a77299537311031fc6f517d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 16 Oct 2012 18:16:05 +0200 Subject: [PATCH 15/21] spicy: show the correct ungrab key combination The gtk accelerator for ungrab is useless, since it has to be handled by the spice widget only. It could be useful to still show the ungrab key sequence in the menu (for help), but unfortunately, spice-gtk grab sequence syntax is not the same as gtk accelerator syntax, and that would be needlessly complicated to handle. Also correctly show the configured sequence in the status bar when the widget has the grab. https://bugzilla.redhat.com/show_bug.cgi?id=851090 --- gtk/spicy.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/gtk/spicy.c b/gtk/spicy.c index 142fc03..080ae72 100644 --- a/gtk/spicy.c +++ b/gtk/spicy.c @@ -305,17 +305,23 @@ static int connect_dialog(SpiceSession *session) static void update_status_window(SpiceWindow *win) { - char status[256]; + gchar *status; if (win == NULL) return; + if (win->mouse_grabbed) { - snprintf(status, sizeof(status), _("Use Shift+F12 to ungrab mouse.")); + SpiceGrabSequence *sequence = spice_display_get_grab_keys(SPICE_DISPLAY(win->spice)); + gchar *seq = spice_grab_sequence_as_string(sequence); + status = g_strdup_printf(_("Use %s to ungrab mouse."), seq); + g_free(seq); } else { - snprintf(status, sizeof(status), _("mouse: %s, agent: %s"), + status = g_strdup_printf(_("mouse: %s, agent: %s"), win->conn->mouse_state, win->conn->agent_state); } + gtk_label_set_text(GTK_LABEL(win->status), status); + g_free(status); } static void update_status(struct spice_connection *conn) @@ -380,13 +386,6 @@ static void menu_cb_fullscreen(GtkAction *action, void *data) window_set_fullscreen(win, !win->fullscreen); } -static void menu_cb_ungrab(GtkAction *action, void *data) -{ - SpiceWindow *win = data; - - spice_display_mouse_ungrab(SPICE_DISPLAY(win->spice)); -} - #ifdef USE_SMARTCARD static void enable_smartcard_actions(SpiceWindow *win, VReader *reader, gboolean can_insert, gboolean can_remove) @@ -760,13 +759,6 @@ static const GtkActionEntry entries[] = { .callback = G_CALLBACK(menu_cb_fullscreen), .accelerator = "F11", },{ - - /* Input menu */ - .name = "UngrabMouse", - .label = N_("_Ungrab mouse"), - .callback = G_CALLBACK(menu_cb_ungrab), - .accelerator = "F12", - },{ #ifdef USE_SMARTCARD .name = "InsertSmartcard", .label = N_("_Insert Smartcard"), @@ -868,7 +860,6 @@ static char ui_xml[] = " \n" " \n" " \n" -" \n" #ifdef USE_SMARTCARD " \n" " \n" -- 1.7.12.1