[Spice-commits] gtk/spicy.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Wed Oct 17 03:05:34 PDT 2012


 gtk/spicy.c |   27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

New commits:
commit f1b4c0922b447edb7ea099d0e211c8a361c49ef4
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Oct 16 18:16:05 2012 +0200

    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

diff --git a/gtk/spicy.c b/gtk/spicy.c
index 6390b79..5758cc4 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)
@@ -415,13 +421,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)
@@ -795,13 +794,6 @@ static const GtkActionEntry entries[] = {
         .callback    = G_CALLBACK(menu_cb_fullscreen),
         .accelerator = "<shift>F11",
     },{
-
-        /* Input menu */
-        .name        = "UngrabMouse",
-        .label       = N_("_Ungrab mouse"),
-        .callback    = G_CALLBACK(menu_cb_ungrab),
-        .accelerator = "<shift>F12",
-    },{
 #ifdef USE_SMARTCARD
 	.name        = "InsertSmartcard",
 	.label       = N_("_Insert Smartcard"),
@@ -903,7 +895,6 @@ static char ui_xml[] =
 "      <menuitem action='Statusbar'/>\n"
 "    </menu>\n"
 "    <menu action='InputMenu'>\n"
-"      <menuitem action='UngrabMouse'/>\n"
 #ifdef USE_SMARTCARD
 "      <menuitem action='InsertSmartcard'/>\n"
 "      <menuitem action='RemoveSmartcard'/>\n"


More information about the Spice-commits mailing list