summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2015-11-10 14:13:55 +0100
committerPavel Grunt <pgrunt@redhat.com>2015-11-18 08:26:42 +0100
commitd734a62e2f38166c88eb8565f8c4309db7a9e714 (patch)
tree337a465fffc848aa83637ccb81c75689203e5a62
parent471cf4226444351e2477640885952613f9bd8856 (diff)
downloadspice-gtk-d734a62e2f38166c88eb8565f8c4309db7a9e714.tar.gz
spice-gtk-d734a62e2f38166c88eb8565f8c4309db7a9e714.tar.xz
spice-gtk-d734a62e2f38166c88eb8565f8c4309db7a9e714.zip
spicy: Add support for changing compression
-rw-r--r--src/spicy.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/spicy.c b/src/spicy.c
index 4de56d9..67873ed 100644
--- a/src/spicy.c
+++ b/src/spicy.c
@@ -633,6 +633,9 @@ static const GtkActionEntry entries[] = {
.name = "OptionMenu",
.label = "_Options",
},{
+ .name = "CompressionMenu",
+ .label = "_Preferred image compression",
+ },{
.name = "HelpMenu",
.label = "_Help",
},{
@@ -753,6 +756,40 @@ static const GtkToggleActionEntry tentries[] = {
}
};
+static const GtkRadioActionEntry compression_entries[] = {
+ {
+ .name = "auto-glz",
+ .label = "auto-glz",
+ .value = SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
+ },{
+ .name = "auto-lz",
+ .label = "auto-lz",
+ .value = SPICE_IMAGE_COMPRESSION_AUTO_LZ,
+ },{
+ .name = "quic",
+ .label = "quic",
+ .value = SPICE_IMAGE_COMPRESSION_QUIC,
+ },{
+ .name = "glz",
+ .label = "glz",
+ .value = SPICE_IMAGE_COMPRESSION_GLZ,
+ },{
+ .name = "lz",
+ .label = "lz",
+ .value = SPICE_IMAGE_COMPRESSION_LZ,
+ },{
+#ifdef USE_LZ4
+ .name = "lz4",
+ .label = "lz4",
+ .value = SPICE_IMAGE_COMPRESSION_LZ4,
+ },{
+#endif
+ .name = "off",
+ .label = "off",
+ .value = SPICE_IMAGE_COMPRESSION_OFF,
+ }
+};
+
static char ui_xml[] =
"<ui>\n"
" <menubar action='MainMenu'>\n"
@@ -788,6 +825,17 @@ static char ui_xml[] =
" <menuitem action='disable-inputs'/>\n"
" <menuitem action='auto-clipboard'/>\n"
" <menuitem action='auto-usbredir'/>\n"
+" <menu action='CompressionMenu'>\n"
+" <menuitem action='auto-glz'/>\n"
+" <menuitem action='auto-lz'/>\n"
+" <menuitem action='quic'/>\n"
+" <menuitem action='glz'/>\n"
+" <menuitem action='lz'/>\n"
+#ifdef USE_LZ4
+" <menuitem action='lz4'/>\n"
+#endif
+" <menuitem action='off'/>\n"
+" </menu>\n"
" </menu>\n"
" <menu action='HelpMenu'>\n"
" <menuitem action='About'/>\n"
@@ -849,6 +897,14 @@ static gboolean configure_event_cb(GtkWidget *widget,
return FALSE;
}
+static void compression_cb(GtkRadioAction *action G_GNUC_UNUSED,
+ GtkRadioAction *current,
+ gpointer user_data)
+{
+ spice_display_change_preferred_compression(SPICE_CHANNEL(user_data),
+ gtk_radio_action_get_current_value(current));
+}
+
static void
spice_window_class_init (SpiceWindowClass *klass)
{
@@ -896,6 +952,13 @@ static SpiceWindow *create_spice_window(spice_connection *conn, SpiceChannel *ch
gtk_action_group_add_actions(win->ag, entries, G_N_ELEMENTS(entries), win);
gtk_action_group_add_toggle_actions(win->ag, tentries,
G_N_ELEMENTS(tentries), win);
+ gtk_action_group_add_radio_actions(win->ag, compression_entries,
+ G_N_ELEMENTS(compression_entries), -1,
+ G_CALLBACK(compression_cb), win->display_channel);
+ if (!spice_channel_test_capability(win->display_channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION)) {
+ GtkAction *compression_menu_action = gtk_action_group_get_action(win->ag, "CompressionMenu");
+ gtk_action_set_sensitive(compression_menu_action, FALSE);
+ }
gtk_ui_manager_insert_action_group(win->ui, win->ag, 0);
gtk_window_add_accel_group(GTK_WINDOW(win->toplevel),
gtk_ui_manager_get_accel_group(win->ui));