summary refs log tree commit diff
path: root/src/components/preferences.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/preferences.rs')
-rw-r--r--src/components/preferences.rs72
1 files changed, 47 insertions, 25 deletions
diff --git a/src/components/preferences.rs b/src/components/preferences.rs
index 67075a2..2b3e640 100644
--- a/src/components/preferences.rs
+++ b/src/components/preferences.rs
@@ -1,7 +1,7 @@
 use gettextrs::*;
 
-use gio::prelude::*;
 use adw::prelude::*;
+use gio::prelude::*;
 use relm4::prelude::*;
 
 pub struct Preferences {
@@ -19,7 +19,9 @@ impl ComposerPreferencesWidgets {
     fn new(settings: &gio::Settings) -> Self {
         let page = adw::PreferencesPage::builder()
             .title(gettext("Post composer"))
-            .description(gettext("Settings for composing new posts and editing existing ones."))
+            .description(gettext(
+                "Settings for composing new posts and editing existing ones.",
+            ))
             .icon_name("editor-symbolic")
             .build();
         let general_group = adw::PreferencesGroup::builder()
@@ -32,20 +34,21 @@ impl ComposerPreferencesWidgets {
         let widgets = Self {
             page,
             general_group,
-            send_html_directly
+            send_html_directly,
         };
 
         let schema = settings.settings_schema().unwrap();
 
         #[expect(clippy::single_element_loop)]
-        for (row, key, property) in [
-            (widgets.send_html_directly.upcast_ref::<adw::PreferencesRow>(), "send-html-directly", "active"),
-        ] {
+        for (row, key, property) in [(
+            widgets
+                .send_html_directly
+                .upcast_ref::<adw::PreferencesRow>(),
+            "send-html-directly",
+            "active",
+        )] {
             let key_data = schema.key(key);
-            settings.bind(key, row, property)
-                .get()
-                .set()
-                .build();
+            settings.bind(key, row, property).get().set().build();
             row.set_title(&gettext(key_data.summary().unwrap()));
             row.set_tooltip_markup(key_data.description().map(gettext).as_deref());
         }
@@ -62,7 +65,7 @@ struct LanguageModelPreferencesWidgets {
     general_group: adw::PreferencesGroup,
     llm_endpoint: adw::EntryRow,
     smart_summary_show_warning: adw::SwitchRow,
-    
+
     smart_summary_group: adw::PreferencesGroup,
     smart_summary_model: adw::EntryRow,
     smart_summary_system_prompt: adw::EntryRow,
@@ -112,24 +115,45 @@ impl LanguageModelPreferencesWidgets {
             smart_summary_model,
             smart_summary_system_prompt,
             smart_summary_prompt_prefix,
-            smart_summary_prompt_suffix
+            smart_summary_prompt_suffix,
         };
 
         let schema = settings.settings_schema().unwrap();
 
         for (row, key, property) in [
-            (widgets.llm_endpoint.upcast_ref::<adw::PreferencesRow>(), "llm-endpoint", "text"),
-            (widgets.smart_summary_show_warning.upcast_ref::<_>(), "smart-summary-show-warning", "active"),
-            (widgets.smart_summary_model.upcast_ref::<_>(), "smart-summary-model", "text"),
-            (widgets.smart_summary_system_prompt.upcast_ref::<_>(), "smart-summary-system-prompt", "text"),
-            (widgets.smart_summary_prompt_prefix.upcast_ref::<_>(), "smart-summary-prompt-prefix", "text"),
-            (widgets.smart_summary_prompt_suffix.upcast_ref::<_>(), "smart-summary-prompt-suffix", "text"),
+            (
+                widgets.llm_endpoint.upcast_ref::<adw::PreferencesRow>(),
+                "llm-endpoint",
+                "text",
+            ),
+            (
+                widgets.smart_summary_show_warning.upcast_ref::<_>(),
+                "smart-summary-show-warning",
+                "active",
+            ),
+            (
+                widgets.smart_summary_model.upcast_ref::<_>(),
+                "smart-summary-model",
+                "text",
+            ),
+            (
+                widgets.smart_summary_system_prompt.upcast_ref::<_>(),
+                "smart-summary-system-prompt",
+                "text",
+            ),
+            (
+                widgets.smart_summary_prompt_prefix.upcast_ref::<_>(),
+                "smart-summary-prompt-prefix",
+                "text",
+            ),
+            (
+                widgets.smart_summary_prompt_suffix.upcast_ref::<_>(),
+                "smart-summary-prompt-suffix",
+                "text",
+            ),
         ] {
             let key_data = schema.key(key);
-            settings.bind(key, row, property)
-                .get()
-                .set()
-                .build();
+            settings.bind(key, row, property).get().set().build();
             row.set_title(&gettext(key_data.summary().unwrap()));
             row.set_tooltip_markup(key_data.description().map(gettext).as_deref());
         }
@@ -179,9 +203,7 @@ impl Component for Preferences {
         root.connect_closed(glib::clone!(
             #[strong(rename_to = settings)]
             model.settings,
-            move |_| {
-                settings.apply()
-            }
+            move |_| { settings.apply() }
         ));
 
         ComponentParts { model, widgets }