diff options
Diffstat (limited to 'editor/dconf-editor.vala')
-rw-r--r-- | editor/dconf-editor.vala | 71 |
1 files changed, 48 insertions, 23 deletions
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala index 5a94320..d3b1e63 100644 --- a/editor/dconf-editor.vala +++ b/editor/dconf-editor.vala @@ -6,11 +6,15 @@ class ConfigurationEditor private Gtk.Window window; private Gtk.TreeView dir_tree_view; private Gtk.TreeView key_tree_view; + private Gtk.Table key_info_table; private Gtk.Label schema_label; private Gtk.Label summary_label; private Gtk.Label description_label; private Gtk.Label type_label; private Gtk.Label default_label; + private Gtk.Action set_default_action; + + private Key? selected_key; public ConfigurationEditor() { @@ -25,6 +29,7 @@ class ConfigurationEditor { critical("Failed to load UI: %s", e.message); } + ui.connect_signals(this); window = (Gtk.Window)ui.get_object("main_window"); window.destroy.connect(Gtk.main_quit); @@ -41,11 +46,13 @@ class ConfigurationEditor scroll = (Gtk.ScrolledWindow)ui.get_object("key_scrolledwindow"); scroll.add(key_tree_view); + key_info_table = (Gtk.Table)ui.get_object("key_info_table"); schema_label = (Gtk.Label)ui.get_object("schema_label"); summary_label = (Gtk.Label)ui.get_object("summary_label"); description_label = (Gtk.Label)ui.get_object("description_label"); type_label = (Gtk.Label)ui.get_object("type_label"); default_label = (Gtk.Label)ui.get_object("default_label"); + set_default_action = (Gtk.Action)ui.get_object("set_default_action"); /* Always select something */ Gtk.TreeIter iter; @@ -73,19 +80,6 @@ class ConfigurationEditor key_tree_view.get_selection().select_iter(iter); } - private Key? get_selected_key() - { - Gtk.TreeIter iter; - Gtk.TreeModel model; - if (key_tree_view.get_selection().get_selected(out model, out iter)) - { - var key_model = (KeyModel) model; - return key_model.get_key(iter); - } - else - return null; - } - private string type_to_description(string type) { switch(type) @@ -105,20 +99,38 @@ class ConfigurationEditor private void key_selected_cb() { - var key = get_selected_key(); + if(selected_key != null) + selected_key.value_changed.disconnect(key_changed_cb); + + Gtk.TreeIter iter; + Gtk.TreeModel model; + if (key_tree_view.get_selection().get_selected(out model, out iter)) + { + var key_model = (KeyModel) model; + selected_key = key_model.get_key(iter); + } + else + selected_key = null; + + if(selected_key != null) + selected_key.value_changed.connect(key_changed_cb); + + key_info_table.sensitive = selected_key != null; + set_default_action.sensitive = selected_key != null && !selected_key.is_default; + string schema_name = "", summary = "", description = "", type = "", default_value = ""; - if (key != null) + if (selected_key != null) { - if (key.schema != null) + if (selected_key.schema != null) { - schema_name = key.schema.schema.id; - if (key.schema.summary != null) - summary = key.schema.summary; - if (key.schema.description != null) - description = key.schema.description; - type = type_to_description(key.schema.type); - default_value = key.schema.default_value.print(false); + schema_name = selected_key.schema.schema.id; + if (selected_key.schema.summary != null) + summary = selected_key.schema.summary; + if (selected_key.schema.description != null) + description = selected_key.schema.description; + type = type_to_description(selected_key.schema.type); + default_value = selected_key.schema.default_value.print(false); } else { @@ -133,6 +145,19 @@ class ConfigurationEditor default_label.set_text(default_value); } + private void key_changed_cb(Key key) + { + set_default_action.sensitive = selected_key != null && !selected_key.is_default; + } + + [CCode (cname = "G_MODULE_EXPORT set_default_cb", instance_pos = -1)] + public void set_default_cb (Gtk.Action action) + { + if (selected_key == null) + return; + selected_key.set_to_default(); + } + public static int main(string[] args) { Gtk.init(ref args); |