[gimp/wip/animation: 175/197] plug-ins: update filter behavior on layer groups in animation play.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 175/197] plug-ins: update filter behavior on layer groups in animation play.
- Date: Sat, 7 Oct 2017 03:13:09 +0000 (UTC)
commit e5bda45efa2e72635af1e1d5422e1f3a1d56b715
Author: Jehan <jehan girinstud io>
Date: Wed Jun 28 02:29:35 2017 +0200
plug-ins: update filter behavior on layer groups in animation play.
Keep the groups and all its contents if its name passes the filter; keep
a group if it has any children which passes its filter (keep only these
children).
.../animation-play/widgets/animation-layer-view.c | 77 +++++++++++++++++---
1 files changed, 68 insertions(+), 9 deletions(-)
---
diff --git a/plug-ins/animation-play/widgets/animation-layer-view.c
b/plug-ins/animation-play/widgets/animation-layer-view.c
index 1cfe74e..000f8e0 100644
--- a/plug-ins/animation-play/widgets/animation-layer-view.c
+++ b/plug-ins/animation-play/widgets/animation-layer-view.c
@@ -75,8 +75,11 @@ static gboolean animation_layer_view_button_press (GtkWidget *widget,
GdkEventButton *event);
/* Utils */
+static gboolean animation_layer_view_keep_group (AnimationLayerView *view,
+ gint parent_layer);
static void animation_layer_view_fill (AnimationLayerView *view,
GtkTreeStore *store,
+ gboolean ignore_filter,
gint parent_layer,
GtkTreeIter *parent);
static GtkTreePath * animation_layer_view_get_row (AnimationLayerView *view,
@@ -220,7 +223,7 @@ animation_layer_view_refresh (AnimationLayerView *view)
/* Actual refresh. */
gtk_tree_store_clear (GTK_TREE_STORE (model));
- animation_layer_view_fill (view, GTK_TREE_STORE (model), 0, NULL);
+ animation_layer_view_fill (view, GTK_TREE_STORE (model), FALSE, 0, NULL);
/* Restore the selected rows. */
for (iter = tattoos; iter; iter = iter->next)
@@ -418,9 +421,43 @@ animation_layer_view_button_press (GtkWidget *widget,
return TRUE;
}
+static gboolean
+animation_layer_view_keep_group (AnimationLayerView *view,
+ gint parent_layer)
+{
+ gint *layers;
+ gint num_layers;
+ gboolean keep = FALSE;
+ gint i;
+
+ g_return_val_if_fail (gimp_item_is_group (parent_layer), FALSE);
+
+ layers = gimp_item_get_children (parent_layer, &num_layers);
+ for (i = 0; i < num_layers; i++)
+ {
+ const gchar *name = gimp_item_get_name (layers[i]);
+
+ if (view->priv->filter_active && view->priv->filter &&
+ g_str_has_prefix (name, view->priv->filter))
+ {
+ keep = TRUE;
+ break;
+ }
+ if (gimp_item_is_group (layers[i]) &&
+ animation_layer_view_keep_group (view, layers[i]))
+ {
+ keep = TRUE;
+ break;
+ }
+ }
+ g_free (layers);
+ return keep;
+}
+
/* animation_layer_view_fill:
* @view: the #AnimationLayerView.
* @store: the #GtkTreeStore to fill.
+ * @ignore_filter: insert all layers under @parent_layer.
* @parent_layer: the parent #GimpLayer id. Set 0 for first call.
* @parent: %NULL to search from the first call (used for recursivity).
*
@@ -430,6 +467,7 @@ animation_layer_view_button_press (GtkWidget *widget,
static void
animation_layer_view_fill (AnimationLayerView *view,
GtkTreeStore *store,
+ gboolean ignore_filter,
gint parent_layer,
GtkTreeIter *parent)
{
@@ -451,18 +489,39 @@ animation_layer_view_fill (AnimationLayerView *view,
for (i = 0; i < num_layers; i++)
{
const gchar *name = gimp_item_get_name (layers[i]);
+ gboolean keep_group;
- if (view->priv->filter_active && view->priv->filter &&
+ if (! ignore_filter &&
+ view->priv->filter_active &&
+ view->priv->filter &&
+ ! gimp_item_is_group (layers[i]) &&
! g_str_has_prefix (name, view->priv->filter))
continue;
- gtk_tree_store_insert (store, &iter, parent, i);
- gtk_tree_store_set (store, &iter,
- COLUMN_LAYER_TATTOO, gimp_item_get_tattoo (layers[i]),
- COLUMN_LAYER_NAME, name,
- -1);
- if (gimp_item_is_group (layers[i]))
+
+ keep_group = gimp_item_is_group (layers[i]) &&
+ (ignore_filter ||
+ ! view->priv->filter_active ||
+ ! view->priv->filter ||
+ g_str_has_prefix (name, view->priv->filter) ||
+ animation_layer_view_keep_group (view, layers[i]));
+ if (! gimp_item_is_group (layers[i]) || keep_group)
+ {
+ gtk_tree_store_insert (store, &iter, parent, i);
+ gtk_tree_store_set (store, &iter,
+ COLUMN_LAYER_TATTOO, gimp_item_get_tattoo (layers[i]),
+ COLUMN_LAYER_NAME, name,
+ -1);
+ }
+ if (gimp_item_is_group (layers[i]) && keep_group)
{
- animation_layer_view_fill (view, store, layers[i], &iter);
+ /* We ignore the filter for children if this group name passes
+ * the filter. */
+ animation_layer_view_fill (view, store,
+ ignore_filter ||
+ (view->priv->filter_active &&
+ view->priv->filter &&
+ g_str_has_prefix (name, view->priv->filter)),
+ layers[i], &iter);
}
}
g_free (layers);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]