system, remote-desktop: Update strings and styling for "Desktop Sharing"

Following the updates on the mokcups at
85110609cd/remote-desktop/remote-desktop.png
This commit is contained in:
Felipe Borges 2024-02-19 13:39:43 +01:00 committed by Ray Strode
parent 4b35dd5b8c
commit 524742acec
2 changed files with 162 additions and 27 deletions

View file

@ -46,19 +46,26 @@
#include <pwquality.h>
#include <unistd.h>
#include "org.gnome.RemoteDesktop.h"
#define GNOME_REMOTE_DESKTOP_SCHEMA_ID "org.gnome.desktop.remote-desktop"
#define GNOME_REMOTE_DESKTOP_RDP_SCHEMA_ID "org.gnome.desktop.remote-desktop.rdp"
#define REMOTE_DESKTOP_STORE_CREDENTIALS_TIMEOUT_S 1
#define REMOTE_DESKTOP_SERVICE "gnome-remote-desktop.service"
#define RDP_SERVER_DBUS_SERVICE "org.gnome.RemoteDesktop.User"
#define RDP_SERVER_OBJECT_PATH "/org/gnome/RemoteDesktop/Rdp/Server"
struct _CcDesktopSharingPage {
AdwBin parent_instance;
GtkWidget *toast_overlay;
GsdRemoteDesktopRdpServer *rdp_server;
AdwSwitchRow *desktop_sharing_row;
AdwSwitchRow *remote_control_row;
GtkWidget *address_label;
AdwActionRow *hostname_row;
AdwActionRow *port_row;
GtkWidget *username_entry;
GtkWidget *password_entry;
GtkWidget *verify_encryption_button;
@ -342,13 +349,20 @@ static void
on_address_copy_clicked (CcDesktopSharingPage *self,
GtkButton *button)
{
GtkLabel *label = GTK_LABEL (self->address_label);
gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (button)),
gtk_label_get_text (label));
adw_action_row_get_subtitle (self->hostname_row));
add_toast (self, _("Device address copied"));
}
static void
on_port_copy_clicked (CcDesktopSharingPage *self,
GtkButton *button)
{
gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (button)),
adw_action_row_get_subtitle (self->port_row));
add_toast (self, _("Port number copied"));
}
static void
on_username_copy_clicked (CcDesktopSharingPage *self,
GtkButton *button)
@ -428,7 +442,7 @@ setup_desktop_sharing_page (CcDesktopSharingPage *self)
self->rdp_settings = g_settings_new (GNOME_REMOTE_DESKTOP_RDP_SCHEMA_ID);
hostname = get_hostname ();
gtk_label_set_label (GTK_LABEL (self->address_label), hostname);
adw_action_row_set_subtitle (self->hostname_row, hostname);
username = cc_grd_lookup_rdp_username (self->cancellable);
password = cc_grd_lookup_rdp_password (self->cancellable);
@ -528,6 +542,7 @@ cc_desktop_sharing_page_dispose (GObject *object)
g_clear_pointer ((GtkWindow **) &self->fingerprint_dialog, gtk_window_destroy);
g_clear_handle_id (&self->store_credentials_id, g_source_remove);
g_clear_object (&self->rdp_server);
g_clear_object (&self->rdp_settings);
G_OBJECT_CLASS (cc_desktop_sharing_page_parent_class)->dispose (object);
@ -547,17 +562,86 @@ cc_desktop_sharing_page_class_init (CcDesktopSharingPageClass * klass)
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, desktop_sharing_row);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, remote_control_row);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, hostname_row);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, port_row);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, username_entry);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, password_entry);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, address_label);
gtk_widget_class_bind_template_child (widget_class, CcDesktopSharingPage, verify_encryption_button);
gtk_widget_class_bind_template_callback (widget_class, on_address_copy_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_port_copy_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_username_copy_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_password_copy_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_verify_encryption_button_clicked);
}
static gboolean
format_port_for_row (GBinding *binding,
const GValue *from_value,
GValue *to_value,
gpointer user_data)
{
int port = g_value_get_int (from_value);
if (port <= 0)
g_value_set_string (to_value, "");
else
g_value_take_string (to_value, g_strdup_printf ("%u", port));
return TRUE;
}
static void
on_connected_to_remote_desktop_rdp_server (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
CcDesktopSharingPage *self = user_data;
g_autoptr (GError) error = NULL;
g_clear_object (&self->rdp_server);
self->rdp_server = gsd_remote_desktop_rdp_server_proxy_new_finish (result, &error);
if (error)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Failed to create remote desktop proxy: %s", error->message);
return;
}
g_object_bind_property_full (self->rdp_server, "port",
self->port_row, "subtitle",
G_BINDING_SYNC_CREATE,
format_port_for_row,
NULL,
NULL,
NULL);
}
static void
connect_to_remote_desktop_rdp_server (CcDesktopSharingPage *self)
{
g_autoptr (GError) error = NULL;
g_autoptr (GDBusConnection) connection = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, self->cancellable, &error);
if (error)
g_warning ("Could not connect to system message bus: %s", error->message);
if (!connection)
return;
gsd_remote_desktop_rdp_server_proxy_new (connection,
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION,
RDP_SERVER_DBUS_SERVICE,
RDP_SERVER_OBJECT_PATH,
self->cancellable,
(GAsyncReadyCallback)
on_connected_to_remote_desktop_rdp_server,
self);
}
static void
cc_desktop_sharing_page_init (CcDesktopSharingPage *self)
{
@ -567,6 +651,7 @@ cc_desktop_sharing_page_init (CcDesktopSharingPage *self)
self->cancellable = g_cancellable_new ();
check_desktop_sharing_available (self);
connect_to_remote_desktop_rdp_server (self);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider,

View file

@ -10,37 +10,52 @@
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwSwitchRow" id="desktop_sharing_row">
<property name="title" translatable="yes">_Desktop Sharing</property>
<property name="use-underline">True</property>
<property name="subtitle" translatable="yes">Share your screen with remote connections</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="remote_control_row">
<property name="title" translatable="yes">Remote _Control</property>
<property name="use-underline">True</property>
<property name="subtitle" translatable="yes">Allows desktop sharing connections to control the screen</property>
<object class="GtkLabel">
<property name="label" translatable="yes">Share your existing desktop with other devices. The remote connection uses the existing screen resolution</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<property name="justify">center</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Connection Details</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Address</property>
<object class="AdwSwitchRow" id="desktop_sharing_row">
<property name="title" translatable="yes">_Desktop Sharing</property>
<property name="use-underline">True</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="remote_control_row">
<property name="title" translatable="yes">Remote _Control</property>
<property name="use-underline">True</property>
<property name="subtitle" translatable="yes">Allows desktop shares to control the screen</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">How to Connect</property>
<property name="description" translatable="yes">Use a remote desktop app to connect using the RDP protocol. Additional information about the device's network location may also be required.</property>
<child>
<object class="AdwActionRow" id="hostname_row">
<property name="title" translatable="yes">_Hostname</property>
<property name="use-underline">True</property>
<property name="activatable-widget">copy_address_button</property>
<style>
<class name="property"/>
</style>
<child type="suffix">
<object class="GtkBox">
<property name="spacing">10</property>
<child>
<object class="GtkLabel" id="address_label">
<property name="selectable">True</property>
</object>
</child>
<child>
<object class="GtkButton">
<object class="GtkButton" id="copy_address_button">
<property name="tooltip-text" translatable="yes">Copy</property>
<property name="valign">center</property>
<property name="icon-name">edit-copy-symbolic</property>
@ -57,6 +72,35 @@
</child>
</object>
</child>
<child>
<object class="AdwActionRow" id="port_row">
<property name="title" translatable="yes">_Port</property>
<property name="use-underline">True</property>
<property name="activatable-widget">copy_address_button</property>
<style>
<class name="property"/>
</style>
<child type="suffix">
<object class="GtkBox">
<property name="spacing">10</property>
<child>
<object class="GtkButton" id="copy_port_button">
<property name="tooltip-text" translatable="yes">Copy</property>
<property name="valign">center</property>
<property name="icon-name">edit-copy-symbolic</property>
<signal name="clicked" handler="on_port_copy_clicked" swapped="yes"/>
<accessibility>
<property name="label" translatable="yes">Copy</property>
</accessibility>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
@ -66,7 +110,10 @@
<child>
<object class="AdwEntryRow" id="username_entry">
<property name="title" translatable="yes">User Name</property>
<property name="title" translatable="yes">Username</property>
<style>
<class name="property"/>
</style>
<child type="suffix">
<object class="GtkButton">
<property name="tooltip-text" translatable="yes">Copy</property>
@ -87,6 +134,9 @@
<child>
<object class="AdwPasswordEntryRow" id="password_entry">
<property name="title" translatable="yes">Password</property>
<style>
<class name="property"/>
</style>
<child type="suffix">
<object class="GtkButton">
<property name="tooltip-text" translatable="yes">Copy</property>