mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 23:10:22 +00:00
inspector: Support editing interned string properties
Sadly, interned string properties cannot be handled generically at all - GObject insists on inserting a strcpy in any attempt to set a string property with generic api, destroying the internedness of the string. Therefore, we have to special-case GtkCssNode in the property editor code :-(
This commit is contained in:
parent
b7d001e613
commit
6852a1eef9
@ -42,6 +42,7 @@
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
|
||||
struct _GtkInspectorPropEditorPrivate
|
||||
{
|
||||
@ -393,6 +394,18 @@ string_modified (GtkEntry *entry, ObjectProperty *p)
|
||||
g_value_unset (&val);
|
||||
}
|
||||
|
||||
static void
|
||||
intern_string_modified (GtkEntry *entry, ObjectProperty *p)
|
||||
{
|
||||
const gchar *s;
|
||||
|
||||
s = g_intern_string (gtk_entry_get_text (entry));
|
||||
if (g_str_equal (p->spec->name, "id"))
|
||||
gtk_css_node_set_id (GTK_CSS_NODE (p->obj), s);
|
||||
else if (g_str_equal (p->spec->name, "name"))
|
||||
gtk_css_node_set_name (GTK_CSS_NODE (p->obj), s);
|
||||
}
|
||||
|
||||
static void
|
||||
string_changed (GObject *object, GParamSpec *pspec, gpointer data)
|
||||
{
|
||||
@ -922,8 +935,12 @@ property_editor (GObject *object,
|
||||
G_CALLBACK (string_changed),
|
||||
prop_edit, G_OBJECT (prop_edit));
|
||||
|
||||
connect_controller (G_OBJECT (prop_edit), "changed",
|
||||
object, spec, G_CALLBACK (string_modified));
|
||||
if (GTK_IS_CSS_NODE (object))
|
||||
connect_controller (G_OBJECT (prop_edit), "changed",
|
||||
object, spec, G_CALLBACK (intern_string_modified));
|
||||
else
|
||||
connect_controller (G_OBJECT (prop_edit), "changed",
|
||||
object, spec, G_CALLBACK (string_modified));
|
||||
}
|
||||
else if (type == G_TYPE_PARAM_BOOLEAN)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user