[Glade-users] custom property setter not fired on commit



Hi Tristan and thank you. Works like a charm.

Now I want to synchronize two properties in my GtkListStore object:
one is the original "columns" property, the other is my own property.

E.g.
columns prop (type, name values)
gint, intcol
gchar, charcol

my columns prop (name, note values)
intcol, "note on intcol"
charcol, "i'm a note"

Note: on "my columns" prop the user can change only the note value, no
change on the number of columns or the names, they are taken from the
original "columns" prop.

Now, I want to keep my property synchronized to the main property.
My coding behave as expected if I use glade_property_set but I have a
problem with the undo/redo stack... again :(

I tried a change in my code but with no success.

Here's a snippet of my set-property function that overrides the
original GtkListStore call.

if(strcmp(property_name, "columns")==0)
{
    ...

    gwidget=glade_widget_get_from_gobject(object);
    property = glade_widget_get_property(gwidget, "my-columns");
    glade_property_get(property, &colfmts);

... change colfmt to reflect "columns"

    glade_command_push_group("Setting columns on %s",
glade_widget_get_name(gwidget));

    g_value_init (&newvalue, MY_TYPE_COLUMN_FORMAT_LIST);
    g_value_take_boxed (&newvalue, colfmts);
    glade_editor_property_commit (eprop, &newvalue);
    g_value_unset (&newvalue);

    /* Chain Up */
    glade_gtk_store_set_property(adaptor, object, property_name, value);
    glade_command_pop_group ();
}

Thank you. Cheers,
Dome


2014-03-15 6:10 GMT+01:00 Tristan Van Berkom <tristan.van.berkom at gmail.com>:
If your custom property is of some unknown GType, like a boxed type
you introduced for example, you will need to provide a
GladeStringFromValue function[0] in your widget adaptor definition.

The string it generates must be unique per possible value that your
GType can have, without this Glade has no way to compare your value
with another value and cannot tell if the value actually changed or
not (and thus needs to be updated in the workspace).

As with all other GladeWidgetAdaptor methods, the string_from_value()
method should chain up to the adaptor implementing the parent widget
type if that is appropriate, here is an example of how we handle it
for the custom "items" property of GtkComboBoxText[1], GtkListStore[2]
also does this for the "columns" property.

Cheers,
    -Tristan

[0]:https://developer.gnome.org/gladeui/unstable/gladeui-glade-widget-adaptor.html#GladeStringFromValueFunc
[1]:https://git.gnome.org/browse/glade/tree/plugins/gtk+/glade-gtk-combo-box-text.c#n82
[2]:https://git.gnome.org/browse/glade/tree/plugins/gtk+/glade-gtk-list-store.c#n243


On Fri, Mar 14, 2014 at 11:12 PM, Domenico Ferrari <domfe at tiscali.it> wrote:
Hi.
I'm doing a new plugin for my widget...
It has a property editable with a TreeView, like "columns" on
GtkListStore object.
In my callback function on "edited" signal I have the following code

  g_value_init (&value, MY_TYPE_COLUMN_FORMAT_LIST);
  g_value_take_boxed (&value, colfmt);
  glade_editor_property_commit (eprop, &value);

but my custom property setter is not fired. If I use
glade_property_set it is correctly called but I miss the undo/redo
stack.
Can I have some help?

Thanks!
_______________________________________________
Glade-users maillist  -  Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]