Commit Graph

221 Commits

Author SHA1 Message Date
Michael Natterer b92dd2c8e3 app: split GimpDisplay in two classes: GimpDisplay and GimpDisplayImpl
GimpDisplay contains only the ID logic and the "gimp" and "config"
pointers, and lives in the core.

GimpDisplayImpl is a subclass and contains all the actual display
stuff. The subclass is only an implementation detail and doesn't
appear in any API.

Remove all hacks which pass displays as gpointer, GObject or
GimpObject through the core, or even lookup its type by name,
just use GimpDisplay.
2019-09-04 14:30:43 +02:00
Niels De Graef 39e4aa3c57 app/core: Use NULL for "simple" signals
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()`.
2019-08-07 16:33:10 +00:00
Michael Natterer abd7cbfc8d Issue #1788 - Inconsistency between FG color and selected color in...
...palette views despite selected color being in the currently
selected pallette

As suggested by Massimo, changing the color comparison EPSILON in
gimppalette.c from 1e-10 to 1e-6 fixes this, and is really small
enough.

Also, generally clean up color comparison epsilons:

- use a #define, not hardcoded values for all uses of
  gimp_rgb[a]_distance()
- call the #defines RGB_EPSILON and RGBA_EPSILON
- make them all 1e-6 or larger
2019-01-02 01:49:43 +01:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer 552a60b8bf app: some g_return_if_fail() were missing or non-standard in GimpContext 2018-06-17 15:12:26 +02:00
Michael Natterer 4260fa3e78 app: some cleanup in GimpContext
Use more g_clear_object() and g_clear_pointer() and remove useless
comments.
2018-06-17 14:42:44 +02:00
Michael Natterer ed1e2b1524 Issue #1213 - Text Tool Preset does not restore font face/name...
...after program restart

GimpContext was always supposed to keep the names of objects (brush,
pattern, font etc.) around even if these objects don't exist, for
cases like refreshing the data in a GimpDataFactory (which worked
fine), but also for deserializing the names of objects which don't
exist *yet* (delayed loading, no-data or whatever).

This commit fixes the delayed loading case (particularly affects fonts):

gimp_context_deserialize_property(): always keep the name of the
object around when it is not found, not only in the no-data case.

gimp_context_copy_property(): always copy the object *and* its name to
the dest context.

Add GimpConfig::duplicate() and ::copy() implementations which chain
up for duplicating/copying all properties and additionally copy all
object names to the new/dest context.
2018-06-17 14:09:55 +02:00
Michael Natterer 6e19413d21 Revert "app: make gimp_data_factory_data_foreach() public"
This reverts commit f521e92d35.
2018-06-04 12:34:41 +02:00
Michael Natterer f521e92d35 app: make gimp_data_factory_data_foreach() public 2018-06-04 12:33:09 +02:00
Michael Natterer 1d2ff6aa1b app: handle fonts more correctly in gimp_context_deserialize_property()
The "no_data" case for fonts is gimp->no_fonts, not gimp->no_data.
2018-06-03 23:15:37 +02:00
Michael Natterer 40b95227af app: make gimp_font_get_standard() return a GimpData
like all other GimpData sublasses.
2018-06-03 22:46:48 +02:00
Michael Natterer e88fb8e9c7 app: remove all old font management code, switch to GimpFontFactory[View]
Biggest change in this commit is reordering stuff in GimpContext
because GimpFont is now a first class citizen.
2018-06-03 01:27:06 +02:00
Michael Natterer 1b7d63cce9 Use g_set_object() in a lot of places, and splrinkle some g_clear_object() 2018-06-01 12:59:52 +02:00
luz.paz 69b2e84924 Source and trivial typos
Found via `codespell` and `grep`
2018-05-12 23:44:47 +02:00
Michael Natterer ef5bd98e99 app: protect GimpContext's "parent" pointer against dangling
with a weak ref and call set_parent(NULL) in dispose().
2018-04-25 19:20:12 +02:00
Michael Natterer 9ac34bda70 app: change the default paint mode in GimpContext to GIMP_LAYER_MODE_NORMAL 2018-04-24 14:00:34 +02:00
Jehan a1b4f4aef5 Bug 793638 - (gimp-edit-stroke ...) crashes gimp-console-2.9 unless...
... (gimp-context-set-paint-method...) is called.
GimpContext initialized with standard paint info at constructed() time
to ensure there is always a paint_info even if none were set manually.
2018-03-18 15:07:50 +01:00
Jehan c3ef34b496 Revert "app: "distance-metric" is now a property of GimpContext."
This reverts commit 2c799d4af9.
Ok. I misunderstood Mitch. This belongs in GimpPDBContext.
2018-03-17 20:05:54 +01:00
Jehan 2c799d4af9 app: "distance-metric" is now a property of GimpContext.
Remove the property from Blend tool and make it use the context one.
2018-03-17 18:18:56 +01:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
Jehan 4c2df9b365 app: all remaining g_assert() replaced by critical warning and return...
... in app/core.
Continuing on my crusade against asserting and crashing GIMP.
2018-01-22 16:20:04 +01:00
Michael Natterer 0cb3e75f79 app: use a lot of g_clear_object() and g_clear_pointer()
More than 2000 lines of code less in app/, instead of

if (instance->member)
  {
    g_object_unref/g_free/g_whatever (instance->member);
    instance->member = NULL;
  }

we now simply use

g_clear_object/pointer (&instance->member);
2017-07-15 18:42:44 +02:00
Michael Natterer 3cf423f0cd *: rename NORMAL to NORMAL_LEGACY and NORMAL_LINEAR to NORMAL
and make NORMAL_LEGACY immutable.
2017-02-26 16:26:34 +01:00
Michael Natterer 152adbb1bd Rename GIMP_LAYER_MODE_FOO_BROKEN to GIMP_LAYER_MODE_FOO_LEGACY
"Broken" sounds like it needs fixing, but it's legacy compat stuff
that will have to stay for all eternity.
2017-01-09 01:27:20 +01:00
Michael Natterer 66060e3307 app, libgimp*, plug-ins: replace enum GimpLayerModeEffects by GimpLayerMode
with proper value names. Mark most values as _BROKEN because they use
weird alpha compositing that has to die. Move GimpLayerModeEffects to
libgimpbase, deprecate it, and set it as compat enum for GimpLayerMode.
Add the GimpLayerModeEffects values as compat constants to script-fu
and pygimp.
2017-01-08 23:00:19 +01:00
Michael Natterer 33276a000e app: add precondition check on "object" in gimp_context_set_by_type() 2016-10-12 22:44:19 +02:00
Michael Natterer d1e3d7c5c7 Bug 731279 - Tool Preset Editor not working correctly
This fixes restoring of brush properties (size, spacing angle etc.)
from presets, which was utterly broken before. The fix consists of
two parts:

- In tool_manager_preset_changed(), always copy the brush properties
  again after setting the preview on the tool options, in order to
  override brush properites that get copied from a linked brush when
  that brush gets set on the tool options.

But no amount of copying stuff again and again would help without:

- In gimp_context_set_by_type(), don't use g_object_set() to set the
  object (brush, pattern etc.). Instead, build a GValue and call
  gimp_context_set_property(). This may seem odd, but avoids a
  g_object_freeze_notify()/thaw_notify() around the g_object_set(),
  which was causing "notify" to be emitted at the very end, after
  everything this context change has triggered. GimpContext is an
  essential core object and there is an expectation of a reasonable
  order of signal emissions and callbacks being called. The "notify"
  at the end was keeping any callbacks of the context's "foo-changed"
  signals to override anything an earlier callback had done, if a
  "notify" callback was overriding that overriding again.

This was probably the reason for a lot of odd behavior observed over
the years. In fact, I have been searching for this for at least 5
years.
2016-10-12 20:33:23 +02:00
Michael Natterer 0f98eda5a5 app: remove gimp_context_[get|set]_[foreground|background]_pixel()
Artifacts from early GEGL posting.
2016-05-28 09:35:25 +02:00
Michael Natterer 28e1a379e6 app: remove const qualifiers from all object parameters
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.
2016-05-19 23:54:14 +02:00
Michael Natterer f2d581a536 Bug 761170 - Warnings building with clang
Fix a bunch of clang warnings.
2016-02-12 22:49:47 +01:00
Michael Natterer e5b6806fe2 app: port tons of files to the new GIMP_CONFIG_PROP_FOO() macros
and remove lots of labels from calls to gimp_prop_foo_new(). Also
had to manually remove some unwanted labels that are now added
automatically, fixes bug #761880.
2016-02-11 23:46:24 +01:00
Michael Natterer a5eff27149 app: add new GimpData subclass GimpMybrush and infrastructure around it
- GimpContext API and property
- a GimpDataFactory
- List and grid views with GimpDataFactoryView
- actions and a context menu

None of this is connected to the actual tool yet, or depends on
libmypaint in any way.
2015-12-20 23:51:44 +01:00
Michael Natterer 701bc8f79b app: make gimp_context_parent_notify() more robust
Ignore notifications on properties that are not "context properties",
which is for example the parent context's "gimp" property.

A notification on "gimp" is recieved when creating the child context
before the parent context is fully constructed, for example in the
parent's constructed() implementation.
2015-11-09 01:38:37 +01:00
Michael Natterer 8a7665d4b7 app: fix a comment in gimpcontext.c 2015-10-13 01:06:41 +02:00
Michael Natterer 22fc50c279 app: rename all values of enum GimpContextPropMask
from GIMP_CONTEXT_FOO_MASK to GIMP_CONTEXT_PROP_MASK_FOO.
Also rename the FIRST and LAST values of enum GimpContextPropType.
2015-09-08 21:18:49 +02:00
Michael Natterer bc4cf9918f Bug 673501 - Issue with Overlay
GIMP's OVERLAY mode was identical to SOFTLIGHT. This commit fixes the
issue and introduces a NEW_OVERLAY mode and enum value.

- change gimp:overlay-mode to be a real (svg-ish) overlay mode
- when compositing, map OVERLAY to gimp:softlight-mode
- when compisiting, map NEW_OVERLAY to gimp:overlay-mode
- bump the XCF version when NEW_OVERLAY is used
- map OVERLAY to SOFTLIGHT when loading and saving XCF
- map OVERLAY to softlight in all PDB setters
- map OVERLAY to softlight when deserializing a GimpContext
- change all paint mode menus to show an entry for NEW_OVERLAY
  instead of OVERLAY
- change PSP, PSD and OpenRaster to use NEW_OVERLAY

These changes should (redundantly) make sure that no OVERLAY enum
value is used in the core any longer because it gets mapped to
SOFTLIGHT at all entry points, with the downside of introducing a
setter/getter asymmetry when OVERLAY was set in a PDB api.
2015-04-29 13:32:58 -04:00
Michael Natterer 9be16e00bc app: make sure name references to GimpData objects are serialized correctly
They were also serialized correctly before, but only because many
GimpData objects were (bogusly) always dirty after loading, which
caused them to always be written do disk on exit. This commit fixes
this problem and updates by-name references explicitly as things are
renamed, instead of relying on bugs.

Add gimp_data_factory_data_clean() which clears the dirty flags from
all a factory's objects. Call the new function on all factories at the
end of gimp_restore(), when all data has been loaded. This might be
total overkill, but ensures that everything is clean in the beginning.

Add new signal GimpContext::prop_name_changed() which is emitted when
any of the context's object properties (brush, gradient etc) is
renamed.

In GimpToolPreset, connect to the new signal and dirty the preset if a
relevant object propery was renamed, making sure the preset is saved
to disk later. Also optmize updates quite a bit by ignoring
notifications on tool option properties that are irrelevant to the
preset.

This might or might not address the issues discussed in bug #739487.
2015-02-26 22:31:58 +01:00
Michael Natterer 980ba7f85a app: move memsize functions into their own files gimp-memsize.[ch] 2014-08-12 13:57:57 +02:00
Michael Natterer bacc9c9635 Bug 688348 - Layer tab and Images tab: not updated on dropping...
...one image onto another

gimp_dock_window_display_changed(): make sure the "auto-follow-active"
logic works both ways: when the active image or display is changed in
a dockable, update the global context. Fixes multi-window mode.

gimp_context_real_set_display(): make sure a context's display and
image are always in a consistent state and never have a display that
is not display->image: when display is the same as context->display,
check that the context's image matches display->image, so that after a
gimp_context_set_display(), the context is consistent in all
cases. Fixes single-window mode.
2013-04-23 21:05:33 +02:00
Michael Natterer c262fee244 Bug 689523 - GIMP crashes (segfault) when loading a context with a font...
Make gimp_context_get|set_font_name() actually deal with
context->font_name, so the context can do its job of keeping the name
of an unavailable object around.
2013-01-18 01:02:31 +01:00
Michael Natterer 0a37a0490f app: fix indentation in GimpContext 2013-01-18 00:50:12 +01:00
Michael Natterer 908f727f0a Chain up unconditionally in GObject::constructed()
It's supported since GLib 2.28.
2012-11-12 21:51:22 +01:00
Michael Natterer 3ad73b3658 libgimpcolor: add GdkPixbuf <-> GeglBuffer utility functions
and update tons of includes in libgimp and app.
2012-05-03 03:37:20 +02:00
Michael Natterer 7ec6c48636 app: use gimp_rgba_set,get_pixel() instead of babl_process() directly 2012-05-02 17:50:53 +02:00
Michael Natterer 867da8f293 app: add gimp_context_get_foreground,background_pixel()
which takes a Babl format to convert from/to.
Include <gegl.h> in a million places.
2012-05-02 17:50:41 +02:00
Michael Natterer cc47b2a600 libgimpwidgets/color: move the cairo color utility functions to libgimpcolor
Add CAIRO_CFLAGS to a lot of Makefiles to make this possible, and
because they pull in cairo via the libgimp headers.
2011-04-28 15:50:39 +02:00
Michael Natterer 5e4eee4653 app: implement GObject::constructed() instead of ::constructor() 2011-01-12 22:53:58 +01:00
Sven Neumann f1d89f712d Bug 626446 - segfaults when started with -i argument
We don't need a standard tool-preset object, so just remove the
code that was copied and pasted from other GimpData objects.
Fixes the crash on startup in non-interactive mode.
2010-08-25 21:47:22 +02:00
Michael Natterer e24c2d2249 app: add a local "container" variable to make the code more readable 2010-06-26 15:49:10 +02:00
Michael Natterer e0d5bab077 app: remove the static variables for the "standard_foo" fallback members
Instead, call gimp_foo_get_standard() when a fallback object is
needed (keeping them around as static variables was a silly
micro-optimization).
2010-06-24 22:33:33 +02:00