Skip to content

Commit

Permalink
Select correct format after install/remove
Browse files Browse the repository at this point in the history
Co-authored-by: awissu <[email protected]>
  • Loading branch information
davidmhewitt and awissu committed Nov 4, 2021
1 parent a2e2314 commit 75862c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/LocaleManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace SwitchboardPlugLocale {
public string get_user_format () {
// The `formats_locale` property is specific to Ubuntu, so check it exists before
// returning the value
if (account_proxy.formats_locale != null) {
if (account_proxy.formats_locale != null && account_proxy.formats_locale != "") {
return account_proxy.formats_locale;
}

Expand Down
2 changes: 0 additions & 2 deletions src/Plug.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ namespace SwitchboardPlugLocale {
}

installer.install_finished.connect ((langcode) => {
langs.add (langcode);
reload.begin ();
});

installer.remove_finished.connect ((langcode) => {
langs.remove (langcode);
reload.begin ();
});

Expand Down
11 changes: 8 additions & 3 deletions src/Widgets/LocaleSetting.vala
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ namespace SwitchboardPlugLocale.Widgets {
public void reload_formats (Gee.ArrayList<string>? locales) {
format_store.clear ();
var user_format = lm.get_user_format ();
int format_id = 0;

int i = 0;
string? active_id = null;
foreach (var locale in locales) {
string country = Gnome.Languages.get_country_from_locale (locale, null);

Expand All @@ -269,15 +269,20 @@ namespace SwitchboardPlugLocale.Widgets {
format_store.set (iter, 0, country, 1, locale);

if (locale == user_format) {
format_id = i;
active_id = locale;
}

i++;
}
}

format_combobox.id_column = 1;
format_combobox.sensitive = i != 1; // set to unsensitive if only have one item
format_combobox.active = format_id;
if (active_id != null) {
format_combobox.active_id = active_id;
} else {
format_combobox.active = 0;
}

format_store.set_sort_column_id (0, Gtk.SortType.ASCENDING);

Expand Down

0 comments on commit 75862c0

Please sign in to comment.