[gimp] app: add an implementation for get_selected() of GimpContainerEntry.



commit 0a43a7063c7db235e2ee32fbfcfca885d1e093c0
Author: Jehan <jehan girinstud io>
Date:   Wed Nov 3 17:06:35 2021 +0100

    app: add an implementation for get_selected() of GimpContainerEntry.
    
    This fixes the container entry never showing (e.g. brush/dynamics) names
    because after commit ca3c4803146, the class could not properly detect if
    the selection changed (as default implementation for this virtual
    function does not suit this subclass).

 app/widgets/gimpcontainerentry.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/app/widgets/gimpcontainerentry.c b/app/widgets/gimpcontainerentry.c
index dc9df67b67..8a05a89779 100644
--- a/app/widgets/gimpcontainerentry.c
+++ b/app/widgets/gimpcontainerentry.c
@@ -65,6 +65,9 @@ static gboolean  gimp_container_entry_select_items(GimpContainerView      *view,
                                                    GList                  *paths);
 static void     gimp_container_entry_clear_items  (GimpContainerView      *view);
 static void    gimp_container_entry_set_view_size (GimpContainerView      *view);
+static gint     gimp_container_entry_get_selected (GimpContainerView      *view,
+                                                   GList                 **items,
+                                                   GList                 **items_data);
 
 static void     gimp_container_entry_changed      (GtkEntry               *entry,
                                                    GimpContainerView      *view);
@@ -112,6 +115,7 @@ gimp_container_entry_view_iface_init (GimpContainerViewInterface *iface)
   iface->select_items  = gimp_container_entry_select_items;
   iface->clear_items   = gimp_container_entry_clear_items;
   iface->set_view_size = gimp_container_entry_set_view_size;
+  iface->get_selected  = gimp_container_entry_get_selected;
 
   iface->insert_data_free = (GDestroyNotify) gtk_tree_iter_free;
 }
@@ -381,6 +385,24 @@ gimp_container_entry_set_view_size (GimpContainerView *view)
   gimp_container_tree_store_set_view_size (GIMP_CONTAINER_TREE_STORE (model));
 }
 
+static gint
+gimp_container_entry_get_selected (GimpContainerView  *view,
+                                   GList             **items,
+                                   GList             **items_data)
+{
+  GimpContainerEntry *container_entry = GIMP_CONTAINER_ENTRY (view);
+
+  if (items)
+    {
+      if (container_entry->viewable != NULL)
+        *items = g_list_prepend (NULL, container_entry->viewable);
+      else
+        *items = NULL;
+    }
+
+  return container_entry->viewable == NULL ? 0 : 1;
+}
+
 static void
 gimp_container_entry_changed (GtkEntry          *entry,
                               GimpContainerView *view)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]