>From 60149720c6955dbfa0bdc9b62104abc15159533e Mon Sep 17 00:00:00 2001 From: Paul Chavent Date: Sat, 27 Aug 2011 00:51:05 +0200 Subject: [PATCH 1/2] Add text properties widget. --- lib/prop_text.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/prop_text.c b/lib/prop_text.c index 6c3c596..277072c 100644 --- a/lib/prop_text.c +++ b/lib/prop_text.c @@ -411,6 +411,30 @@ textprop_save(TextProperty *prop, AttributeNode attr) text_destroy(text); } +static GtkWidget * +textprop_get_widget(TextProperty *prop, PropDialog *dialog) +{ + GtkWidget *ret = gtk_entry_new(); + gtk_entry_set_activates_default(GTK_ENTRY(ret), TRUE); + prophandler_connect(&prop->common, G_OBJECT(ret), "changed"); + return ret; +} + +static void +textprop_reset_widget(TextProperty *prop, GtkWidget *widget) +{ + gtk_entry_set_text(GTK_ENTRY(widget), + prop->text_data ? prop->text_data : ""); +} + +static void +textprop_set_from_widget(TextProperty *prop, GtkWidget *widget) +{ + g_free(prop->text_data); + prop->text_data = + g_strdup (gtk_entry_get_text (GTK_ENTRY(widget))); +} + static void textprop_get_from_offset(TextProperty *prop, void *base, guint offset, guint offset2) @@ -436,9 +460,9 @@ static const PropertyOps textprop_ops = { (PropertyType_Copy) textprop_copy, (PropertyType_Load) textprop_load, (PropertyType_Save) textprop_save, - (PropertyType_GetWidget) noopprop_get_widget, - (PropertyType_ResetWidget) noopprop_reset_widget, - (PropertyType_SetFromWidget) noopprop_set_from_widget, + (PropertyType_GetWidget) textprop_get_widget, + (PropertyType_ResetWidget) textprop_reset_widget, + (PropertyType_SetFromWidget) textprop_set_from_widget, (PropertyType_CanMerge) noopprop_can_merge, (PropertyType_GetFromOffset) textprop_get_from_offset, -- 1.7.4.4