system: Move "Remote Login" from Sharing panel to System

Fixes #2836
This commit is contained in:
Felipe Borges 2024-01-30 14:12:34 +01:00
parent 617816be06
commit c0c357c3bc
16 changed files with 278 additions and 118 deletions

View file

@ -24,11 +24,9 @@
#include "cc-list-row.h"
#include "cc-sharing-resources.h"
#include "cc-remote-login.h"
#include "file-share-properties.h"
#include "cc-media-sharing.h"
#include "cc-sharing-networks.h"
#include "cc-systemd-service.h"
#include "org.gnome.SettingsDaemon.Sharing.h"
#ifdef GDK_WINDOWING_WAYLAND
@ -69,10 +67,6 @@ struct _CcSharingPanel
GtkWidget *personal_file_sharing_require_password_switch_row;
GtkWidget *personal_file_sharing_row;
GtkWidget *personal_file_sharing_switch;
GtkWidget *remote_login_dialog;
AdwPreferencesPage *remote_login_page;
GtkWidget *remote_login_row;
GtkWidget *remote_login_switch;
GtkWidget *shared_folders_grid;
GtkWidget *shared_folders_listbox;
@ -99,12 +93,6 @@ cc_sharing_panel_dispose (GObject *object)
self->personal_file_sharing_dialog = NULL;
}
if (self->remote_login_dialog)
{
gtk_window_destroy (GTK_WINDOW (self->remote_login_dialog));
self->remote_login_dialog = NULL;
}
G_OBJECT_CLASS (cc_sharing_panel_parent_class)->dispose (object);
}
@ -140,10 +128,6 @@ cc_sharing_panel_class_init (CcSharingPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_require_password_switch_row);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_vbox);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, personal_file_sharing_row);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_dialog);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_page);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_row);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, remote_login_switch);
gtk_widget_class_bind_template_child (widget_class, CcSharingPanel, shared_folders_listbox);
g_type_ensure (CC_TYPE_LIST_ROW);
@ -527,12 +511,6 @@ cc_sharing_panel_setup_label_with_hostname (CcSharingPanel *self,
/* TRANSLATORS: %s is replaced with a link to a dav://<hostname> URL */
text = g_strdup_printf (_("File Sharing allows you to share your Public folder with others on your current network using: %s"), url);
}
else if (page == self->remote_login_page)
{
g_autofree gchar *command = g_strdup_printf ("<a href=\"ssh %s\">ssh %s</a>", hostname, hostname);
/* TRANSLATORS: %s is replaced with a link to a "ssh <hostname>" command to run */
text = g_strdup_printf (_("When remote login is enabled, remote users can connect using the Secure Shell command:\n%s"), command);
}
else
g_assert_not_reached ();
@ -609,24 +587,6 @@ cc_sharing_panel_setup_personal_file_sharing_dialog (CcSharingPanel *self)
self->personal_file_sharing_row);
}
static void
remote_login_switch_activate (CcSharingPanel *self)
{
cc_remote_login_set_enabled (cc_panel_get_cancellable (CC_PANEL (self)), ADW_SWITCH_ROW (self->remote_login_switch));
}
static void
cc_sharing_panel_setup_remote_login_dialog (CcSharingPanel *self)
{
cc_remote_login_get_enabled (ADW_SWITCH_ROW (self->remote_login_switch));
cc_sharing_panel_bind_switch_to_label (self, self->remote_login_switch,
self->remote_login_row);
g_signal_connect_object (self->remote_login_switch, "notify::active",
G_CALLBACK (remote_login_switch_activate), self, G_CONNECT_SWAPPED);
}
static gboolean
cc_sharing_panel_check_schema_available (CcSharingPanel *self,
const gchar *schema_id)
@ -674,19 +634,13 @@ sharing_proxy_ready (GObject *source,
else
gtk_widget_set_visible (self->personal_file_sharing_row, FALSE);
/* remote login */
cc_sharing_panel_setup_remote_login_dialog (self);
parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self)));
gtk_window_set_transient_for (GTK_WINDOW (self->media_sharing_dialog),
GTK_WINDOW (parent));
gtk_window_set_transient_for (GTK_WINDOW (self->personal_file_sharing_dialog),
GTK_WINDOW (parent));
gtk_window_set_transient_for (GTK_WINDOW (self->remote_login_dialog),
GTK_WINDOW (parent));
cc_sharing_panel_setup_label_with_hostname (self, self->personal_file_sharing_page);
cc_sharing_panel_setup_label_with_hostname (self, self->remote_login_page);
}
static void

View file

@ -39,15 +39,6 @@
<signal name="activated" handler="gtk_window_present" object="media_sharing_dialog"/>
</object>
</child>
<child>
<object class="CcListRow" id="remote_login_row">
<property name="icon-name">utilities-terminal-symbolic</property>
<property name="show-arrow">True</property>
<property name="subtitle" translatable="yes">Enable SSH access for this device</property>
<property name="title" translatable="yes">_Remote Login</property>
<signal name="activated" handler="gtk_window_present" object="remote_login_dialog"/>
</object>
</child>
</object>
</child>
</object>
@ -134,48 +125,6 @@
</property>
</object>
<object class="AdwWindow" id="remote_login_dialog">
<property name="title" translatable="yes">Remote Login</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="hide-on-close">True</property>
<property name="width-request">360</property>
<property name="height-request">294</property>
<property name="default-width">360</property>
<property name="default-height">294</property>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">Escape</property>
<property name="action">action(window.close)</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar"/>
</child>
<property name="content">
<object class="AdwPreferencesPage" id="remote_login_page">
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwSwitchRow" id="remote_login_switch">
<property name="title" translatable="yes">_Remote Login</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</property>
</object>
<object class="AdwWindow" id="media_sharing_dialog">
<property name="title" translatable="yes">Media Sharing</property>

View file

@ -10,31 +10,10 @@ i18n.merge_file(
install_dir: control_center_desktopdir
)
polkit_conf = configuration_data()
polkit_conf.set('libexecdir', control_center_libexecdir)
polkit = 'org.gnome.controlcenter.remote-login-helper.policy'
polkit_in = configure_file(
input: polkit + '.in.in',
output: polkit + '.in',
configuration: polkit_conf
)
i18n.merge_file(
input: polkit_in,
output: polkit,
po_dir: po_dir,
install: true,
install_dir: join_paths(control_center_datadir, 'polkit-1', 'actions')
)
sources = files(
'cc-sharing-panel.c',
'cc-media-sharing.c',
'cc-remote-login.c',
'cc-sharing-networks.c',
'cc-systemd-service.c',
'file-share-properties.c',
)

View file

@ -31,6 +31,7 @@
#include "datetime/cc-datetime-page.h"
#include "region/cc-region-page.h"
#include "remote-desktop/cc-remote-desktop-page.h"
#include "remote-login/cc-remote-login-page.h"
#include "users/cc-users-page.h"
struct _CcSystemPanel
@ -38,10 +39,27 @@ struct _CcSystemPanel
CcPanel parent_instance;
AdwNavigationView *navigation;
GtkWidget *remote_login_dialog;
};
CC_PANEL_REGISTER (CcSystemPanel, cc_system_panel)
static void
on_secure_shell_row_clicked (CcSystemPanel *self)
{
if (self->remote_login_dialog == NULL) {
GtkWidget *parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self)));
self->remote_login_dialog = g_object_new (CC_TYPE_REMOTE_LOGIN_PAGE, NULL);
gtk_window_set_transient_for (GTK_WINDOW (self->remote_login_dialog),
GTK_WINDOW (parent));
}
gtk_window_present (GTK_WINDOW (self->remote_login_dialog));
}
static void
cc_system_panel_class_init (CcSystemPanelClass *klass)
{
@ -51,10 +69,13 @@ cc_system_panel_class_init (CcSystemPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcSystemPanel, navigation);
gtk_widget_class_bind_template_callback (widget_class, on_secure_shell_row_clicked);
g_type_ensure (CC_TYPE_ABOUT_PAGE);
g_type_ensure (CC_TYPE_DATE_TIME_PAGE);
g_type_ensure (CC_TYPE_REGION_PAGE);
g_type_ensure (CC_TYPE_REMOTE_DESKTOP_PAGE);
g_type_ensure (CC_TYPE_REMOTE_LOGIN_PAGE);
g_type_ensure (CC_TYPE_USERS_PAGE);
}

View file

@ -64,6 +64,16 @@
</object>
</child>
<child>
<object class="CcListRow">
<property name="title" translatable="yes">Secu_re Shell</property>
<property name="subtitle" translatable="yes">SSH network access</property>
<property name="icon-name">utilities-terminal-symbolic</property>
<property name="show-arrow">True</property>
<signal name="activated" handler="on_secure_shell_row_clicked" object="CcSystemPanel" swapped="yes"/>
</object>
</child>
<child>
<object class="CcListRow">
<property name="title" translatable="yes">_About</property>

View file

@ -42,6 +42,9 @@ sources = files(
'remote-desktop/cc-remote-desktop-page.c',
'remote-desktop/cc-tls-certificate.c',
'remote-desktop/cc-systemd-service.c',
'remote-login/cc-remote-login.c',
'remote-login/cc-remote-login-page.c',
'remote-login/cc-systemd-service.c',
'users/cc-add-user-dialog.c',
'users/cc-avatar-chooser.c',
'users/cc-crop-area.c',
@ -141,6 +144,7 @@ subdir('about')
subdir('datetime')
subdir('region')
subdir('remote-desktop')
subdir('remote-login')
subdir('users')
panels_libs += static_library(

View file

@ -0,0 +1,111 @@
/*
* Copyright 2024 Red Hat, Inc
*
* 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/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "cc-remote-login-page"
#include <glib/gi18n.h>
#include "cc-hostname.c"
#include "cc-list-row.h"
#include "cc-remote-login.h"
#include "cc-remote-login-page.h"
#include "cc-systemd-service.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
struct _CcRemoteLoginPage {
AdwWindow parent_instance;
AdwActionRow *hostname_row;
AdwSwitchRow *remote_login_row;
AdwToastOverlay *toast_overlay;
GCancellable *cancellable;
};
G_DEFINE_TYPE (CcRemoteLoginPage, cc_remote_login_page, ADW_TYPE_WINDOW)
static void
on_copy_ssh_command_button_clicked (CcRemoteLoginPage *self)
{
gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (self)),
adw_action_row_get_subtitle (ADW_ACTION_ROW (self->hostname_row)));
adw_toast_overlay_add_toast (self->toast_overlay, adw_toast_new (_("Command copied")));
}
static void
remote_login_row_activate (CcRemoteLoginPage *self)
{
cc_remote_login_set_enabled (self->cancellable, self->remote_login_row);
}
static void
cc_remote_login_page_dispose (GObject *object)
{
CcRemoteLoginPage *self = (CcRemoteLoginPage *) object;
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
G_OBJECT_CLASS (cc_remote_login_page_parent_class)->dispose (object);
}
static void
cc_remote_login_page_class_init (CcRemoteLoginPageClass * klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = cc_remote_login_page_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/system/remote-login/cc-remote-login-page.ui");
gtk_widget_class_bind_template_child (widget_class, CcRemoteLoginPage, hostname_row);
gtk_widget_class_bind_template_child (widget_class, CcRemoteLoginPage, remote_login_row);
gtk_widget_class_bind_template_child (widget_class, CcRemoteLoginPage, toast_overlay);
gtk_widget_class_bind_template_callback (widget_class, on_copy_ssh_command_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, remote_login_row_activate);
}
static void
cc_remote_login_page_init (CcRemoteLoginPage *self)
{
g_autofree gchar *hostname = NULL;
g_autofree gchar *command = NULL;
gtk_widget_init_template (GTK_WIDGET (self));
self->cancellable = g_cancellable_new ();
cc_remote_login_get_enabled (self->remote_login_row);
g_signal_connect_object (self->remote_login_row,
"notify::active",
G_CALLBACK (remote_login_row_activate),
self,
G_CONNECT_SWAPPED);
hostname = cc_hostname_get_display_hostname (cc_hostname_get_default ());
command = g_strdup_printf ("ssh %s", hostname);
adw_action_row_set_subtitle (self->hostname_row, command);
}

View file

@ -0,0 +1,30 @@
/*
* Copyright 2024 Red Hat, Inc
*
* 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/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <adwaita.h>
G_BEGIN_DECLS
#define CC_TYPE_REMOTE_LOGIN_PAGE (cc_remote_login_page_get_type ())
G_DECLARE_FINAL_TYPE (CcRemoteLoginPage, cc_remote_login_page, CC, CC_TYPE_REMOTE_LOGIN_PAGE, AdwWindow)
G_END_DECLS

View file

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="CcRemoteLoginPage" parent="AdwWindow">
<property name="title" translatable="yes">Secure Shell</property>
<property name="hide-on-close">True</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="destroy-with-parent">True</property>
<property name="width-request">360</property>
<property name="height-request">294</property>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">Escape</property>
<property name="action">action(window.close)</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar"/>
</child>
<property name="content">
<object class="AdwToastOverlay" id="toast_overlay">
<property name="child">
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="GtkLabel">
<property name="halign">center</property>
<property name="wrap">True</property>
<property name="lines">2</property>
<property name="label" translatable="yes">Access this device using Secure Shell (SSH)</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwSwitchRow" id="remote_login_row">
<property name="title" translatable="yes">Secu_re Shell</property>
<property name="use-underline">True</property>
<property name="sensitive">False</property>
</object>
</child>
<child>
<object class="AdwActionRow" id="hostname_row">
<property name="title" translatable="yes">SSH Login Command</property>
<style>
<class name="property"/>
</style>
<child type="suffix">
<object class="GtkButton">
<property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Copy</property>
<property name="icon-name">edit-copy-symbolic</property>
<signal name="clicked" handler="on_copy_ssh_command_button_clicked" object="CcRemoteLoginPage" swapped="yes"/>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</property>
</object>
</property>
</template>
</interface>

View file

@ -0,0 +1,17 @@
polkit_conf = configuration_data()
polkit_conf.set('libexecdir', control_center_libexecdir)
polkit = 'org.gnome.controlcenter.remote-login-helper.policy'
polkit_in = configure_file(
input: polkit + '.in.in',
output: polkit + '.in',
configuration: polkit_conf
)
i18n.merge_file(
input: polkit_in,
output: polkit,
po_dir: po_dir,
install: true,
install_dir: join_paths(control_center_datadir, 'polkit-1', 'actions')
)

View file

@ -15,6 +15,7 @@
<file preprocess="xml-stripblanks">region/cc-format-preview.ui</file>
<file preprocess="xml-stripblanks">remote-desktop/cc-remote-desktop-page.ui</file>
<file>remote-desktop/remote-desktop.css</file>
<file preprocess="xml-stripblanks">remote-login/cc-remote-login-page.ui</file>
<file preprocess="xml-stripblanks">users/cc-add-user-dialog.ui</file>
<file preprocess="xml-stripblanks">users/cc-avatar-chooser.ui</file>
<file preprocess="xml-stripblanks">users/cc-fingerprint-dialog.ui</file>