mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
give to gobject a name
This commit is contained in:
parent
d627fd1b72
commit
3ab3d53e75
@ -26,7 +26,7 @@ const RESPONSE_CANCEL: (&str, &str) = ("cancel", "Cancel");
|
||||
pub struct Widget {
|
||||
// pub action: Rc<Action>,
|
||||
pub form: Rc<Form>,
|
||||
pub gobject: AlertDialog,
|
||||
pub alert_dialog: AlertDialog,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
@ -40,36 +40,36 @@ impl Widget {
|
||||
// Init child container
|
||||
let form = Rc::new(Form::new(profile, action.clone()));
|
||||
|
||||
// Init main `GObject`
|
||||
let gobject = AlertDialog::builder()
|
||||
// Init main widget
|
||||
let alert_dialog = AlertDialog::builder()
|
||||
.heading(HEADING)
|
||||
.body(BODY)
|
||||
.close_response(RESPONSE_CANCEL.0)
|
||||
.default_response(RESPONSE_APPLY.0)
|
||||
.extra_child(&form.gobject)
|
||||
.extra_child(&form.g_box)
|
||||
.build();
|
||||
|
||||
// Set response variants
|
||||
gobject.add_responses(&[
|
||||
alert_dialog.add_responses(&[
|
||||
RESPONSE_CANCEL,
|
||||
// RESPONSE_MANAGE,
|
||||
RESPONSE_APPLY,
|
||||
]);
|
||||
|
||||
// Deactivate not implemented feature @TODO
|
||||
// gobject.set_response_enabled(RESPONSE_MANAGE.0, false);
|
||||
// alert_dialog.set_response_enabled(RESPONSE_MANAGE.0, false);
|
||||
|
||||
// Decorate default response preset
|
||||
gobject.set_response_appearance(RESPONSE_APPLY.0, ResponseAppearance::Suggested);
|
||||
gobject.set_response_appearance(RESPONSE_CANCEL.0, ResponseAppearance::Destructive);
|
||||
alert_dialog.set_response_appearance(RESPONSE_APPLY.0, ResponseAppearance::Suggested);
|
||||
alert_dialog.set_response_appearance(RESPONSE_CANCEL.0, ResponseAppearance::Destructive);
|
||||
|
||||
// Init events
|
||||
action.update.connect_activate({
|
||||
let form = form.clone();
|
||||
let gobject = gobject.clone();
|
||||
let alert_dialog = alert_dialog.clone();
|
||||
move || {
|
||||
// Deactivate apply button if the form values could not be processed
|
||||
gobject.set_response_enabled(RESPONSE_APPLY.0, form.is_valid());
|
||||
alert_dialog.set_response_enabled(RESPONSE_APPLY.0, form.is_valid());
|
||||
}
|
||||
});
|
||||
|
||||
@ -77,7 +77,7 @@ impl Widget {
|
||||
Self {
|
||||
// action,
|
||||
form,
|
||||
gobject,
|
||||
alert_dialog,
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ impl Widget {
|
||||
/// Callback wrapper for `apply` [response](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/signal.AlertDialog.response.html)
|
||||
/// * return `Value` enum or new record request on `None`
|
||||
pub fn on_apply(&self, callback: impl Fn(Value) + 'static) {
|
||||
self.gobject.connect_response(Some(RESPONSE_APPLY.0), {
|
||||
self.alert_dialog.connect_response(Some(RESPONSE_APPLY.0), {
|
||||
let form = self.form.clone();
|
||||
move |this, response| {
|
||||
// Prevent double-click action
|
||||
@ -100,6 +100,6 @@ impl Widget {
|
||||
|
||||
/// Show dialog with new preset
|
||||
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
|
||||
self.gobject.present(parent)
|
||||
self.alert_dialog.present(parent)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ pub struct Form {
|
||||
pub list: Rc<List>,
|
||||
pub name: Rc<Name>,
|
||||
// pub save: Rc<Save>,
|
||||
pub gobject: Box,
|
||||
pub g_box: Box,
|
||||
}
|
||||
|
||||
impl Form {
|
||||
@ -38,13 +38,13 @@ impl Form {
|
||||
let drop = Rc::new(Drop::new(profile.clone(), action.clone(), list.clone()));
|
||||
|
||||
// Init main container
|
||||
let gobject = Box::builder().orientation(Orientation::Vertical).build();
|
||||
let g_box = Box::builder().orientation(Orientation::Vertical).build();
|
||||
|
||||
gobject.append(&list.gobject);
|
||||
gobject.append(&name.gobject);
|
||||
gobject.append(&file.gobject);
|
||||
gobject.append(&drop.gobject);
|
||||
gobject.append(&save.gobject);
|
||||
g_box.append(&list.dropdown);
|
||||
g_box.append(&name.entry);
|
||||
g_box.append(&file.button);
|
||||
g_box.append(&drop.button);
|
||||
g_box.append(&save.button);
|
||||
|
||||
// Connect events
|
||||
list.on_select({
|
||||
@ -85,7 +85,7 @@ impl Form {
|
||||
list,
|
||||
name,
|
||||
// save,
|
||||
gobject,
|
||||
g_box,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ const RESPONSE_CONFIRM: (&str, &str) = ("confirm", "Confirm");
|
||||
|
||||
pub struct Drop {
|
||||
profile_identity_gemini_id: Rc<RefCell<Option<i64>>>,
|
||||
pub gobject: Button,
|
||||
pub button: Button,
|
||||
}
|
||||
|
||||
impl Drop {
|
||||
@ -35,8 +35,8 @@ impl Drop {
|
||||
// Init selected option holder
|
||||
let profile_identity_gemini_id = Rc::new(RefCell::new(None::<i64>));
|
||||
|
||||
// Init `GObject`
|
||||
let gobject = Button::builder()
|
||||
// Init main widget
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
.margin_top(MARGIN)
|
||||
.tooltip_text(TOOLTIP_TEXT)
|
||||
@ -44,16 +44,16 @@ impl Drop {
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked({
|
||||
button.connect_clicked({
|
||||
let action = action.clone();
|
||||
let gobject = gobject.clone();
|
||||
let button = button.clone();
|
||||
let profile_identity_gemini_id = profile_identity_gemini_id.clone();
|
||||
move |_| {
|
||||
// Get selected identity from holder
|
||||
match profile_identity_gemini_id.borrow().as_ref() {
|
||||
Some(profile_identity_gemini_id) => {
|
||||
// Init main `GObject`
|
||||
let dialog = AlertDialog::builder()
|
||||
// Init sub-widget
|
||||
let alert_dialog = AlertDialog::builder()
|
||||
.heading(HEADING)
|
||||
.body(BODY)
|
||||
.close_response(RESPONSE_CANCEL.0)
|
||||
@ -61,23 +61,23 @@ impl Drop {
|
||||
.build();
|
||||
|
||||
// Set response variants
|
||||
dialog.add_responses(&[RESPONSE_CANCEL, RESPONSE_CONFIRM]);
|
||||
alert_dialog.add_responses(&[RESPONSE_CANCEL, RESPONSE_CONFIRM]);
|
||||
|
||||
// Decorate default response preset
|
||||
dialog.set_response_appearance(
|
||||
alert_dialog.set_response_appearance(
|
||||
RESPONSE_CONFIRM.0,
|
||||
ResponseAppearance::Suggested,
|
||||
);
|
||||
|
||||
dialog.set_response_appearance(
|
||||
alert_dialog.set_response_appearance(
|
||||
RESPONSE_CANCEL.0,
|
||||
ResponseAppearance::Destructive,
|
||||
);
|
||||
|
||||
// Connect confirmation event
|
||||
dialog.connect_response(Some(RESPONSE_CONFIRM.0), {
|
||||
alert_dialog.connect_response(Some(RESPONSE_CONFIRM.0), {
|
||||
let action = action.clone();
|
||||
let gobject = gobject.clone();
|
||||
let button = button.clone();
|
||||
let list = list.clone();
|
||||
let profile = profile.clone();
|
||||
let profile_identity_gemini_id = *profile_identity_gemini_id;
|
||||
@ -85,17 +85,17 @@ impl Drop {
|
||||
match profile.identity.gemini.delete(profile_identity_gemini_id) {
|
||||
Ok(_) => {
|
||||
if list.remove(profile_identity_gemini_id).is_some() {
|
||||
gobject.set_css_classes(&["success"]);
|
||||
gobject.set_label("Identity successfully deleted")
|
||||
button.set_css_classes(&["success"]);
|
||||
button.set_label("Identity successfully deleted")
|
||||
} else {
|
||||
gobject.set_css_classes(&["error"]);
|
||||
gobject.set_label("List item not found")
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label("List item not found")
|
||||
// @TODO unexpected
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
gobject.set_css_classes(&["error"]);
|
||||
gobject.set_label(&e.to_string())
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
}
|
||||
action.update.activate()
|
||||
@ -103,7 +103,7 @@ impl Drop {
|
||||
});
|
||||
|
||||
// Show dialog
|
||||
dialog.present(Some(&gobject))
|
||||
alert_dialog.present(Some(&button))
|
||||
}
|
||||
None => todo!(), // unexpected
|
||||
}
|
||||
@ -113,7 +113,7 @@ impl Drop {
|
||||
// Return activated `Self`
|
||||
Self {
|
||||
profile_identity_gemini_id,
|
||||
gobject,
|
||||
button,
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ impl Drop {
|
||||
/// Update `profile_identity_gemini_id` holder,
|
||||
/// toggle visibility depending on given value
|
||||
pub fn update(&self, profile_identity_gemini_id: Option<i64>) {
|
||||
self.gobject.set_visible(match profile_identity_gemini_id {
|
||||
self.button.set_visible(match profile_identity_gemini_id {
|
||||
Some(value) => {
|
||||
self.profile_identity_gemini_id.replace(Some(value));
|
||||
true
|
||||
|
@ -14,7 +14,7 @@ const MARGIN: i32 = 8;
|
||||
|
||||
pub struct File {
|
||||
pub pem: Rc<RefCell<Option<GString>>>,
|
||||
pub gobject: Button,
|
||||
pub button: Button,
|
||||
}
|
||||
|
||||
impl File {
|
||||
@ -25,8 +25,8 @@ impl File {
|
||||
// Init PEM
|
||||
let pem = Rc::new(RefCell::new(None));
|
||||
|
||||
// Init `GObject`
|
||||
let gobject = Button::builder()
|
||||
// Init main gobject
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
.margin_top(MARGIN)
|
||||
.tooltip_text(TOOLTIP_TEXT)
|
||||
@ -34,13 +34,13 @@ impl File {
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked({
|
||||
let gobject = gobject.clone();
|
||||
button.connect_clicked({
|
||||
let button = button.clone();
|
||||
let pem = pem.clone();
|
||||
let update = action.update.clone();
|
||||
move |_| {
|
||||
// Lock open button (prevent double click)
|
||||
gobject.set_sensitive(false);
|
||||
button.set_sensitive(false);
|
||||
|
||||
// Init file filters related with PEM extension
|
||||
let filters = ListStore::new::<FileFilter>();
|
||||
@ -61,7 +61,7 @@ impl File {
|
||||
.default_filter(&filter_pem)
|
||||
.build()
|
||||
.open(None::<&Window>, None::<&Cancellable>, {
|
||||
let gobject = gobject.clone();
|
||||
let button = button.clone();
|
||||
let pem = pem.clone();
|
||||
let update = update.clone();
|
||||
move |result| {
|
||||
@ -72,23 +72,23 @@ impl File {
|
||||
match TlsCertificate::from_file(filename) {
|
||||
Ok(certificate) => {
|
||||
pem.replace(to_pem(certificate));
|
||||
gobject.set_css_classes(&["success"]);
|
||||
gobject.set_label(filename)
|
||||
button.set_css_classes(&["success"]);
|
||||
button.set_label(filename)
|
||||
}
|
||||
Err(reason) => {
|
||||
gobject.set_css_classes(&["error"]);
|
||||
gobject.set_label(reason.message())
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(reason.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
None => todo!(),
|
||||
},
|
||||
Err(reason) => {
|
||||
gobject.set_css_classes(&["warning"]);
|
||||
gobject.set_label(reason.message())
|
||||
button.set_css_classes(&["warning"]);
|
||||
button.set_label(reason.message())
|
||||
}
|
||||
}
|
||||
gobject.set_sensitive(true); // unlock
|
||||
button.set_sensitive(true); // unlock
|
||||
update.activate()
|
||||
}
|
||||
});
|
||||
@ -96,7 +96,7 @@ impl File {
|
||||
});
|
||||
|
||||
// Return activated `Self`
|
||||
Self { pem, gobject }
|
||||
Self { pem, button }
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -104,9 +104,9 @@ impl File {
|
||||
/// Change visibility status
|
||||
/// * grab focus on `is_visible`
|
||||
pub fn update(&self, is_visible: bool) {
|
||||
self.gobject.set_visible(is_visible);
|
||||
self.button.set_visible(is_visible);
|
||||
if is_visible {
|
||||
self.gobject.grab_focus();
|
||||
self.button.grab_focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@ use gtk::{
|
||||
};
|
||||
|
||||
pub struct List {
|
||||
pub gobject: DropDown,
|
||||
model: ListStore,
|
||||
pub dropdown: DropDown,
|
||||
list_store: ListStore,
|
||||
}
|
||||
|
||||
impl List {
|
||||
@ -20,14 +20,14 @@ impl List {
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
// Init model with custom `GObject` properties
|
||||
let model = ListStore::new::<Item>();
|
||||
// Init `ListStore` with custom `DropDown` properties
|
||||
let list_store = ListStore::new::<Item>();
|
||||
|
||||
// Setup item factory
|
||||
// * wanted only to append items after `DropDown` init
|
||||
let factory = SignalListItemFactory::new();
|
||||
|
||||
factory.connect_setup(|_, gobject| {
|
||||
factory.connect_setup(|_, dropdown| {
|
||||
// Init widget for dropdown item
|
||||
let widget = Box::builder()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
@ -45,15 +45,15 @@ impl List {
|
||||
);
|
||||
|
||||
// Done
|
||||
gobject
|
||||
dropdown
|
||||
.downcast_ref::<ListItem>()
|
||||
.unwrap()
|
||||
.set_child(Some(&widget));
|
||||
});
|
||||
|
||||
factory.connect_bind(|_, gobject| {
|
||||
factory.connect_bind(|_, dropdown| {
|
||||
// Downcast requirements
|
||||
let list_item = gobject.downcast_ref::<ListItem>().unwrap();
|
||||
let list_item = dropdown.downcast_ref::<ListItem>().unwrap();
|
||||
let item = list_item.item().and_downcast::<Item>().unwrap();
|
||||
let container = list_item.child().and_downcast::<Box>().unwrap();
|
||||
|
||||
@ -74,11 +74,17 @@ impl List {
|
||||
.set_label(&item.subtitle());
|
||||
});
|
||||
|
||||
// Init main `GObject`
|
||||
let gobject = DropDown::builder().model(&model).factory(&factory).build();
|
||||
// Init main `DropDown`
|
||||
let dropdown = DropDown::builder()
|
||||
.model(&list_store)
|
||||
.factory(&factory)
|
||||
.build();
|
||||
|
||||
// Return activated `Self`
|
||||
Self { model, gobject }
|
||||
Self {
|
||||
list_store,
|
||||
dropdown,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -86,16 +92,17 @@ impl List {
|
||||
/// Append new item
|
||||
pub fn append(&self, value: Value, title: &str, subtitle: &str, is_selected: bool) {
|
||||
let item = Item::new(value, title, subtitle);
|
||||
self.model.append(&item);
|
||||
self.list_store.append(&item);
|
||||
if is_selected {
|
||||
self.gobject.set_selected(self.model.find(&item).unwrap()); // @TODO panic or handle?
|
||||
self.dropdown
|
||||
.set_selected(self.list_store.find(&item).unwrap()); // @TODO panic or handle?
|
||||
}
|
||||
}
|
||||
|
||||
/// Find list item by `Value`
|
||||
/// * return `position` found
|
||||
pub fn find(&self, value: i64) -> Option<u32> {
|
||||
self.model
|
||||
self.list_store
|
||||
.find_with_equal_func(|this| value == this.clone().downcast::<Item>().unwrap().value())
|
||||
}
|
||||
|
||||
@ -104,7 +111,7 @@ impl List {
|
||||
pub fn remove(&self, value: i64) -> Option<u32> {
|
||||
match self.find(value) {
|
||||
Some(position) => {
|
||||
self.model.remove(position);
|
||||
self.list_store.remove(position);
|
||||
Some(position)
|
||||
}
|
||||
None => None,
|
||||
@ -116,7 +123,7 @@ impl List {
|
||||
/// Run callback function on `connect_selected_notify` event
|
||||
/// * return `Value` enum match selected item
|
||||
pub fn on_select(&self, callback: impl Fn(Value) + 'static) {
|
||||
self.gobject.connect_selected_notify(move |list| {
|
||||
self.dropdown.connect_selected_notify(move |list| {
|
||||
callback(
|
||||
list.selected_item()
|
||||
.and_downcast::<Item>()
|
||||
@ -130,7 +137,7 @@ impl List {
|
||||
|
||||
/// Get formatted `value` match selected item
|
||||
pub fn selected(&self) -> Value {
|
||||
self.gobject
|
||||
self.dropdown
|
||||
.selected_item()
|
||||
.and_downcast::<Item>()
|
||||
.unwrap()
|
||||
|
@ -12,7 +12,7 @@ const MIN_LENGTH: u16 = 1;
|
||||
const MAX_LENGTH: u16 = 36;
|
||||
|
||||
pub struct Name {
|
||||
pub gobject: Entry,
|
||||
pub entry: Entry,
|
||||
}
|
||||
|
||||
impl Name {
|
||||
@ -20,8 +20,8 @@ impl Name {
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(action: Rc<Action>) -> Self {
|
||||
// Init `GObject`
|
||||
let gobject = Entry::builder()
|
||||
// Init main gobject
|
||||
let entry = Entry::builder()
|
||||
.margin_top(MARGIN)
|
||||
.max_length(MAX_LENGTH as i32)
|
||||
.placeholder_text(PLACEHOLDER_TEXT)
|
||||
@ -29,10 +29,10 @@ impl Name {
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_changed(move |_| action.update.activate());
|
||||
entry.connect_changed(move |_| action.update.activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
Self { entry }
|
||||
}
|
||||
|
||||
// Actions
|
||||
@ -40,20 +40,20 @@ impl Name {
|
||||
/// Change visibility status
|
||||
/// * grab focus on `is_visible`
|
||||
pub fn update(&self, is_visible: bool) {
|
||||
self.gobject.set_visible(is_visible);
|
||||
self.entry.set_visible(is_visible);
|
||||
if is_visible {
|
||||
self.gobject.grab_focus();
|
||||
self.entry.grab_focus();
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.gobject.text_length() >= MIN_LENGTH && self.gobject.text_length() <= MAX_LENGTH
|
||||
self.entry.text_length() >= MIN_LENGTH && self.entry.text_length() <= MAX_LENGTH
|
||||
}
|
||||
|
||||
pub fn value(&self) -> Option<GString> {
|
||||
let text = self.gobject.text();
|
||||
let text = self.entry.text();
|
||||
if text.is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@ const MARGIN: i32 = 8;
|
||||
|
||||
pub struct Save {
|
||||
profile_identity_gemini_id: Rc<RefCell<Option<i64>>>,
|
||||
pub gobject: Button,
|
||||
pub button: Button,
|
||||
}
|
||||
|
||||
impl Save {
|
||||
@ -26,8 +26,8 @@ impl Save {
|
||||
// Init selected option holder
|
||||
let profile_identity_gemini_id = Rc::new(RefCell::new(None));
|
||||
|
||||
// Init `GObject`
|
||||
let gobject = Button::builder()
|
||||
// Init main widget
|
||||
let button = Button::builder()
|
||||
.label(LABEL)
|
||||
.margin_top(MARGIN)
|
||||
.tooltip_text(TOOLTIP_TEXT)
|
||||
@ -35,15 +35,15 @@ impl Save {
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked({
|
||||
button.connect_clicked({
|
||||
let profile_identity_gemini_id = profile_identity_gemini_id.clone();
|
||||
let gobject = gobject.clone();
|
||||
let button = button.clone();
|
||||
move |_| {
|
||||
// Get selected identity from holder
|
||||
match profile_identity_gemini_id.borrow().as_ref() {
|
||||
Some(profile_identity_gemini_id) => {
|
||||
// Lock open button (prevent double click)
|
||||
gobject.set_sensitive(false);
|
||||
button.set_sensitive(false);
|
||||
|
||||
// Create PEM file based on option ID selected
|
||||
match Certificate::new(profile.clone(), *profile_identity_gemini_id) {
|
||||
@ -68,7 +68,7 @@ impl Save {
|
||||
.initial_name(format!("{}.pem", certificate.name))
|
||||
.build()
|
||||
.save(None::<&Window>, None::<&Cancellable>, {
|
||||
let gobject = gobject.clone();
|
||||
let button = button.clone();
|
||||
move |result| {
|
||||
match result {
|
||||
Ok(file) => match file.path() {
|
||||
@ -78,47 +78,46 @@ impl Save {
|
||||
certificate.data.as_bytes(),
|
||||
) {
|
||||
Ok(_) => {
|
||||
gobject.set_css_classes(&[
|
||||
button.set_css_classes(&[
|
||||
"success",
|
||||
]);
|
||||
gobject.set_label(&format!(
|
||||
button.set_label(&format!(
|
||||
"Saved to {}",
|
||||
path.to_string_lossy()
|
||||
))
|
||||
}
|
||||
Err(e) => {
|
||||
gobject.set_css_classes(&[
|
||||
button.set_css_classes(&[
|
||||
"error",
|
||||
]);
|
||||
gobject
|
||||
.set_label(&e.to_string())
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
gobject.set_css_classes(&["error"]);
|
||||
gobject.set_label(&e.to_string())
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
},
|
||||
None => {
|
||||
gobject.set_css_classes(&["warning"]);
|
||||
gobject.set_label(
|
||||
button.set_css_classes(&["warning"]);
|
||||
button.set_label(
|
||||
"Could not init destination path",
|
||||
)
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
gobject.set_css_classes(&["warning"]);
|
||||
gobject.set_label(e.message())
|
||||
button.set_css_classes(&["warning"]);
|
||||
button.set_label(e.message())
|
||||
}
|
||||
}
|
||||
gobject.set_sensitive(true); // unlock
|
||||
button.set_sensitive(true); // unlock
|
||||
}
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
gobject.set_css_classes(&["error"]);
|
||||
gobject.set_label(&e.to_string())
|
||||
button.set_css_classes(&["error"]);
|
||||
button.set_label(&e.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +129,7 @@ impl Save {
|
||||
// Return activated `Self`
|
||||
Self {
|
||||
profile_identity_gemini_id,
|
||||
gobject,
|
||||
button,
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +138,7 @@ impl Save {
|
||||
/// Update `profile_identity_gemini_id` holder,
|
||||
/// toggle visibility depending on given value
|
||||
pub fn update(&self, profile_identity_gemini_id: Option<i64>) {
|
||||
self.gobject.set_visible(match profile_identity_gemini_id {
|
||||
self.button.set_visible(match profile_identity_gemini_id {
|
||||
Some(value) => {
|
||||
self.profile_identity_gemini_id.replace(Some(value));
|
||||
true
|
||||
|
Loading…
x
Reference in New Issue
Block a user