Skip to content
Commits on Source (10)
42.2 - 01 Jul, 2022
===================
Changes since 42.1
- Ensure spice graphics is specified in vm creation
- Recommend openSUSE 15.4
42.1 - 30 May, 2022
===================
Changes since 42.0.1
- Use host-model cpu mode when using QEMU emulation
- Exclude unreleased OSes from being promoted
- Fix issue with renaming box
- Don't require product-key for express installs
- Added/updated/fixed translations:
- Serbian
- Catalan
- Bulgarian
- Slovak
- Basque
- Friulian
- Brazilian Portuguese
- Russian
- British English
- German
- French
- Ukrainian
- Polish
- Czech
42.0.1 - 18 Mar, 2022
=====================
......
......@@ -8,7 +8,7 @@ Following are the owners for each logo:
Fedora: Red Hat, Inc.
Ubuntu: Canonical Ltd.
openSUSE: Novell, Inc. [2]
openSUSE: SUSE LLC [2]
Debian: SPI (Software in the Public Interest).
Red Hat Enterprise Linux: Red Hat, Inc.
......
......@@ -43,6 +43,7 @@
</screenshot>
</screenshots>
<releases>
<release version="42.2" date="2022-07-01"/>
<release version="42.1" date="2022-05-30"/>
<release version="42.0" date="2022-03-18">
<p>GNOME Boxes 42.0 is the result of six months of bugfixes, performance improvements, and feature development including:</p>
......
......@@ -14,7 +14,7 @@
<os_id>http://fedoraproject.org/fedora/</os_id>
<os_id>http://fedoraproject.org/silverblue/</os_id>
<os_id>http://ubuntu.com/ubuntu/</os_id>
<os_id>http://opensuse.org/opensuse/</os_id>
<os_id>http://opensuse.org/opensuse/15.4</os_id>
<os_id>http://opensuse.org/opensuse/tumbleweed</os_id>
<os_id>http://debian.org/debian/</os_id>
<os_id>http://endlessos.com/eos/</os_id>
......
gnome-boxes (42.2-1ubuntu1) kinetic; urgency=medium
* Sync with Debian (LP: #1980416). Remaining changes:
- Update recommended-downloads patch to only feature Ubuntu
- Use dh_migrations to remove the old cached Ubuntu logo
-- Jeremy Bicha <jbicha@ubuntu.com> Fri, 01 Jul 2022 09:09:50 -0400
gnome-boxes (42.2-1) unstable; urgency=medium
* New upstream release
* Refresh recommended-downloads.patch
-- Jeremy Bicha <jbicha@ubuntu.com> Fri, 01 Jul 2022 08:53:33 -0400
gnome-boxes (42.1-1ubuntu1) kinetic; urgency=medium
[ Nathan Pratta Teodosio ]
......
......@@ -7,7 +7,7 @@ Subject: Update recommended downloads
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/data/recommended-downloads.xml b/data/recommended-downloads.xml
index 178a4ae..dd0660f 100644
index 6502791..dd0660f 100644
--- a/data/recommended-downloads.xml
+++ b/data/recommended-downloads.xml
@@ -9,14 +9,6 @@
......@@ -19,7 +19,7 @@ index 178a4ae..dd0660f 100644
- <os_id>http://fedoraproject.org/fedora/</os_id>
- <os_id>http://fedoraproject.org/silverblue/</os_id>
<os_id>http://ubuntu.com/ubuntu/</os_id>
- <os_id>http://opensuse.org/opensuse/</os_id>
- <os_id>http://opensuse.org/opensuse/15.4</os_id>
- <os_id>http://opensuse.org/opensuse/tumbleweed</os_id>
- <os_id>http://debian.org/debian/</os_id>
- <os_id>http://endlessos.com/eos/</os_id>
......
project ('gnome-boxes',
['vala', 'c'],
version: '42.1',
version: '42.2',
license: 'LGPLv2+',
meson_version: '>= 0.50.0',
)
......
......@@ -91,10 +91,13 @@ private class Boxes.VMConfigurator {
set_target_media_config (domain, target_path, install_media);
install_media.setup_domain_config (domain);
add_usb_support (domain, install_media);
if (SPICE_AVAILABLE) {
domain.add_device (create_graphics_device());
add_usb_support (domain, install_media);
if (!App.is_running_in_flatpak ())
add_smartcard_support (domain);
if (!App.is_running_in_flatpak ())
add_smartcard_support (domain);
}
set_video_config (domain, install_media);
set_sound_config (domain, install_media);
......
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
/* gtk-frdp-viewer.c
*
* Copyright (C) 2018 Felipe Borges <felipeborges@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtk-frdp.h>
static void
on_activate (GtkApplication *app)
{
GtkWindow *window;
GtkWidget *display;
g_assert (GTK_IS_APPLICATION (app));
/* Get the current window or create one if necessary. */
window = gtk_application_get_active_window (app);
if (window == NULL)
window = g_object_new (GTK_TYPE_APPLICATION_WINDOW,
"application", app,
NULL);
display = frdp_display_new ();
gtk_container_add (GTK_CONTAINER (window), display);
gtk_widget_show (display);
frdp_display_open_host (FRDP_DISPLAY (display), "109.168.97.222", 3389);
g_object_set (display,
"username", "demo2",
"password", "D3m02014*Test",
NULL);
gtk_window_present (window);
}
int
main (int argc,
char *argv[])
{
g_autoptr(GtkApplication) app = NULL;
int ret;
app = gtk_application_new ("org.gnome.GtkFrdpViewer", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
ret = g_application_run (G_APPLICATION (app), argc, argv);
return ret;
}
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GtkFrdp
win = Gtk.Window()
display = GtkFrdp.Display()
display.open_host("10.43.12.92", 3389)
win.add(display)
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
/* gtk-frdp-viewer.vala
*
* Copyright (C) 2018 Felipe Borges <felipeborges@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Gtk;
using Frdp;
private class GtkRdpViewer.Application: Gtk.Application {
public const int DEFAULT_RDP_PORT = 3389;
private Gtk.ApplicationWindow window;
private Frdp.Display display;
static string option_connect_address;
const OptionEntry[] options = {
{ "connect", 0, 0, OptionArg.STRING, ref option_connect_address, "Connect to address", null },
{ null }
};
public Application () {
application_id = "org.gnome.GtkRdpViewer";
flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
}
protected override void activate () {
if (window != null)
return;
window = new Gtk.ApplicationWindow (this);
display = new Frdp.Display();
window.add(display);
window.show_all ();
}
protected override int command_line (GLib.ApplicationCommandLine cmdline) {
option_connect_address = null;
var opt_context = new OptionContext ("A RDP Viewer");
opt_context.add_main_entries (options, null);
opt_context.set_help_enabled (true);
try {
string[] args1 = cmdline.get_arguments ();
unowned string[] args2 = args1;
opt_context.parse (ref args2);
} catch (OptionError error) {
cmdline.printerr ("%s\n", error.message);
return 1;
}
if (option_connect_address != null) {
connect_to (option_connect_address);
}
return 0;
}
private void connect_to (string address) {
activate ();
display.open_host (address, DEFAULT_RDP_PORT);
}
}
public int main (string[] args) {
var app = new GtkRdpViewer.Application ();
var exit_status = app.run (args);
return exit_status;
}
example_application_sources = [
'gtk-frdp-viewer.c',
]
example_application = executable('gtk-frdp-viewer', example_application_sources,
dependencies: gtk_frdp_dep,
)
vala_args = [
'--vapidir', vapidir,
]
vala_example_application = executable('gtk-frdp-viewer-vala',
'gtk-frdp-viewer.vala',
vala_args: vala_args,
link_with: gtk_frdp_lib,
dependencies: [
dependency ('gtk+-3.0'),
gtk_frdp_vapi,
],
)
<?xml version="1.0" encoding="UTF-8"?>
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:gnome="http://api.gnome.org/doap-extensions#"
xmlns="http://usefulinc.com/ns/doap#">
<name>gtk-frdp</name>
<shortname>gtk-frdp</shortname>
<shortdesc>A RDP viewer widget for Gtk+</shortdesc>
<description>gtk-frdp is a RDP viewer widget powered by FreeRDP and Gtk+, developed initially to be used in GNOME Boxes.</description>
<homepage rdf:resource="https://wiki.gnome.org/Apps/Boxes" />
<download-page rdf:resource="http://download.gnome.org/sources/gtk-frdp/" />
<programming-language>C</programming-language>
<maintainer>
<foaf:Person>
<foaf:name>Felipe Borges</foaf:name>
<foaf:mbox rdf:resource="mailto:felipeborges@gnome.org" />
<gnome:userid>felipeborges</gnome:userid>
</foaf:Person>
</maintainer>
</Project>
project('gtk-frdp',
['c', 'vala'],
version: '0.1.0',
meson_version: '>= 0.40.0',
)
config_h = configuration_data()
configure_file(
output: 'gtk-frdp-config.h',
configuration: config_h,
)
add_project_arguments([
'-I' + meson.build_root(),
], language: 'c')
package_subdir = get_option('package_subdir')
libdir = join_paths(get_option('libdir'), package_subdir)
girdir = join_paths(get_option('datadir'), package_subdir, 'gir-1.0')
typelibdir = join_paths(libdir, 'girepository-1.0')
if package_subdir != ''
vapidir = join_paths(get_option('datadir'), package_subdir, 'vapi')
else
vapidir = join_paths(get_option('datadir'), 'vala', 'vapi')
endif
gnome = import('gnome')
subdir('src')
subdir('examples')
# Subproject
option('package_subdir', type: 'string',
description: 'Subdirectory to append to all installed files, for use as subproject'
)
Display
.authenticate.username out unowned=false
.authenticate.password out unowned=false
.authenticate.domain out unowned=false
/* frdp-display.c
*
* Copyright (C) 2018 Felipe Borges <felipeborges@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "frdp-display.h"
#include "frdp-session.h"
struct _FrdpDisplayPrivate
{
FrdpSession *session;
};
G_DEFINE_TYPE_WITH_PRIVATE (FrdpDisplay, frdp_display, GTK_TYPE_DRAWING_AREA)
enum
{
PROP_O = 0,
PROP_USERNAME,
PROP_PASSWORD,
PROP_SCALING
};
enum
{
RDP_CONNECTED,
RDP_DISCONNECTED,
RDP_NEEDS_AUTHENTICATION,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
static gboolean
frdp_display_is_initialized (FrdpDisplay *self)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
return priv->session != NULL && frdp_display_is_open (self);
}
static gboolean
frdp_display_key_press_event (GtkWidget *widget,
GdkEventKey *key)
{
FrdpDisplay *self = FRDP_DISPLAY (widget);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
guint16 keycode = key->hardware_keycode;
if (!frdp_display_is_initialized (self))
return TRUE;
switch (key->type) {
case GDK_KEY_PRESS:
frdp_session_send_key (priv->session, FRDP_KEY_EVENT_PRESS, keycode);
break;
case GDK_KEY_RELEASE:
frdp_session_send_key (priv->session, FRDP_KEY_EVENT_RELEASE, keycode);
break;
default:
g_warn_if_reached ();
break;
}
return TRUE;
}
static gboolean
frdp_display_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event)
{
FrdpDisplay *self = FRDP_DISPLAY (widget);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
if (!frdp_display_is_initialized (self))
return TRUE;
frdp_session_mouse_event (priv->session,
FRDP_MOUSE_EVENT_MOVE,
event->x,
event->y);
return TRUE;
}
static gboolean
frdp_display_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
FrdpDisplay *self = FRDP_DISPLAY (widget);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
guint16 flags = 0;
if (!frdp_display_is_initialized (self))
return TRUE;
if ((event->button < 1) || (event->button > 3))
return FALSE;
if ((event->type != GDK_BUTTON_PRESS) &&
(event->type != GDK_BUTTON_RELEASE))
return FALSE;
if (event->type == GDK_BUTTON_PRESS)
flags |= FRDP_MOUSE_EVENT_DOWN;
switch(event->button) {
case GDK_BUTTON_PRIMARY:
flags |= FRDP_MOUSE_EVENT_BUTTON1;
break;
case GDK_BUTTON_MIDDLE:
flags |= FRDP_MOUSE_EVENT_BUTTON3;
break;
case GDK_BUTTON_SECONDARY:
flags |= FRDP_MOUSE_EVENT_BUTTON2;
break;
case 8:
flags |= FRDP_MOUSE_EVENT_BUTTON4;
break;
case 9:
flags |= FRDP_MOUSE_EVENT_BUTTON5;
break;
default:
return FALSE;
}
frdp_session_mouse_event (priv->session,
flags,
event->x,
event->y);
return TRUE;
}
static gboolean
frdp_display_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
FrdpDisplay *self = FRDP_DISPLAY (widget);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
guint16 flags = FRDP_MOUSE_EVENT_WHEEL;
if (!frdp_display_is_initialized (self))
return TRUE;
switch (event->direction) {
case GDK_SCROLL_UP:
flags = FRDP_MOUSE_EVENT_WHEEL;
break;
case GDK_SCROLL_DOWN:
flags = FRDP_MOUSE_EVENT_WHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
break;
case GDK_SCROLL_LEFT:
flags = FRDP_MOUSE_EVENT_HWHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
break;
case GDK_SCROLL_RIGHT:
flags = FRDP_MOUSE_EVENT_HWHEEL;
break;
case GDK_SCROLL_SMOOTH:
/* Calculate delta and decide which event we have
* a delta X means horizontal, a delta Y means vertical scroll.
* Fixes https://bugzilla.gnome.org/show_bug.cgi?id=675959
*/
if (event->delta_x > 0.5)
flags = FRDP_MOUSE_EVENT_HWHEEL;
else if (event->delta_x < -0.5)
flags = FRDP_MOUSE_EVENT_HWHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
else if (event->delta_y > 0.5)
flags = FRDP_MOUSE_EVENT_WHEEL;
else if (event->delta_y < -0.5)
flags = FRDP_MOUSE_EVENT_WHEEL | FRDP_MOUSE_EVENT_WHEEL_NEGATIVE;
else {
g_debug ("scroll smooth unhandled");
return FALSE;
}
break;
default:
return FALSE;
}
frdp_session_mouse_event (priv->session,
flags,
event->x,
event->y);
return TRUE;
}
static gboolean
frdp_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
FrdpDisplay *self = FRDP_DISPLAY (widget);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
frdp_session_mouse_pointer(priv->session, TRUE);
return TRUE;
}
static gboolean
frdp_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
FrdpDisplay *self = FRDP_DISPLAY (widget);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
frdp_session_mouse_pointer(priv->session, FALSE);
return TRUE;
}
static void
frdp_display_disconnected (GObject *source_object,
gpointer user_data)
{
FrdpDisplay *self = FRDP_DISPLAY (user_data);
g_signal_emit (self, signals[RDP_DISCONNECTED], 0);
g_debug ("rdp disconnected");
}
static void
frdp_display_open_host_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
FrdpDisplay *self = FRDP_DISPLAY (user_data);
FrdpSession *session = (FrdpSession*) source_object;
gboolean success;
GError *error = NULL;
success = frdp_session_connect_finish (session,
result,
&error);
if (success) {
g_signal_emit (self, signals[RDP_CONNECTED], 0);
g_debug ("Connection established");
} else {
g_signal_emit (self, signals[RDP_DISCONNECTED], 0);
g_debug ("Connection failed");
frdp_display_close (self);
}
}
static void
frdp_display_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
FrdpDisplay *self = FRDP_DISPLAY (object);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
FrdpSession *session = priv->session;
gpointer str_property;
switch (property_id)
{
case PROP_USERNAME:
g_object_get (session, "username", &str_property, NULL);
g_value_set_string (value, str_property);
break;
case PROP_PASSWORD:
g_object_get (session, "password", &str_property, NULL);
g_value_set_string (value, str_property);
break;
case PROP_SCALING:
g_object_get (session, "scaling", &str_property, NULL);
g_value_set_boolean (value, (gboolean)GPOINTER_TO_INT (str_property));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
frdp_display_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
FrdpDisplay *self = FRDP_DISPLAY (object);
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
FrdpSession *session = priv->session;
switch (property_id)
{
case PROP_USERNAME:
g_object_set (session, "username", g_value_get_string (value), NULL);
break;
case PROP_PASSWORD:
g_object_set (session, "password", g_value_get_string (value), NULL);
break;
case PROP_SCALING:
frdp_display_set_scaling (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
frdp_display_class_init (FrdpDisplayClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gobject_class->get_property = frdp_display_get_property;
gobject_class->set_property = frdp_display_set_property;
widget_class->key_press_event = frdp_display_key_press_event;
widget_class->key_release_event = frdp_display_key_press_event;
widget_class->motion_notify_event = frdp_display_motion_notify_event;
widget_class->button_press_event = frdp_display_button_press_event;
widget_class->button_release_event = frdp_display_button_press_event;
widget_class->scroll_event = frdp_display_scroll_event;
widget_class->enter_notify_event = frdp_enter_notify_event;
widget_class->leave_notify_event = frdp_leave_notify_event;
g_object_class_install_property (gobject_class,
PROP_USERNAME,
g_param_spec_string ("username",
"username",
"username",
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PASSWORD,
g_param_spec_string ("password",
"password",
"password",
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SCALING,
g_param_spec_boolean ("scaling",
"scaling",
"scaling",
TRUE,
G_PARAM_READWRITE));
signals[RDP_CONNECTED] = g_signal_new ("rdp-connected",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[RDP_DISCONNECTED] = g_signal_new ("rdp-disconnected",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[RDP_NEEDS_AUTHENTICATION] = g_signal_new ("rdp-needs-authentication",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
}
static void
frdp_display_init (FrdpDisplay *self)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (self);
gtk_widget_add_events (GTK_WIDGET (self),
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_SCROLL_MASK |
GDK_SMOOTH_SCROLL_MASK |
GDK_KEY_PRESS_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
priv->session = frdp_session_new (self);
}
/**
* frdp_display_open_host:
* @display: (transfer none): the RDP display widget
* @host: (transfer none): the hostname or IP address
* @port: the service name or port number
*
* Opens a TCP connection to the given @host litening on
* @port.
*/
void
frdp_display_open_host (FrdpDisplay *display,
const gchar *host,
guint port)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (display);
g_return_if_fail (host != NULL);
g_signal_connect (priv->session, "rdp-disconnected",
G_CALLBACK (frdp_display_disconnected),
display);
frdp_session_connect (priv->session,
host,
port,
NULL, // TODO: Cancellable
frdp_display_open_host_cb,
g_object_ref (display));
g_debug ("Connecting to %s…", host);
}
/**
* frdp_display_is_open:
* @display: (transfer none): the RDP display widget
*
* Check if the connection for the display is currently open
*
* Returns: TRUE if open, FALSE if closing/closed
*/
gboolean
frdp_display_is_open (FrdpDisplay *display)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (display);
return frdp_session_is_open (priv->session);
}
/**
* frdp_display_close:
* @display: (transfer none): the RDP display widget
*
* Request the closing of the RDP session.
*/
void
frdp_display_close (FrdpDisplay *display)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (display);
frdp_session_close (priv->session);
}
/**
* frdp_display_set_scaling:
* @display: (transfer none): the RDP display widget
* @scaling: TRUE to scale the desktop to fit, FALSE otherwise
*
* Set whether the remote desktop contents is automatically
* scaled to fit the available widget size, or whether it will
* be rendered at 1:1 size
*/
void
frdp_display_set_scaling (FrdpDisplay *display,
gboolean scaling)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (display);
g_object_set (priv->session, "scaling", scaling, NULL);
if (scaling) {
gtk_widget_set_size_request (GTK_WIDGET (display), -1, -1);
gtk_widget_set_halign (GTK_WIDGET (display), GTK_ALIGN_FILL);
gtk_widget_set_valign (GTK_WIDGET (display), GTK_ALIGN_FILL);
} else {
gtk_widget_set_halign (GTK_WIDGET (display), GTK_ALIGN_CENTER);
gtk_widget_set_valign (GTK_WIDGET (display), GTK_ALIGN_CENTER);
}
gtk_widget_queue_draw_area (GTK_WIDGET (display), 0, 0,
gtk_widget_get_allocated_width (GTK_WIDGET (display)),
gtk_widget_get_allocated_height (GTK_WIDGET (display)));
}
/*
* frdp_display_new:
*
* Create a new widget capable of connecting to a RDP server
* and displaying its contents
*
* The widget will be initially be in a disconnected state
*
* Returns: (transfer full): the new RDP display widget
*/
GtkWidget *frdp_display_new (void)
{
return GTK_WIDGET (g_object_new (FRDP_TYPE_DISPLAY, NULL));
}
gboolean
frdp_display_authenticate (FrdpDisplay *self,
gchar **username,
gchar **password,
gchar **domain)
{
FrdpDisplayClass *klass = FRDP_DISPLAY_DISPLAY_GET_CLASS (self);
g_signal_emit (self, signals[RDP_NEEDS_AUTHENTICATION], 0);
return klass->authenticate (self, username, password, domain);
}
/**
* frdp_display_get_pixbuf:
* @display: (transfer none): the RDP display widget
*
* Take a screenshot of the display.
*
* Returns: (transfer full): a #GdkPixbuf with the screenshot image buffer
*/
GdkPixbuf *
frdp_display_get_pixbuf (FrdpDisplay *display)
{
FrdpDisplayPrivate *priv = frdp_display_get_instance_private (display);
return frdp_session_get_pixbuf (priv->session);
}
/* frdp-display.h
*
* Copyright (C) 2018 Felipe Borges <felipeborges@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define FRDP_TYPE_DISPLAY (frdp_display_get_type())
#define FRDP_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), FRDP_TYPE_DISPLAY, FrdpDisplay))
G_DECLARE_DERIVABLE_TYPE (FrdpDisplay, frdp_display, FRDP_DISPLAY, DISPLAY, GtkDrawingArea)
typedef struct _FrdpDisplayPrivate FrdpDisplayPrivate;
struct _FrdpDisplayClass
{
GtkDrawingAreaClass parent_parent;
gboolean (*authenticate) (FrdpDisplay *self, gchar **username, gchar **password, gchar **domain);
};
GtkWidget *frdp_display_new (void);
void frdp_display_open_host (FrdpDisplay *display,
const gchar *host,
guint port);
gboolean frdp_display_is_open (FrdpDisplay *display);
void frdp_display_close (FrdpDisplay *display);
void frdp_display_set_scaling (FrdpDisplay *display,
gboolean scaling);
gboolean frdp_display_authenticate (FrdpDisplay *self,
gchar **username,
gchar **password,
gchar **domain);
GdkPixbuf *frdp_display_get_pixbuf (FrdpDisplay *display);
G_END_DECLS
This diff is collapsed.