[dconf] editor: Allow complex values to be edited. Note that tuples are broken in glib < 2.27.4, see bug #64
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] editor: Allow complex values to be edited. Note that tuples are broken in glib < 2.27.4, see bug #64
- Date: Tue, 15 Mar 2011 06:45:19 +0000 (UTC)
commit 07f2cd62e3d9918149776136705d5e076ddce5ae
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Mar 15 17:45:13 2011 +1100
editor: Allow complex values to be edited. Note that tuples are broken in glib < 2.27.4, see bug #644786
editor/dconf-view.vala | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index 2c57385..a46293e 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -71,7 +71,7 @@ private class KeyValueRenderer: Gtk.CellRenderer
break;
default:
text_renderer.text = key.value.print(false);
- mode = Gtk.CellRendererMode.INERT;
+ mode = Gtk.CellRendererMode.EDITABLE;
break;
}
}
@@ -248,7 +248,25 @@ private class KeyValueRenderer: Gtk.CellRenderer
private void text_edited_cb(Gtk.CellRendererText renderer, string path, string text)
{
var key = get_key_from_path(path);
- key.value = new Variant.string(text);
+ if (key.type_string == "s" || key.type_string == "<enum>")
+ {
+ key.value = new Variant.string(text);
+ }
+ else
+ {
+ debug("%s %s", key.type_string, text);
+ try
+ {
+ var value = Variant.parse(new VariantType(key.type_string), text);
+ key.value = value;
+ }
+ catch (VariantParseError e)
+ {
+ var dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, "Error setting value: %s", e.message);
+ dialog.run();
+ dialog.destroy();
+ }
+ }
}
private void spin_edited_cb(Gtk.CellRendererText renderer, string path, string text)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]