Commit Graph

132 Commits

Author SHA1 Message Date
901f056878 app: improve GimpPickableButton and split GimpPickablePopup.
Improvements of GimpPickableButton:

- Update the selected pickable live as you choose it in the popup. This allows
  for instance to get live preview of GEGL operations while staying within the
  pickable popup.
- Store the initially selected pickable (before popping up) so that when one
  cancels (either with Esc key or by clicking outside the popup, but not on the
  parent button), the button comes back to the previous pickable.
- Properly destroy the popup when the parent widget is finalized to avoid
  annoying cases where the popup might still be alive.

Additionally I split the GimpPickablePopup with a GimpPickableChooser containing
most of the GUI, which will make it usable as plug-in pickable chooser as well!
2023-10-01 21:02:33 +02:00
8a53b7c219 widgets: Fix compiler warning in gimpcontainerview
Initialize "border" to 0 to remove a warning that
"'border' may be used uninitialized"
2023-06-26 14:12:42 +00:00
bc83b283fd app: avoiding infinite loops of signals calling each other.
This is a better fix for the previously reverted commit, avoiding
"floating-selection-changed" and "select-items" to recursively calling
each other.

The other fix on context update is similar and was also triggering
crashes because of recursive signal calling after the previous revert.
2022-02-02 21:13:33 +01:00
748dc77bb5 Revert "app: check selected items changed before running "select-items"."
This reverts commit ca3c480314.

The fix was wrong and was creating other issues such as #7655. We must
always emit this signal.
2022-02-02 21:13:33 +01:00
ca28934dfc app: fix "%d items selected" label when multi-selecting.
This got broken in commit 28f6b1b268 because you want to always throw
the signal. Yet the context must only be updated with a grid view in the
GimpContainerEditor. Now it should work correctly (hopefully!).
2021-12-23 13:44:59 +01:00
28f6b1b268 app: fix gimp_container_view_multi_selected().
The whole hack for types managed by context is not needed anymore. It
works fine with generic code. Also because of this hack, there was a bug
when clicking on some button raising a container popup (such as the
"Dynamics" button in tool options) would reset the context to default
value (e.g. reset to "Basic Dynamics") on the first click, without
raising the popup. Only the second click would raise a popup.
2021-12-23 13:43:51 +01:00
9a1a7a766c app: implement GimpContainerViewInterface's get_selected() for…
… GimpContainerComboBox and add a warning when the implementation is
missing.

Basically the default get_selected() implementation only works for
context properties, not for more generic usage of GimpContainerView. The
new warning will be a lot more informative and will help any future
cases where we might experience this bug.
2021-12-23 13:43:51 +01:00
ac1721917c app: reording private functions' declarations and definitions.
Keep them all together and in the same order, instead of mixing public
and private functions.
2021-12-23 13:39:43 +01:00
ca3c480314 app: check selected items changed before running "select-items".
This prevents repeatitively running the same signals when it is useless.

In particular, I encountered a case of infinite loops between
"floating-selection-changed" and "select-items" ending up infinitely
calling each other (then crashing GIMP).
2021-12-23 13:39:43 +01:00
8faf6a832c app: get rid of GimpContainerViewInterface select_item signal.
Now that we have implementations for select_items everywhere and that
all the code is only wired to call or handle select_items, the single
item variant select_item is of no use anymore. Let's make a big cleanup.
2021-12-23 12:55:11 +01:00
2a404cb41d app: more "select-item" signal handlers changed to "select-items" ones. 2021-12-23 12:55:11 +01:00
1a3dbe2099 app: implement a select_items() method for GimpContainerComboBox…
… and use gimp_container_view_select_items() when the context changes.

Even though some types of containers still expect only a single
selected content, we should slowly move to multiple item code. The
reason is to avoid 2 code paths which makes the code more complicated
and bug-prone. When all child classes of GimpContainerView will have a
valid select_items() implementation, we can work on getting rid of the
select_item() in favor of the multi-item one.
2021-12-23 12:55:11 +01:00
eed28c0941 app: Popup menu at rect in GimpEditor
Rather than trying to fix up our own heuristics using a
`GtkMenuPositionFunc`, use whatever GTK provides to position given a
specific rectangle, which also has the benefit of nicely integrating
with GDK backends such as Wayland. Another advantage is that we can use
GdkGravity to center the popup.

Since GTK 3, GtkWidget also gained a "popup-menu" signal, which we
can/should use instead of rolling our own context signals.
2021-12-13 20:57:21 +01:00
68dcb4b421 app: fix sending signals to finalized object.
Fixing:

> GLib-GObject-WARNING **: 01:43:13.747: instance with invalid (NULL) class pointer
> GLib-GObject-CRITICAL **: 14:15:37.327: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

When changing brushes through tool options. Thanks to ankh for noticing
this.
2021-04-21 14:19:05 +02:00
86af7c3fa2 app: make "layers-new-last-values" multi-selection aware.
It allows to create several layers at once, by adding them all with
default generated names above each respectively selected layer.
2020-05-17 18:32:16 +02:00
309ccf71b4 app: allow multi-item drop on GimpContainerView buttons.
This was already implemented for the new button which had its own drag'n
drop handler, and now also for other buttons (in particular the delete
button which is multi-item aware).
2020-05-17 18:32:15 +02:00
c2023f3aa1 app: s/insert_item_after()/insert_items_after() in GimpContainerView.
In the middle of multi-item insertion, you don't want to run
gimp_container_view_select_items() as was being done in
gimp_item_tree_view_insert_item_after(). As it turns out, this is the
only implementation for this virtual function, and it doesn't need to be
run on the specific inserted viewable, just make it a call to run when
all insertions are done.
2020-05-17 18:32:15 +02:00
f7b86c9062 app: fix selection after a drag'n drop move.
Though it's not finished yet, I am changing "active layer" into
"selected layers" logics. Probably the "active layer" concept will be
back eventually (i.e. even in a multi-selection a specific layer could
be said "active", highlighted in the list a bit differently, hence one
could edit this specific layer only). But for simplicity, for now, it's
better to first get rid of it, otherwise it's just messy.
2020-05-17 18:32:15 +02:00
3bc1d09c30 app: do not lose multi item selection when dragging or right-clicking.
Basically the single click selection must happen on mouse button
release, not initial press, otherwise it would cancel your multiple
selection when you were actually about to drag the items.

As for contextual menu, it should trigger a selection only when the
clicked item is not in the current multiple selection.
2020-05-17 18:32:15 +02:00
288bec3b79 app: add a "select-items" signal to GimpContainerView.
Properly pass the multi-selection information through the container
classes. Previous implementation was incomplete (most code paths with
multiple item selected were just ignored) and data was passed through
the "select-item" signal with the GimpViewable to NULL and the data to a
list of items (instead of being a GtkTreeIter otherwise). Having a
pointer data which changes meaning in the same function/class is not the
best idea. So instead "select-items" will have 2 list as parameters: a
list of items and a list of GtkTreePath to be used similarly and with
less ambiguity.
2020-05-17 18:32:15 +02:00
1743f474e5 app/widgets: Use G_DECLARE_INTERFACE()
This cuts aways a little of the GObject boilerplate.
2019-08-09 19:48:21 +00:00
63695b4b21 libgimbase: merge gimpparam.h into gimpparamspecs.h
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
2019-07-31 10:16:21 +02:00
5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
1b7d63cce9 Use g_set_object() in a lot of places, and splrinkle some g_clear_object() 2018-06-01 12:59:52 +02:00
Ell
cdd96059f7 app: port all interfaces to G_DEFINE_INTERFACE()
... instead of calling g_type_register_static() ourselves.
2018-05-27 05:56:34 -04:00
Ell
88c63420e8 app: ignore gimp_container_view_{select,activate,context}_item() ...
... while the container is frozen

In GimpContainerView, do nothing in response to a
gimp_container_view_{select,activate,context}_item() call while the
view's container is frozen.  While the container is frozen the view
is empty, and these functions can segfault.
2018-05-07 02:56:10 -04:00
b671a43a31 Bug 793815 - segmentation fault on a handler using finalized user data.
The bug is very hard to reproduce, probably because it requires specific
timing conditions but this looks like this commit would prevent it.
Apparently the signal handler gimp_container_view_name_changed() may
have been run while the container view (set as user data) was most
likely already finalized, hence leaving an invalid dangling pointer.
Let's just make sure we disconnect this handler (and another) when we
finalize the container view and its private data.
2018-02-26 19:12:50 +01:00
Ell
d027a059ef app: respond to viewable expanded state changes in container views
Add an "expanded-changed" signal to GimpViewable, which should be
emitted by subclasses when the viewable's expanded state changes.
Emit this signal when the expanded state of group layers changes.
Respond to this signal in GimpContainerView, by calling a new
expand_item() virtual function.  Implement expand_item() in
GimpContainerTreeView, expanding or collapsing the item as
necessary.
2017-10-22 12:30:21 -04:00
c9fc83a932 app: make gimp_container_view_remove_container() more robust
Don't special case on view_iface->model_is_tree and always run
gimp_container_view_remove_foreach(), also on the view's toplevel
container.  Run gimp_container_view_clear_items() anyway on the
toplevel as an optimization, but with a big comment. This makes all
views (on list *and* tree models) behave the same way, and makes
view_iface->model_is_tree practically obsolete, will remove it later.
2014-06-06 22:48:35 +02:00
338e0ddf8d Bug 707255 - Open preferences when quitting causes assertion failure
When removing the container of a GimpContainerView,
gimp_container_view_remove_container() must be the last call. It was
causing a `GIMP_IS_CONTAINER (container)' failure in subsequent
gimp_container_get_children_type().
For good practice, unsetting a container works now the exact reversed
order as the setting of a container.
2013-09-05 23:41:23 +12:00
04a3c65aa1 Bug 707255 - Open preferences when quitting causes assertion failure.
Wrong order of destruction functions were causing critical warnings on
g_signal_handlers_disconnect_by_func() calls.
Also g_object_ref/unref() the container because the tree handler might
hold the last ref to the container, once it's disconnected the container
could be gone.
2013-09-05 23:23:24 +12:00
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
788ba611af app: base multiple selection API on the GtkSelectionMode enum
change get,set_multiple_selection(gboolean) to
get,set_selection_mode(GtkSelectionMode) so the APIs are consistent
with GTK+.
2010-05-19 20:07:31 +02:00
7ea16558b6 app: some cosmetic cleanup in the multiple selection code 2010-04-04 15:00:26 +02:00
b46a89a302 app: Add methods to enable multiple selection in GimpContainerView
Enable multiple selection in GimpDataFactoryView now. It remains
disabled everywhere else.
2010-03-11 18:24:56 +02:00
9e2723d390 app: Revert add flags for multiple selection support
Don't add additional constructor argument.
2010-03-11 18:24:56 +02:00
13b172b675 app: Add flags for multiple selection support
Multiple item selection is disabled by default and
currently enabled only for data views.
2010-03-07 18:59:28 +02:00
ebe9e51b62 app: Add support for multiple items selection
Implemented infrastructure for multiple selection support.
GimpContainerTreeView actually provides such functionality.
All other GimpContainerViews should work as before.
2010-03-07 18:59:27 +02:00
842f1df2f2 Bug 611514 - Layers inside layer groups can't be dragged to layer dock buttons
In the drop callbacks, don't check if the GimpContainerView's container
contains the dropped item, it might be in a sub-container. Instead,
simply checking if the GimpContainerView knows the item is sufficient
(and also much simpler than a recursive container serach).
2010-03-02 17:54:29 +01:00
ebe72148dd Add new vfunc GimpContainerView::insert_item_after()
The new function is called after the item is inserted. This is a much
smaller change than turning all vfuncs into signals just to be able
connect_after to one of them.
2009-09-16 19:53:13 +02:00
00682ee7cf Replace the hash table of container handlers by a single GimpTreeHandler 2009-08-04 20:19:13 +02:00
ac052aabf4 Add items at the right place again (did not affect item treeviews) 2009-08-04 00:13:58 +02:00
ad806713ae Add a per-class flags that indicates that a container view's model is a tree
* app/widgets/gimpcontainerview.h: add "gboolean model_is_tree"
  to GimpContainerViewInterface.

* app/widgets/gimpcontainerview.c: default to FALSE and enable the
  commented-out optimization in remove_container() for list-only
  container views.
2009-08-03 23:42:55 +02:00
ee022e907e Add basic support for trees of containers in GimpContainerView classes
* app/widgets/gimpcontainerview.[ch]: add and remove container trees
  recursively. Change virtual function ::add_item() to pass the
  insert_data of the parent viewable.

* app/widgets/gimpcontainercombobox.c
* app/widgets/gimpcontainerentry.c
* app/widgets/gimpcontainergridview.c: changed accordingly.

* app/widgets/gimpcontainertreeview.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimplayertreeview.c: dito, but actually use the passed
  parent_insert_data to insert the item at the right place in the
  GtkTreeView.
2009-08-01 19:13:35 +02:00
96126034c9 Get rid of antique code duplication
Factor out large portions of identical code into new utility functions
gimp_container_view_connect_context() and
gimp_container_view_disconnect_context().
2009-07-28 21:02:32 +02:00
3ae83c5ced Fix setting a context for the unlikely case that the container is frozen 2009-07-28 19:17:42 +02:00
eff6d4f930 Cosmetic changes 2009-07-28 19:15:36 +02:00
b54a0fdf88 Replace the name_changed_handler_id GQuark by a hash of quarks
Keep around the handler IDs for the "name-changed" signals of the
container's children in a hash table that maps containers to handler
IDs and move adding/removing of the handler to
add_container()/remove_container(). This way the name-changed code is
prepared for handling multiple containers.
2009-07-28 19:08:07 +02:00
13ec6cca81 Add utility functions for adding/removing a container to/from the view
In preparation of having a tree of containers, added

gimp_container_view_add_container(),
gimp_container_view_remove_container() and
gimp_container_view_remove_foreach()

which do all the job of inserting/removing items and
connecting/disconnecting the "add", "remove" and "reorder" signals.

Also refactored things so when the toplevel container freezes/thaws,
it simply gets removed from the view instead of ignoring its signals.

gimp_container_view_real_set_container()
gimp_container_view_freeze()
gimp_container_view_thaw(): use the new add_container() and
remove_container() APIs and fix the code for the unlikely case
that a frozen container gets added/removed.
2009-07-28 16:47:28 +02:00
1b759561ce Keep the item hash table around permanently
GHashTable has g_hash_table_remove_all() since GLib 2.12, so there is
no need any longer to clear the hash table by destroyung it. Instead,
keep the hash around during the view's entire lifetime and remove all
re-creation code and all checks for its existence.
2009-07-28 15:04:43 +02:00