mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2025-01-08 21:17:49 +03:00
Enable spice auto-usbredir
This commit is contained in:
parent
2dcd3fa617
commit
dfb26d59b0
@ -171,6 +171,10 @@ create_spice_session(VirtViewerSessionSpice *self)
|
||||
if (manager)
|
||||
g_signal_connect(manager, "auto-connect-failed",
|
||||
G_CALLBACK(usb_auto_connect_failed), self);
|
||||
|
||||
g_object_bind_property(self, "auto-usbredir",
|
||||
self->priv->gtk_session, "auto-usbredir",
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -35,10 +35,18 @@
|
||||
struct _VirtViewerSessionPrivate
|
||||
{
|
||||
GList *displays;
|
||||
|
||||
gboolean auto_usbredir;
|
||||
};
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE(VirtViewerSession, virt_viewer_session, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_AUTO_USBREDIR,
|
||||
};
|
||||
|
||||
static void
|
||||
virt_viewer_session_finalize(GObject *obj)
|
||||
{
|
||||
@ -54,13 +62,61 @@ virt_viewer_session_finalize(GObject *obj)
|
||||
G_OBJECT_CLASS(virt_viewer_session_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_set_property(GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerSession *self = VIRT_VIEWER_SESSION(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_USBREDIR:
|
||||
virt_viewer_session_set_auto_usbredir(self, g_value_get_boolean(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_get_property(GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerSession *self = VIRT_VIEWER_SESSION(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_USBREDIR:
|
||||
g_value_set_boolean(value, virt_viewer_session_get_auto_usbredir(self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_class_init(VirtViewerSessionClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(class);
|
||||
|
||||
object_class->set_property = virt_viewer_session_set_property;
|
||||
object_class->get_property = virt_viewer_session_get_property;
|
||||
object_class->finalize = virt_viewer_session_finalize;
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_AUTO_USBREDIR,
|
||||
g_param_spec_boolean("auto-usbredir",
|
||||
"USB redirection",
|
||||
"USB redirection",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_signal_new("session-connected",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
@ -269,10 +325,29 @@ gboolean virt_viewer_session_channel_open_fd(VirtViewerSession *session,
|
||||
return VIRT_VIEWER_SESSION_GET_CLASS(session)->channel_open_fd(session, channel, fd);
|
||||
}
|
||||
|
||||
void virt_viewer_session_set_auto_usbredir(VirtViewerSession *self, gboolean auto_usbredir)
|
||||
{
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(self));
|
||||
|
||||
if (self->priv->auto_usbredir == auto_usbredir)
|
||||
return;
|
||||
|
||||
self->priv->auto_usbredir = auto_usbredir;
|
||||
g_object_notify(G_OBJECT(self), "auto-usbredir");
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_get_auto_usbredir(VirtViewerSession *self)
|
||||
{
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
|
||||
|
||||
return self->priv->auto_usbredir;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* tab-width: 8
|
||||
* End:
|
||||
*/
|
||||
|
@ -108,6 +108,9 @@ gboolean virt_viewer_session_channel_open_fd(VirtViewerSession* session,
|
||||
VirtViewerSessionChannel* channel, int fd);
|
||||
gboolean virt_viewer_session_open_uri(VirtViewerSession *session, gchar *uri);
|
||||
|
||||
void virt_viewer_session_set_auto_usbredir(VirtViewerSession* session, gboolean auto_usbredir);
|
||||
gboolean virt_viewer_session_get_auto_usbredir(VirtViewerSession* session);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_SESSION_H */
|
||||
|
Loading…
Reference in New Issue
Block a user