[dconf-editor] Construct more things at construct time.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Construct more things at construct time.
- Date: Wed, 19 Dec 2018 17:20:47 +0000 (UTC)
commit d85662082c7190f9c9fe0dc9c8f54dca271e82a1
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Dec 18 14:27:09 2018 +0100
Construct more things at construct time.
editor/adaptative-window.vala | 42 ++++++++++++++++++++++++++++++++++--------
editor/browser-stack.vala | 9 +++++++--
editor/dconf-view.vala | 11 +++++------
editor/dconf-window.vala | 32 +++++++++++++++-----------------
4 files changed, 61 insertions(+), 33 deletions(-)
---
diff --git a/editor/adaptative-window.vala b/editor/adaptative-window.vala
index 248c586..46acc46 100644
--- a/editor/adaptative-window.vala
+++ b/editor/adaptative-window.vala
@@ -162,12 +162,38 @@ private abstract class AdaptativeWindow : ApplicationWindow
{
[CCode (notify = false)] public NightTimeAwareHeaderBar nta_headerbar { protected get; protected
construct; }
- private StyleContext context;
+ private StyleContext window_style_context;
+
+ [CCode (notify = false)] public string window_title
+ {
+ protected construct
+ {
+ string? _value = value;
+ if (_value == null)
+ assert_not_reached ();
+
+ title = value;
+ }
+ }
+
+ [CCode (notify = false)] public string specific_css_class_or_empty
+ {
+ protected construct
+ {
+ string? _value = value;
+ if (_value == null)
+ assert_not_reached ();
+
+ window_style_context = get_style_context ();
+ if (value != "")
+ window_style_context.add_class (value);
+ }
+ }
construct
{
- context = get_style_context ();
- context.add_class ("startup");
+ // window_style_context is created by specific_css_class_or_empty
+ window_style_context.add_class ("startup");
height_request = 283; // 294px max for Purism Librem 5 landscape, for 720px width
width_request = 349; // 360px max for Purism Librem 5 portrait, for 654px height
@@ -183,7 +209,7 @@ private abstract class AdaptativeWindow : ApplicationWindow
load_window_state ();
- Timeout.add (300, () => { context.remove_class ("startup"); return Source.REMOVE; });
+ Timeout.add (300, () => { window_style_context.remove_class ("startup"); return Source.REMOVE; });
}
/*\
@@ -295,9 +321,9 @@ private abstract class AdaptativeWindow : ApplicationWindow
{
old_state = new_state;
if (new_state)
- context.add_class (class_name);
+ window_style_context.add_class (class_name);
else
- context.remove_class (class_name);
+ window_style_context.remove_class (class_name);
}
/*\
@@ -372,8 +398,8 @@ private abstract class AdaptativeWindow : ApplicationWindow
nta_headerbar.set_highcontrast_state (highcontrast_new_state);
if (highcontrast_new_state)
- context.add_class ("hc-theme");
+ window_style_context.add_class ("hc-theme");
else
- context.remove_class ("hc-theme");
+ window_style_context.remove_class ("hc-theme");
}
}
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index 2c607ac..27a823e 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -33,9 +33,9 @@ private class BrowserStack : Grid, AdaptativeWidget, BrowserContent
search_view.set_window_size (new_size);
}
- [CCode (notify = false)] internal ModificationsHandler modifications_handler
+ [CCode (notify = false)] public ModificationsHandler modifications_handler
{
- set
+ internal construct
{
folder_view.modifications_handler = value;
object_view.modifications_handler = value;
@@ -70,6 +70,11 @@ private class BrowserStack : Grid, AdaptativeWidget, BrowserContent
destroy.connect (() => settings.disconnect (small_keys_list_rows_handler));
}
+ internal BrowserStack (ModificationsHandler modifications_handler)
+ {
+ Object (modifications_handler: modifications_handler);
+ }
+
/*\
* * Views
\*/
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index f255d9c..ba89df0 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -28,11 +28,11 @@ private class DConfView : BrowserView, AdaptativeWidget
create_bookmarks_list ();
}
- internal DConfView ()
+ internal DConfView (ModificationsHandler modifications_handler)
{
- BrowserStack _dconf_content = new BrowserStack ();
+ BrowserStack _dconf_content = new BrowserStack (modifications_handler);
_dconf_content.show ();
- Object (browser_content: (BrowserContent) _dconf_content);
+ Object (browser_content: (BrowserContent) _dconf_content, modifications_handler:
modifications_handler);
dconf_content = _dconf_content;
}
@@ -45,13 +45,12 @@ private class DConfView : BrowserView, AdaptativeWidget
}
private ModificationsHandler _modifications_handler;
- [CCode (notify = false)] internal ModificationsHandler modifications_handler
+ [CCode (notify = false)] public ModificationsHandler modifications_handler
{
private get { return _modifications_handler; }
- set
+ internal construct
{
_modifications_handler = value;
- dconf_content.modifications_handler = value;
sorting_options = new SortingOptions (value.model);
sorting_options.notify ["case-sensitive"].connect (on_case_sensitive_changed);
_modifications_handler.delayed_changes_changed.connect (update_in_window_modifications);
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 5edf61d..3ad44f5 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -87,7 +87,7 @@ internal enum ViewType {
private class DConfWindow : BrowserWindow
{
- private SettingsModel model = new SettingsModel ();
+ private SettingsModel model;
private ModificationsHandler modifications_handler;
private GLib.Settings settings = new GLib.Settings ("ca.desrt.dconf-editor.Settings");
@@ -104,15 +104,22 @@ private class DConfWindow : BrowserWindow
private DConfHeaderBar headerbar;
private DConfView main_view;
- private StyleContext context;
- construct
+ internal DConfWindow (bool disable_warning, string? schema, string? path, string? key_name,
NightLightMonitor night_light_monitor)
{
- title = _("dconf Editor");
- context = get_style_context ();
- context.add_class ("dconf-editor");
+ SettingsModel _model = new SettingsModel ();
+ ModificationsHandler _modifications_handler = new ModificationsHandler (_model);
+ DConfHeaderBar _headerbar = new DConfHeaderBar (night_light_monitor);
+ DConfView _main_view = new DConfView (_modifications_handler);
- headerbar = (DConfHeaderBar) nta_headerbar;
- main_view = (DConfView) base_view;
+ Object (nta_headerbar : (NightTimeAwareHeaderBar) _headerbar,
+ base_view : (BaseView) _main_view,
+ window_title : _("dconf Editor"),
+ specific_css_class_or_empty : "dconf-editor");
+
+ model = _model;
+ modifications_handler = _modifications_handler;
+ headerbar = _headerbar;
+ main_view = _main_view;
create_modifications_revealer ();
@@ -124,20 +131,11 @@ private class DConfWindow : BrowserWindow
headerbar_update_bookmarks_icons_handler = headerbar.update_bookmarks_icons.connect
(update_bookmarks_icons_from_variant);
main_view_update_bookmarks_icons_handler = main_view.update_bookmarks_icons.connect
(update_bookmarks_icons_from_variant);
- }
-
- internal DConfWindow (bool disable_warning, string? schema, string? path, string? key_name,
NightLightMonitor night_light_monitor)
- {
- DConfHeaderBar _headerbar = new DConfHeaderBar (night_light_monitor);
- DConfView _main_view = new DConfView ();
- Object (nta_headerbar: (NightTimeAwareHeaderBar) _headerbar, base_view: (BaseView) _main_view);
use_shortpaths_changed_handler = settings.changed ["use-shortpaths"].connect_after (reload_view);
settings.bind ("use-shortpaths", model, "use-shortpaths",
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
- modifications_handler = new ModificationsHandler (model);
revealer.modifications_handler = modifications_handler;
- main_view.modifications_handler = modifications_handler;
delayed_changes_changed_handler = modifications_handler.delayed_changes_changed.connect (() => {
uint total_changes_count = modifications_handler.dconf_changes_count +
modifications_handler.gsettings_changes_count;
if (total_changes_count == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]