It returns all the fonts (possibly more than 1) with a given name. I left the
function gimp_font_get_by_name() as a utility when one don't want to choose (or
is not able anyway, e.g. a script with minimal information), though I wondered
if we should not simplify with a single function (the new one, which is the
correct one now that it is possible to have several fonts with a given name).
It is easy to test with fonts named the same. For instance I could find 2
different fonts, both named 'Holiday'. This call in the Python console returns
both:
> Gimp.fonts_get_by_name('Holiday')
As part of this commit, I also implemented resource arrays (or subtype arrays)
as PDB arguments and return types.
Even if the container is empty, then we return a GStrv of length 1 (i.e.
an array of length 1, terminating with NULL).
In particular, it improves gimp_container_get_filtered_name_array() as
well, and in turn various list-returning functions in libgimp. This
makes the API more consistent after changes from commit 8eb7f6df9e.
Note that a NULL return can be acceptable for error cases, but an empty
list because this is the expected result for the request should be an
empty GStrv, not NULL.
GLib has a specific type of NULL-terminated string arrays:
`G_TYPE_STRV`, which is the `GType` of `char**` aka `GStrv`.
By using this type, we can avoid having a `GimpStringArray` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GStrv`, we allow other languages to pass on string lists as they are
used to, while the bindings will make sure to do the right thing.
In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with string arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).
Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
Add a new GimpContainer::search() virtual function, and a
corresponding gimp_container_search() function, which works
similarly to gimp_container_foreach(), except that the callback
returns a boolean. When the callback returns TRUE, the search is
stopped, and the current object is returned.
Implement GimpContainer::search() in GimpList.
... if not using unique names
Add a new GimpContainer::get_unique_names() virtual function, and a
corresponding gimp_container_get_unique_names() function, which
determines if the container uses unique names for its objects.
Override get_unique_names() in GimpList, to return the corresponding
property.
In gimp_container_deserialize(), don't merge new objects with
existing objects sharing the same name if the container doesn't use
unique names.
Apart from being less code, this actually gives us a nice performance
improvement. Up until a few years ago, if you pass `NULL` as the
marshaller for a signal, GLib would fall back to
`g_cclosure_marshal_generic` which uses libffi to pack/unpack its
arguments. One could avoid this by specifying a more specific
marshaller which would then be used to immediately pack and unpack into
GValues with the correct type.
Lately however, as a way of optimizing signal emission (which can be
quite expensive), GLib added a possibility to set a va_marshaller, which
skips the unnecessary GValue packing and unpacking and just uses a
valist variant.
Since the performance difference is big enough, if the marshaller
argument is NULL, `g_signal_new()` will now check for the simple
marshallers (return type NONE and a single argument) and set both the
generic and the valist marshaller. In other words, less code for us with
bigger optimizations.
In case you also want va_marshallers for more complex signals, you can
use `g_signal_set_va_marshaller()`.
Basically this commit makes sure that all return values that are marked
as "Returns:" also have a `(nullable)` annotation if it is mentioned on
the same line that NULL can also be returned.
This will prevent a few problems in GObject-introspection.
which means that it's now included normally via gimpbase.h
and not any longer via gimpbasetypes.h which we only did out
of lazyness. A *lot* of files in libgimp* and app/ now need to
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
They are unreliable because every type checking cast discards them,
they are useless anyway, visual clutter, added inconsistently, and
generally suck. Wanted to do this a long time ago, it was a bad idea
in the first place.
by turning the -1 into n_children - 1 directly in gimp_container_reorder()
instead of having all subclasses deal with the -1 separately. Remove -1
handling from gimp_list_reorder().
Also, optimize reordering to the same index away without increasing
the function's cost (it was doing a gimp_container_have() before, now
it doees gimp_container_get_child_index(), which both have the same
cost).
instead of gimp_container_get_neighbor_of_active() in gimp-utils.c.
Move the additional GimpContext logic of the old function into the
callers, but use the new function in more places.
2009-01-17 Michael Natterer <mitch@gimp.org>
* all files with a GPL header and all COPYING files:
Change licence to GPLv3 (and to LGPLv3 for libgimp).
Cleaned up some copyright headers and regenerated the parsers in
the ImageMap plugin.
svn path=/trunk/; revision=27913
* app/core/gimpcontainer.[ch]: Move the rest of the class instance
members to GimpContainerPriv and rename the member num_children to
n_children.
svn path=/trunk/; revision=27694
2008-10-11 Michael Natterer <mitch@gimp.org>
Fix old bug in the GimpContainer implementation that wasn't
visible before the drawable stack completly b0rked when removing
the second-last item:
* app/core/gimpcontainer.c: add default implementations of ::add()
and ::remove() and update container->num_children there instead of
in the gimp_container_add() and _remove() wrapper functions.
This way not only external callbacks connected to the "add" and
"remove" signals are called with the correct num_children, also
implemtations of ::add() and ::remove() in subclass have the right
number available before/after upchaining. Add paranoia code to the
wrapper functions which check if the subclass reall chains up.
* app/core/gimplist.c: chain up in add() and remove().
svn path=/trunk/; revision=27227
2008-04-09 Sven Neumann <sven@gimp.org>
* app/core/gimpcontainer.[ch]: added new methods
gimp_container_get_{first,last}_child().
* app/actions/file-actions.c (file_actions_close_all_update)
* app/dialogs/layer-add-mask-dialog.c (layer_add_mask_dialog_new)
* app/dialogs/palette-import-dialog.c (palette_import_image_callback)
* app/gui/gui-vtable.c (gui_get_empty_display):
* app/widgets/gimpmenudock.c (gimp_menu_dock_image_changed): use
the new GimpContainer methods.
* app/core/gimpundostack.c: use the new GimpContainer methods and
cleaned up the code.
svn path=/trunk/; revision=25426
2007-02-11 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c (gimp_container_deserialize): plug leak
introduced with last commit: simply always use the deserialized
name, also on ojects already existing in the container.
svn path=/trunk/; revision=21890
2007-02-10 Michael Natterer <mitch@gimp.org>
Made templates say "ppi" instead of "dpi". Fixes bug #376990:
* app/core/gimp-templates.c
(gimp_templates_migrate_get_child_by_name): find the child also
if the name differs only in the substrings "dpi" and "ppi".
* app/core/gimpcontainer.c (gimp_container_deserialize): if we
found a child, give it the deserialized name if it isn't the same
as its old name.
* etc/templaterc: applied patch from Michael Schumacher that
replaces "dpi" by "ppi".
svn path=/trunk/; revision=21888
2006-09-24 Michael Natterer <mitch@gimp.org>
Some more proper typing instead of using pointers:
* libgimpconfig/gimpconfig-params.h: added macro
GIMP_CONFIG_INSTALL_PROP_BOXED().
* app/core/gimpcontainer.c: made "children-type" a GParamSpecGType.
* app/widgets/gimpcontrollerinfo.c: made "mapping" a
GParamSpecBoxed and use g_hash_table_unref() instead of destroy().
* app/widgets/gimppdbdialog.c: made "select-type" a GParamSpecGType.
* app/dialogs/module-dialog.c
* app/widgets/gimpcolordisplayeditor.c
* app/widgets/gimpcontrollerlist.c
* app/widgets/gimpfileprocview.c
* app/widgets/gimppluginaction.c: use proper object types, boxed
types and G_TYPE_GTYPE instead of G_TYPE_POINTER for various list
stores and signal signatues.
2006-01-18 Michael Natterer <mitch@gimp.org>
* app/config/config-types.c: define GIMP_PARAM_STATIC_STRINGS
which is G_PARAM_STATIC_NAME|NICK|BLURB. Also define
GIMP_PARAM_READABLE, _WRITABLE and _READWRITE which include
GIMP_PARAM_STATIC_STRINGS.
* app/*/*.c: use them for all object properties so their
strings are not copied.
2005-12-10 Michael Natterer <mitch@gimp.org>
* app/config/*.c
* app/core/*.c
* app/display/*.c
* app/text/*.c
* app/vectors/*.c: port to G_DEFINE_TYPE() and friends. Some related
core reordering and cleanup.
2004-06-17 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c (gimp_container_deserialize): add newly
created children to the container *after* deserializing them so
GimpContainer::add() callbacks get the already deserialized
object.
* app/widgets/gimpcontrollers.c: connect to "add" and "remove" of
the controller list and remember / clear the wheel controller when
it appears / disappears.
2004-05-13 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c (gimp_container_add_handler): don't
try to lookup detailed "notify::foo" signal specs.
2004-03-16 Michael Natterer <mitch@gimp.org>
* app/core/gimplist.c (gimp_list_dispose): removed this function.
It was removing all items without freezing the container first,
which caused excessive signal handler activity in GimpContext.
Cleaned up the whole file a bit.
* app/core/gimpcontainer.c (gimp_container_dispose): call
gimp_container_clear() which does the right thing and e.g. speeds
up quitting significantly when gimp->documents is huge.
Reported by Jimmac.
2004-02-18 Michael Natterer <mitch@gimp.org>
Some code review:
* app/config/gimpconfig-deserialize.c
* app/config/gimpconfig-serialize.c: removed obsolete code which
made sure serialize_property()/deserialize_property() are only
called for properties of the correct class. We do it the right way
for quite a while now and clear the inherited function pointers in
gimp_config_iface_base_init().
* app/config/gimprc.c (gimp_rc_dispose): don't forget to chain up.
* app/base/gimplut.c
* app/base/lut-funcs.c
* app/config/gimpconfig-deserialize.c
* app/config/gimpconfig-serialize.c
* app/config/gimpconfig-types.c
* app/config/gimprc.c
* app/core/gimp-modules.c
* app/core/gimpbrush.c
* app/core/gimpcontainer.c
* app/core/gimpdocumentlist.c
* app/core/gimpitem.c
* app/gui/about-dialog.c
* app/gui/color-notebook.c
* app/gui/gui.c
* app/gui/tips-dialog.c
* app/paint/gimppaintcore.c
* app/paint-funcs/paint-funcs.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainermenuimpl.c
* app/widgets/gimpselectioneditor.c: removed I/O includes from
files which don't use lowlevel APIs any more. Also removes
a whole bunch of G_OS_WIN32 special casing. Removed trailing
whitespace. Misc tiny cleanups.
2003-10-11 Sven Neumann <sven@gimp.org>
* app/core/gimpcontainer.c (gimp_container_deserialize): when
deserializing a GimpContainer child, use the child's GimpConfig
implementation, not the container's.