mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 08:44:40 +01:00
objects: Chain up before on constructed
This commit is contained in:
parent
a889337d66
commit
01fe270a55
11 changed files with 54 additions and 68 deletions
|
@ -112,8 +112,8 @@ mod imp {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.action_set_enabled("add.save", false);
|
||||
self.parent_constructed(obj);
|
||||
obj.action_set_enabled("add.save", false);
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for AccountAddDialog {}
|
||||
|
|
|
@ -136,18 +136,18 @@ mod imp {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.init_widgets();
|
||||
self.parent_constructed(obj);
|
||||
obj.setup_widget();
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for AccountDetailsPage {
|
||||
fn unmap(&self, widget: &Self::Type) {
|
||||
self.parent_unmap(widget);
|
||||
self.edit_stack.set_visible_child_name("edit");
|
||||
self.account_label.stop_editing(false);
|
||||
self.counter_label.stop_editing(false);
|
||||
self.provider_stack.set_visible_child_name("display");
|
||||
self.provider_entry.set_text("");
|
||||
self.parent_unmap(widget);
|
||||
}
|
||||
}
|
||||
impl BoxImpl for AccountDetailsPage {}
|
||||
|
@ -158,7 +158,7 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl AccountDetailsPage {
|
||||
fn init_widgets(&self) {
|
||||
fn setup_widget(&self) {
|
||||
let imp = self.imp();
|
||||
imp.qrcode_picture
|
||||
.set_paintable(Some(&imp.qrcode_paintable));
|
||||
|
|
|
@ -90,8 +90,26 @@ mod imp {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.setup_widgets();
|
||||
self.parent_constructed(obj);
|
||||
let account = obj.account();
|
||||
account
|
||||
.bind_property("name", obj, "title")
|
||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||
.build();
|
||||
|
||||
account
|
||||
.bind_property("name", obj, "tooltip-text")
|
||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||
.build();
|
||||
|
||||
account
|
||||
.bind_property("otp", &*self.otp_label, "label")
|
||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||
.build();
|
||||
|
||||
// Only display the increment button if it is a HOTP account
|
||||
self.increment_btn
|
||||
.set_visible(account.provider().method() == OTPMethod::HOTP);
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for AccountRow {}
|
||||
|
@ -113,27 +131,4 @@ impl AccountRow {
|
|||
fn account(&self) -> Account {
|
||||
self.property("account")
|
||||
}
|
||||
|
||||
fn setup_widgets(&self) {
|
||||
let imp = self.imp();
|
||||
let account = self.account();
|
||||
account
|
||||
.bind_property("name", self, "title")
|
||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||
.build();
|
||||
|
||||
account
|
||||
.bind_property("name", self, "tooltip-text")
|
||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||
.build();
|
||||
|
||||
account
|
||||
.bind_property("otp", &*imp.otp_label, "label")
|
||||
.flags(glib::BindingFlags::DEFAULT | glib::BindingFlags::SYNC_CREATE)
|
||||
.build();
|
||||
|
||||
// Only display the increment button if it is a HOTP account
|
||||
imp.increment_btn
|
||||
.set_visible(account.provider().method() == OTPMethod::HOTP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ mod imp {
|
|||
|
||||
impl ObjectImpl for EditableLabel {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.stack.set_visible_child_name("label");
|
||||
self.parent_constructed(obj);
|
||||
self.stack.set_visible_child_name("label");
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for EditableLabel {
|
||||
|
@ -78,8 +78,8 @@ mod imp {
|
|||
|
||||
impl ObjectImpl for EditableSpin {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.stack.set_visible_child_name("label");
|
||||
self.parent_constructed(obj);
|
||||
self.stack.set_visible_child_name("label");
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for EditableSpin {
|
||||
|
|
|
@ -87,8 +87,8 @@ mod imp {
|
|||
|
||||
impl WidgetImpl for PasswordPage {
|
||||
fn unmap(&self, widget: &Self::Type) {
|
||||
widget.reset();
|
||||
self.parent_unmap(widget);
|
||||
widget.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ mod imp {
|
|||
SIGNALS.as_ref()
|
||||
}
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.placeholder_page.set_icon_name(Some(config::APP_ID));
|
||||
self.parent_constructed(obj);
|
||||
self.placeholder_page.set_icon_name(Some(config::APP_ID));
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for ProvidersDialog {}
|
||||
|
@ -314,8 +314,20 @@ mod row {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.setup_widgets();
|
||||
self.parent_constructed(obj);
|
||||
let hbox = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.margin_bottom(12)
|
||||
.margin_end(6)
|
||||
.margin_top(12)
|
||||
.margin_start(6)
|
||||
.build();
|
||||
self.title_label.set_valign(gtk::Align::Center);
|
||||
self.title_label.set_halign(gtk::Align::Start);
|
||||
self.title_label.set_wrap(true);
|
||||
self.title_label.set_ellipsize(pango::EllipsizeMode::End);
|
||||
hbox.append(&self.title_label);
|
||||
obj.set_child(Some(&hbox));
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for ProviderActionRow {}
|
||||
|
@ -327,23 +339,6 @@ mod row {
|
|||
}
|
||||
|
||||
impl ProviderActionRow {
|
||||
fn setup_widgets(&self) {
|
||||
let imp = self.imp();
|
||||
let hbox = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.margin_bottom(12)
|
||||
.margin_end(6)
|
||||
.margin_top(12)
|
||||
.margin_start(6)
|
||||
.build();
|
||||
imp.title_label.set_valign(gtk::Align::Center);
|
||||
imp.title_label.set_halign(gtk::Align::Start);
|
||||
imp.title_label.set_wrap(true);
|
||||
imp.title_label.set_ellipsize(pango::EllipsizeMode::End);
|
||||
hbox.append(&imp.title_label);
|
||||
self.set_child(Some(&hbox));
|
||||
}
|
||||
|
||||
pub fn set_provider(&self, provider: Provider) {
|
||||
self.set_property("provider", &provider);
|
||||
self.imp().title_label.set_text(&provider.name());
|
||||
|
|
|
@ -68,8 +68,8 @@ mod imp {
|
|||
|
||||
impl ObjectImpl for ProviderImage {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.setup_widgets();
|
||||
self.parent_constructed(obj);
|
||||
obj.setup_widgets();
|
||||
}
|
||||
|
||||
fn properties() -> &'static [ParamSpec] {
|
||||
|
|
|
@ -45,8 +45,8 @@ mod imp {
|
|||
|
||||
impl ObjectImpl for ProvidersList {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.setup_widgets();
|
||||
self.parent_constructed(obj);
|
||||
obj.setup_widgets();
|
||||
}
|
||||
|
||||
fn signals() -> &'static [Signal] {
|
||||
|
|
|
@ -157,9 +157,9 @@ mod imp {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.parent_constructed(obj);
|
||||
obj.setup_widgets();
|
||||
obj.action_set_enabled("providers.save", false);
|
||||
self.parent_constructed(obj);
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for ProviderPage {}
|
||||
|
|
|
@ -98,8 +98,8 @@ mod imp {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.setup_widgets();
|
||||
self.parent_constructed(obj);
|
||||
obj.setup_widgets();
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for ProviderRow {}
|
||||
|
|
|
@ -55,8 +55,17 @@ mod imp {
|
|||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
obj.setup_widgets();
|
||||
self.parent_constructed(obj);
|
||||
let gesture = gtk::GestureClick::new();
|
||||
gesture.connect_pressed(clone!(@weak obj as row => move |_,_,_,_| {
|
||||
row.open_uri();
|
||||
}));
|
||||
|
||||
obj.add_controller(&gesture);
|
||||
|
||||
let image_suffix = gtk::Image::from_icon_name("link-symbolic");
|
||||
image_suffix.add_css_class("dim-label");
|
||||
obj.add_suffix(&image_suffix);
|
||||
}
|
||||
}
|
||||
impl WidgetImpl for UrlRow {}
|
||||
|
@ -70,19 +79,6 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl UrlRow {
|
||||
fn setup_widgets(&self) {
|
||||
let gesture = gtk::GestureClick::new();
|
||||
gesture.connect_pressed(clone!(@weak self as row => move |_,_,_,_| {
|
||||
row.open_uri();
|
||||
}));
|
||||
|
||||
self.add_controller(&gesture);
|
||||
|
||||
let image_suffix = gtk::Image::from_icon_name("link-symbolic");
|
||||
image_suffix.add_css_class("dim-label");
|
||||
self.add_suffix(&image_suffix);
|
||||
}
|
||||
|
||||
fn open_uri(&self) {
|
||||
if let Some(ref uri) = *self.imp().uri.borrow() {
|
||||
gtk::show_uri(gtk::Window::NONE, uri, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue