[gimp/wip/Jehan/layers-dockable-refresh: 74/74] app: fix selecting an object in an icon view.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/Jehan/layers-dockable-refresh: 74/74] app: fix selecting an object in an icon view.
- Date: Sun, 7 Nov 2021 17:00:44 +0000 (UTC)
commit 72e834a5bb21257eb915c90b36f205745f93c11c
Author: Jehan <jehan girinstud io>
Date: Sun Nov 7 17:55:30 2021 +0100
app: fix selecting an object in an icon view.
We must make sure to care about slight discrepancies between context
object and actually selected icon representing an object, which might be
slightly different at selection change time (just before everything
syncs up).
app/widgets/gimpcontainereditor.c | 12 +++++++
app/widgets/gimpcontainericonview.c | 62 +++++++++++++++++++++++++++++++++++--
2 files changed, 72 insertions(+), 2 deletions(-)
---
diff --git a/app/widgets/gimpcontainereditor.c b/app/widgets/gimpcontainereditor.c
index 91f2836aa1..60c7c34e13 100644
--- a/app/widgets/gimpcontainereditor.c
+++ b/app/widgets/gimpcontainereditor.c
@@ -455,6 +455,18 @@ gimp_container_editor_select_items (GimpContainerView *view,
if (klass->select_item)
klass->select_item (editor, viewable);
+ if (editor->priv->container)
+ {
+ const gchar *signal_name;
+ GType children_type;
+
+ children_type = gimp_container_get_children_type (editor->priv->container);
+ signal_name = gimp_context_type_to_signal_name (children_type);
+
+ if (signal_name)
+ gimp_context_set_by_type (editor->priv->context, children_type, viewable);
+ }
+
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)))
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)),
gimp_editor_get_popup_data (GIMP_EDITOR (editor->view)));
diff --git a/app/widgets/gimpcontainericonview.c b/app/widgets/gimpcontainericonview.c
index 00d4f4ff33..9dabf90c2d 100644
--- a/app/widgets/gimpcontainericonview.c
+++ b/app/widgets/gimpcontainericonview.c
@@ -622,11 +622,32 @@ gimp_container_icon_view_selection_changed (GtkIconView *gtk_icon_view
GimpContainerIconView *icon_view)
{
GimpContainerView *view = GIMP_CONTAINER_VIEW (icon_view);
- GList *items;
+ GList *items = NULL;
GList *paths;
+ GList *list;
+
+ paths = gtk_icon_view_get_selected_items (icon_view->view);
+
+ for (list = paths; list; list = list->next)
+ {
+ GtkTreeIter iter;
+ GimpViewRenderer *renderer;
+
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (icon_view->model), &iter,
+ (GtkTreePath *) list->data);
+
+ gtk_tree_model_get (icon_view->model, &iter,
+ GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
+ -1);
+
+ if (renderer->viewable)
+ items = g_list_prepend (items, renderer->viewable);
+
+ g_object_unref (renderer);
+ }
- gimp_container_icon_view_get_selected (view, &items, &paths);
gimp_container_view_multi_selected (view, items, paths);
+
g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
g_list_free (items);
}
@@ -800,6 +821,43 @@ gimp_container_icon_view_get_selected (GimpContainerView *view,
GimpContainerIconView *icon_view = GIMP_CONTAINER_ICON_VIEW (view);
GList *selected_paths;
gint selected_count;
+ GimpContainer *container;
+
+ container = gimp_container_view_get_container (view);
+
+ if (container)
+ {
+ const gchar *signal_name;
+ GimpContext *context;
+ GType children_type;
+
+ context = gimp_container_view_get_context (view);
+ children_type = gimp_container_get_children_type (container);
+ signal_name = gimp_context_type_to_signal_name (children_type);
+
+ /* As a special case, for containers tied to a context object, we
+ * look up this object as being selected.
+ * */
+ if (signal_name && context)
+ {
+ GimpObject *object;
+
+ object = gimp_context_get_by_type (context, children_type);
+
+ selected_count = object ? 1 : 0;
+ if (items)
+ {
+ if (object)
+ *items = g_list_prepend (NULL, object);
+ else
+ *items = NULL;
+ }
+ if (paths)
+ *paths = NULL;
+
+ return selected_count;
+ }
+ }
selected_paths = gtk_icon_view_get_selected_items (icon_view->view);
selected_count = g_list_length (selected_paths);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]