Commit 96bcb94b authored by Julian Sparber's avatar Julian Sparber

accountsettings: add UI for account settings

* add UI for account settings
* display name and avatar

https://gitlab.gnome.org/World/fractal/issues/21
parent e7cc5354
......@@ -188,6 +188,24 @@ row .timestamp {
background-color: @theme_bg_color;
}
.advanced_revealer {
border-radius: 3px;
border: 1px solid @borders;
background-color: @theme_base_color;
}
.advanced_revealer_header {
padding: 18px;
}
.advanced_revealer_divider {
border-radius: 0px;
border-bottom: 1px solid @borders;
}
.advanced_revealer_body {
padding: 18px;
}
/*#FIXME css style to remove round corners in the header*/
stack headerbar:last-child:not(:only-child) {
border-top-left-radius: 0px;
......
......@@ -21,6 +21,7 @@
<file preprocess="xml-stripblanks">ui/room_config.ui</file>
<file preprocess="xml-stripblanks">ui/room_menu.ui</file>
<file preprocess="xml-stripblanks">ui/user_menu.ui</file>
<file preprocess="xml-stripblanks">ui/account_settings.ui</file>
<file preprocess="xml-stripblanks">ui/markdown_popover.ui</file>
<file preprocess="xml-stripblanks">ui/server_chooser_menu.ui</file>
<file preprocess="xml-stripblanks">ui/stickers_popover.ui</file>
......
This diff is collapsed.
......@@ -2,7 +2,6 @@
<!-- Generated with glade 3.20.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopoverMenu" id="user_popover">
<property name="can_focus">False</property>
<child>
......@@ -100,9 +99,22 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="account_settings_menu">
<property name="visible">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="action_name">app.account_settings</property>
......@@ -111,20 +123,20 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
......@@ -148,5 +160,4 @@
</packing>
</child>
</object>
</interface>
......@@ -9,6 +9,7 @@ use app::App;
impl App {
pub fn create_actions(&self) {
let settings = gio::SimpleAction::new("settings", None);
let account = gio::SimpleAction::new("account_settings", None);
let dir = gio::SimpleAction::new("directory", None);
let chat = gio::SimpleAction::new("start_chat", None);
let newr = gio::SimpleAction::new("new_room", None);
......@@ -27,6 +28,7 @@ impl App {
let op = &self.op;
op.lock().unwrap().gtk_app.add_action(&settings);
op.lock().unwrap().gtk_app.add_action(&account);
op.lock().unwrap().gtk_app.add_action(&dir);
op.lock().unwrap().gtk_app.add_action(&chat);
op.lock().unwrap().gtk_app.add_action(&newr);
......@@ -48,6 +50,8 @@ impl App {
settings.connect_activate(move |_, _| { println!("SETTINGS"); });
settings.set_enabled(false);
account.connect_activate(clone!(op => move |_, _| op.lock().unwrap().show_account_settings_dialog()) );
dir.connect_activate(clone!(op => move |_, _| op.lock().unwrap().set_state(AppState::Directory) ));
logout.connect_activate(clone!(op => move |_, _| op.lock().unwrap().logout() ));
room.connect_activate(clone!(op => move |_, _| op.lock().unwrap().show_room_dialog() ));
......
extern crate gtk;
use self::gtk::prelude::*;
use glib;
//use std::sync::{Arc, Mutex};
use app::App;
impl App {
pub fn connect_account_settings(&self) {
let op = &self.op;
let builder = &self.ui.builder;
let cancel = self.ui.builder
.get_object::<gtk::Button>("cancel_account_settings")
.expect("Can't find cancel_account_settings in ui file.");
let dialog = self.ui.builder
.get_object::<gtk::Dialog>("account_settings_dialog")
.expect("Can't find account_settings_dialog in ui file.");
let advanced_toggle = self.ui.builder
.get_object::<gtk::EventBox>("account_settings_advanced_toggle")
.expect("Can't find account_settings_advanced_toggle in ui file.");
let delete_toggle = self.ui.builder
.get_object::<gtk::EventBox>("account_settings_delete_toggle")
.expect("Can't find account_settings_delete_toggle in ui file.");
dialog.connect_delete_event(clone!(op => move |_, _| {
op.lock().unwrap().close_account_settings_dialog();
glib::signal::Inhibit(true)
}));
cancel.connect_clicked(clone!(op => move |_| {
op.lock().unwrap().close_account_settings_dialog();
}));
advanced_toggle.connect_button_press_event(clone!(builder => move |this, _| {
let widget = builder
.get_object::<gtk::Revealer>("account_settings_advanced")
.expect("Can't find account_settings_advanced in ui file.");
if widget.get_reveal_child() {
this.get_style_context().unwrap().remove_class("advanced_revealer_divider");
widget.set_reveal_child(false);
}
else {
this.get_style_context().unwrap().add_class("advanced_revealer_divider");
widget.set_reveal_child(true);
}
glib::signal::Inhibit(false)
}));
delete_toggle.connect_button_press_event(clone!(builder => move |this, _| {
let widget = builder
.get_object::<gtk::Revealer>("account_settings_delete")
.expect("Can't find account_settings_delete in ui file.");
if widget.get_reveal_child() {
this.get_style_context().unwrap().remove_class("advanced_revealer_divider");
widget.set_reveal_child(false);
}
else {
this.get_style_context().unwrap().add_class("advanced_revealer_divider");
widget.set_reveal_child(true);
}
glib::signal::Inhibit(false)
}));
/*
invite.set_sensitive(false);
invite.connect_clicked(clone!(op => move |_| {
op.lock().unwrap().start_chat();
}));
*/
}
}
......@@ -5,6 +5,7 @@ use self::gtk::prelude::*;
mod attach;
mod autocomplete;
mod direct;
mod account;
mod directory;
mod headerbar;
mod invite;
......@@ -83,6 +84,7 @@ impl App {
self.connect_leave_room_dialog();
self.connect_new_room_dialog();
self.connect_join_room_dialog();
self.connect_account_settings();
self.connect_search();
......
extern crate gtk;
use self::gtk::prelude::*;
use appop::AppOp;
//use backend::BKCommand;
use widgets;
use widgets::AvatarExt;
impl AppOp {
pub fn show_account_settings_dialog(&self) {
let dialog = self.ui.builder
.get_object::<gtk::Dialog>("account_settings_dialog")
.expect("Can't find account_settings_dialog in ui file.");
let avatar = self.ui.builder
.get_object::<gtk::Container>("account_settings_avatar")
.expect("Can't find account_settings_avatar in ui file.");
let name = self.ui.builder
.get_object::<gtk::Entry>("account_settings_name")
.expect("Can't find account_settings_name in ui file.");
/* remove all old avatar from the popover */
for w in avatar.get_children().iter() {
avatar.remove(w);
}
name.set_text(&self.username.clone().unwrap_or_default());
name.grab_focus_without_selecting();
name.set_position(-1);
let w = widgets::Avatar::circle_avatar(self.avatar.clone().unwrap_or_default(), Some(100));
avatar.add(&w);
avatar.show();
dialog.present();
}
pub fn close_account_settings_dialog(&mut self) {
let dialog = self.ui.builder
.get_object::<gtk::Dialog>("account_settings_dialog")
.expect("Can't find account_settings_dialog in ui file.");
/*
let avatar = self.ui.builder
.get_object::<gtk::Container>("account_settings_avatar")
.expect("Can't find account_settings_avatar in ui file.");
let name = self.ui.builder
.get_object::<gtk::Entry>("account_settings_name")
.expect("Can't find account_settings_name in ui file.");
*/
let advanced = self.ui.builder
.get_object::<gtk::Revealer>("account_settings_advanced")
.expect("Can't find account_settings_advanced in ui file.");
let delete = self.ui.builder
.get_object::<gtk::Revealer>("account_settings_delete")
.expect("Can't find account_settings_delete in ui file.");
let advanced_toggle = self.ui.builder
.get_object::<gtk::EventBox>("account_settings_advanced_toggle")
.expect("Can't find account_settings_advanced_toggle in ui file.");
let delete_toggle = self.ui.builder
.get_object::<gtk::EventBox>("account_settings_delete_toggle")
.expect("Can't find account_settings_delete_toggle in ui file.");
advanced_toggle.get_style_context().unwrap().remove_class("advanced_revealer_divider");
delete_toggle.get_style_context().unwrap().remove_class("advanced_revealer_divider");
advanced.set_reveal_child(false);
delete.set_reveal_child(false);
dialog.hide();
dialog.resize(700, 200);
}
}
......@@ -29,6 +29,7 @@ use app::InternalCommand;
mod login;
mod sync;
mod user;
mod account;
mod notifications;
mod state;
mod room;
......
......@@ -9,7 +9,7 @@ pub struct UI {
impl UI {
pub fn new() -> UI {
// The orther here is important because some ui file depends on others
// The order here is important because some ui file depends on others
let builder = gtk::Builder::new();
......@@ -52,6 +52,8 @@ impl UI {
.expect("Can't load ui file: new_room.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/room_config.ui")
.expect("Can't load ui file: room_config.ui");
builder.add_from_resource("/org/gnome/Fractal/ui/account_settings.ui")
.expect("Can't load ui file: account_settings.ui");
// Depends on room config
builder.add_from_resource("/org/gnome/Fractal/ui/filechooser.ui")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment