Commit Graph

32 Commits

Author SHA1 Message Date
Jehan e1a489a43a libgimp: sink the floating references after adding them to hash table.
Though the previous implementation worked fine on C plug-ins, I realized
it was problematic on bindings. In particular, the Python binding at
least was somehow freeing returned floating objects, unless assigned to
a variable.
For instance, the widget returned by the following code:

> dialog.get_color_widget('color', True, GimpUi.ColorAreaType.FLAT)

… was freed by the PyGObject binding when it was floating, even though
(transfer none) was set (hence telling the binding it should not free
the returned object). The workaround was to assign it to some variable,
even though I was not planning to use it.
Making sure all references are full fixes it.

GObject docs also notes:

> **Note**: Floating references are a C convenience API and should not
> be used in modern GObject code. Language bindings in particular find
> the concept highly problematic, as floating references are not
> identifiable through annotations, and neither are deviations from the
> floating reference behavior, like types that inherit from
> GInitiallyUnowned and still return a full reference from
> g_object_new().
2021-04-20 17:08:31 +02:00
Jehan ca72c41fcd libgimp, libgimpwidgets: support of GimpRGB properties in…
… GimpProcedureDialog.

Technically I added:
- New gimp_prop_color_select_new() property widget to create a
  GimpColorButton for a given GimpRGB property.
- gimp_procedure_dialog_get_widget() now supports a GimpRGB property and
  will create a GimpColorArea by default.
- When the default doesn't suit you, a new function
  gimp_procedure_dialog_get_color_widget() allows to create either a
  GimpColorArea or a GimpColorButton (editable = TRUE), as well as
  choose the area type (small or large checks, as well as flat area,
  i.e. no alpha support).
2021-04-20 16:54:40 +02:00
Jehan 3f09030b03 libgimp: new gimp_procedure_dialog_set_sensitive().
New function to set some procedure dialog's widget sensitive, either
with a constant value, or by binding it to a boolean property (or its
inverse) of a config object.
2021-04-06 21:47:10 +02:00
Jehan 891097ba2f libgimp: gimp_procedure_dialog_fill() allows no properties listed.
As the docs says, this was always allowed and would just imply we want a
dialog with all properties in order of declaration.

Yet this usage would output this warning:

> plug-ins/file-fli/fli-gimp.c:976:3: warning: not enough variable arguments to fit a sentinel [-Wformat=]

This commit take care of this warning.
2021-04-05 18:52:52 +02:00
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan 052fbedc83 libgimp: allow NULL title for gimp_procedure_dialog_new()…
… but only when a menu label was set with
gimp_procedure_set_menu_label(). In such case, this menu label is used
as dialog title (with mnemonic underscore removed).
2021-02-02 17:14:43 +01:00
Jehan 5e9c33b2c9 libgimp: add missing documentation for gimp_procedure_dialog_new().
This is important for introspection in particular with annotations.
2021-02-02 15:53:34 +01:00
Jehan c9b0cafc1d libgimp: rename "Save|Load Defaults" buttons in GimpProcedureDialog.
The term "Defaults" is not clear enough and looks like it may be
redundant with the "Factory Defaults" button. Let's try an alternative
"Save Settings" and "Load Saved Settings".

Also adding some tooltips.

And finally making the "Load Saved Settings" only sensitive if the "Save
Settings" button had been used at least once.
2021-01-07 21:59:59 +01:00
Jehan 478193fbcd libgimp: add down arrow to "Reset" button to show it will pop-up a menu.
This is what the GNOME's HIG calls a "button menu" apparently. Adding
this arrow makes it clearer that it is not a finale action but an
intermediate one allowing you to see more choices.
See also report #6145 where this was raised among other things.
2021-01-06 18:16:34 +01:00
Niels De Graef 9fd2433f21 libgimp: Add gtkdoc comments in gimpproceduredialog
Although they're only used for a private function, gtk-doc still
complains about the empty param docs, so let's just add something.
2021-01-02 13:00:37 +01:00
Jehan 929311f208 libgimp: improve gimp_procedure_dialog_check_mnemonic().
Use gtk_widget_list_mnemonic_labels() to look for mnemonic of common GTK
widgets. Also warn when several mnemonic were set on a given widget
("wasting" keys when it seems we are always looking for available
mnemonics).
Also warn with core action IDs too when they miss a mnemonic.
2020-12-30 13:31:16 +01:00
Jehan 733986513a Issue #5967: Inconvenient focus in PNG export.
Make sure that the OK button ("Export", etc.) is always the default
action in a GimpProcedureDialog. This allows to quickly validate the
default settings.
2020-11-26 01:57:53 +01:00
Jehan b7d55fa066 libgimp, libgimpwidgets: fix gimp_prop_scale_entry_new() for integer…
… properties.
Also a forgotten fix in a call of this function in GimpProcedureDialog.
2020-11-26 00:28:14 +01:00
Jehan 87062e22ec libgimp: new gimp_procedure_dialog_get_scale_entry() function.
Though a GimpScaleEntry could already be created with
gimp_procedure_dialog_get_widget(), this specific function allows to add
a factor to the property range.
2020-11-25 12:25:59 +01:00
Jehan 8d5008d76f libgimp, libgimpbase, libgimpwidgets: new gimp_range_estimate_settings()
Similar code was used in 2 places basically (GimpLabelSpin and
GimpProcedureDialog) so just make it an utils function. It's good anyway
to have a generic function to estimate suitable increments and decimal
places depending on a range.

As a consequence also gimp_label_spin_new() now takes a gint digits
(instead of guint), with -1 meaning we want digits computed from the
range.
Similarly gimp_prop_scale_entry_new() docs adds the -1 meaning too.
2020-11-25 01:34:36 +01:00
Jehan 3fb2ff1b9d libgimp: improvements to GimpProcedureDialog API.
- New gimp_procedure_dialog_fill_box(_list)() functions to create a
  GtkBox in the layout.
- Generating widgets for parameters of type double (and computing
  appropriate "ok defaults" digits for these, depending on the min-max
  range of the property).
2020-11-24 20:55:03 +01:00
Jehan 3918a0a04c libgimp: new metadata support concept in GimpSaveProcedure and new…
… class GimpSaveProcedureDialog.
The idea is that we have basically the same code in most file format
plug-ins to handle various generic metadata, yet usually with slight
differences here and there. Even behavior is sometimes a bit different
even though there is no reason for the logics to be different from one
format to another.

So I move the metadata support logics into GimpSaveProcedure (and
GimpProcedureConfig still keeps the main export logics). The GUI logics
is now in a new GimpSaveProcedureDialog. So export plug-ins will now get
the creation of generic metadata nearly for free. All they have to do is
to tell what kind of metadata the GimpSaveProcedure supports with the
gimp_save_procedure_set_support_*() functions.

Then consistency will apply:
- If a format supports a given metadata, they will always have an
  auxiliary argument with the same name across plug-ins.
- The label and tooltips will also be always the same in the GUI.
- Order of metadata widgets will also stay consistent.
- The widgets will work the same (no more "Comment" text view missing in
  one plug-in but present in another, or with an entry here, and a text
  view there, and so on).

Also adding gimp_save_procedure_dialog_add_metadata() to allow plug-ins
to "declare" one of their options as a metadata option, and therefore
have it packed within the "Metadata" block which is now created (for
instance for PNG/TIFF/JPEG specific metadata). This allows a nicer
organization of dialogs.
2020-11-23 02:15:13 +01:00
Jehan c58b7ad80b libgimp: mnemonic duplicate verification in GimpProcedureDialog.
A very common issue we have with dialog creation is good mnemonics. In
particular, we want to:
* Keep consistent mnemonics for common features (basically the core
  buttons) common to all plug-in dialogs.
* Have mnemonics for all options.
* Avoid duplicate mnemonics if possible.

Mnemonics are a usability/accessibility feature which can be important
for people using the keyboard a lot (not necessarily only because they
prefer keyboard, but also possibly because of various disorders).

This code will check at runtime that there are no missing or duplicate
mnemonics and simply print to stderr. We don't want to bother overly the
users about these, but we want developers and translators to be aware
about these so that they can easily spot and fix them.
2020-11-20 09:37:26 +01:00
Jehan cd0ac72314 libgimp: generated text buffer should also have a tooltip taken from…
… the property blurb.
2020-11-20 01:47:18 +01:00
Jehan 5fa38d5765 libgimp: bug fixes and design improvements for generated widgets. 2020-11-20 00:06:27 +01:00
Jehan e6e2e11ff6 libgimp: some more functions to GimpProcedureDialog.
gimp_procedure_dialog_fill_frame() allows creating a GtkFrame, in
particular with a boolean widget which can therefore control
sensitivity of the frame contents.
gimp_procedure_dialog_get_label() creates a simple text label.
2020-11-14 00:21:46 +01:00
Jehan 7b6f2e5c2b libgimp, libgimpwidgets, plug-ins: improved GimpProcedureDialog API.
- New GimpLabelIntWidget which is a label associated to any widget with
  an integer "value" property.
- New gimp_procedure_dialog_get_int_combo() which creates a labeled
  combo box from an integer property of the GimpProcedureConfig.
- Renamed gimp_procedure_dialog_populate*() with
  gimp_procedure_dialog_fill*(). Naming is hard! I hesitated using
  _pack() as well (similarly to GtkBox API).
- New gimp_procedure_dialog_fill_flowbox*() functions to create a
  GtkFlowBox filled with property widgets (or other container widgets as
  we can pack them one in another). This is an alternative way to build
  your GUI with sane defaults, with list of property names.
2020-11-13 21:27:56 +01:00
Jehan 673f490a95 libgimp: also size prop switch widget's label as GimpLabeled's labels.
To get nice rendering with labels and edit widgets aligned, add the prop
switch label into the same size group.
2020-11-13 20:24:08 +01:00
Jehan 2322c3759a libgimp: improve design and usability of generated procedure dialog.
- Add some border width on the main dialog box.
- Remove the additional border width on the button box but add some
  padding instead to separate it a bit from the specific plug-in
  widgets.
- Add GimpLabelSpin as one of the possible property widgets to represent
  an integer property and make it the default.
- Put labels of GimpLabeled widgets into a common GtkSizeGroup so that
  labels and entry widgets are aligned, hence much faster to parse with
  the eyes.
2020-11-05 18:06:52 +01:00
Jehan c1a32e5763 libgimp: add some first API to populate a GimpProcedureDialog.
This is still a very early baseline for a more extended API. This first
version is not able to capture the complexity of most existing plug-in
dialogs.
2020-11-03 11:06:02 +01:00
Michael Natterer afe19ff393 libgimp: GimpProcedureDialog: next time save before committing... 2020-01-05 18:57:17 +01:00
Michael Natterer f2cf791a25 libgimp: document GimpProcedureDialog's properties 2020-01-05 18:37:58 +01:00
Michael Natterer e1a9b9242e libgimp: remove underscores from the procedure conifig load/save functions
They are needed by GimpProcedureDialog wich is in libgimp. Keep them
in the private header anyway for now.
2019-09-28 20:53:21 +02:00
Michael Natterer 45e96a0ff4 libgimp: improve handling of procedure default values a lot
Add internal GimpProcedureConfig API to load/save "default values"
which are to be treated as if they were the hardcoded GParamSpec
defaults, but user-configurable. Also make all other load/save
functions available to other libgimp files.

In gimp_procedure_run(), if incomplete arguments are passed, don't
just complete them with the GParamSpec defaults, but look up the
user-saved defaults and use them if they exist. This happens before
everything else and brings back the PNG export feature of using
user-saved defaults also in non-interactive mode (but for all
procedures not just PNG export).

In GimpProcedureDialog, add "Load Defaults" and "Save Defaults"
buttons, they are the only way of managing the user-configurable
procedure defaults.

When clicking "Reset", show a popover with the reset options "Initial
Values" and "Factory Defaults".
2019-09-26 19:26:23 +02:00
Michael Natterer 247f99ce22 libgimp: change GimpProcedureDialog's "OK" with the procedure type
- "_Open" for GimpLoadProcedure
- "_Export" for GimpSaveProcedure
- "_OK" otherwise
2019-09-23 20:00:19 +02:00
Michael Natterer aa41baef1e libgimp: add gimp_procedure_config_get_procedure()
and use it in gimp_procedure_dialog_new() to make sure that the passed
config was created by the passed procedure.
2019-09-20 19:33:50 +02:00
Michael Natterer bfb7f43dbc libgimp: add GimpProcedureDialog, the new dialog class for plug-ins
It knows about the procedure and its config, and so far implements the
entire construction boilerplate and "Reset" on its own.
2019-09-20 19:24:40 +02:00