mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-07-07 19:50:33 +00:00
Do not assume external gsettings schemas exist
The problem with GSettings is that it errors when a schema is not found causing the application to abort. We now check for schema existence of external schemas that we optionally want to use. https://bugzilla.gnome.org/show_bug.cgi?id=721748
This commit is contained in:
parent
dbb2e0feb0
commit
bf021dcadd
|
@ -47,7 +47,7 @@ namespace Gitg
|
|||
|
||||
private Ggit.Diff? d_diff;
|
||||
private Commit? d_commit;
|
||||
private Settings d_fontsettings;
|
||||
private Settings? d_fontsettings;
|
||||
private bool d_has_selection;
|
||||
|
||||
private static Gee.HashMap<string, DiffView> s_diff_map;
|
||||
|
@ -276,6 +276,23 @@ namespace Gitg
|
|||
settings.default_monospace_font_size = fsize;
|
||||
}
|
||||
|
||||
private Settings? try_settings(string schema_id)
|
||||
{
|
||||
var source = SettingsSchemaSource.get_default();
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (source.lookup(schema_id, true) != null)
|
||||
{
|
||||
return new Settings(schema_id);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void constructed()
|
||||
{
|
||||
base.constructed();
|
||||
|
@ -293,18 +310,22 @@ namespace Gitg
|
|||
settings.javascript_can_access_clipboard = true;
|
||||
settings.enable_page_cache = false;
|
||||
|
||||
d_fontsettings = new Settings("org.gnome.desktop.interface");
|
||||
set_settings(settings);
|
||||
|
||||
update_font_settings();
|
||||
d_fontsettings = try_settings("org.gnome.desktop.interface");
|
||||
|
||||
d_fontsettings.changed["monospace-font-name"].connect((s, k) => {
|
||||
if (d_fontsettings != null)
|
||||
{
|
||||
update_font_settings();
|
||||
});
|
||||
|
||||
d_fontsettings.changed["font-name"].connect((s, k) => {
|
||||
update_font_settings();
|
||||
});
|
||||
d_fontsettings.changed["monospace-font-name"].connect((s, k) => {
|
||||
update_font_settings();
|
||||
});
|
||||
|
||||
d_fontsettings.changed["font-name"].connect((s, k) => {
|
||||
update_font_settings();
|
||||
});
|
||||
}
|
||||
|
||||
++s_diff_id;
|
||||
s_diff_map[s_diff_id.to_string()] = this;
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace GitgFiles
|
|||
private TreeStore d_model;
|
||||
private Gtk.Paned d_paned;
|
||||
private GtkSource.View d_source;
|
||||
private Settings d_fontsettings;
|
||||
private Settings d_stylesettings;
|
||||
private Settings? d_fontsettings;
|
||||
private Settings? d_stylesettings;
|
||||
|
||||
private Gtk.ScrolledWindow d_scrolled_files;
|
||||
private Gtk.ScrolledWindow d_scrolled;
|
||||
|
@ -98,6 +98,23 @@ namespace GitgFiles
|
|||
}
|
||||
}
|
||||
|
||||
private Settings? try_settings(string schema_id)
|
||||
{
|
||||
var source = SettingsSchemaSource.get_default();
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (source.lookup(schema_id, true) != null)
|
||||
{
|
||||
return new Settings(schema_id);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void build_ui()
|
||||
{
|
||||
var ret = GitgExt.UI.from_builder("files/view-files.ui",
|
||||
|
@ -122,7 +139,7 @@ namespace GitgFiles
|
|||
d_imagevp.add(d_image);
|
||||
d_imagevp.show_all();
|
||||
|
||||
d_fontsettings = new Settings("org.gnome.desktop.interface");
|
||||
d_fontsettings = try_settings("org.gnome.desktop.interface");
|
||||
|
||||
if (d_fontsettings != null)
|
||||
{
|
||||
|
@ -133,7 +150,7 @@ namespace GitgFiles
|
|||
update_font();
|
||||
}
|
||||
|
||||
d_stylesettings = new Settings("org.gnome.gedit.preferences.editor");
|
||||
d_stylesettings = try_settings("org.gnome.gedit.preferences.editor");
|
||||
|
||||
if (d_stylesettings != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user