Skip to content

Commit a5ca3cd

Browse files
committed
GNOME - Port to Adw.SwitchRow
1 parent fd00344 commit a5ca3cd

File tree

6 files changed

+15
-35
lines changed

6 files changed

+15
-35
lines changed

NickvisionMoney.GNOME/Blueprints/account_settings_dialog.blp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,13 @@ Adw.Window _root {
149149
}
150150

151151
Adw.PreferencesGroup {
152-
Adw.ActionRow {
152+
Adw.SwitchRow _useCustomCurrencyRow {
153153
title: _("Use Custom Currency");
154-
155-
[suffix]
156-
Gtk.Switch _switchCustomCurrency {
157-
valign: center;
158-
}
159-
160-
activatable-widget: _switchCustomCurrency;
161154
}
162155
}
163156

164157
Adw.PreferencesGroup {
165-
sensitive: bind _switchCustomCurrency.active;
158+
sensitive: bind _useCustomCurrencyRow.active;
166159

167160
Adw.EntryRow _customSymbolRow {
168161
title: _("Currency Symbol");

NickvisionMoney.GNOME/Blueprints/new_account_dialog.blp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,8 @@ Adw.Window _root {
113113
}
114114
}
115115

116-
Adw.ActionRow _overwriteRow {
116+
Adw.SwitchRow _overwriteRow {
117117
title: _("Overwrite Existing Accounts");
118-
119-
[suffix]
120-
Gtk.Switch _overwriteSwitch {
121-
valign: center;
122-
active: true;
123-
}
124118
}
125119
}
126120

NickvisionMoney.GNOME/Blueprints/preferences_dialog.blp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,14 @@ Adw.PreferencesWindow _root {
105105
Adw.PreferencesGroup {
106106
title: _("Locale");
107107

108-
Adw.ActionRow {
108+
Adw.SwitchRow _nativeDigitsSwitch {
109109
title: _("Use Native Digits");
110110
subtitle: _("Whether to use numerals that are native for your locale instead of latin digits.");
111-
activatable-widget: _nativeDigitsSwitch;
112111

113112
[prefix]
114113
Gtk.Image {
115114
icon-name: "preferences-desktop-locale-symbolic";
116115
}
117-
118-
[suffix]
119-
Gtk.Switch _nativeDigitsSwitch {
120-
valign: center;
121-
}
122116
}
123117

124118
Adw.ComboRow _insertSeparatorRow {

NickvisionMoney.GNOME/Views/AccountSettingsDialog.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public partial class AccountSettingsDialog : Adw.Window
2626
[Gtk.Connect] private readonly Adw.ComboRow _transactionRemindersRow;
2727
[Gtk.Connect] private readonly Gtk.Label _reportedCurrencyLabel;
2828
[Gtk.Connect] private readonly Adw.ActionRow _customCurrencyRow;
29-
[Gtk.Connect] private readonly Gtk.Switch _switchCustomCurrency;
29+
[Gtk.Connect] private readonly Adw.SwitchRow _useCustomCurrencyRow;
3030
[Gtk.Connect] private readonly Adw.EntryRow _customSymbolRow;
3131
[Gtk.Connect] private readonly Adw.EntryRow _customCodeRow;
3232
[Gtk.Connect] private readonly Adw.ComboRow _customAmountStyleRow;
@@ -120,11 +120,11 @@ private AccountSettingsDialog(Gtk.Builder builder, AccountSettingsDialogControll
120120
_viewStack.GetChildByName("main").SetVisible(false);
121121
_titleLabel.SetLabel(_("Currency"));
122122
};
123-
_switchCustomCurrency.OnNotify += (sender, e) =>
123+
_useCustomCurrencyRow.OnNotify += (sender, e) =>
124124
{
125125
if (e.Pspec.GetName() == "state")
126126
{
127-
_switchCustomCurrency.GrabFocus();
127+
_useCustomCurrencyRow.GrabFocus();
128128
}
129129
else if (e.Pspec.GetName() == "active")
130130
{
@@ -284,7 +284,7 @@ private AccountSettingsDialog(Gtk.Builder builder, AccountSettingsDialogControll
284284
_accountTypeRow.SetSelected((uint)_controller.Metadata.AccountType);
285285
_incomeButton.SetActive(_controller.Metadata.DefaultTransactionType == TransactionType.Income);
286286
_transactionRemindersRow.SetSelected((uint)_controller.Metadata.TransactionRemindersThreshold);
287-
_switchCustomCurrency.SetActive(_controller.Metadata.UseCustomCurrency);
287+
_useCustomCurrencyRow.SetActive(_controller.Metadata.UseCustomCurrency);
288288
_customSymbolRow.SetText(_controller.Metadata.CustomCurrencySymbol ?? "");
289289
_customCodeRow.SetText(_controller.Metadata.CustomCurrencyCode ?? "");
290290
_customAmountStyleRow.SetModel(Gtk.StringList.New(_controller.CustomCurrencyAmountStyleStrings));
@@ -358,7 +358,7 @@ private void Validate()
358358
};
359359
var customDecimalDigits = _customDecimalDigitsRow.GetSelected() == 5 ? 99 : _customDecimalDigitsRow.GetSelected() + 2;
360360
var oldSymbol = _controller.Metadata.CustomCurrencySymbol;
361-
var checkStatus = _controller.UpdateMetadata(_nameRow.GetText(), (AccountType)_accountTypeRow.GetSelected(), _switchCustomCurrency.GetActive(), _customSymbolRow.GetText(), _customCodeRow.GetText(), (int?)_customAmountStyleRow.GetSelected(), customDecimalSeparator, customGroupSeparator, (int?)customDecimalDigits, transactionType, (RemindersThreshold)_transactionRemindersRow.GetSelected(), _newPasswordRow.GetText(), _newPasswordConfirmRow.GetText());
361+
var checkStatus = _controller.UpdateMetadata(_nameRow.GetText(), (AccountType)_accountTypeRow.GetSelected(), _useCustomCurrencyRow.GetActive(), _customSymbolRow.GetText(), _customCodeRow.GetText(), (int?)_customAmountStyleRow.GetSelected(), customDecimalSeparator, customGroupSeparator, (int?)customDecimalDigits, transactionType, (RemindersThreshold)_transactionRemindersRow.GetSelected(), _newPasswordRow.GetText(), _newPasswordConfirmRow.GetText());
362362
_nameRow.RemoveCssClass("error");
363363
_nameRow.SetTitle(_("Name"));
364364
_customCurrencyRow.RemoveCssClass("error");

NickvisionMoney.GNOME/Views/NewAccountDialog.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public partial class NewAccountDialog : Adw.Window
2626
[Gtk.Connect] private readonly Gtk.LevelBar _accountPasswordStrengthBar;
2727
[Gtk.Connect] private readonly Adw.EntryRow _folderRow;
2828
[Gtk.Connect] private readonly Gtk.Button _selectFolderButton;
29-
[Gtk.Connect] private readonly Adw.ActionRow _overwriteRow;
30-
[Gtk.Connect] private readonly Gtk.Switch _overwriteSwitch;
29+
[Gtk.Connect] private readonly Adw.SwitchRow _overwriteRow;
3130
[Gtk.Connect] private readonly Gtk.Button _nextButton1;
3231
[Gtk.Connect] private readonly Adw.ComboRow _accountTypeRow;
3332
[Gtk.Connect] private readonly Gtk.ToggleButton _incomeButton;
@@ -91,11 +90,11 @@ private NewAccountDialog(Gtk.Builder builder, NewAccountDialogController control
9190
_accountPasswordStrengthBar.AddOffsetValue("strong", 4);
9291
_accountPasswordStrengthBar.AddOffsetValue("verystrong", 5);
9392
_selectFolderButton.OnClicked += SelectFolder;
94-
_overwriteSwitch.OnNotify += (sender, e) =>
93+
_overwriteRow.OnNotify += (sender, e) =>
9594
{
9695
if(e.Pspec.GetName() == "active")
9796
{
98-
_controller.OverwriteExisting = _overwriteSwitch.GetActive();
97+
_controller.OverwriteExisting = _overwriteRow.GetActive();
9998
ValidateName();
10099
}
101100
};

NickvisionMoney.GNOME/Views/PreferencesDialog.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public partial class PreferencesDialog : Adw.PreferencesWindow
2929
[Gtk.Connect] private readonly Gtk.ColorDialogButton _accountCheckingColorButton;
3030
[Gtk.Connect] private readonly Gtk.ColorDialogButton _accountSavingsColorButton;
3131
[Gtk.Connect] private readonly Gtk.ColorDialogButton _accountBusinessColorButton;
32-
[Gtk.Connect] private readonly Gtk.Switch _nativeDigitsSwitch;
32+
[Gtk.Connect] private readonly Adw.SwitchRow _nativeDigitsRow;
3333
[Gtk.Connect] private readonly Adw.ComboRow _insertSeparatorRow;
3434
[Gtk.Connect] private readonly Adw.EntryRow _csvBackupRow;
3535
[Gtk.Connect] private readonly Gtk.Button _selectBackupFolderButton;
@@ -86,7 +86,7 @@ private PreferencesDialog(Gtk.Builder builder, PreferencesViewController control
8686
_accountSavingsColorButton.SetExtRgba(accountSavingsColor!.Value);
8787
GdkExt.RGBA.Parse(out var accountBusinessColor, _controller.AccountBusinessColor);
8888
_accountBusinessColorButton.SetExtRgba(accountBusinessColor!.Value);
89-
_nativeDigitsSwitch.SetActive(_controller.UseNativeDigits);
89+
_nativeDigitsRow.SetActive(_controller.UseNativeDigits);
9090
_insertSeparatorRow.SetSelected((uint)_controller.InsertSeparator);
9191
if (File.Exists(_controller.CSVBackupFolder))
9292
{
@@ -123,7 +123,7 @@ private void Hide(Gtk.Widget sender, EventArgs e)
123123
_controller.AccountSavingsColor = color.ToString();
124124
color = _accountBusinessColorButton.GetExtRgba();
125125
_controller.AccountBusinessColor = color.ToString();
126-
_controller.UseNativeDigits = _nativeDigitsSwitch.GetActive();
126+
_controller.UseNativeDigits = _nativeDigitsRow.GetActive();
127127
_controller.InsertSeparator = (InsertSeparator)_insertSeparatorRow.GetSelected();
128128
_controller.SaveConfiguration();
129129
Destroy();

0 commit comments

Comments
 (0)