RSS/Atom feed Twitter
Site is read-only, email is disabled

meta-data browser: EntryWidget + treemodel = chicken/egg problem

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

meta-data browser: EntryWidget + treemodel = chicken/egg problem Roman Joost 12 Jul 15:12
  meta-data browser: EntryWidget + treemodel = chicken/egg problem Martin Nordholts 13 Jul 12:00
   meta-data browser: EntryWidget + treemodel = chicken/egg problem Roman Joost 15 Jul 02:20
Roman Joost
2009-07-12 15:12:20 UTC (over 15 years ago)

meta-data browser: EntryWidget + treemodel = chicken/egg problem

Hi folks,

I pimped an GtkEntry widget for the metadata editor - thanks to Sven for his help.

the problem:

The XMP metadata is stored in a treemodel. The metadata browser has currently two notebook panes where the user can enter data: the description tab for title, author, description and the advanced tab which is a view onto that treemodel.

If I type in the title in the description tab, the change is reflected in the treemodel therefore also visible in the advanced tab. If I change values in the advanced tab I was not able to e.g. update the title entry widget.

my possible solution:

My GtkEntry is instantiated with the xmp_model (read treemodel), the schema uri (e.g. http://purl.org/dc/elements/1.1/) and the property name (e.g. "title"). I subscribe to the 'row-changed' signal of the treemodel (now maybe that's my first mistake), as well as the entry changed signal (maybe another mistake). During initialisation nothing is written to the model and my entry widget is not emitting any signals.

When I enter the first characters in the entry, the following happens:

1. the schema is set (row-changed signal is emitted) 2. the property *value* is set (another row-changed signal)

That raises actually to a big problem, because when I populate two of my Entry widgets in the browser I get a pingpong going on between the Entries. Funny, but not usable.

Is it possible to subscribe to a row-changed event by also using a GtkTreePath as some kind of selector? The problem is, that on instantiation time, I don't have a value set in the treestore, therefore also no path :( Maybe using the treestore as a view (model) as well as a data (model) is another problem here.

I also thought about changing the xmp-model to emit custom signals, like a 'property changed' event, which uses the schema_uri and the property as an identifier. I can't really see that solving my problem here though.

Additionally, I've read the GtkEntry and GtkCellView source code for any additional information. The GtkCellView is storing the model in a private (need to read what this is about) and a it is using a reference for the row. Maybe that's something I should try...

Any help or pointers to documentation or source code would be very much appreciated!

Cheers,

Martin Nordholts
2009-07-13 12:00:11 UTC (over 15 years ago)

meta-data browser: EntryWidget + treemodel = chicken/egg problem

On 07/12/2009 03:12 PM, Roman Joost wrote:

When I enter the first characters in the entry, the following happens:

1. the schema is set (row-changed signal is emitted) 2. the property *value* is set (another row-changed signal)

That raises actually to a big problem, because when I populate two of my Entry widgets in the browser I get a pingpong going on between the Entries. Funny, but not usable.

When a listener makes changes to a the thing it listens to, it typically will want to have
g_signal_handlers_block_by_func()/g_signal_handlers_unblock_by_func() around the piece of code that does the change, and/or "if (new_value == current_value) return;" at the beginning of the callback to prevent the pingpong you are describing. Sometimes it's tricky to get this right.

HTH, Martin

Roman Joost
2009-07-15 02:20:27 UTC (over 15 years ago)

meta-data browser: EntryWidget + treemodel = chicken/egg problem

Hi Martin,

On Mon, Jul 13, 2009 at 12:02:29PM +0200, Martin Nordholts wrote:

On 07/12/2009 03:12 PM, Roman Joost wrote:

When I enter the first characters in the entry, the following happens:

1. the schema is set (row-changed signal is emitted) 2. the property *value* is set (another row-changed signal)

That raises actually to a big problem, because when I populate two of my Entry widgets in the browser I get a pingpong going on between the Entries. Funny, but not usable.

When a listener makes changes to a the thing it listens to, it typically will want to have
g_signal_handlers_block_by_func()/g_signal_handlers_unblock_by_func() around the piece of code that does the change, and/or "if (new_value == current_value) return;" at the beginning of the callback to prevent the pingpong you are describing. Sometimes it's tricky to get this right.

Thanks for this hint. I haven't tried it so far, but I looks like I need it if one of my handlers already dealt with the signal successfully.

It's actually interesting, that I tried various different ideas on implementing this. When I think I already tried everything, there is another idea popping up which I try. So there is progress :)

Cheers,