Browse Source
The main goal here is to move safety-related settings to a new tab so we can add more in the future. Since we do not want more tabs, we have to: - Move the sessions to a subpage accessible with a button in the "General" tab. While we are here, we reorder most of this tab. - Move the settings that were in the "Privacy" section of the "Security" tab to a new "Safety" tab. - Rename the "Security" tab to "Encryption", to avoid confusion between "Security" and "Safety".merge-requests/1958/merge
27 changed files with 476 additions and 348 deletions
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 786 B |
@ -1,36 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<interface> |
||||
<template class="SecurityPage" parent="AdwPreferencesPage"> |
||||
<property name="icon-name">security-symbolic</property> |
||||
<property name="title" translatable="yes">Security</property> |
||||
<property name="name">security</property> |
||||
<child> |
||||
<object class="AdwPreferencesGroup"> |
||||
<property name="title" translatable="yes">Privacy</property> |
||||
<child> |
||||
<object class="AdwSwitchRow" id="public_read_receipts_row"> |
||||
<property name="selectable">False</property> |
||||
<property name="title" translatable="yes">Send Read Receipts</property> |
||||
<property name="subtitle" translatable="yes">Allow other members of the rooms you participate in to track which messages you have seen</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="AdwSwitchRow" id="typing_row"> |
||||
<property name="selectable">False</property> |
||||
<property name="title" translatable="yes">Send Typing Notifications</property> |
||||
<property name="subtitle" translatable="yes">Allow other members of the rooms you participate in to see when you are typing a message</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="ButtonCountRow" id="ignored_users_row"> |
||||
<property name="title" translatable="yes">Ignored Users</property> |
||||
<property name="subtitle" translatable="yes">All messages or invitations sent by these users will be ignored. You will still see some of their activity, like when they join or leave a room.</property> |
||||
<property name="action-name">account-settings.show-subpage</property> |
||||
<property name="action-target">'ignored-users'</property> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
<template class="EncryptionPage" parent="AdwPreferencesPage"> |
||||
<property name="icon-name">encryption-symbolic</property> |
||||
<property name="title" translatable="yes">Encryption</property> |
||||
<property name="name">encryption</property> |
||||
<child> |
||||
<object class="AdwPreferencesGroup"> |
||||
<property name="title" translatable="yes">Crypto Identity</property> |
||||
@ -0,0 +1,137 @@
|
||||
use adw::{prelude::*, subclass::prelude::*}; |
||||
use gtk::{glib, glib::clone, CompositeTemplate}; |
||||
|
||||
mod ignored_users_subpage; |
||||
|
||||
pub(super) use self::ignored_users_subpage::IgnoredUsersSubpage; |
||||
use crate::{components::ButtonCountRow, session::model::Session}; |
||||
|
||||
mod imp { |
||||
use std::cell::RefCell; |
||||
|
||||
use glib::subclass::InitializingObject; |
||||
|
||||
use super::*; |
||||
|
||||
#[derive(Debug, Default, CompositeTemplate, glib::Properties)] |
||||
#[template(resource = "/org/gnome/Fractal/ui/session/view/account_settings/safety_page/mod.ui")] |
||||
#[properties(wrapper_type = super::SafetyPage)] |
||||
pub struct SafetyPage { |
||||
#[template_child] |
||||
public_read_receipts_row: TemplateChild<adw::SwitchRow>, |
||||
#[template_child] |
||||
typing_row: TemplateChild<adw::SwitchRow>, |
||||
#[template_child] |
||||
ignored_users_row: TemplateChild<ButtonCountRow>, |
||||
/// The current session.
|
||||
#[property(get, set = Self::set_session, nullable)] |
||||
session: glib::WeakRef<Session>, |
||||
ignored_users_count_handler: RefCell<Option<glib::SignalHandlerId>>, |
||||
bindings: RefCell<Vec<glib::Binding>>, |
||||
} |
||||
|
||||
#[glib::object_subclass] |
||||
impl ObjectSubclass for SafetyPage { |
||||
const NAME: &'static str = "SafetyPage"; |
||||
type Type = super::SafetyPage; |
||||
type ParentType = adw::PreferencesPage; |
||||
|
||||
fn class_init(klass: &mut Self::Class) { |
||||
Self::bind_template(klass); |
||||
} |
||||
|
||||
fn instance_init(obj: &InitializingObject<Self>) { |
||||
obj.init_template(); |
||||
} |
||||
} |
||||
|
||||
#[glib::derived_properties] |
||||
impl ObjectImpl for SafetyPage { |
||||
fn dispose(&self) { |
||||
if let Some(session) = self.session.upgrade() { |
||||
if let Some(handler) = self.ignored_users_count_handler.take() { |
||||
session.ignored_users().disconnect(handler); |
||||
} |
||||
} |
||||
|
||||
for binding in self.bindings.take() { |
||||
binding.unbind(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
impl WidgetImpl for SafetyPage {} |
||||
impl PreferencesPageImpl for SafetyPage {} |
||||
|
||||
impl SafetyPage { |
||||
/// Set the current session.
|
||||
fn set_session(&self, session: Option<&Session>) { |
||||
let prev_session = self.session.upgrade(); |
||||
|
||||
if prev_session.as_ref() == session { |
||||
return; |
||||
} |
||||
|
||||
if let Some(session) = prev_session { |
||||
if let Some(handler) = self.ignored_users_count_handler.take() { |
||||
session.ignored_users().disconnect(handler); |
||||
} |
||||
} |
||||
for binding in self.bindings.take() { |
||||
binding.unbind(); |
||||
} |
||||
|
||||
if let Some(session) = session { |
||||
let ignored_users = session.ignored_users(); |
||||
let ignored_users_count_handler = ignored_users.connect_items_changed(clone!( |
||||
#[weak(rename_to = imp)] |
||||
self, |
||||
move |ignored_users, _, _, _| { |
||||
imp.ignored_users_row |
||||
.set_count(ignored_users.n_items().to_string()); |
||||
} |
||||
)); |
||||
self.ignored_users_row |
||||
.set_count(ignored_users.n_items().to_string()); |
||||
|
||||
self.ignored_users_count_handler |
||||
.replace(Some(ignored_users_count_handler)); |
||||
|
||||
let session_settings = session.settings(); |
||||
|
||||
let public_read_receipts_binding = session_settings |
||||
.bind_property( |
||||
"public-read-receipts-enabled", |
||||
&*self.public_read_receipts_row, |
||||
"active", |
||||
) |
||||
.bidirectional() |
||||
.sync_create() |
||||
.build(); |
||||
let typing_binding = session_settings |
||||
.bind_property("typing-enabled", &*self.typing_row, "active") |
||||
.bidirectional() |
||||
.sync_create() |
||||
.build(); |
||||
|
||||
self.bindings |
||||
.replace(vec![public_read_receipts_binding, typing_binding]); |
||||
} |
||||
|
||||
self.session.set(session); |
||||
self.obj().notify_session(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
glib::wrapper! { |
||||
/// Safety settings page.
|
||||
pub struct SafetyPage(ObjectSubclass<imp::SafetyPage>) |
||||
@extends gtk::Widget, adw::PreferencesPage, @implements gtk::Accessible; |
||||
} |
||||
|
||||
impl SafetyPage { |
||||
pub fn new(session: &Session) -> Self { |
||||
glib::Object::builder().property("session", session).build() |
||||
} |
||||
} |
||||
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<interface> |
||||
<template class="SafetyPage" parent="AdwPreferencesPage"> |
||||
<property name="icon-name">safety-symbolic</property> |
||||
<property name="title" translatable="yes">Safety</property> |
||||
<property name="name">safety</property> |
||||
<child> |
||||
<object class="AdwPreferencesGroup"> |
||||
<child> |
||||
<object class="ButtonCountRow" id="ignored_users_row"> |
||||
<property name="title" translatable="yes">Ignored Users</property> |
||||
<property name="subtitle" translatable="yes">All messages or invitations sent by these users will be ignored. You will still see some of their activity, like when they join or leave a room.</property> |
||||
<property name="action-name">account-settings.show-subpage</property> |
||||
<property name="action-target">'ignored-users'</property> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="AdwPreferencesGroup"> |
||||
<property name="title" translatable="yes">Privacy</property> |
||||
<child> |
||||
<object class="AdwSwitchRow" id="public_read_receipts_row"> |
||||
<property name="selectable">False</property> |
||||
<property name="title" translatable="yes">Send Read Receipts</property> |
||||
<property name="subtitle" translatable="yes">Allow other members of the rooms you participate in to track which messages you have seen</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="AdwSwitchRow" id="typing_row"> |
||||
<property name="selectable">False</property> |
||||
<property name="title" translatable="yes">Send Typing Notifications</property> |
||||
<property name="subtitle" translatable="yes">Allow other members of the rooms you participate in to see when you are typing a message</property> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</template> |
||||
</interface> |
||||
@ -0,0 +1,6 @@
|
||||
mod user_session_list_subpage; |
||||
mod user_session_row; |
||||
mod user_session_subpage; |
||||
|
||||
use self::user_session_row::*; |
||||
pub(super) use self::{user_session_list_subpage::*, user_session_subpage::*}; |
||||
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<interface> |
||||
<template class="UserSessionListSubpage" parent="AdwNavigationPage"> |
||||
<property name="title" translatable="yes">Sessions</property> |
||||
<property name="child"> |
||||
<object class="AdwToolbarView"> |
||||
<child type="top"> |
||||
<object class="AdwHeaderBar"/> |
||||
</child> |
||||
<property name="content"> |
||||
<object class="AdwPreferencesPage"> |
||||
<child> |
||||
<object class="AdwPreferencesGroup" id="current_session_group"> |
||||
<property name="title" translatable="yes">Current Session</property> |
||||
<child> |
||||
<object class="GtkListBox" id="current_session"> |
||||
<accessibility> |
||||
<property name="label" translatable="yes">Current Session</property> |
||||
</accessibility> |
||||
<signal name="row-activated" handler="show_session_subpage" swapped="yes"/> |
||||
<style> |
||||
<class name="content"/> |
||||
</style> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="AdwPreferencesGroup" id="other_sessions_group"> |
||||
<property name="title" translatable="yes">Other Active Sessions</property> |
||||
<child> |
||||
<object class="GtkStack" id="stack"> |
||||
<property name="transition-type">crossfade</property> |
||||
<child> |
||||
<object class="GtkStackPage"> |
||||
<property name="name">loading</property> |
||||
<property name="child"> |
||||
<object class="AdwSpinner"> |
||||
<property name="width-request">32</property> |
||||
<property name="height-request">32</property> |
||||
<property name="halign">center</property> |
||||
<property name="margin-top">24</property> |
||||
<property name="margin-bottom">24</property> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="GtkStackPage"> |
||||
<property name="name">list</property> |
||||
<property name="child"> |
||||
<object class="GtkListBox" id="other_sessions"> |
||||
<accessibility> |
||||
<property name="label" translatable="yes">Other Active Sessions</property> |
||||
</accessibility> |
||||
<signal name="row-activated" handler="show_session_subpage" swapped="yes"/> |
||||
<style> |
||||
<class name="content"/> |
||||
</style> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="GtkStackPage"> |
||||
<property name="name">error</property> |
||||
<property name="child"> |
||||
<object class="GtkBox"> |
||||
<property name="orientation">vertical</property> |
||||
<property name="spacing">18</property> |
||||
<property name="margin-top">24</property> |
||||
<property name="margin-bottom">24</property> |
||||
<child> |
||||
<object class="GtkLabel"> |
||||
<property name="wrap">true</property> |
||||
<property name="wrap-mode">word-char</property> |
||||
<property name="label" translatable="yes">Could not load the list of connected devices</property> |
||||
<style> |
||||
<class name="dimmed"/> |
||||
</style> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="GtkButton"> |
||||
<property name="can-shrink">true</property> |
||||
<property name="label" translatable="yes">Try Again</property> |
||||
<property name="halign">center</property> |
||||
<property name="action-name">account-settings.reload-user-sessions</property> |
||||
<style> |
||||
<class name="suggested-action"/> |
||||
<class name="standalone-button"/> |
||||
<class name="pill"/> |
||||
</style> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</property> |
||||
</template> |
||||
</interface> |
||||
@ -1,100 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<interface> |
||||
<template class="UserSessionsPage" parent="AdwPreferencesPage"> |
||||
<property name="icon-name">devices-symbolic</property> |
||||
<property name="title" translatable="yes">Sessions</property> |
||||
<property name="name">sessions</property> |
||||
<child> |
||||
<object class="AdwPreferencesGroup" id="current_session_group"> |
||||
<property name="title" translatable="yes">Current Session</property> |
||||
<child> |
||||
<object class="GtkListBox" id="current_session"> |
||||
<accessibility> |
||||
<property name="label" translatable="yes">Current Session</property> |
||||
</accessibility> |
||||
<signal name="row-activated" handler="show_session_subpage" swapped="yes"/> |
||||
<style> |
||||
<class name="content"/> |
||||
</style> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="AdwPreferencesGroup" id="other_sessions_group"> |
||||
<property name="title" translatable="yes">Other Active Sessions</property> |
||||
<child> |
||||
<object class="GtkStack" id="stack"> |
||||
<property name="transition-type">crossfade</property> |
||||
<child> |
||||
<object class="GtkStackPage"> |
||||
<property name="name">loading</property> |
||||
<property name="child"> |
||||
<object class="AdwSpinner"> |
||||
<property name="width-request">32</property> |
||||
<property name="height-request">32</property> |
||||
<property name="halign">center</property> |
||||
<property name="margin-top">24</property> |
||||
<property name="margin-bottom">24</property> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="GtkStackPage"> |
||||
<property name="name">list</property> |
||||
<property name="child"> |
||||
<object class="GtkListBox" id="other_sessions"> |
||||
<accessibility> |
||||
<property name="label" translatable="yes">Other Active Sessions</property> |
||||
</accessibility> |
||||
<signal name="row-activated" handler="show_session_subpage" swapped="yes"/> |
||||
<style> |
||||
<class name="content"/> |
||||
</style> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="GtkStackPage"> |
||||
<property name="name">error</property> |
||||
<property name="child"> |
||||
<object class="GtkBox"> |
||||
<property name="orientation">vertical</property> |
||||
<property name="spacing">18</property> |
||||
<property name="margin-top">24</property> |
||||
<property name="margin-bottom">24</property> |
||||
<child> |
||||
<object class="GtkLabel"> |
||||
<property name="wrap">true</property> |
||||
<property name="wrap-mode">word-char</property> |
||||
<property name="label" translatable="yes">Could not load the list of connected devices</property> |
||||
<style> |
||||
<class name="dimmed"/> |
||||
</style> |
||||
</object> |
||||
</child> |
||||
<child> |
||||
<object class="GtkButton"> |
||||
<property name="can-shrink">true</property> |
||||
<property name="label" translatable="yes">Try Again</property> |
||||
<property name="halign">center</property> |
||||
<property name="action-name">account-settings.reload-user-sessions</property> |
||||
<style> |
||||
<class name="suggested-action"/> |
||||
<class name="standalone-button"/> |
||||
<class name="pill"/> |
||||
</style> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</property> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</object> |
||||
</child> |
||||
</template> |
||||
</interface> |
||||
Loading…
Reference in new issue