[dconf-editor] Use PropertyRow for properties in key-editor dialogs.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Use PropertyRow for properties in key-editor dialogs.
- Date: Fri, 6 May 2016 01:55:07 +0000 (UTC)
commit 3ca4cf89f83c5795561895dd8214092ac3e191f5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri May 6 03:45:00 2016 +0200
Use PropertyRow for properties in key-editor dialogs.
editor/Makefile.am | 3 +-
editor/dconf-editor.css | 27 +++++
editor/dconf-editor.gresource.xml | 1 +
editor/dconf-view.vala | 63 ++++++++---
editor/key-editor-no-schema.ui | 65 ++++-------
editor/key-editor.ui | 223 +++++++++----------------------------
editor/property-row.ui | 36 ++++++
7 files changed, 189 insertions(+), 229 deletions(-)
---
diff --git a/editor/Makefile.am b/editor/Makefile.am
index a0c28ba..c8c2b05 100644
--- a/editor/Makefile.am
+++ b/editor/Makefile.am
@@ -32,7 +32,8 @@ resource_data = \
bookmark.ui \
help-overlay.ui \
pathbar.ui \
- pathbar-item.ui
+ pathbar-item.ui \
+ property-row.ui
resources.c: $(resource_data)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --target=$@ --generate-source $<
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index e41497b..15e9347 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -113,3 +113,30 @@
.pathbar:dir(rtl) > button:nth-child(2):hover > .item {
border-bottom-color:blue;
}
+
+/*\
+* * properties list
+\*/
+
+/* cool list background and padding */
+list.properties-list {
+ background-color:initial;
+ padding:0.3em 0;
+}
+list.properties-list > row {
+ padding:0 6px; /* align on headerbar's buttons */
+}
+
+/* rows usual height */
+list.properties-list > row > grid > label {
+ min-height:1.5rem;
+ padding-top:0.6rem;
+ padding-bottom:0.6rem;
+}
+
+/* rows content placement */
+list.properties-list > row > grid > :first-child {
+ min-width:12.5rem;
+}
+list.properties-list:dir(ltr) > row > grid > label { padding-right:1em; }
+list.properties-list:dir(rtl) > row > grid > label { padding-left:1em; }
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index 9b3ff8f..08fc477 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -11,6 +11,7 @@
<file preprocess="xml-stripblanks">key-editor-no-schema.ui</file>
<file preprocess="xml-stripblanks">pathbar.ui</file>
<file preprocess="xml-stripblanks">pathbar-item.ui</file>
+ <file preprocess="xml-stripblanks">property-row.ui</file>
</gresource>
<gresource prefix="/ca/desrt/dconf-editor/gtk">
<file preprocess="xml-stripblanks" alias="menus.ui">dconf-editor-menu.ui</file>
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index 2b5bd25..8f99b2e 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -17,6 +17,25 @@
using Gtk;
+[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/property-row.ui")]
+private class PropertyRow : ListBoxRow
+{
+ [GtkChild] private Label name_label;
+ [GtkChild] private Label value_label;
+
+ public string label { get; construct; }
+
+ construct
+ {
+ name_label.set_text (label);
+ }
+
+ public void set_text (string text) /* TODO all properties cannot be edited after construction */
+ {
+ value_label.set_text (text);
+ }
+}
+
private abstract class KeyEditorDialog : Dialog
{
protected bool custom_value_is_valid { get; set; default = true; }
@@ -206,7 +225,7 @@ private class KeyEditorNoSchema : KeyEditorDialog // TODO add type informa
[GtkChild] private Button button_apply;
[GtkChild] private Grid grid;
- [GtkChild] private Label type_label;
+ [GtkChild] private PropertyRow type_row;
private DConfKey key;
@@ -220,12 +239,18 @@ private class KeyEditorNoSchema : KeyEditorDialog // TODO add type informa
((HeaderBar) this.get_header_bar ()).subtitle = ((!) key.parent).full_name; // TODO
get_header_bar() is [transfer none]
Widget _key_editor_child = create_child ((Key) _key);
- grid.attach (_key_editor_child, 1, 1, 1, 1);
+ grid.attach (_key_editor_child, 1, 0, 1, 1);
+ _key_editor_child.valign = Align.CENTER;
+
Widget? warning = add_warning ((Key) _key);
if (warning != null)
- grid.attach ((!) warning, 0, 2, 2, 1);
+ {
+ grid.attach ((!) warning, 0, 1, 2, 1);
+ warning.hexpand = true;
+ warning.halign = Align.CENTER;
+ }
- type_label.set_text (key_to_description ());
+ type_row.set_text (key_to_description ());
notify ["custom-value-is-valid"].connect (() => { button_apply.set_sensitive
(custom_value_is_valid); });
}
@@ -244,11 +269,11 @@ private class KeyEditor : KeyEditorDialog
[GtkChild] private Button button_apply;
[GtkChild] private Grid grid;
- [GtkChild] private Label schema_label;
- [GtkChild] private Label summary_label;
- [GtkChild] private Label description_label;
- [GtkChild] private Label type_label;
- [GtkChild] private Label default_label;
+ [GtkChild] private PropertyRow schema_row;
+ [GtkChild] private PropertyRow summary_row;
+ [GtkChild] private PropertyRow description_row;
+ [GtkChild] private PropertyRow type_row;
+ [GtkChild] private PropertyRow default_row;
[GtkChild] private Switch custom_value_switch;
@@ -264,19 +289,25 @@ private class KeyEditor : KeyEditorDialog
((HeaderBar) this.get_header_bar ()).subtitle = ((!) key.parent).full_name; // TODO
get_header_bar() is [transfer none]
Widget _key_editor_child = create_child ((Key) key);
- grid.attach (_key_editor_child, 1, 6, 1, 1);
+ grid.attach (_key_editor_child, 1, 0, 1, 1);
+ _key_editor_child.valign = Align.CENTER;
custom_value_switch.bind_property ("active", _key_editor_child, "sensitive",
BindingFlags.SYNC_CREATE | BindingFlags.INVERT_BOOLEAN);
+
Widget? warning = add_warning ((Key) _key);
if (warning != null)
- grid.attach ((!) warning, 0, 7, 2, 1);
+ {
+ grid.attach ((!) warning, 0, 1, 2, 1);
+ warning.hexpand = true;
+ warning.halign = Align.CENTER;
+ }
// infos
- schema_label.set_text (key.schema_id);
- summary_label.set_text (key.summary);
- description_label.set_text (key.description);
- type_label.set_text (key_to_description ());
- default_label.set_text (Key.cool_text_value_from_variant (key.default_value, key.type_string));
+ schema_row.set_text (key.schema_id);
+ summary_row.set_text (key.summary);
+ description_row.set_text (key.description);
+ type_row.set_text (key_to_description ());
+ default_row.set_text (Key.cool_text_value_from_variant (key.default_value, key.type_string));
// switch
diff --git a/editor/key-editor-no-schema.ui b/editor/key-editor-no-schema.ui
index 90f9277..306a872 100644
--- a/editor/key-editor-no-schema.ui
+++ b/editor/key-editor-no-schema.ui
@@ -50,56 +50,39 @@
</object>
</child>
<child>
- <object class="GtkGrid" id="grid">
+ <object class="GtkListBox">
<property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="margin">8</property>
- <property name="row-spacing">6</property>
- <property name="column-spacing">12</property>
+ <property name="selection-mode">none</property>
+ <style>
+ <class name="properties-list"/>
+ </style>
<child>
- <object class="GtkLabel">
+ <object class="PropertyRow" id="type_row">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
<property name="label" translatable="yes" comments="Translators: as in datatype (integer,
boolean, string, etc.)">Type</property>
</object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">Custom value</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
+ </child><!-- TODO report bug; doesn't warn if </child><child> is removed -->
<child>
- <object class="GtkLabel" id="type_label">
+ <object class="GtkListBoxRow">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
<property name="can-focus">False</property>
- <property name="max-width-chars">42</property>
- <property name="width-chars">42</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="row-spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="vexpand">true</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Custom value</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
</object>
</child>
diff --git a/editor/key-editor.ui b/editor/key-editor.ui
index e56feb9..10a3805 100644
--- a/editor/key-editor.ui
+++ b/editor/key-editor.ui
@@ -28,213 +28,94 @@
</action-widgets>
<child internal-child="vbox">
<object class="GtkBox">
- <property name="margin">6</property><!-- TODO test -->
+ <property name="border-width">0</property>
<child>
- <object class="GtkGrid" id="grid">
+ <object class="GtkListBox">
<property name="visible">True</property>
- <property name="row-spacing">6</property>
- <property name="column-spacing">12</property>
+ <property name="selection-mode">none</property>
+ <style>
+ <class name="properties-list"/>
+ </style>
<child>
- <object class="GtkLabel">
+ <object class="PropertyRow" id="schema_row">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
<property name="label" translatable="yes">Schema</property>
</object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="PropertyRow" id="summary_row">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
<property name="label" translatable="yes">Summary</property>
</object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="PropertyRow" id="description_row">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
<property name="label" translatable="yes">Description</property>
</object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="PropertyRow" id="type_row">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
<property name="label" translatable="yes" comments="Translators: as in datatype (integer,
boolean, string, etc.)">Type</property>
</object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="PropertyRow" id="default_row">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
<property name="label" translatable="yes">Default</property>
</object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel">
+ <object class="GtkListBoxRow">
<property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">end</property>
- <property name="label" translatable="yes">Use default value</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">5</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="halign">end</property>
-<!-- <property name="valign">start</property> TODO -->
- <property name="label" translatable="yes">Custom value</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">6</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="schema_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
<property name="can-focus">False</property>
- <property name="max-width-chars">42</property>
- <property name="width-chars">42</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="vexpand">true</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Use default value</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="custom_value_switch">
+ <property name="visible">True</property>
+ <property name="width-request">100</property><!-- same request than for
button_cancel/button_apply -->
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
<child>
- <object class="GtkLabel" id="summary_label">
+ <object class="GtkListBoxRow">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
<property name="can-focus">False</property>
- <property name="max-width-chars">42</property>
- <property name="width-chars">42</property>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="description_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
- <property name="can-focus">False</property>
- <property name="max-width-chars">42</property>
- <property name="width-chars">42</property>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="type_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
- <property name="can-focus">False</property>
- <property name="max-width-chars">42</property>
- <property name="width-chars">42</property>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="default_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
- <property name="can-focus">False</property>
- <property name="max-width-chars">42</property>
- <property name="width-chars">42</property>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSwitch" id="custom_value_switch">
- <property name="visible">True</property>
- <property name="width-request">100</property><!-- same request than for
button_cancel/button_apply -->
- <property name="halign">end</property>
- <property name="hexpand">True</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="vexpand">true</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Custom value</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">5</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
</child>
</object>
</child>
diff --git a/editor/property-row.ui b/editor/property-row.ui
new file mode 100644
index 0000000..5be3285
--- /dev/null
+++ b/editor/property-row.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <template class="PropertyRow" parent="GtkListBoxRow">
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel" id="name_label">
+ <property name="visible">True</property>
+ <property name="valign">start</property>
+ <property name="vexpand">true</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="value_label">
+ <property name="visible">True</property>
+ <property name="valign">start</property>
+ <property name="vexpand">true</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="wrap">True</property>
+ <property name="selectable">True</property>
+ <property name="can-focus">False</property>
+ <property name="max-width-chars">42</property>
+ <property name="width-chars">42</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]