Fix compiler warnings in Application.Configuration
This commit is contained in:
parent
21482ffcbe
commit
f83a5a57c1
5 changed files with 85 additions and 69 deletions
|
|
@ -119,47 +119,6 @@ public class Application.Configuration : Geary.BaseObject {
|
|||
|
||||
public bool single_key_shortcuts { get; set; default = false; }
|
||||
|
||||
/**
|
||||
* The set of enabled spell checker languages.
|
||||
*
|
||||
* This specifies the languages used for spell checking by the
|
||||
* client. By default, the set will contain languages based on
|
||||
* environment variables.
|
||||
*
|
||||
* @see Util.International.get_user_preferred_languages
|
||||
*/
|
||||
public string[] spell_check_languages {
|
||||
owned get {
|
||||
GLib.Variant? value =
|
||||
settings.get_value(SPELL_CHECK_LANGUAGES).get_maybe();
|
||||
string[] langs = (value != null)
|
||||
? value.get_strv()
|
||||
: Util.International.get_user_preferred_languages();
|
||||
return langs;
|
||||
}
|
||||
set {
|
||||
settings.set_value(
|
||||
SPELL_CHECK_LANGUAGES,
|
||||
new GLib.Variant.maybe(null, new GLib.Variant.strv(value))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of visible spell checker languages.
|
||||
*
|
||||
* This is the list of languages shown when selecting languages to
|
||||
* be used for spell checking.
|
||||
*/
|
||||
public string[] spell_check_visible_languages {
|
||||
owned get {
|
||||
return settings.get_strv(SPELL_CHECK_VISIBLE_LANGUAGES);
|
||||
}
|
||||
set {
|
||||
settings.set_strv(SPELL_CHECK_VISIBLE_LANGUAGES, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool startup_notifications {
|
||||
get { return settings.get_boolean(STARTUP_NOTIFICATIONS_KEY); }
|
||||
set { set_boolean(STARTUP_NOTIFICATIONS_KEY, value); }
|
||||
|
|
@ -190,22 +149,6 @@ public class Application.Configuration : Geary.BaseObject {
|
|||
set { settings.set_double(CONVERSATION_VIEWER_ZOOM_KEY, value); }
|
||||
}
|
||||
|
||||
public int[] composer_window_size {
|
||||
owned get {
|
||||
int[] size = new int[2];
|
||||
var s = settings.get_value(COMPOSER_WINDOW_SIZE_KEY);
|
||||
if (s.n_children () == 2) {
|
||||
size = { (int) s.get_child_value(0), (int) s.get_child_value(1)};
|
||||
} else {
|
||||
size = {-1,-1};
|
||||
}
|
||||
return size;
|
||||
}
|
||||
set {
|
||||
settings.set_value(COMPOSER_WINDOW_SIZE_KEY, value);
|
||||
}
|
||||
}
|
||||
|
||||
/** The number of seconds to wait before sending an email. */
|
||||
public int undo_send_delay {
|
||||
get { return settings.get_int(UNDO_SEND_DELAY); }
|
||||
|
|
@ -233,6 +176,78 @@ public class Application.Configuration : Geary.BaseObject {
|
|||
message("Unable to set configuration value %s = %s", name, value.to_string());
|
||||
}
|
||||
|
||||
/** Returns the saved size of the composer window. */
|
||||
public int[] get_composer_window_size() {
|
||||
int[] size = new int[2];
|
||||
var s = this.settings.get_value(COMPOSER_WINDOW_SIZE_KEY);
|
||||
if (s.n_children () == 2) {
|
||||
size = { (int) s.get_child_value(0), (int) s.get_child_value(1)};
|
||||
} else {
|
||||
size = {-1,-1};
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/** Sets the saved size of the composer window. */
|
||||
public void set_composer_window_size(int[] value) {
|
||||
this.settings.set_value(COMPOSER_WINDOW_SIZE_KEY, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns enabled spell checker languages.
|
||||
*
|
||||
* This specifies the languages used for spell checking by the
|
||||
* client. By default, the set will contain languages based on
|
||||
* environment variables.
|
||||
*
|
||||
* @see Util.International.get_user_preferred_languages
|
||||
*/
|
||||
public string[] get_spell_check_languages() {
|
||||
GLib.Variant? value = this.settings.get_value(
|
||||
SPELL_CHECK_LANGUAGES
|
||||
).get_maybe();
|
||||
string[] langs = (value != null)
|
||||
? value.get_strv()
|
||||
: Util.International.get_user_preferred_languages();
|
||||
return langs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets enabled spell checker languages.
|
||||
*
|
||||
* This specifies the languages used for spell checking by the
|
||||
* client. By default, the set will contain languages based on
|
||||
* environment variables.
|
||||
*
|
||||
* @see Util.International.get_user_preferred_languages
|
||||
*/
|
||||
public void set_spell_check_languages(string[] value) {
|
||||
this.settings.set_value(
|
||||
SPELL_CHECK_LANGUAGES,
|
||||
new GLib.Variant.maybe(null, new GLib.Variant.strv(value))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns visible spell checker languages.
|
||||
*
|
||||
* This is the list of languages shown when selecting languages to
|
||||
* be used for spell checking.
|
||||
*/
|
||||
public string[] get_spell_check_visible_languages() {
|
||||
return this.settings.get_strv(SPELL_CHECK_VISIBLE_LANGUAGES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets visible spell checker languages.
|
||||
*
|
||||
* This is the list of languages shown when selecting languages to
|
||||
* be used for spell checking.
|
||||
*/
|
||||
public void set_spell_check_visible_languages(string[] value) {
|
||||
this.settings.set_strv(SPELL_CHECK_VISIBLE_LANGUAGES, value);
|
||||
}
|
||||
|
||||
public Geary.SearchQuery.Strategy get_search_strategy() {
|
||||
switch (settings.get_string(SEARCH_STRATEGY_KEY).down()) {
|
||||
case "exact":
|
||||
|
|
|
|||
|
|
@ -175,8 +175,9 @@ public abstract class Components.WebView : WebKit.WebView, Geary.BaseInterface {
|
|||
|
||||
private static inline void update_spellcheck(WebKit.WebContext context,
|
||||
Application.Configuration config) {
|
||||
context.set_spell_checking_enabled(config.spell_check_languages.length > 0);
|
||||
context.set_spell_checking_languages(config.spell_check_languages);
|
||||
string[] langs = config.get_spell_check_languages();
|
||||
context.set_spell_checking_enabled(langs.length > 0);
|
||||
context.set_spell_checking_languages(langs);
|
||||
}
|
||||
|
||||
private static inline uint to_wk2_font_size(Pango.FontDescription font) {
|
||||
|
|
|
|||
|
|
@ -2279,7 +2279,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
|||
this.select_dictionary_button, config
|
||||
);
|
||||
this.spell_check_popover.selection_changed.connect((active_langs) => {
|
||||
config.spell_check_languages = active_langs;
|
||||
config.set_spell_check_languages(active_langs);
|
||||
update_subject_spell_checker();
|
||||
});
|
||||
}
|
||||
|
|
@ -2482,7 +2482,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
|||
|
||||
private void update_subject_spell_checker() {
|
||||
Gspell.Language? lang = null;
|
||||
string[] langs = this.application.config.spell_check_languages;
|
||||
string[] langs = this.application.config.get_spell_check_languages();
|
||||
if (langs.length == 1) {
|
||||
lang = Gspell.Language.lookup(langs[0]);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class Composer.Window : Gtk.ApplicationWindow, Container {
|
|||
if (monitor == null) {
|
||||
monitor = display.get_monitor_at_point(1, 1);
|
||||
}
|
||||
int[] size = this.application.config.composer_window_size;
|
||||
int[] size = this.application.config.get_composer_window_size();
|
||||
//check if stored values are reasonable
|
||||
if (monitor != null &&
|
||||
size[0] >= 0 && size[0] <= monitor.geometry.width &&
|
||||
|
|
@ -94,9 +94,9 @@ public class Composer.Window : Gtk.ApplicationWindow, Container {
|
|||
// Only store if the values are reasonable-looking.
|
||||
if (width > 0 && width <= monitor.geometry.width &&
|
||||
height > 0 && height <= monitor.geometry.height) {
|
||||
this.application.config.composer_window_size = {
|
||||
width, height
|
||||
};
|
||||
this.application.config.set_composer_window_size({
|
||||
width, height
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ public class SpellCheckPopover {
|
|||
private void setup_popover() {
|
||||
// We populate the popover with the list of languages that the user wants to see
|
||||
string[] languages = Util.International.get_available_dictionaries();
|
||||
string[] enabled_langs = this.config.spell_check_languages;
|
||||
string[] visible_langs = this.config.spell_check_visible_languages;
|
||||
string[] enabled_langs = this.config.get_spell_check_languages();
|
||||
string[] visible_langs = this.config.get_spell_check_visible_languages();
|
||||
|
||||
content = new Gtk.Box(Gtk.Orientation.VERTICAL, 6);
|
||||
search_box = new Gtk.SearchEntry();
|
||||
|
|
@ -302,7 +302,7 @@ public class SpellCheckPopover {
|
|||
bool is_visible) {
|
||||
langs_list.invalidate_filter();
|
||||
|
||||
string[] visible_langs = this.config.spell_check_visible_languages;
|
||||
string[] visible_langs = this.config.get_spell_check_visible_languages();
|
||||
string lang = row.lang_code;
|
||||
if (is_visible) {
|
||||
if (!(lang in visible_langs)) {
|
||||
|
|
@ -317,7 +317,7 @@ public class SpellCheckPopover {
|
|||
}
|
||||
visible_langs = new_langs;
|
||||
}
|
||||
this.config.spell_check_visible_languages = visible_langs;
|
||||
this.config.set_spell_check_visible_languages(visible_langs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue