about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGabriel Brand <gabr.brand@gmail.com>2024-02-11 19:00:41 +0100
committerGabriel Brand <gabr.brand@gmail.com>2024-02-11 19:00:41 +0100
commit7c065014f4b23c0eb50b3662bc5cb14f0a8df746 (patch)
treefee1231fba4adc7e9d97f6fda6c1ac2b8cdd5ac8
parent444fd7892c462e90035c5925011c390a937eb105 (diff)
downloadFurtherance-7c065014f4b23c0eb50b3662bc5cb14f0a8df746.tar.zst
Port to libadwaita 1.4 widgets
-rw-r--r--Cargo.toml2
-rw-r--r--src/gtk/preferences_window.ui157
-rw-r--r--src/ui/preferences_window.rs43
3 files changed, 68 insertions, 134 deletions
diff --git a/Cargo.toml b/Cargo.toml
index ee28afe..f4d425f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,4 +29,4 @@ version = "0.8.0"
 [dependencies.adw]
 package = "libadwaita"
 version = "0.6.0"
-features = ["v1_2"]
+features = ["v1_4"]
\ No newline at end of file
diff --git a/src/gtk/preferences_window.ui b/src/gtk/preferences_window.ui
index a1192ac..08f9720 100644
--- a/src/gtk/preferences_window.ui
+++ b/src/gtk/preferences_window.ui
@@ -10,15 +10,9 @@
             <property name="title" translatable="yes">Appearance</property>
             <property name="visible">True</property>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="dark_theme_switch">
                 <property name="title" translatable="yes">_Dark theme</property>
                 <property name="use_underline">True</property>
-                <property name="activatable_widget">dark_theme_switch</property>
-                <child>
-                  <object class="GtkSwitch" id="dark_theme_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
               </object>
             </child>
           </object>
@@ -34,24 +28,19 @@
                 <property name="show_enable_switch">True</property>
                 <property name="use_underline">True</property>
                 <child>
-                  <object class="AdwActionRow">
+                  <object class="AdwSpinRow" id="notify_of_idle_spin">
                     <property name="title" translatable="yes">_Minutes to idle</property>
                     <property name="subtitle" translatable="yes">Number of minutes before the user is considered idle</property>
                     <property name="use_underline">True</property>
-                    <child>
-                      <object class="GtkSpinButton" id="notify_of_idle_spin">
-                        <property name="valign">center</property>
-                        <property name="adjustment">
-                          <object class="GtkAdjustment">
-                            <property name="upper">60</property>
-                            <property name="lower">1</property>
-                            <property name="step_increment">1</property>
-                            <property name="page_increment">10</property>
-                          </object>
-                        </property>
-                        <property name="numeric">True</property>
+                    <property name="adjustment">
+                      <object class="GtkAdjustment">
+                        <property name="upper">60</property>
+                        <property name="lower">1</property>
+                        <property name="step_increment">1</property>
+                        <property name="page_increment">10</property>
                       </object>
-                    </child>
+                    </property>
+                    <property name="numeric">True</property>
                   </object>
                 </child>
               </object>
@@ -69,24 +58,19 @@
                 <property name="show_enable_switch">True</property>
                 <property name="use_underline">True</property>
                 <child>
-                  <object class="AdwActionRow">
+                  <object class="AdwSpinRow" id="pomodoro_spin">
                     <property name="title" translatable="yes">Interval</property>
                     <property name="subtitle" translatable="yes">Start time in minutes</property>
                     <property name="use_underline">True</property>
-                    <child>
-                      <object class="GtkSpinButton" id="pomodoro_spin">
-                        <property name="valign">center</property>
-                        <property name="adjustment">
-                          <object class="GtkAdjustment">
-                            <property name="upper">999</property>
-                            <property name="lower">1</property>
-                            <property name="step_increment">1</property>
-                            <property name="page_increment">15</property>
-                          </object>
-                        </property>
-                        <property name="numeric">True</property>
+                    <property name="adjustment">
+                      <object class="GtkAdjustment">
+                        <property name="upper">999</property>
+                        <property name="lower">1</property>
+                        <property name="step_increment">1</property>
+                        <property name="page_increment">15</property>
                       </object>
-                    </child>
+                    </property>
+                    <property name="numeric">True</property>
                   </object>
                 </child>
               </object>
@@ -98,38 +82,27 @@
                 <property name="show_enable_switch">True</property>
                 <property name="use_underline">True</property>
                 <child>
-                  <object class="AdwActionRow">
+                  <object class="AdwSpinRow" id="autosave_spin">
                     <property name="title" translatable="yes">Autosave every X _minutes</property>
                     <property name="use_underline">True</property>
-                    <child>
-                      <object class="GtkSpinButton" id="autosave_spin">
-                        <property name="valign">center</property>
-                        <property name="adjustment">
-                          <object class="GtkAdjustment">
-                            <property name="upper">60</property>
-                            <property name="lower">1</property>
-                            <property name="step_increment">1</property>
-                            <property name="page_increment">10</property>
-                          </object>
-                        </property>
-                        <property name="numeric">True</property>
+                    <property name="adjustment">
+                      <object class="GtkAdjustment">
+                        <property name="upper">60</property>
+                        <property name="lower">1</property>
+                        <property name="step_increment">1</property>
+                        <property name="page_increment">10</property>
                       </object>
-                    </child>
+                    </property>
+                    <property name="numeric">True</property>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="inclusive_total_switch">
                 <property name="title" translatable="yes">Inclusive total time</property>
-                <property name="use_underline">True</property>
-                <property name="activatable_widget">inclusive_total_switch</property>
                 <property name="subtitle" translatable="yes">Today's total time includes the ongoing timer</property>
-                <child>
-                  <object class="GtkSwitch" id="inclusive_total_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
+                <property name="use_underline">True</property>
               </object>
             </child>
           </object>
@@ -145,15 +118,9 @@
             <property name="title" translatable="yes">Task List</property>
             <property name="visible">True</property>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="delete_confirmation_switch">
                 <property name="title" translatable="yes">_Delete confirmation</property>
                 <property name="use_underline">True</property>
-                <property name="activatable_widget">delete_confirmation_switch</property>
-                <child>
-                  <object class="GtkSwitch" id="delete_confirmation_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
               </object>
             </child>
             <child>
@@ -163,64 +130,41 @@
                 <property name="show_enable_switch">True</property>
                 <property name="use_underline">True</property>
                 <child>
-                  <object class="AdwActionRow">
+                  <object class="AdwSpinRow" id="limit_days_spin">
                     <property name="title" translatable="yes">_Days ago</property>
                     <property name="subtitle" translatable="yes">Number of days to display in the list</property>
                     <property name="use_underline">True</property>
-                    <child>
-                      <object class="GtkSpinButton" id="limit_days_spin">
-                        <property name="valign">center</property>
-                        <property name="adjustment">
-                          <object class="GtkAdjustment">
-                            <property name="upper">365</property>
-                            <property name="lower">1</property>
-                            <property name="step_increment">1</property>
-                            <property name="page_increment">10</property>
-                          </object>
-                        </property>
-                        <property name="numeric">True</property>
+                    <property name="adjustment">
+                      <object class="GtkAdjustment">
+                        <property name="upper">365</property>
+                        <property name="lower">1</property>
+                        <property name="step_increment">1</property>
+                        <property name="page_increment">10</property>
                       </object>
-                    </child>
+                    </property>
+                    <property name="numeric">True</property>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="show_daily_sums_switch">
                 <property name="title" translatable="yes">Show daily sums</property>
                 <property name="use_underline">True</property>
-                <property name="activatable_widget">show_daily_sums_switch</property>
-                <child>
-                  <object class="GtkSwitch" id="show_daily_sums_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
               </object>
             </child>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="show_seconds_switch">
                 <property name="title" translatable="yes">_Show seconds</property>
-                <property name="use_underline">True</property>
-                <property name="activatable_widget">show_seconds_switch</property>
                 <property name="subtitle" translatable="yes">Tasks list only. Seconds always show on timer</property>
-                <child>
-                  <object class="GtkSwitch" id="show_seconds_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
+                <property name="use_underline">True</property>
               </object>
             </child>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="show_tags_switch">
                 <property name="title" translatable="yes">Show tags</property>
-                <property name="use_underline">True</property>
-                <property name="activatable_widget">show_tags_switch</property>
                 <property name="subtitle" translatable="yes">Tags are saved, just not shown</property>
-                <child>
-                  <object class="GtkSwitch" id="show_tags_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
+                <property name="use_underline">True</property>
               </object>
             </child>
           </object>
@@ -230,15 +174,9 @@
             <property name="title" translatable="yes">Task Input</property>
             <property name="visible">True</property>
             <child>
-              <object class="AdwActionRow">
+              <object class="AdwSwitchRow" id="autocomplete_switch">
                 <property name="title" translatable="yes">_Autocomplete</property>
                 <property name="use_underline">True</property>
-                <property name="activatable_widget">autocomplete_switch</property>
-                <child>
-                  <object class="GtkSwitch" id="autocomplete_switch">
-                    <property name="valign">center</property>
-                  </object>
-                </child>
               </object>
             </child>
           </object>
@@ -282,7 +220,7 @@
                     <property name="valign">center</property>
                     <property name="label" translatable="yes">Browse</property>
                     <style>
-                      <class name="flat"/>
+                      <class name="flat" />
                     </style>
                   </object>
                 </child>
@@ -294,4 +232,3 @@
     </child>
   </template>
 </interface>
-
diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs
index d3de8de..7d8406b 100644
--- a/src/ui/preferences_window.rs
+++ b/src/ui/preferences_window.rs
@@ -36,49 +36,47 @@ mod imp {
         #[template_child]
         pub appearance_group: TemplateChild<adw::PreferencesGroup>,
         #[template_child]
-        pub dark_theme_switch: TemplateChild<gtk::Switch>,
+        pub dark_theme_switch: TemplateChild<adw::SwitchRow>,
 
         #[template_child]
         pub idle_group: TemplateChild<adw::PreferencesGroup>,
         #[template_child]
         pub notify_of_idle_expander: TemplateChild<adw::ExpanderRow>,
         #[template_child]
-        pub notify_of_idle_spin: TemplateChild<gtk::SpinButton>,
+        pub notify_of_idle_spin: TemplateChild<adw::SpinRow>,
 
         #[template_child]
-        pub task_list_group: TemplateChild<adw::PreferencesGroup>,
-        #[template_child]
-        pub limit_tasks_expander: TemplateChild<adw::ExpanderRow>,
+        pub timer_group: TemplateChild<adw::PreferencesGroup>,
         #[template_child]
-        pub limit_days_spin: TemplateChild<gtk::SpinButton>,
+        pub pomodoro_expander: TemplateChild<adw::ExpanderRow>,
         #[template_child]
-        pub delete_confirmation_switch: TemplateChild<gtk::Switch>,
+        pub pomodoro_spin: TemplateChild<adw::SpinRow>,
         #[template_child]
-        pub show_seconds_switch: TemplateChild<gtk::Switch>,
+        pub autosave_expander: TemplateChild<adw::ExpanderRow>,
         #[template_child]
-        pub show_daily_sums_switch: TemplateChild<gtk::Switch>,
+        pub autosave_spin: TemplateChild<adw::SpinRow>,
         #[template_child]
-        pub show_tags_switch: TemplateChild<gtk::Switch>,
+        pub inclusive_total_switch: TemplateChild<adw::SwitchRow>,
 
         #[template_child]
-        pub task_input_group: TemplateChild<adw::PreferencesGroup>,
+        pub task_list_group: TemplateChild<adw::PreferencesGroup>,
         #[template_child]
-        pub autocomplete_switch: TemplateChild<gtk::Switch>,
-
+        pub delete_confirmation_switch: TemplateChild<adw::SwitchRow>,
         #[template_child]
-        pub timer_group: TemplateChild<adw::PreferencesGroup>,
+        pub limit_tasks_expander: TemplateChild<adw::ExpanderRow>,
         #[template_child]
-        pub pomodoro_expander: TemplateChild<adw::ExpanderRow>,
+        pub limit_days_spin: TemplateChild<adw::SpinRow>,
         #[template_child]
-        pub pomodoro_spin: TemplateChild<gtk::SpinButton>,
-
+        pub show_daily_sums_switch: TemplateChild<adw::SwitchRow>,
         #[template_child]
-        pub autosave_expander: TemplateChild<adw::ExpanderRow>,
+        pub show_seconds_switch: TemplateChild<adw::SwitchRow>,
         #[template_child]
-        pub autosave_spin: TemplateChild<gtk::SpinButton>,
+        pub show_tags_switch: TemplateChild<adw::SwitchRow>,
 
         #[template_child]
-        pub inclusive_total_switch: TemplateChild<gtk::Switch>,
+        pub task_input_group: TemplateChild<adw::PreferencesGroup>,
+        #[template_child]
+        pub autocomplete_switch: TemplateChild<adw::SwitchRow>,
 
         #[template_child]
         pub week_start_combo: TemplateChild<adw::ComboRow>,
@@ -209,7 +207,7 @@ impl FurPreferencesWindow {
                 window.reset_history_box();
             });
 
-        imp.limit_days_spin.connect_value_changed(move |_| {
+        imp.limit_days_spin.connect_value_notify(move |_| {
             let window = FurtheranceWindow::default();
             window.reset_history_box();
         });
@@ -240,7 +238,7 @@ impl FurPreferencesWindow {
                 window.refresh_timer();
         });
 
-        imp.pomodoro_spin.connect_value_changed(move |new_val| {
+        imp.pomodoro_spin.connect_value_notify(move |new_val| {
             settings_manager::set_int("pomodoro-time", new_val.value() as i32);
             let window = FurtheranceWindow::default();
             window.refresh_timer();
@@ -299,4 +297,3 @@ impl FurPreferencesWindow {
         }));
     }
 }
-