[dconf-editor] Ensure headerbar and base_view creation.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Ensure headerbar and base_view creation.
- Date: Wed, 19 Dec 2018 17:20:52 +0000 (UTC)
commit eb06ef6b10a5f0358d0ee45ab4e343e4d284fd5c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Dec 18 15:25:51 2018 +0100
Ensure headerbar and base_view creation.
editor/adaptative-window.ui | 11 ++++++++
editor/adaptative-window.vala | 36 ++++++++++++++++----------
editor/base-headerbar.vala | 2 +-
editor/base-window.ui | 1 -
editor/base-window.vala | 54 ++++++++++++++++++++-------------------
editor/dconf-editor.gresource.xml | 1 +
editor/meson.build | 1 +
7 files changed, 65 insertions(+), 41 deletions(-)
---
diff --git a/editor/adaptative-window.ui b/editor/adaptative-window.ui
new file mode 100644
index 0000000..0dcf2f2
--- /dev/null
+++ b/editor/adaptative-window.ui
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="dconf-editor">
+ <!-- interface-requires gtk+ 3.0 -->
+ <template class="AdaptativeWindow" parent="GtkApplicationWindow">
+ <property name="height-request">283</property> <!-- 294px max for Purism Librem 5 landscape, for 720px
width -->
+ <property name="width-request">349</property> <!-- 360px max for Purism Librem 5 portrait, for 654px
height -->
+ <signal name="window-state-event" handler="on_window_state_event"/>
+ <signal name="size-allocate" handler="on_size_allocate"/>
+ <signal name="destroy" handler="on_destroy"/>
+ </template>
+</interface>
diff --git a/editor/adaptative-window.vala b/editor/adaptative-window.vala
index 46acc46..72a1f3a 100644
--- a/editor/adaptative-window.vala
+++ b/editor/adaptative-window.vala
@@ -158,11 +158,24 @@ private abstract class NightTimeAwareHeaderBar : HeaderBar
}
}
+[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/adaptative-window.ui")]
private abstract class AdaptativeWindow : ApplicationWindow
{
- [CCode (notify = false)] public NightTimeAwareHeaderBar nta_headerbar { protected get; protected
construct; }
+ private NightTimeAwareHeaderBar headerbar;
+ [CCode (notify = false)] public NightTimeAwareHeaderBar nta_headerbar
+ {
+ protected get { return headerbar; }
+ protected construct
+ {
+ NightTimeAwareHeaderBar? _value = value;
+ if (_value == null)
+ assert_not_reached ();
- private StyleContext window_style_context;
+ headerbar = value;
+ value.show ();
+ set_titlebar (value);
+ }
+ }
[CCode (notify = false)] public string window_title
{
@@ -176,6 +189,7 @@ private abstract class AdaptativeWindow : ApplicationWindow
}
}
+ private StyleContext window_style_context;
[CCode (notify = false)] public string specific_css_class_or_empty
{
protected construct
@@ -195,18 +209,8 @@ private abstract class AdaptativeWindow : ApplicationWindow
// 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
-
- nta_headerbar.show ();
- set_titlebar (nta_headerbar);
-
manage_high_contrast ();
- window_state_event.connect (on_window_state_event);
- size_allocate.connect (on_size_allocate);
- destroy.connect (on_destroy);
-
load_window_state ();
Timeout.add (300, () => { window_style_context.remove_class ("startup"); return Source.REMOVE; });
@@ -216,6 +220,7 @@ private abstract class AdaptativeWindow : ApplicationWindow
* * callbacks
\*/
+ [GtkCallback]
private bool on_window_state_event (Widget widget, Gdk.EventWindowState event)
{
if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
@@ -227,6 +232,7 @@ private abstract class AdaptativeWindow : ApplicationWindow
return false;
}
+ [GtkCallback]
private void on_size_allocate (Allocation allocation)
{
int height = allocation.height;
@@ -236,12 +242,16 @@ private abstract class AdaptativeWindow : ApplicationWindow
update_window_state ();
}
+ [GtkCallback]
private void on_destroy ()
{
+ before_destroy ();
save_window_state ();
base.destroy ();
}
+ protected virtual void before_destroy () {}
+
/*\
* * manage adaptative children
\*/
@@ -395,7 +405,7 @@ private abstract class AdaptativeWindow : ApplicationWindow
if (highcontrast_new_state == highcontrast_state)
return;
highcontrast_state = highcontrast_new_state;
- nta_headerbar.set_highcontrast_state (highcontrast_new_state);
+ headerbar.set_highcontrast_state (highcontrast_new_state);
if (highcontrast_new_state)
window_style_context.add_class ("hc-theme");
diff --git a/editor/base-headerbar.vala b/editor/base-headerbar.vala
index dee77ba..d13af39 100644
--- a/editor/base-headerbar.vala
+++ b/editor/base-headerbar.vala
@@ -66,7 +66,7 @@ private class BaseHeaderBar : NightTimeAwareHeaderBar, AdaptativeWidget
* * hamburger menu
\*/
- [CCode (notify = false)] public string about_action_label { private get; protected construct; }
+ [CCode (notify = false)] public string about_action_label { private get; protected construct; } // TODO
add default = _("About");
protected override void update_hamburger_menu ()
{
diff --git a/editor/base-window.ui b/editor/base-window.ui
index b10cca0..56866fd 100644
--- a/editor/base-window.ui
+++ b/editor/base-window.ui
@@ -4,7 +4,6 @@
<template class="BaseWindow" parent="AdaptativeWindow">
<property name="visible">False</property>
<signal name="key-press-event" handler="on_key_press_event"/>
- <signal name="destroy" handler="on_destroy"/>
<child>
<object class="GtkGrid" id="main_grid">
<property name="visible">True</property>
diff --git a/editor/base-window.vala b/editor/base-window.vala
index ea531e8..4334daf 100644
--- a/editor/base-window.vala
+++ b/editor/base-window.vala
@@ -20,7 +20,22 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/base-window.ui")]
private class BaseWindow : AdaptativeWindow, AdaptativeWidget
{
- [CCode (notify = false)] public BaseView base_view { protected get; protected construct; }
+ private BaseView main_view;
+ [CCode (notify = false)] public BaseView base_view
+ {
+ protected get { return main_view; }
+ protected construct
+ {
+ BaseView? _value = value;
+ if (_value == null)
+ assert_not_reached ();
+
+ main_view = value;
+ value.vexpand = true;
+ value.visible = true;
+ add_to_main_grid (value);
+ }
+ }
private BaseHeaderBar headerbar;
@@ -28,10 +43,6 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
{
headerbar = (BaseHeaderBar) nta_headerbar;
- base_view.vexpand = true;
- base_view.visible = true;
- add_to_main_grid (base_view);
-
install_action_entries ();
}
@@ -78,7 +89,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
protected virtual bool handle_copy_text (out string copy_text)
{
- return base_view.handle_copy_text (out copy_text);
+ return main_view.handle_copy_text (out copy_text);
}
protected virtual bool get_alt_copy_text (out string copy_text)
{
@@ -141,7 +152,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
}
}
- base_view.close_popovers ();
+ main_view.close_popovers ();
string text;
if (handle_copy_text (out text))
@@ -150,10 +161,10 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
private void copy_alt (/* SimpleAction action, Variant? path_variant */)
{
- if (base_view.is_in_in_window_mode ()) // TODO better
+ if (main_view.is_in_in_window_mode ()) // TODO better
return;
- base_view.close_popovers ();
+ main_view.close_popovers ();
string text;
if (get_alt_copy_text (out text))
@@ -174,7 +185,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
private void paste (/* SimpleAction action, Variant? variant */)
{
- if (base_view.is_in_in_window_mode ())
+ if (main_view.is_in_in_window_mode ())
return;
Widget? focus = get_focus ();
@@ -233,28 +244,19 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
private void toggle_hamburger (/* SimpleAction action, Variant? variant */)
{
headerbar.toggle_hamburger_menu ();
- base_view.close_popovers ();
+ main_view.close_popovers ();
}
protected virtual void menu_pressed (/* SimpleAction action, Variant? variant */)
{
headerbar.toggle_hamburger_menu ();
- base_view.close_popovers ();
+ main_view.close_popovers ();
}
/*\
* * global callbacks
\*/
- [GtkCallback]
- private void on_destroy ()
- {
- before_destroy ();
- base.destroy ();
- }
-
- protected virtual void before_destroy () {}
-
[GtkCallback]
protected virtual bool on_key_press_event (Widget widget, Gdk.EventKey event)
{
@@ -270,7 +272,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
BaseWindow _this = (BaseWindow) widget;
_this.headerbar.close_popovers ();
- _this.base_view.close_popovers ();
+ _this.main_view.close_popovers ();
if ((event.state & Gdk.ModifierType.SHIFT_MASK) == 0)
return false; // help overlay
_this.about ();
@@ -365,7 +367,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
in_window_about = true;
headerbar.show_about_view ();
- base_view.show_about_view ();
+ main_view.show_about_view ();
set_focus_visible (false); // about-list grabs focus
}
@@ -375,7 +377,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
{
in_window_about = false;
headerbar.show_default_view ();
- base_view.show_default_view ();
+ main_view.show_default_view ();
}
else
assert_not_reached ();
@@ -387,11 +389,11 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
protected void show_notification (string notification)
{
- base_view.show_notification (notification);
+ main_view.show_notification (notification);
}
protected void hide_notification ()
{
- base_view.hide_notification ();
+ main_view.hide_notification ();
}
}
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index 66651eb..4dd5187 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/ca/desrt/dconf-editor/ui">
+ <file preprocess="xml-stripblanks">adaptative-window.ui</file>
<file preprocess="xml-stripblanks">base-headerbar.ui</file>
<file preprocess="xml-stripblanks">base-view.ui</file>
<file preprocess="xml-stripblanks">base-window.ui</file>
diff --git a/editor/meson.build b/editor/meson.build
index da15164..2f1e58c 100644
--- a/editor/meson.build
+++ b/editor/meson.build
@@ -111,6 +111,7 @@ sources = files(
)
resource_data = files(
+ 'adaptative-window.ui',
'base-headerbar.ui',
'base-view.ui',
'base-window.ui',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]