Re: [Gimp-developer] GimpConfig

2005-01-24 Thread Sven Neumann
Hi,

RaphaÃl Quinet <[EMAIL PROTECTED]> writes:

> I expected this suggestion, which is why I wrote that I was worried
> about the parameters the could be used by more than one plug-in.  If
> each plug-in uses its own config file, then it will become tricky for
> two plug-ins to share some config settings.

I don't think two plug-ins should share a configuration file and
access it directly. If there are settings that need to be shared
between plug-ins, then these settinges should be handled in the core
and should be passed to the plug-ins using the PDB (probably by means
of some yet-to-be-added generic methods to pass GimpConfig settings
between core and plug-ins).


Sven
___
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: [Gimp-developer] GimpConfig

2005-01-24 Thread Raphaël Quinet
On Sat, 22 Jan 2005 14:00:42 +0100, Sven Neumann <[EMAIL PROTECTED]> wrote:
> Raphaël Quinet <[EMAIL PROTECTED]> writes:
> > [...]  I am worried about the configuration parameters that could
> > be used by more than one plug-in.
> >
> Of course plug-ins must not access gimprc directly. gimprc is the core
> rc file and must only be read and written by the core. I was rather
> thinking of letting each plug-in use it's own config file, located in
> the ~/.gimp-2.x directory.

I expected this suggestion, which is why I wrote that I was worried
about the parameters the could be used by more than one plug-in.  If
each plug-in uses its own config file, then it will become tricky for
two plug-ins to share some config settings.  This could happen if the
load and save plug-ins for some file format want to share some
settings, or for parameters that could be shared by many plug-ins,
such as some metadata (default author, default copyright/license,
etc.) or color profile information, whether some conversions should be
done automatically, ...  Some of these things could be handled by the
GIMP and stored into global parasites as we already have the default
comment but that would only solve a part of the problem.  Besides, I
would prefer to get rid of the default-comment parasite and move that
to a proper GimpConfig object instead of having to add several new
global parasites for the configurable defaults of some other parts of
the metadata (author, copyright, etc.).

So we still have a problem for the settings that are used by more than
one plug-in.  If two plug-ins (or a plug-in and the core) want to save
some settings into the same file (gimprc or some other shared file)
and do it at the same time, then you don't know if you will only get
the settings from one, from both, or if you will get garbage.

Although the race conditions would not occur too often and we could
decide to ignore them, there are some situations that make them more
likely.  For example, when you have several images open and you save
them all before quitting the GIMP.

> Regarding concurrent writes, I should probably note that
> GimpConfigWriter writes to a temporary file and moves it to the final
> destination when done.

This is a good thing and that prevents the "garbage" case from
happening.  But there is still a problem if two plug-ins want to
update some config settings stored in the same file: you will only get
the updates from one plug-in (or from the core), but you don't know
which one.  Of course, if both plug-ins want to update the same
settings, then the user will only get what he deserves.  But if they
want to update different settings (no conflict) then one of them will
be lost.  This could be avoided if all GimpConfig updates were
serialized through the PDB.

-Raphaël
___
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: [Gimp-developer] GimpConfig

2005-01-22 Thread Sven Neumann
Hi,

RaphaÃl Quinet <[EMAIL PROTECTED]> writes:

> This is again a good idea, but does this mean that the plug-ins
> converted to use GimpConfig would then start accessing the config
> files directly?  I would prefer to make sure that all set/get
> operations for the configuration options are going through the PDB and
> handled by the core (this could of course be done transparently by the
> GimpConfig implementation).  If not, then it will be necessary to
> implement some kind of locking mechanism for the files, in order to
> avoid problems in case the core and a plug-in are trying to update the
> same file.  I am worried about the configuration parameters that could
> be used by more than one plug-in.

Of course plug-ins must not access gimprc directly. gimprc is the core
rc file and must only be read and written by the core. I was rather
thinking of letting each plug-in use it's own config file, located in
the ~/.gimp-2.x directory.

Regarding concurrent writes, I should probably note that
GimpConfigWriter writes to a temporary file and moves it to the final
destination when done.


Sven
___
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: [Gimp-developer] GimpConfig [was: jpeg-exif development summary]

2005-01-21 Thread Raphaël Quinet
On Fri, 21 Jan 2005 00:29:00 +0100, Sven Neumann <[EMAIL PROTECTED]> wrote:
> Raphaël Quinet <[EMAIL PROTECTED]> writes:
> > So the default should be to open the images with the correct
> > orientation without asking, and there should be an option in the
> > preferences (gimprc) that allows the user to ignore the EXIF
> > Orientation tag or to be asked every time.  The threshold for adding
> > new options to the gimprc should be high, but I think that this one
> > deserves it.
> 
> Sure, that has never been questioned. The best thing would probably be
> to add a "[ ] Don't ask me again" toggle to the dialog.

Well, the main point was that most users should not even see that
dialog once, unless they explicitely change the default option in the
preferences.  This is in line with what other programs are doing and
it is IMHO better because most users should not have to care about
the details of the file format.

> But I would
> suggest that this is delayed until we have established a framework for
> plug-ins to deal with such preferences. It would be wrong to depend on
> a modifications to the core here. All plug-ins should have an easy way
> to store configuration and presets. The current gimprc API in the PDB
> is not really sufficient for this.

Even though the current gimprc API in the PDB is rather simple (both
the query and set operations are limited to simple strings), it is not
too bad.  It is of course a good idea to improve it, but it should not
be discarded too early.  Using strings, there is the problem of
marshalling/unmarshalling the data, but having to use the PDB for this
is a good feature from my point of view: it automatically avoids some
concurrency problems that could occur if the plug-ins were accessing
files directly.  It also provides a single point from which some
additional policies could be applied.

> If we want to improve the image export functionality, and I think we
> want to do that for 2.4, we will also need such functionality. I want
> to suggest that we implement this by moving most of the GimpConfig
> functionality from the core to libgimpbase or, alternatively, to a new
> library, maybe called libgimpconfig. We should try to get this done
> early in 2.3 since it will allow us to solve quite a bit of useability
> issues that people have with plug-ins.
[...]

This is again a good idea, but does this mean that the plug-ins
converted to use GimpConfig would then start accessing the config
files directly?  I would prefer to make sure that all set/get
operations for the configuration options are going through the PDB and
handled by the core (this could of course be done transparently by the
GimpConfig implementation).  If not, then it will be necessary to
implement some kind of locking mechanism for the files, in order to
avoid problems in case the core and a plug-in are trying to update the
same file.  I am worried about the configuration parameters that could
be used by more than one plug-in.

> There are a few things that we will need to decide upon, like in which
> library this should live, what namespace it should use (is GimpConfig
> a good name?), and how much of the core GimpConfig we actually want to
> expose to plug-ins and modules. There are a couple of features like
> the ability to nest objects that would perhaps better be kept for the
> core only as they add quite a bit of complexity.

For the namespace, GimpConfig is fine.  GimpProperty (or
GimpPlugInProperty) could be better for those who are familiar with
Java and persistent properties, but could also introduce some
confusion with the existing usage of properties that can be set on
objects.  Regarding the features, I agree that nested objects would be
a bit overkill: being able to store simple data types (and edit them
with the appropriate widgets) would probably be sufficient.

-Raphaël
___
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


Re: [Gimp-developer] GimpConfig

2005-01-20 Thread William Skaggs

Sven wrote:

> I want to suggest that we implement this by moving most of the 
> GimpConfig functionality from the core to libgimpbase or, alternatively, 
> to a new library, maybe called libgimpconfig.

 [ . . . ]

> There are a few things that we will need to decide upon, like in which
> library this should live, what namespace it should use (is GimpConfig
> a good name?), and how much of the core GimpConfig we actually want to
> expose to plug-ins and modules. There are a couple of features like
> the ability to nest objects that would perhaps better be kept for the
> core only as they add quite a bit of complexity.

Looking at the code, it seemed to me that these would be good things
to do, and not all that hard.  There is plenty of space in libgimpbase,
and the name GimpConfig seems perfectly fine.  The code in app/config
is nice and clean, and separates easily into things that can be moved
without too much trouble, and things that ought to stay there.  It 
also seemed to me that the best way to do it was in a single burst
of furious energy, because it would be quite difficult to do it
gradually and have GIMP continue to build during the process.  And
then a fit of insanity came over me . . .

When I came back to consciousness about six hours later, somehow in 
my personal tree all these files had migrated over into libgimpbase:

gimpconfig.[ch]
gimpconfig-deserialize.[ch]
gimpconfig-error.[ch]
gimpconfig-params.[ch]
gimpconfig-path.[ch]
gimpconfig-serialize.[ch]
gimpconfig-types.[ch]
gimpconfig-utils.[ch]
gimpconfigwriter.[ch]
gimpscanner.[ch]
gimpxmlparser.[ch]

And somehow the includes had been fixed in about 200 files scattered
through the core code so that app would actually build.  There is
some significant ugliness involved -- in particular, I have
config/config-types.h included in a lot of places where it shouldn't
be -- but the point is that it builds, and things like that can be
fixed one file at a time without breaking the build.

So now I have this mass of code that is going to bitrot at a furious
rate unless something is done with it, and I am wondering if I can
unload it.

Best,
  -- Bill
 

 
__ __ __ __
Sent via the CNPRC Email system at primate.ucdavis.edu


 
   
___
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer


[Gimp-developer] GimpConfig [was: jpeg-exif development summary]

2005-01-20 Thread Sven Neumann
Hi,

RaphaÃl Quinet <[EMAIL PROTECTED]> writes:

> So the default should be to open the images with the correct
> orientation without asking, and there should be an option in the
> preferences (gimprc) that allows the user to ignore the EXIF
> Orientation tag or to be asked every time.  The threshold for adding
> new options to the gimprc should be high, but I think that this one
> deserves it.

Sure, that has never been questioned. The best thing would probably be
to add a "[ ] Don't ask me again" toggle to the dialog. But I would
suggest that this is delayed until we have established a framework for
plug-ins to deal with such preferences. It would be wrong to depend on
a modifications to the core here. All plug-ins should have an easy way
to store configuration and presets. The current gimprc API in the PDB
is not really sufficient for this.

If we want to improve the image export functionality, and I think we
want to do that for 2.4, we will also need such functionality. I want
to suggest that we implement this by moving most of the GimpConfig
functionality from the core to libgimpbase or, alternatively, to a new
library, maybe called libgimpconfig. We should try to get this done
early in 2.3 since it will allow us to solve quite a bit of useability
issues that people have with plug-ins.

In the core we already make heavy use of the GimpConfig interface.  It
basically adds serialization capabilites to any GObject that
implements it. There's a default implementation that takes care of
serializing and deserializing all object properties that have a
certain flag set in their GParamSpec.

GimpConfig was originally developed to solve the problem that it used
to be a PITA to add a new configuration value to gimprc. Nowadays this
is as simple as adding a new property to one of the classes that form
the GimpRc object. Adding a property to a GObject involves registering
a param-spec, a description of the property that defines the type of
the value and includes a default value, a description and more.

This information can then be used to serialize the value (generate a
string representation) and to deserialize it (load the serialized
values back in). No extra code needs to be written for this.

The addition of the object properties also pays out when a user
interfaces is needed to control the properties. We have a couple of
convenience constructors in the core. The more generic ones could also
be moved to libgimpwidgets. We use these functions to create the
widgets in the tool-options dialogs and also the preference dialog.
For example in order to create a check-button with a label next to it,
we call

 gimp_prop_check_button_new (config, property_name, label_text);

The returned button is a view on the property value. It is synced with
the object config. Any change to the button is applied to the object
and the button will also change it's state if the value changes by
other means. Having this functionality available for all plug-ins and
modules will certainly improve things. Plug-in user interface often
mainly consist of a couple of widgets to control a number of
configurations. If the plug-in implements an object that represents
this configuration, the GUI code reduces to a few lines. Implementing
a Reset button boils down to calling gimp_config_reset(). This will
reset all object properties to their default values. Saving the
current values as new default values would also become trivial. Even
maintaining a couple of configurations like we do for the tool-options
is easy. We can probably implement that as convenience functions in
GimpDialog.

The next step would of course be to move the PDB to using object
properties as well. The work invested in porting plug-ins to
GimpConfig will pay out again then.

There are a few things that we will need to decide upon, like in which
library this should live, what namespace it should use (is GimpConfig
a good name?), and how much of the core GimpConfig we actually want to
expose to plug-ins and modules. There are a couple of features like
the ability to nest objects that would perhaps better be kept for the
core only as they add quite a bit of complexity.


Sven
___
Gimp-developer mailing list
Gimp-developer@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer