[dconf-editor] Remove sidebar.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Remove sidebar.
- Date: Fri, 29 Apr 2016 01:28:19 +0000 (UTC)
commit 93b827539a6472a6d3022ff0c1b669807920c999
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Apr 29 03:17:37 2016 +0200
Remove sidebar.
editor/Makefile.am | 1 +
editor/dconf-editor.css | 19 ++++++++-
editor/dconf-editor.gresource.xml | 1 +
editor/dconf-editor.ui | 8 ++--
editor/dconf-model.vala | 21 ++++++++++-
editor/dconf-window.vala | 75 ++++++++++++++++++++++--------------
editor/folder-list-box-row.ui | 27 +++++++++++++
editor/help-overlay.ui | 36 +-----------------
editor/key-list-box-row.vala | 18 +++++++++
editor/pathbar.ui | 16 ++++++++
editor/pathbar.vala | 10 ++++-
11 files changed, 160 insertions(+), 72 deletions(-)
---
diff --git a/editor/Makefile.am b/editor/Makefile.am
index bcf158e..a0c28ba 100644
--- a/editor/Makefile.am
+++ b/editor/Makefile.am
@@ -24,6 +24,7 @@ resource_data = \
dconf-editor-menu.ui \
dconf-editor.css \
dconf-editor.ui \
+ folder-list-box-row.ui \
key-list-box-row.ui \
key-editor.ui \
key-editor-no-schema.ui \
diff --git a/editor/dconf-editor.css b/editor/dconf-editor.css
index 70bf706..24c1b94 100644
--- a/editor/dconf-editor.css
+++ b/editor/dconf-editor.css
@@ -15,8 +15,23 @@
along with Dconf Editor. If not, see <http://www.gnu.org/licenses/>.
*/
-scrolledwindow.sidebar {
- min-width:15em;
+/*\
+* * folder rows
+\*/
+
+.dconf-list > row > .folder > grid {
+ background-image:-gtk-icontheme("folder-symbolic");
+ background-size:24px;
+ background-repeat:no-repeat;
+}
+
+.dconf-list:dir(ltr) > row > .folder > grid {
+ padding-left:48px;
+ background-position:12px center;
+}
+.dconf-list:dir(rtl) > row > .folder > grid {
+ padding-right:48px;
+ background-position:calc(100%-12px) center;
}
/*\
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index 901ca48..9b3ff8f 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -5,6 +5,7 @@
<file preprocess="xml-stripblanks">bookmarks.ui</file>
<file>dconf-editor.css</file>
<file preprocess="xml-stripblanks">dconf-editor.ui</file>
+ <file preprocess="xml-stripblanks">folder-list-box-row.ui</file>
<file preprocess="xml-stripblanks">key-list-box-row.ui</file>
<file preprocess="xml-stripblanks">key-editor.ui</file>
<file preprocess="xml-stripblanks">key-editor-no-schema.ui</file>
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index fb47230..1bce336 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -155,11 +155,8 @@
<property name="expand">True</property>
<child>
<object class="GtkScrolledWindow">
- <property name="visible">True</property>
+ <property name="visible">False</property>
<property name="hscrollbar-policy">never</property>
- <style>
- <class name="sidebar"/>
- </style>
<child>
<object class="GtkTreeView" id="dir_tree_view">
<property name="visible">True</property>
@@ -198,6 +195,9 @@
<property name="visible">True</property>
<property name="activate-on-single-click">True</property>
<property name="selection-mode">browse</property><!-- permits to not have an item
selected -->
+ <style>
+ <class name="dconf-list"/>
+ </style>
<signal name="row-activated" handler="row_activated_cb"/>
<child type="placeholder"> <!-- see
nautilus/src/resources/ui/nautilus-folder-is-empty.ui -->
<object class="GtkGrid">
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index b9777d8..6115257 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -64,6 +64,7 @@ public class Directory : SettingObject
if (_key_model == null)
{
_key_model = new GLib.ListStore (typeof (SettingObject));
+ create_folders ();
create_gsettings_keys ();
create_dconf_keys ();
}
@@ -73,7 +74,20 @@ public class Directory : SettingObject
private void insert_key (Key key)
{
- ((!) _key_model).insert_sorted (key, (a, b) => { return strcmp (((SettingObject) a).name,
((SettingObject) b).name); });
+ ((!) _key_model).insert_sorted ((SettingObject) key, (a, b) => { return strcmp (((SettingObject)
a).name, ((SettingObject) b).name); });
+ }
+
+ /*\
+ * * Folders creation
+ \*/
+
+ public void create_folders ()
+ {
+ children.foreach ((dir) => {
+ ((!) _key_model).insert_sorted ((SettingObject) dir, (a, b) => {
+ return strcmp (((SettingObject) a).name, ((SettingObject) b).name);
+ });
+ });
}
/*\
@@ -329,6 +343,11 @@ public class SettingsModel : Object, Gtk.TreeModel
client.watch_sync ("/");
}
+ public Directory get_root_directory ()
+ {
+ return root;
+ }
+
/*\
* * Recursive creation of views (directories)
\*/
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index fd28a9f..f0ab233 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -65,7 +65,7 @@ class DConfWindow : ApplicationWindow
dir_tree_view.set_model (model);
current_path = settings.get_string ("saved-view");
- if (!settings.get_boolean ("restore-view") || current_path == "/" || current_path == "" ||
!scroll_to_path (current_path))
+ if (!settings.get_boolean ("restore-view") || current_path == "" || !scroll_to_path (current_path))
{
TreeIter iter;
if (model.get_iter_first (out iter))
@@ -145,23 +145,26 @@ class DConfWindow : ApplicationWindow
key_model = null;
TreeIter iter;
+ Directory dir;
if (dir_tree_selection.get_selected (null, out iter))
- {
- key_model = model.get_directory (iter).key_model;
- current_path = model.get_directory (iter).full_name;
- bookmarks_button.current_path = current_path;
- pathbar.set_path (current_path);
-
- GLib.Menu menu = new GLib.Menu ();
- menu.append (_("Copy current path"), "app.copy(\"" + current_path + "\")"); // TODO protection
against some chars in text? 1/2
- GLib.Menu section = new GLib.Menu ();
- section.append (_("Reset visible keys"), "win.reset-visible");
- /* section.append (_("Reset recursively"), "win.reset-recursive"); */
- section.freeze ();
- menu.append_section (null, section);
- menu.freeze ();
- info_button.set_menu_model ((MenuModel) menu);
- }
+ dir = model.get_directory (iter);
+ else
+ dir = model.get_root_directory ();
+
+ key_model = dir.key_model;
+ current_path = dir.full_name;
+ bookmarks_button.current_path = current_path;
+ pathbar.set_path (current_path);
+
+ GLib.Menu menu = new GLib.Menu ();
+ menu.append (_("Copy current path"), "app.copy(\"" + current_path + "\")"); // TODO protection
against some chars in text? 1/2
+ GLib.Menu section = new GLib.Menu ();
+ section.append (_("Reset visible keys"), "win.reset-visible");
+ /* section.append (_("Reset recursively"), "win.reset-recursive"); */
+ section.freeze ();
+ menu.append_section (null, section);
+ menu.freeze ();
+ info_button.set_menu_model ((MenuModel) menu);
key_list_box.bind_model (key_model, new_list_box_row);
}
@@ -169,6 +172,12 @@ class DConfWindow : ApplicationWindow
[GtkCallback]
private bool scroll_to_path (string full_name)
{
+ if (full_name == "/")
+ {
+ dir_tree_selection.unselect_all ();
+ return true;
+ }
+
TreeIter iter;
if (model.get_iter_first (out iter))
{
@@ -196,7 +205,17 @@ class DConfWindow : ApplicationWindow
private Widget new_list_box_row (Object item)
{
- if (((Key) item).has_schema)
+ if (((SettingObject) item).is_view)
+ {
+ FolderListBoxRow box = new FolderListBoxRow (((SettingObject) item).name, ((SettingObject)
item).full_name);
+ box.button_press_event.connect (on_button_pressed);
+ box.on_row_clicked.connect (() => {
+ if (!scroll_to_path (((SettingObject) item).full_name))
+ warning ("Something got wrong with this folder.");
+ });
+ return box;
+ }
+ else if (((Key) item).has_schema)
{
KeyListBoxRowEditable key_list_box_row = new KeyListBoxRowEditable ((GSettingsKey) item);
key_list_box_row.button_press_event.connect (on_button_pressed);
@@ -328,9 +347,6 @@ class DConfWindow : ApplicationWindow
bookmarks_button.active = false;
return false;
}
- else if (name == "plus" || name == "minus" ||
- name == "KP_Add" || name == "KP_Subtract") //
https://bugzilla.gnome.org/show_bug.cgi?id=762256 is WONTFIX
- return false; // TODO GtkTreeView has a weird behaviour if
expanding without children
if (bookmarks_button.active || info_button.active) // TODO open bug about modal popovers and
search_bar
return false;
@@ -351,17 +367,21 @@ class DConfWindow : ApplicationWindow
return;
TreeIter iter;
+ bool on_first_directory;
int position = 0;
if (dir_tree_selection.get_selected (null, out iter))
{
ListBoxRow? selected_row = (ListBoxRow) key_list_box.get_selected_row ();
if (selected_row != null)
position = ((!) selected_row).get_index () + 1;
+
+ on_first_directory = true;
}
- else if (!model.get_iter_first (out iter)) // TODO doesn't that reset iter?
+ else if (model.get_iter_first (out iter))
+ on_first_directory = false;
+ else
return; // TODO better
- bool on_first_directory = true;
do
{
Directory dir = model.get_directory (iter);
@@ -377,8 +397,9 @@ class DConfWindow : ApplicationWindow
GLib.ListStore key_model = dir.key_model;
while (position < key_model.get_n_items ())
{
- Key key = (Key) key_model.get_object (position);
- if (key_matches (key, search_entry.text))
+ SettingObject object = (SettingObject) key_model.get_object (position);
+ if (object.name.index_of (search_entry.text) >= 0 ||
+ (!object.is_view && key_matches ((Key) object, search_entry.text)))
{
select_dir (iter);
key_list_box.select_row (key_list_box.get_row_at_index (position));
@@ -404,10 +425,6 @@ class DConfWindow : ApplicationWindow
private bool key_matches (Key key, string text)
{
- /* Check key name */
- if (key.name.index_of (text) >= 0)
- return true;
-
/* Check key schema (description) */
if (key.has_schema)
{
diff --git a/editor/folder-list-box-row.ui b/editor/folder-list-box-row.ui
new file mode 100644
index 0000000..dbb1e78
--- /dev/null
+++ b/editor/folder-list-box-row.ui
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <template class="FolderListBoxRow" parent="GtkEventBox">
+ <property name="visible">True</property>
+ <style>
+ <class name="folder"/>
+ </style>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="height-request">42</property>
+ <!-- no margin_start: done via CSS -->
+ <property name="column-spacing">6</property>
+ <property name="margin-end">6</property><!-- same as column_spacing -->
+ <property name="hexpand">True</property><!-- TODO add to key-list-box-row.ui? -->
+ <child>
+ <object class="GtkLabel" id="folder_name_label">
+ <property name="visible">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/editor/help-overlay.ui b/editor/help-overlay.ui
index baf3026..c9d3548 100644
--- a/editor/help-overlay.ui
+++ b/editor/help-overlay.ui
@@ -4,7 +4,7 @@
<child>
<object class="GtkShortcutsSection">
<property name="visible">True</property>
- <property name="max-height">12</property>
+ <property name="max-height">8</property>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
@@ -69,40 +69,6 @@
<child>
<object class="GtkShortcutsGroup">
<property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Tree navigation</property>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Expand</property>
- <property name="accelerator">plus</property>
- </object>
- </child>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Expand all
subtrees</property>
- <property name="accelerator"><Shift>Right</property>
- </object>
- </child>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Collapse</property>
- <property name="accelerator">minus</property>
- </object>
- </child>
- <child>
- <object class="GtkShortcutsShortcut">
- <property name="visible">True</property>
- <property name="title" translatable="yes" context="shortcut window">Collapse all
subtrees</property>
- <property name="accelerator"><Shift>Left</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkShortcutsGroup">
- <property name="visible">True</property>
<property name="title" translatable="yes" context="shortcut window">Generic</property>
<child>
<object class="GtkShortcutsShortcut">
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index 0584624..0cc6e78 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -24,6 +24,24 @@ private interface ClickableListBoxRow : Object
public abstract string get_text ();
}
+[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/folder-list-box-row.ui")]
+private class FolderListBoxRow : EventBox, ClickableListBoxRow
+{
+ [GtkChild] private Label folder_name_label;
+ private string full_name;
+
+ public FolderListBoxRow (string label, string path)
+ {
+ folder_name_label.set_text (label);
+ full_name = path;
+ }
+
+ public string get_text ()
+ {
+ return full_name;
+ }
+}
+
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/key-list-box-row.ui")]
private abstract class KeyListBoxRow : EventBox
{
diff --git a/editor/pathbar.ui b/editor/pathbar.ui
index e66b9e8..c341160 100644
--- a/editor/pathbar.ui
+++ b/editor/pathbar.ui
@@ -6,5 +6,21 @@
<style>
<class name="pathbar"/>
</style>
+ <child>
+ <object class="GtkButton" id="root_button">
+ <property name="visible">True</property>
+ <property name="focus-on-click">False</property>
+ <signal name="clicked" handler="set_root_path"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">dconf-editor-symbolic</property>
+ <style>
+ <class name="item"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
</template>
</interface>
diff --git a/editor/pathbar.vala b/editor/pathbar.vala
index 96670e8..af088bf 100644
--- a/editor/pathbar.vala
+++ b/editor/pathbar.vala
@@ -20,12 +20,14 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathbar.ui")]
public class PathBar : Box
{
+ [GtkChild] Button root_button;
+
public signal bool path_selected (string path);
public void set_path (string path, bool notify = false)
requires (path [0] == '/')
{
- @foreach ((child) => { child.destroy (); });
+ @foreach ((child) => { if (child != root_button) child.destroy (); });
string [] split = path.split ("/", 0);
@@ -55,6 +57,12 @@ public class PathBar : Box
if (!path_selected (path))
warning ("something has got wrong with pathbar");
}
+
+ [GtkCallback]
+ private void set_root_path ()
+ {
+ set_path ("/", true);
+ }
}
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/pathbar-item.ui")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]