[Spice-devel] [spice-gtk PATCH] spicy: Make "CopyToGuest" and "PasteFromGuest" insensitive if spice agent is not connected

Hans de Goede hdegoede at redhat.com
Mon Sep 24 00:53:33 PDT 2012


Hi,

Thanks, looks good, so I've added it to git master. Notice though that
spicy is merely a little spice-gtk test-client, and our prefered spice-client
is remote-viewer (which is part of virt-viewer).

Regards,

Hans


On 09/24/2012 09:27 AM, Dunrong Huang wrote:
> "CopyToGuest" and "CopyToGuest" can not work if spice agent is not
> connected, e.g. guest does not install or enable spice agent, or spice
> server does not create vdagent channel.
>
> In these cases, make those item insensitive.
>
> Signed-off-by: Dunrong Huang <riegamaths at gmail.com>
> ---
>   gtk/spicy.c | 38 ++++++++++++++++++++++++++++++++++++++
>   1 个文件被修改,插入 38 行(+)
>
> diff --git a/gtk/spicy.c b/gtk/spicy.c
> index 142fc03..6390b79 100644
> --- a/gtk/spicy.c
> +++ b/gtk/spicy.c
> @@ -329,6 +329,41 @@ static void update_status(struct spice_connection *conn)
>       }
>   }
>
> +static const char *spice_edit_properties[] = {
> +    "CopyToGuest",
> +    "PasteFromGuest",
> +};
> +
> +static void update_edit_menu_window(SpiceWindow *win)
> +{
> +    int i;
> +    GtkAction *toggle;
> +
> +    if (win == NULL) {
> +        return;
> +    }
> +
> +    /* Make "CopyToGuest" and "PasteFromGuest" insensitive if spice
> +     * agent is not connected */
> +    for (i = 0; i < G_N_ELEMENTS(spice_edit_properties); i++) {
> +        toggle = gtk_action_group_get_action(win->ag, spice_edit_properties[i]);
> +        if (toggle) {
> +            gtk_action_set_sensitive(toggle, win->conn->agent_connected);
> +        }
> +    }
> +}
> +
> +static void update_edit_menu(struct spice_connection *conn)
> +{
> +    int i;
> +
> +    for (i = 0; i < SPICE_N_ELEMENTS(conn->wins); i++) {
> +        if (conn->wins[i]) {
> +            update_edit_menu_window(conn->wins[i]);
> +        }
> +    }
> +}
> +
>   static void menu_cb_connect(GtkAction *action, void *data)
>   {
>       struct spice_connection *conn;
> @@ -1305,6 +1340,8 @@ static SpiceWindow *create_spice_window(spice_connection *conn, SpiceChannel *ch
>                                         win, 0);
>       }
>
> +    update_edit_menu_window(win);
> +
>       toggle = gtk_action_group_get_action(win->ag, "Toolbar");
>       state = gtk_widget_get_visible(win->toolbar);
>       gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggle), state);
> @@ -1462,6 +1499,7 @@ static void main_agent_update(SpiceChannel *channel, gpointer data)
>       g_object_get(channel, "agent-connected", &conn->agent_connected, NULL);
>       conn->agent_state = conn->agent_connected ? _("yes") : _("no");
>       update_status(conn);
> +    update_edit_menu(conn);
>   }
>
>   static void inputs_modifiers(SpiceChannel *channel, gpointer data)
>


More information about the Spice-devel mailing list