diff options
author | Pavel Grunt <pgrunt@redhat.com> | 2017-03-02 14:05:06 +0100 |
---|---|---|
committer | Pavel Grunt <pgrunt@redhat.com> | 2017-03-06 09:49:30 +0100 |
commit | 9c133dcde4be15b05fdfc5fa2e82c85c68ca2f5b (patch) | |
tree | c89ffc1c0d5a6e544becb89ebbf4c8cf81397a2a /tools | |
parent | b8dd12ac81a90644a4f41941d7d172987c4689cd (diff) |
spicy: Add dialog for precise resizing
It helps when testing whether the guest resizes to requested resolution
Acked-by: Victor Toso <victortoso@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/spicy.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/spicy.c b/tools/spicy.c index ce6b40b..cd1677f 100644 --- a/tools/spicy.c +++ b/tools/spicy.c @@ -566,6 +566,61 @@ static void keyboard_grab_cb(GtkWidget *widget, gint grabbed, gpointer data) } } +static void menu_cb_resize_to(GtkAction *action G_GNUC_UNUSED, + gpointer data) +{ + SpiceWindow *win = data; + GtkWidget *dialog; + GtkWidget *spin_width, *spin_height, *spin_x, *spin_y; + GtkGrid *grid; + gint width, height; + dialog = gtk_dialog_new_with_buttons("Resize guest to", + GTK_WINDOW(win->toplevel), + GTK_DIALOG_DESTROY_WITH_PARENT, + "_Apply", + GTK_RESPONSE_APPLY, + "_Cancel", + GTK_RESPONSE_CANCEL, + NULL); + + spin_width = gtk_spin_button_new_with_range(0, G_MAXINT, 10); + spin_height = gtk_spin_button_new_with_range(0, G_MAXINT, 10); + spin_x = gtk_spin_button_new_with_range(0, G_MAXINT, 10); + spin_y = gtk_spin_button_new_with_range(0, G_MAXINT, 10); + + gtk_widget_get_preferred_width(win->spice, NULL, &width); + gtk_widget_get_preferred_height(win->spice, NULL, &height); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_width), width); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_height), height); + + grid = GTK_GRID(gtk_grid_new()); + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), + GTK_WIDGET(grid)); + gtk_grid_attach(grid, gtk_label_new("Resize the guest display:"), 0, 0, 2, 1); + gtk_grid_attach(grid, gtk_label_new("width:"), 0, 2, 1, 1); + gtk_grid_attach(grid, spin_width, 1, 2, 1, 1); + gtk_grid_attach(grid, gtk_label_new("height:"), 0, 3, 1, 1); + gtk_grid_attach(grid, spin_height, 1, 3, 1, 1); + gtk_grid_attach(grid, gtk_label_new("x:"), 0, 4, 1, 1); + gtk_grid_attach(grid, spin_x, 1, 4, 1, 1); + gtk_grid_attach(grid, gtk_label_new("y:"), 0, 5, 1, 1); + gtk_grid_attach(grid, spin_y, 1, 5, 1, 1); + + gtk_widget_show_all(dialog); + if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_APPLY) { + spice_main_update_display_enabled(win->conn->main, win->id + win->monitor_id, TRUE, FALSE); + spice_main_set_display(win->conn->main, + win->id + win->monitor_id, + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_x)), + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_y)), + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_width)), + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_height))); + spice_main_send_monitor_config(win->conn->main); + } + gtk_widget_destroy(dialog); +} + static void restore_configuration(SpiceWindow *win) { gboolean state; @@ -692,6 +747,11 @@ static const GtkActionEntry entries[] = { .callback = G_CALLBACK(menu_cb_fullscreen), .accelerator = "<shift>F11", },{ + .name = "ResizeTo", + .label = "_Resize to", + .callback = G_CALLBACK(menu_cb_resize_to), + .accelerator = "", + },{ #ifdef USE_SMARTCARD .name = "InsertSmartcard", .label = "_Insert Smartcard", @@ -905,6 +965,9 @@ static char ui_xml[] = " <toolitem action='PasteFromGuest'/>\n" " <separator/>\n" " <toolitem action='Fullscreen'/>\n" +" <separator/>\n" +" <toolitem action='ResizeTo'/>\n" +" <separator/>\n" " </toolbar>\n" "</ui>\n"; |