[Spice-commits] 2 commits - src/channel-display.c src/channel-smartcard.c src/spice-channel.c src/spice-channel-cache.h src/spice-grabsequence.c src/spice-util.c src/usb-device-manager.c src/usb-device-widget.c src/wocky-http-proxy.c
Fabiano FidĂȘncio
fidencio at kemper.freedesktop.org
Fri Jan 22 01:51:51 PST 2016
src/channel-display.c | 6 +++---
src/channel-smartcard.c | 4 ++--
src/spice-channel-cache.h | 8 ++++----
src/spice-channel.c | 8 ++++----
src/spice-grabsequence.c | 9 +++++----
src/spice-util.c | 4 ++--
src/usb-device-manager.c | 29 +++++++++++++++++++++++++++++
src/usb-device-widget.c | 23 ++++++++++++++++++-----
src/wocky-http-proxy.c | 4 ++--
9 files changed, 69 insertions(+), 26 deletions(-)
New commits:
commit 5166f891e566586bffcdc21b4b7386bf260bedc9
Author: Fabiano FidĂȘncio <fidencio at redhat.com>
Date: Tue Jan 19 22:27:28 2016 +0100
usb-device-{manager,widget}: Add counter of free channels
As the message showed when the last usbredir channel is taken can be a
bit confusing, let's add a counter of free channels to the widget's
label.
In order to add the counter, a new property for SpiceUsbDeviceManager
was introduced ("free-channels").
Related: rhbz#1298772
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index c62f56e..647edd0 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -89,6 +89,7 @@ enum {
PROP_AUTO_CONNECT,
PROP_AUTO_CONNECT_FILTER,
PROP_REDIRECT_ON_CONNECT,
+ PROP_FREE_CHANNELS,
};
enum
@@ -390,6 +391,20 @@ static void spice_usb_device_manager_get_property(GObject *gobject,
case PROP_REDIRECT_ON_CONNECT:
g_value_set_string(value, priv->redirect_on_connect);
break;
+ case PROP_FREE_CHANNELS: {
+ int free_channels = 0;
+#if USE_USBREDIR
+ int i;
+ for (i = 0; i < priv->channels->len; i++) {
+ SpiceUsbredirChannel *channel = g_ptr_array_index(priv->channels, i);
+
+ if (!spice_usbredir_channel_get_device(channel))
+ free_channels++;
+ }
+#endif
+ g_value_set_int(value, free_channels);
+ break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -550,6 +565,20 @@ static void spice_usb_device_manager_class_init(SpiceUsbDeviceManagerClass *klas
pspec);
/**
+ * SpiceUsbDeviceManager:n-free-channels:
+ *
+ * Get a list of avaialable channels for redirecting USB devices.
+ */
+ pspec = g_param_spec_int("free-channels", "Free channels",
+ "The number of available channels for redirecting USB devices",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READABLE);
+ g_object_class_install_property(gobject_class, PROP_FREE_CHANNELS,
+ pspec);
+
+ /**
* SpiceUsbDeviceManager::device-added:
* @manager: the #SpiceUsbDeviceManager that emitted the signal
* @device: #SpiceUsbDevice boxed object corresponding to the added device
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index fe983c9..59273f9 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -72,6 +72,7 @@ struct _SpiceUsbDeviceWidgetPrivate {
gchar *device_format_string;
SpiceUsbDeviceManager *manager;
GtkWidget *info_bar;
+ GtkWidget *label;
gchar *err_msg;
gsize device_count;
};
@@ -181,7 +182,6 @@ static GObject *spice_usb_device_widget_constructor(
SpiceUsbDeviceWidgetPrivate *priv;
GPtrArray *devices = NULL;
GError *err = NULL;
- GtkWidget *label;
gchar *str;
int i;
@@ -197,12 +197,12 @@ static GObject *spice_usb_device_widget_constructor(
if (!priv->session)
g_error("SpiceUsbDeviceWidget constructed without a session");
- label = gtk_label_new(NULL);
+ priv->label = gtk_label_new(NULL);
str = g_strdup_printf("<b>%s</b>", _("Select USB devices to redirect"));
- gtk_label_set_markup(GTK_LABEL (label), str);
+ gtk_label_set_markup(GTK_LABEL (priv->label), str);
g_free(str);
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
- gtk_box_pack_start(GTK_BOX(self), label, FALSE, FALSE, 0);
+ gtk_misc_set_alignment(GTK_MISC(priv->label), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(self), priv->label, FALSE, FALSE, 0);
priv->manager = spice_usb_device_manager_get(priv->session, &err);
if (err) {
@@ -401,6 +401,19 @@ static gboolean spice_usb_device_widget_update_status(gpointer user_data)
{
SpiceUsbDeviceWidget *self = SPICE_USB_DEVICE_WIDGET(user_data);
SpiceUsbDeviceWidgetPrivate *priv = self->priv;
+ gchar *str, *markup_str;
+ const gchar *free_channels_str;
+ int free_channels;
+
+ g_object_get(priv->manager, "free-channels", &free_channels, NULL);
+ free_channels_str = ngettext(_("Select USB devices to redirect (%d free channel)"),
+ _("Select USB devices to redirect (%d free channels)"),
+ free_channels);
+ str = g_strdup_printf(free_channels_str, free_channels);
+ markup_str = g_strdup_printf("<b>%s</b>", str);
+ gtk_label_set_markup(GTK_LABEL (priv->label), markup_str);
+ g_free(markup_str);
+ g_free(str);
priv->device_count = 0;
gtk_container_foreach(GTK_CONTAINER(self), check_can_redirect, self);
commit b757d75b9bfe70951e89f1ca2d8b1dcc845591d6
Author: Fabiano FidĂȘncio <fidencio at redhat.com>
Date: Wed Jan 13 14:19:27 2016 +0100
Remove GSLice usage
It's being slowly deprecated in glib
https://bugzilla.gnome.org/show_bug.cgi?id=754687
diff --git a/src/channel-display.c b/src/channel-display.c
index dc73235..6a474b1 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -635,7 +635,7 @@ static void destroy_surface(gpointer data)
display_surface *surface = data;
destroy_canvas(surface);
- g_slice_free(display_surface, surface);
+ g_free(surface);
}
static void spice_display_channel_init(SpiceDisplayChannel *channel)
@@ -869,7 +869,7 @@ static void display_handle_mode(SpiceChannel *channel, SpiceMsgIn *in)
g_warn_if_fail(c->mark == FALSE);
- surface = g_slice_new0(display_surface);
+ surface = g_new0(display_surface, 1);
surface->format = mode->bits == 32 ?
SPICE_SURFACE_FMT_32_xRGB : SPICE_SURFACE_FMT_16_555;
surface->width = mode->x_res;
@@ -1674,7 +1674,7 @@ static void display_handle_surface_create(SpiceChannel *channel, SpiceMsgIn *in)
{
SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
SpiceMsgSurfaceCreate *create = spice_msg_in_parsed(in);
- display_surface *surface = g_slice_new0(display_surface);
+ display_surface *surface = g_new0(display_surface, 1);
surface->surface_id = create->surface_id;
surface->format = create->format;
diff --git a/src/channel-smartcard.c b/src/channel-smartcard.c
index b5535e6..e2e1aad 100644
--- a/src/channel-smartcard.c
+++ b/src/channel-smartcard.c
@@ -241,7 +241,7 @@ smartcard_message_free(SpiceSmartcardChannelMessage *message)
{
if (message->message)
spice_msg_out_unref(message->message);
- g_slice_free(SpiceSmartcardChannelMessage, message);
+ g_free(message);
}
#if USE_SMARTCARD
@@ -301,7 +301,7 @@ smartcard_message_new(VSCMsgType msg_type, SpiceMsgOut *msg_out)
{
SpiceSmartcardChannelMessage *message;
- message = g_slice_new0(SpiceSmartcardChannelMessage);
+ message = g_new0(SpiceSmartcardChannelMessage, 1);
message->message = msg_out;
message->message_type = msg_type;
diff --git a/src/spice-channel-cache.h b/src/spice-channel-cache.h
index e609a67..75cc2cd 100644
--- a/src/spice-channel-cache.h
+++ b/src/spice-channel-cache.h
@@ -37,7 +37,7 @@ typedef struct display_cache {
static inline display_cache_item* cache_item_new(guint64 id, gboolean lossy)
{
- display_cache_item *self = g_slice_new(display_cache_item);
+ display_cache_item *self = g_new(display_cache_item, 1);
self->id = id;
self->lossy = lossy;
self->ref_count = 1;
@@ -46,12 +46,12 @@ static inline display_cache_item* cache_item_new(guint64 id, gboolean lossy)
static inline void cache_item_free(display_cache_item *self)
{
- g_slice_free(display_cache_item, self);
+ g_free(self);
}
static inline display_cache* cache_new(GDestroyNotify value_destroy)
{
- display_cache * self = g_slice_new(display_cache);
+ display_cache * self = g_new(display_cache, 1);
self->table = g_hash_table_new_full(g_int64_hash, g_int64_equal,
(GDestroyNotify) cache_item_free,
value_destroy);
@@ -131,7 +131,7 @@ static inline void cache_clear(display_cache *cache)
static inline void cache_free(display_cache *cache)
{
g_hash_table_unref(cache->table);
- g_slice_free(display_cache, cache);
+ g_free(cache);
}
G_END_DECLS
diff --git a/src/spice-channel.c b/src/spice-channel.c
index 41c94d0..ff85715 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -471,7 +471,7 @@ SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel)
g_return_val_if_fail(channel != NULL, NULL);
- in = g_slice_new0(SpiceMsgIn);
+ in = g_new0(SpiceMsgIn, 1);
in->refcount = 1;
in->channel = channel;
@@ -519,7 +519,7 @@ void spice_msg_in_unref(SpiceMsgIn *in)
} else {
g_free(in->data);
}
- g_slice_free(SpiceMsgIn, in);
+ g_free(in);
}
G_GNUC_INTERNAL
@@ -624,7 +624,7 @@ SpiceMsgOut *spice_msg_out_new(SpiceChannel *channel, int type)
g_return_val_if_fail(c != NULL, NULL);
- out = g_slice_new0(SpiceMsgOut);
+ out = g_new0(SpiceMsgOut, 1);
out->refcount = 1;
out->channel = channel;
out->ro_check = msg_check_read_only(c->channel_type, type);
@@ -660,7 +660,7 @@ void spice_msg_out_unref(SpiceMsgOut *out)
if (out->refcount > 0)
return;
spice_marshaller_destroy(out->marshaller);
- g_slice_free(SpiceMsgOut, out);
+ g_free(out);
}
/* system context */
diff --git a/src/spice-grabsequence.c b/src/spice-grabsequence.c
index 26bf96f..a51d9e6 100644
--- a/src/spice-grabsequence.c
+++ b/src/spice-grabsequence.c
@@ -56,7 +56,7 @@ SpiceGrabSequence *spice_grab_sequence_new(guint nkeysyms, guint *keysyms)
{
SpiceGrabSequence *sequence;
- sequence = g_slice_new0(SpiceGrabSequence);
+ sequence = g_new0(SpiceGrabSequence, 1);
sequence->nkeysyms = nkeysyms;
sequence->keysyms = g_new0(guint, nkeysyms);
memcpy(sequence->keysyms, keysyms, sizeof(guint)*nkeysyms);
@@ -79,7 +79,7 @@ SpiceGrabSequence *spice_grab_sequence_new_from_string(const gchar *str)
int i;
SpiceGrabSequence *sequence;
- sequence = g_slice_new0(SpiceGrabSequence);
+ sequence = g_new0(SpiceGrabSequence, 1);
keysymstr = g_strsplit(str, "+", 5);
@@ -114,7 +114,8 @@ SpiceGrabSequence *spice_grab_sequence_copy(SpiceGrabSequence *srcSequence)
{
SpiceGrabSequence *sequence;
- sequence = g_slice_dup(SpiceGrabSequence, srcSequence);
+ sequence = g_new0(SpiceGrabSequence, 1);
+ sequence->nkeysyms = srcSequence->nkeysyms;
sequence->keysyms = g_new0(guint, srcSequence->nkeysyms);
memcpy(sequence->keysyms, srcSequence->keysyms,
sizeof(guint) * sequence->nkeysyms);
@@ -132,7 +133,7 @@ SpiceGrabSequence *spice_grab_sequence_copy(SpiceGrabSequence *srcSequence)
void spice_grab_sequence_free(SpiceGrabSequence *sequence)
{
g_free(sequence->keysyms);
- g_slice_free(SpiceGrabSequence, sequence);
+ g_free(sequence);
}
diff --git a/src/spice-util.c b/src/spice-util.c
index 84ed94a..fd97ee7 100644
--- a/src/spice-util.c
+++ b/src/spice-util.c
@@ -153,7 +153,7 @@ static WeakHandlerCtx *
whc_new (GObject *instance,
GObject *observer)
{
- WeakHandlerCtx *ctx = g_slice_new0 (WeakHandlerCtx);
+ WeakHandlerCtx *ctx = g_new0 (WeakHandlerCtx, 1);
ctx->instance = instance;
ctx->observer = observer;
@@ -164,7 +164,7 @@ whc_new (GObject *instance,
static void
whc_free (WeakHandlerCtx *ctx)
{
- g_slice_free (WeakHandlerCtx, ctx);
+ g_free (ctx);
}
static void observer_destroyed_cb (gpointer, GObject *);
diff --git a/src/wocky-http-proxy.c b/src/wocky-http-proxy.c
index ce23b0e..d84cd72 100644
--- a/src/wocky-http-proxy.c
+++ b/src/wocky-http-proxy.c
@@ -285,7 +285,7 @@ free_connect_data (ConnectAsyncData *data)
if (data->cancellable != NULL)
g_object_unref (data->cancellable);
- g_slice_free (ConnectAsyncData, data);
+ g_free (data);
}
static void
@@ -364,7 +364,7 @@ wocky_http_proxy_connect_async (GProxy *proxy,
callback, user_data,
wocky_http_proxy_connect_async);
- data = g_slice_new0 (ConnectAsyncData);
+ data = g_new0 (ConnectAsyncData, 1);
if (cancellable != NULL)
data->cancellable = g_object_ref (cancellable);
data->simple = simple;
More information about the Spice-commits
mailing list