details_page: Use property class in action rows

This commit is contained in:
Maximiliano Sandoval 2024-12-31 12:48:48 +01:00 committed by Bilal Elmoussaoui
parent 004a7bd664
commit bc6cd9daaf
2 changed files with 24 additions and 34 deletions

View file

@ -115,23 +115,19 @@
<property name="selection-mode">none</property> <property name="selection-mode">none</property>
<property name="margin-bottom">18</property> <property name="margin-bottom">18</property>
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow" id="algorithm_row">
<property name="title" translatable="yes">Algorithm</property> <property name="title" translatable="yes">Algorithm</property>
<child> <style>
<object class="GtkLabel" id="algorithm_label"> <class name="property"/>
<property name="halign">end</property> </style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow" id="method_row">
<property name="title" translatable="yes">Computing Method</property> <property name="title" translatable="yes">Computing Method</property>
<child> <style>
<object class="GtkLabel" id="method_label"> <class name="property"/>
<property name="halign">end</property> </style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
@ -147,22 +143,18 @@
<object class="AdwActionRow" id="period_row"> <object class="AdwActionRow" id="period_row">
<property name="title" translatable="yes">Period</property> <property name="title" translatable="yes">Period</property>
<property name="subtitle" translatable="yes">Duration in seconds until the next password update</property> <property name="subtitle" translatable="yes">Duration in seconds until the next password update</property>
<child> <style>
<object class="GtkLabel" id="period_label"> <class name="property"/>
<property name="halign">end</property> </style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow" id="digits_row">
<property name="title" translatable="yes">Digits</property> <property name="title" translatable="yes">Digits</property>
<property name="subtitle" translatable="yes">Length of the generated code</property> <property name="subtitle" translatable="yes">Length of the generated code</property>
<child> <style>
<object class="GtkLabel" id="digits_label"> <class name="property"/>
<property name="halign">end</property> </style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>

View file

@ -33,15 +33,13 @@ mod imp {
#[template_child(id = "list")] #[template_child(id = "list")]
pub listbox: TemplateChild<gtk::ListBox>, pub listbox: TemplateChild<gtk::ListBox>,
#[template_child] #[template_child]
pub algorithm_label: TemplateChild<gtk::Label>, pub algorithm_row: TemplateChild<adw::ActionRow>,
#[template_child] #[template_child]
pub method_label: TemplateChild<gtk::Label>, pub method_row: TemplateChild<adw::ActionRow>,
#[template_child] #[template_child]
pub counter_spinbutton: TemplateChild<adw::SpinRow>, pub counter_spinbutton: TemplateChild<adw::SpinRow>,
#[template_child] #[template_child]
pub period_label: TemplateChild<gtk::Label>, pub digits_row: TemplateChild<adw::ActionRow>,
#[template_child]
pub digits_label: TemplateChild<gtk::Label>,
#[template_child] #[template_child]
pub period_row: TemplateChild<adw::ActionRow>, pub period_row: TemplateChild<adw::ActionRow>,
#[template_child] #[template_child]
@ -164,19 +162,19 @@ impl AccountDetailsPage {
fn set_provider(&self, provider: Provider) { fn set_provider(&self, provider: Provider) {
let imp = self.imp(); let imp = self.imp();
imp.provider_entry.set_text(&provider.name()); imp.provider_entry.set_text(&provider.name());
imp.algorithm_label imp.algorithm_row
.set_text(&provider.algorithm().to_locale_string()); .set_subtitle(&provider.algorithm().to_locale_string());
imp.method_label imp.method_row
.set_text(&provider.method().to_locale_string()); .set_subtitle(&provider.method().to_locale_string());
if provider.method().is_event_based() { if provider.method().is_event_based() {
imp.counter_spinbutton.set_visible(true); imp.counter_spinbutton.set_visible(true);
imp.period_row.set_visible(false); imp.period_row.set_visible(false);
} else { } else {
imp.counter_spinbutton.set_visible(false); imp.counter_spinbutton.set_visible(false);
imp.period_row.set_visible(true); imp.period_row.set_visible(true);
imp.period_label.set_text(&provider.period().to_string()); imp.period_row.set_subtitle(&provider.period().to_string());
} }
imp.digits_label.set_text(&provider.digits().to_string()); imp.digits_row.set_subtitle(&provider.digits().to_string());
if let Some(help) = provider.help_url() { if let Some(help) = provider.help_url() {
imp.help_row.set_uri(help); imp.help_row.set_uri(help);
imp.help_row.set_visible(true); imp.help_row.set_visible(true);