[dconf-editor] Make RegistryList work on small screens.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Make RegistryList work on small screens.
- Date: Wed, 14 Nov 2018 13:47:17 +0000 (UTC)
commit 3031ae6fef4c88267e13dec8b8d5c0980143e78d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Oct 24 17:08:27 2018 +0200
Make RegistryList work on small screens.
editor/browser-stack.vala | 9 ++++
editor/browser-view.vala | 1 +
editor/dconf-editor.css | 4 +-
editor/dconf-editor.ui | 4 +-
editor/dconf-window.vala | 29 ++++++++--
editor/key-list-box-row.ui | 42 ++++++++++-----
editor/key-list-box-row.vala | 62 ++++++++++++++++-----
editor/model-utils.vala | 125 +++++++++++++++++++++++++++++++++++++++++++
editor/registry-info.vala | 2 +-
editor/registry-list.vala | 52 ++++++++++++++++--
editor/setting-object.vala | 42 ---------------
11 files changed, 293 insertions(+), 79 deletions(-)
---
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index e42b626..cae6092 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -36,6 +36,15 @@ private class BrowserStack : Grid
}
}
+ internal bool extra_small_window
+ {
+ set
+ {
+ folder_view.extra_small_window = value;
+ search_view.extra_small_window = value;
+ }
+ }
+
internal ModificationsHandler modifications_handler
{
set {
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 00658ca..385cc76 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -60,6 +60,7 @@ private class BrowserView : Grid
private GLib.ListStore? key_model = null;
internal bool small_keys_list_rows { set { current_child.small_keys_list_rows = value; }}
+ internal bool extra_small_window { set { current_child.extra_small_window = value; }}
private ModificationsHandler _modifications_handler;
internal ModificationsHandler modifications_handler
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index 565deb3..d9b5ac3 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -106,8 +106,8 @@
.keys-list:dir(ltr) > row > .key > grid { padding-left: 10px;
padding-right:20px; } /* looks cool */
.keys-list:dir(rtl) > row > .key > grid { padding-right:10px;
padding-left: 20px; }
- .keys-list:dir(ltr) > row > .key > grid > :last-child { margin-left:
4em; }
- .keys-list:dir(rtl) > row > .key > grid > :last-child {
margin-right:4em; }
+window:not(.extra-small-window) .keys-list:dir(ltr) > row > .key > grid > :last-child { margin-left:
4em; }
+window:not(.extra-small-window) .keys-list:dir(rtl) > row > .key > grid > :last-child {
margin-right:4em; }
/* technical padding: icon visual padding + icon size + some padding */
.keys-list > row > .managed > grid { transition:padding-left
0.3s,
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index 4852525..cd8d4eb 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -4,8 +4,8 @@
<template class="DConfWindow" parent="GtkApplicationWindow">
<property name="visible">False</property>
<property name="title" translatable="yes">dconf Editor</property>
- <property name="height-request">420</property>
- <property name="width-request">550</property>
+ <property name="height-request">290</property> <!-- 294 max for Purism Librem 5 landscape -->
+ <property name="width-request">550</property> <!-- 360 max for Purism Librem 5 portrait -->
<signal name="key-press-event" handler="on_key_press_event"/>
<signal name="button-press-event" handler="on_button_press_event"/>
<signal name="window-state-event" handler="on_window_state_event"/>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 33fa8ec..68be360 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -441,6 +441,7 @@ private class DConfWindow : ApplicationWindow
return false;
}
+ private bool extra_small_window = false;
[GtkCallback]
private void on_size_allocate (Allocation allocation)
{
@@ -449,7 +450,12 @@ private class DConfWindow : ApplicationWindow
StyleContext context = get_style_context ();
if (allocation.width > MAX_ROW_WIDTH + 42)
{
- context.remove_class ("extra-small-window");
+ if (extra_small_window)
+ {
+ extra_small_window = false;
+ context.remove_class ("extra-small-window");
+ browser_view.extra_small_window = false;
+ }
context.remove_class ("small-window");
context.add_class ("large-window");
}
@@ -457,19 +463,34 @@ private class DConfWindow : ApplicationWindow
{
context.remove_class ("large-window");
context.add_class ("small-window");
- context.add_class ("extra-small-window");
+ if (!extra_small_window)
+ {
+ extra_small_window = true;
+ context.add_class ("extra-small-window");
+ browser_view.extra_small_window = true;
+ }
}
else if (allocation.width < 787)
{
context.remove_class ("large-window");
- context.remove_class ("extra-small-window");
+ if (extra_small_window)
+ {
+ extra_small_window = false;
+ context.remove_class ("extra-small-window");
+ browser_view.extra_small_window = false;
+ }
context.add_class ("small-window");
}
else
{
context.remove_class ("large-window");
context.remove_class ("small-window");
- context.remove_class ("extra-small-window");
+ if (extra_small_window)
+ {
+ extra_small_window = false;
+ context.remove_class ("extra-small-window");
+ browser_view.extra_small_window = false;
+ }
}
/* save size */
diff --git a/editor/key-list-box-row.ui b/editor/key-list-box-row.ui
index 3e5dff9..adac4e2 100644
--- a/editor/key-list-box-row.ui
+++ b/editor/key-list-box-row.ui
@@ -12,17 +12,35 @@
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<child>
- <object class="GtkLabel" id="key_name_label">
+ <object class="GtkGrid">
<property name="visible">True</property>
- <property name="vexpand">True</property>
- <property name="valign">end</property>
- <property name="xalign">0</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">PANGO_WRAP_WORD_CHAR</property>
- <property name="single-line-mode">True</property>
- <style>
- <class name="key-name"/>
- </style>
+ <property name="halign">fill</property>
+ <child>
+ <object class="GtkLabel" id="key_name_label">
+ <property name="visible">True</property>
+ <property name="vexpand">True</property>
+ <property name="valign">end</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">PANGO_WRAP_WORD_CHAR</property>
+ <property name="single-line-mode">True</property>
+ <style>
+ <class name="key-name"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="key_type_label">
+ <property name="visible">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="valign">end</property>
+ <property name="xalign">1</property>
+ <property name="wrap">False</property>
+ <property name="ellipsize">end</property>
+ <property name="single-line-mode">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="left-attach">0</property>
@@ -40,7 +58,7 @@
<property name="wrap-mode">PANGO_WRAP_WORD_CHAR</property>
<property name="lines">2</property>
<property name="ellipsize">end</property>
- <property name="single-line-mode">True</property>
+ <property name="single-line-mode">True</property> <!-- TODO needed? 1/2 -->
<style>
<class name="key-summary"/>
<class name="dim-label"/>
@@ -60,7 +78,7 @@
<property name="wrap-mode">PANGO_WRAP_WORD_CHAR</property>
<property name="lines">3</property>
<property name="ellipsize">end</property>
- <property name="single-line-mode">True</property>
+ <property name="single-line-mode">True</property> <!-- TODO needed? 2/2 -->
<style>
<class name="key-value"/>
</style>
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 72efad8..acb3cdc 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -54,6 +54,7 @@ private class ListBoxRowHeader : Grid
Label label = new Label ((!) header_text);
label.visible = true;
label.halign = Align.START;
+ label.set_ellipsize (Pango.EllipsizeMode.END);
StyleContext context = label.get_style_context ();
context.add_class ("dim-label");
context.add_class ("header-label");
@@ -177,6 +178,7 @@ private class KeyListBoxRow : ClickableListBoxRow
{
[GtkChild] private Grid key_name_and_value_grid;
[GtkChild] private Label key_name_label;
+ [GtkChild] private Label key_type_label;
[GtkChild] private Label key_value_label;
[GtkChild] private Label key_info_label;
private Switch? boolean_switch = null;
@@ -217,6 +219,30 @@ private class KeyListBoxRow : ClickableListBoxRow
}
}
+ private bool _extra_small_window = false;
+ internal bool extra_small_window
+ {
+ set
+ {
+ _extra_small_window = value;
+ if (value)
+ {
+ if (boolean_switch != null)
+ ((!) boolean_switch).hide ();
+ key_value_label.hide ();
+ key_type_label.show ();
+ }
+ else
+ {
+ key_type_label.hide ();
+ if (_use_switch && !delay_mode)
+ ((!) boolean_switch).show ();
+ else
+ key_value_label.show ();
+ }
+ }
+ }
+
construct
{
if (has_schema)
@@ -228,6 +254,7 @@ private class KeyListBoxRow : ClickableListBoxRow
{
boolean_switch = new Switch ();
((!) boolean_switch).can_focus = false;
+ ((!) boolean_switch).halign = Align.END;
((!) boolean_switch).valign = Align.CENTER;
if (has_schema)
((!) boolean_switch).set_detailed_action_name ("ui.empty(('',uint16 0,true,true))");
@@ -325,22 +352,25 @@ private class KeyListBoxRow : ClickableListBoxRow
* * Updating
\*/
- internal void update_label (string key_value_string, bool italic)
+ private bool key_value_label_has_italic_label_class = false;
+ private bool key_type_label_has_italic_label_class = false;
+ internal void update_label (string key_value_string, bool key_value_italic, string key_type_string, bool
key_type_italic)
{
- if (italic)
+ if (key_value_italic)
{
- StyleContext context = key_value_label.get_style_context ();
- if (!context.has_class ("italic-label"))
- context.add_class ("italic-label");
+ if (!key_value_label_has_italic_label_class) key_value_label.get_style_context ().add_class
("italic-label");
}
- else
+ else if (key_value_label_has_italic_label_class) key_value_label.get_style_context ().remove_class
("italic-label");
+ key_value_label_has_italic_label_class = key_value_italic;
+ key_value_label.set_label (key_value_string);
+
+ if (key_type_italic)
{
- StyleContext context = key_value_label.get_style_context ();
- if (context.has_class ("italic-label"))
- context.remove_class ("italic-label");
+ if (!key_type_label_has_italic_label_class) key_type_label.get_style_context ().add_class
("italic-label");
}
-
- key_value_label.set_label (key_value_string);
+ else if (key_type_label_has_italic_label_class) key_type_label.get_style_context ().remove_class
("italic-label");
+ key_type_label_has_italic_label_class = key_type_italic;
+ key_type_label.set_label (key_type_string);
}
private bool _use_switch = false;
@@ -356,14 +386,22 @@ private class KeyListBoxRow : ClickableListBoxRow
private void hide_or_show_switch ()
requires (boolean_switch != null)
{
- if (_use_switch && !delay_mode)
+ if (_extra_small_window)
+ {
+ key_value_label.hide ();
+ ((!) boolean_switch).hide ();
+ key_type_label.show ();
+ }
+ else if (_use_switch && !delay_mode)
{
key_value_label.hide ();
+ key_type_label.hide ();
((!) boolean_switch).show ();
}
else
{
((!) boolean_switch).hide ();
+ key_type_label.hide ();
key_value_label.show ();
}
}
diff --git a/editor/model-utils.vala b/editor/model-utils.vala
index aab5144..6618e40 100644
--- a/editor/model-utils.vala
+++ b/editor/model-utils.vala
@@ -195,4 +195,129 @@ namespace ModelUtils
else
return base_path + name;
}
+
+ /*\
+ * * Types translations
+ \*/
+
+ internal static string key_to_description (string type, bool capitalized)
+ {
+ string untranslated1 = key_to_untranslated_description (type, capitalized);
+ string test = _(untranslated1);
+ if (test != untranslated1)
+ return test;
+
+ string untranslated2 = key_to_untranslated_description (type, !capitalized);
+ test = _(untranslated2);
+ if (test != untranslated2)
+ return test;
+
+ return untranslated1;
+ }
+
+ private static string key_to_untranslated_description (string type, bool capitalized)
+ {
+ switch (type) // TODO byte, bytestring, bytestring array
+ {
+ case "b": return capitalized ? "Boolean" : "boolean";
+ case "s": return capitalized ? "String" : "string";
+ case "as": return capitalized ? "String array" : "string array";
+ case "<enum>": return capitalized ? "Enumeration" : "enumeration";
+ case "<flags>": return capitalized ? "Flags" : "flags";
+ case "d": return capitalized ? "Double" : "double";
+ case "h": return "D-Bus handle type";
+ case "o": return "D-Bus object path";
+ case "ao": return "D-Bus object path array";
+ case "g": return "D-Bus signature";
+ case "y":
+ case "n":
+ case "q":
+ case "i":
+ case "u":
+ case "x":
+ case "t": return capitalized ? "Integer" : "integer";
+ case "v": return capitalized ? "Variant" : "variant";
+ case "()": return capitalized ? "Empty tuple" : "empty tuple";
+ default:
+ return type;
+ }
+ }
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _B_ = _("Boolean");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _b_ = _("boolean");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _S_ = _("String");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _s_ = _("string");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _As_ = _("String array");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _as_ = _("string array");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _Enum_ = _("Enumeration");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _enum_ = _("enumeration");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _Flags_ = _("Flags");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _flags_ = _("flags");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _D_ = _("Double");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _d_ = _("double");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense); this handle type is
an index; you may maintain the word "handle" */
+ private const string _H_ = _("D-Bus handle type");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense); this handle type
is an index; you may maintain the word "handle" */
+ private const string _h_ = _("D-Bus handle type");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _O_ = _("D-Bus object path");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _o_ = _("D-Bus object path");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _Ao_ = _("D-Bus object path array");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _ao_ = _("D-Bus object path array");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _G_ = _("D-Bus signature");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _g_ = _("D-Bus signature");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _Integer_ = _("Integer");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _integer_ = _("integer");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _V_ = _("Variant");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _v_ = _("variant");
+
+ /* Translators: that's the name of a data type; capitalized (if that makes sense) */
+ private const string _Empty_tuple_ = _("Empty tuple");
+
+ /* Translators: that's the name of a data type; non capitalized (if that makes sense) */
+ private const string _empty_tuple_ = _("empty tuple");
}
diff --git a/editor/registry-info.vala b/editor/registry-info.vala
index 67cda4a..3c3995c 100644
--- a/editor/registry-info.vala
+++ b/editor/registry-info.vala
@@ -162,7 +162,7 @@ private class RegistryInfo : Grid, BrowsableView
tmp_bool);
}
/* Translators: as in datatype (integer, boolean, string, etc.) */
- add_row_from_label (_("Type"), Key.key_to_description
(type_code));
+ add_row_from_label (_("Type"),
ModelUtils.key_to_description (type_code, true));
bool range_type_is_range = false;
uint8 range_type;
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index 9b56b05..f621b67 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -54,6 +54,20 @@ private abstract class RegistryList : Grid, BrowsableView
}
}
+ private bool _extra_small_window;
+ internal bool extra_small_window
+ {
+ set
+ {
+ _extra_small_window = value;
+ key_list_box.foreach ((row) => {
+ Widget? row_child = ((ListBoxRow) row).get_child ();
+ if (row_child != null && (!) row_child is KeyListBoxRow)
+ ((KeyListBoxRow) (!) row_child).extra_small_window = value;
+ });
+ }
+ }
+
protected void select_row_and_if_true_grab_focus (ListBoxRow row, bool grab_focus)
{
key_list_box.select_row (row);
@@ -380,6 +394,7 @@ private abstract class RegistryList : Grid, BrowsableView
KeyListBoxRow key_row = create_key_list_box_row (full_name, context_id, properties,
modifications_handler.get_current_delay_mode (), search_mode_non_local_result);
key_row.small_keys_list_rows = _small_keys_list_rows;
+ key_row.extra_small_window = _extra_small_window;
ulong delayed_modifications_changed_handler =
modifications_handler.delayed_changes_changed.connect ((_modifications_handler) => set_delayed_icon
(_modifications_handler, key_row));
set_delayed_icon (modifications_handler, key_row);
@@ -444,7 +459,7 @@ private abstract class RegistryList : Grid, BrowsableView
else if (key_conflict == KeyConflict.HARD)
{
row.get_style_context ().add_class ("hard-conflict");
- row.update_label (_("conflicting keys"), true);
+ row.update_label (_("conflicting keys"), true, _("conflict"), true);
if (type_code == "b")
row.use_switch (false);
}
@@ -532,14 +547,20 @@ private abstract class RegistryList : Grid, BrowsableView
css_context.remove_class ("edited");
else
css_context.add_class ("edited");
- row.update_label (Key.cool_text_value_from_variant (key_value), false);
+
+ string key_value_text = Key.cool_text_value_from_variant (key_value);
+ string key_type_label;
+ bool key_type_italic;
+ get_type_or_value (type_string, key_value_text, out key_type_label, out key_type_italic);
+
+ row.update_label (key_value_text, false, key_type_label, key_type_italic);
}
private static void update_dconf_row (KeyListBoxRow row, string type_string, Variant? key_value)
{
if (key_value == null)
{
- row.update_label (_("Key erased."), true);
+ row.update_label (_("key erased"), true, _("erased"), true);
if (type_string == "b")
row.use_switch (false);
}
@@ -552,7 +573,30 @@ private abstract class RegistryList : Grid, BrowsableView
row.update_switch (key_value_boolean, "bro.toggle-dconf-key-switch(" + switch_variant.print
(false) + ")");
row.use_switch (true);
}
- row.update_label (Key.cool_text_value_from_variant ((!) key_value), false);
+
+ string key_value_text = Key.cool_text_value_from_variant ((!) key_value);
+ string key_type_label;
+ bool key_type_italic;
+ get_type_or_value (type_string, key_value_text, out key_type_label, out key_type_italic);
+ row.update_label (key_value_text, false, key_type_label, key_type_italic);
+ }
+ }
+
+ private static void get_type_or_value (string type_string, string key_value_text, out string
key_type_label, out bool key_type_italic)
+ {
+ if (type_string == "b" || type_string == "mb" || type_string == "y" || type_string == "h" ||
type_string == "g" || type_string == "d" || type_string == "n" || type_string == "q" || type_string == "i" ||
type_string == "u")
+ {
+ key_type_label = key_value_text;
+ key_type_italic = false;
+ }
+ else
+ {
+ key_type_label = ModelUtils.key_to_description (type_string, false);
+ if ((type_string != "<enum>")
+ && (type_string != "<flags>")
+ && (key_type_label == type_string || key_type_label.length > 12))
+ key_type_label = _("type ā%sā").printf (type_string);
+ key_type_italic = true;
}
}
diff --git a/editor/setting-object.vala b/editor/setting-object.vala
index fd6d8bb..61bbbee 100644
--- a/editor/setting-object.vala
+++ b/editor/setting-object.vala
@@ -56,48 +56,6 @@ private abstract class Key : SettingObject
internal signal void value_changed ();
internal ulong key_value_changed_handler = 0;
- internal static string key_to_description (string type) // TODO move in model-utils.vala
- {
- switch (type)
- {
- case "b":
- return _("Boolean");
- case "s":
- return _("String");
- case "as":
- return _("String array");
- case "<enum>":
- return _("Enumeration");
- case "<flags>":
- return _("Flags");
- case "d":
- return _("Double");
- case "h":
- /* Translators: this handle type is an index; you may maintain the word "handle" */
- return _("D-Bus handle type");
- case "o":
- return _("D-Bus object path");
- case "ao":
- return _("D-Bus object path array");
- case "g":
- return _("D-Bus signature");
- case "y": // TODO byte, bytestring, bytestring array
- case "n":
- case "q":
- case "i":
- case "u":
- case "x":
- case "t":
- return _("Integer");
- case "v":
- return _("Variant");
- case "()":
- return _("Empty tuple");
- default:
- return type;
- }
- }
-
protected static void get_min_and_max_string (out string min, out string max, string type_string)
{
switch (type_string)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]