gimplayermodecombobox.c 22.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
 *
 * gimplayermodecombobox.c
 * Copyright (C) 2017  Michael Natterer <mitch@gimp.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <gtk/gtk.h>
#include <gegl.h>

#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"

#include "widgets-types.h"

31
#include "operations/layer-modes/gimp-layer-modes.h"
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

#include "gimplayermodecombobox.h"


/**
 * SECTION: gimplayermodecombobox
 * @title: GimpLayerModeComboBox
 * @short_description: A #GimpEnumComboBox subclass for selecting a layer mode.
 *
 * A #GtkComboBox subclass for selecting a layer mode
 **/


enum
{
  PROP_0,
  PROP_LAYER_MODE,
  PROP_GROUP,
  PROP_WITH_BEHIND,
  PROP_WITH_REPLACE
};


struct _GimpLayerModeComboBoxPrivate
{
  GimpLayerMode      layer_mode;
  GimpLayerModeGroup group;
  gboolean           with_behind;
  gboolean           with_replace;
};


static void     gimp_layer_mode_combo_box_constructed      (GObject               *object);
static void     gimp_layer_mode_combo_box_set_property     (GObject               *object,
                                                            guint                  prop_id,
                                                            const GValue          *value,
                                                            GParamSpec            *pspec);
static void     gimp_layer_mode_combo_box_get_property     (GObject               *object,
                                                            guint                  prop_id,
                                                            GValue                *value,
                                                            GParamSpec            *pspec);

static void     gimp_layer_mode_combo_box_changed          (GtkComboBox           *gtk_combo);

static void     gimp_layer_mode_combo_box_update_model     (GimpLayerModeComboBox *combo,
                                                            gboolean               change_mode);
static void     gimp_layer_mode_combo_box_insert_value     (GtkListStore          *store,
                                                            gint                   after,
                                                            gint                   insert_value);
static void     gimp_layer_mode_combo_box_insert_separator (GtkListStore          *store,
                                                            gint                   after,
                                                            gint                   separator_value);
static gboolean gimp_layer_mode_combo_box_separator_func   (GtkTreeModel          *model,
                                                            GtkTreeIter           *iter,
                                                            gpointer               data);


G_DEFINE_TYPE (GimpLayerModeComboBox, gimp_layer_mode_combo_box,
               GIMP_TYPE_ENUM_COMBO_BOX)

#define parent_class gimp_layer_mode_combo_box_parent_class


static void
gimp_layer_mode_combo_box_class_init (GimpLayerModeComboBoxClass *klass)
{
  GObjectClass     *object_class = G_OBJECT_CLASS (klass);
  GtkComboBoxClass *combo_class  = GTK_COMBO_BOX_CLASS (klass);

  object_class->constructed  = gimp_layer_mode_combo_box_constructed;
  object_class->set_property = gimp_layer_mode_combo_box_set_property;
  object_class->get_property = gimp_layer_mode_combo_box_get_property;

  combo_class->changed       = gimp_layer_mode_combo_box_changed;

  g_object_class_install_property (object_class, PROP_LAYER_MODE,
                                   g_param_spec_enum ("layer-mode",
                                                      NULL, NULL,
                                                      GIMP_TYPE_LAYER_MODE,
                                                      GIMP_LAYER_MODE_NORMAL,
                                                      GIMP_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT));

  g_object_class_install_property (object_class, PROP_GROUP,
                                   g_param_spec_enum ("group",
                                                      NULL, NULL,
                                                      GIMP_TYPE_LAYER_MODE_GROUP,
                                                      GIMP_LAYER_MODE_GROUP_DEFAULT,
                                                      GIMP_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT));

  g_object_class_install_property (object_class, PROP_WITH_BEHIND,
                                   g_param_spec_boolean ("with-behind",
                                                         NULL, NULL,
                                                         FALSE,
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));

  g_object_class_install_property (object_class, PROP_WITH_REPLACE,
                                   g_param_spec_boolean ("with-replace",
                                                         NULL, NULL,
                                                         FALSE,
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));

  g_type_class_add_private (klass, sizeof (GimpLayerModeComboBoxPrivate));
}

static void
gimp_layer_mode_combo_box_init (GimpLayerModeComboBox *combo)
{
  combo->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo,
                                             GIMP_TYPE_LAYER_MODE_COMBO_BOX,
                                             GimpLayerModeComboBoxPrivate);

  gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
                                        gimp_layer_mode_combo_box_separator_func,
                                        GINT_TO_POINTER (-1),
                                        NULL);
}

static void
gimp_layer_mode_combo_box_constructed (GObject *object)
{
  GimpLayerModeComboBox *combo = GIMP_LAYER_MODE_COMBO_BOX (object);

  G_OBJECT_CLASS (parent_class)->constructed (object);

160 161
  gimp_layer_mode_combo_box_update_model (combo, FALSE);

162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo),
                                 combo->priv->layer_mode);
}

static void
gimp_layer_mode_combo_box_set_property (GObject      *object,
                                        guint         prop_id,
                                        const GValue *value,
                                        GParamSpec   *pspec)
{
  GimpLayerModeComboBox *combo = GIMP_LAYER_MODE_COMBO_BOX (object);

  switch (prop_id)
    {
    case PROP_LAYER_MODE:
      gimp_layer_mode_combo_box_set_mode (combo, g_value_get_enum (value));
      break;

    case PROP_GROUP:
      gimp_layer_mode_combo_box_set_group (combo, g_value_get_enum (value));
      break;

    case PROP_WITH_BEHIND:
      combo->priv->with_behind = g_value_get_boolean (value);
      break;

    case PROP_WITH_REPLACE:
      combo->priv->with_replace = g_value_get_boolean (value);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
gimp_layer_mode_combo_box_get_property (GObject    *object,
                                        guint       prop_id,
                                        GValue     *value,
                                        GParamSpec *pspec)
{
  GimpLayerModeComboBox *combo = GIMP_LAYER_MODE_COMBO_BOX (object);

  switch (prop_id)
    {
    case PROP_LAYER_MODE:
      g_value_set_enum (value, combo->priv->layer_mode);
      break;

    case PROP_GROUP:
      g_value_set_enum (value, combo->priv->group);
      break;

    case PROP_WITH_BEHIND:
      g_value_set_boolean (value, combo->priv->with_behind);
      break;

    case PROP_WITH_REPLACE:
      g_value_set_boolean (value, combo->priv->with_replace);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
gimp_layer_mode_combo_box_changed (GtkComboBox *gtk_combo)
{
  GimpLayerModeComboBox *combo = GIMP_LAYER_MODE_COMBO_BOX (gtk_combo);
  GimpLayerMode          mode;

  if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo),
                                     (gint *) &mode))
    {
      combo->priv->layer_mode = mode;

      g_object_notify (G_OBJECT (combo), "layer-mode");
    }
}


/**
 * gimp_layer_mode_combo_box_new:
 * Foo.
 *
 * Return value: a new #GimpLayerModeComboBox.
 **/
GtkWidget *
253 254
gimp_layer_mode_combo_box_new (gboolean with_behind,
                               gboolean with_replace)
255
{
256 257 258 259
  return g_object_new (GIMP_TYPE_LAYER_MODE_COMBO_BOX,
                       "with-behind",  with_behind,
                       "with-replace", with_replace,
                       NULL);
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
}

void
gimp_layer_mode_combo_box_set_mode (GimpLayerModeComboBox *combo,
                                    GimpLayerMode          mode)
{
  g_return_if_fail (GIMP_IS_LAYER_MODE_COMBO_BOX (combo));

  if (mode != combo->priv->layer_mode)
    {
      GtkTreeModel *model;
      GtkTreeIter   dummy;

      model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));

275 276
      g_object_freeze_notify (G_OBJECT (combo));

277 278 279
      if (! gimp_int_store_lookup_by_value (model, mode, &dummy))
        {
          combo->priv->group = gimp_layer_mode_get_group (mode);
280
          g_object_notify (G_OBJECT (combo), "group");
281 282 283 284 285

          gimp_layer_mode_combo_box_update_model (combo, FALSE);
        }

      gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), mode);
286 287

      g_object_thaw_notify (G_OBJECT (combo));
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
    }
}

GimpLayerMode
gimp_layer_mode_combo_box_get_mode (GimpLayerModeComboBox *combo)
{
  g_return_val_if_fail (GIMP_IS_LAYER_MODE_COMBO_BOX (combo),
                        GIMP_LAYER_MODE_NORMAL);

  return combo->priv->layer_mode;
}

void
gimp_layer_mode_combo_box_set_group (GimpLayerModeComboBox *combo,
                                     GimpLayerModeGroup     group)
{
  g_return_if_fail (GIMP_IS_LAYER_MODE_COMBO_BOX (combo));

  if (group != combo->priv->group)
    {
308 309
      g_object_freeze_notify (G_OBJECT (combo));

310
      combo->priv->group = group;
311
      g_object_notify (G_OBJECT (combo), "group");
312 313

      gimp_layer_mode_combo_box_update_model (combo, TRUE);
314 315

      g_object_thaw_notify (G_OBJECT (combo));
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
    }
}

GimpLayerModeGroup
gimp_layer_mode_combo_box_get_group (GimpLayerModeComboBox *combo)
{
  g_return_val_if_fail (GIMP_IS_LAYER_MODE_COMBO_BOX (combo),
                        GIMP_LAYER_MODE_GROUP_DEFAULT);

  return combo->priv->group;
}


/*  private functions  */

331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
static void
gimp_enum_store_add_value (GtkListStore *store,
                           GEnumValue   *value)
{
  GtkTreeIter  iter = { 0, };
  const gchar *desc;
  gchar       *stripped;

  desc = gimp_enum_value_get_desc (GIMP_ENUM_STORE (store)->enum_class, value);

  /* no mnemonics in combo boxes */
  stripped = gimp_strip_uline (desc);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter,
                      GIMP_INT_STORE_VALUE, value->value,
                      GIMP_INT_STORE_LABEL, stripped,
                      -1);

  g_free (stripped);
}

static GtkListStore *
gimp_enum_store_new_from_array (GType       enum_type,
                                gint        n_values,
                                const gint *values)
357 358
{
  GtkListStore *store;
359 360 361 362 363 364
  GEnumValue   *value;
  gint          i;

  g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
  g_return_val_if_fail (n_values > 1, NULL);
  g_return_val_if_fail (values != NULL, NULL);
365

366 367 368
  store = g_object_new (GIMP_TYPE_ENUM_STORE,
                        "enum-type", enum_type,
                        NULL);
369

370 371 372 373 374 375 376 377 378 379 380 381 382 383
  for (i = 0; i < n_values; i++)
    {
      value = g_enum_get_value (GIMP_ENUM_STORE (store)->enum_class, values[i]);
      if (value)
        gimp_enum_store_add_value (store, value);
    }

  return store;
}

static void
gimp_layer_mode_combo_box_fix_default_store (GimpLayerModeComboBox *combo,
                                             GtkListStore          *store)
{
384 385 386 387 388 389 390 391 392 393
  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DISSOLVE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_ADDITION, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_BURN, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
Ell's avatar
Ell committed
394
                                              GIMP_LAYER_MODE_HARD_MIX, -1);
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DIVIDE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_LCH_LIGHTNESS, -1);

  if (combo->priv->with_behind)
    {
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_DISSOLVE,
                                              GIMP_LAYER_MODE_BEHIND);
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_BEHIND,
                                              GIMP_LAYER_MODE_COLOR_ERASE);
    }

  if (combo->priv->with_replace)
    {
      gimp_layer_mode_combo_box_insert_value (store,
415
                                              GIMP_LAYER_MODE_NORMAL,
416 417 418 419 420 421 422 423 424 425
                                              GIMP_LAYER_MODE_REPLACE);
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_COLOR_ERASE,
                                              GIMP_LAYER_MODE_ERASE);
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_ERASE,
                                              GIMP_LAYER_MODE_ANTI_ERASE);
    }
}

426 427 428
static void
gimp_layer_mode_combo_box_fix_linear_store (GimpLayerModeComboBox *combo,
                                            GtkListStore          *store)
429 430 431 432 433 434 435 436 437 438 439
{
  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DISSOLVE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_ADDITION_LINEAR, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_BURN_LINEAR, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
Ell's avatar
Ell committed
440
                                              GIMP_LAYER_MODE_HARD_MIX_LINEAR, -1);
441 442 443 444 445 446 447 448 449 450 451 452 453 454

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DIVIDE_LINEAR, -1);

  if (combo->priv->with_behind)
    {
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_DISSOLVE,
                                              GIMP_LAYER_MODE_BEHIND_LINEAR);
    }

  if (combo->priv->with_replace)
    {
      gimp_layer_mode_combo_box_insert_value (store,
455
                                              GIMP_LAYER_MODE_NORMAL_LINEAR,
456 457 458 459 460 461 462 463 464 465
                                              GIMP_LAYER_MODE_REPLACE);
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_REPLACE,
                                              GIMP_LAYER_MODE_ERASE);
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_ERASE,
                                              GIMP_LAYER_MODE_ANTI_ERASE);
    }
}

466 467 468
static void
gimp_layer_mode_combo_box_fix_perceptual_store (GimpLayerModeComboBox *combo,
                                                GtkListStore          *store)
469 470 471 472 473 474 475 476 477 478 479
{
  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DISSOLVE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_ADDITION, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_BURN, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
Ell's avatar
Ell committed
480
                                              GIMP_LAYER_MODE_HARD_MIX, -1);
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DIVIDE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_HSV_VALUE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_LCH_LIGHTNESS, -1);

  if (combo->priv->with_behind)
    {
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_DISSOLVE,
                                              GIMP_LAYER_MODE_BEHIND);
      gimp_layer_mode_combo_box_insert_value (store,
                                              GIMP_LAYER_MODE_BEHIND,
                                              GIMP_LAYER_MODE_COLOR_ERASE);
    }
}

502 503 504
static void
gimp_layer_mode_combo_box_fix_legacy_store (GimpLayerModeComboBox *combo,
                                            GtkListStore          *store)
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
{
  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DISSOLVE, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_ADDITION_LEGACY, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_BURN_LEGACY, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_HARDLIGHT_LEGACY, -1);

  gimp_layer_mode_combo_box_insert_separator (store,
                                              GIMP_LAYER_MODE_DIVIDE_LEGACY, -1);
}

static void
gimp_layer_mode_combo_box_update_model (GimpLayerModeComboBox *combo,
                                        gboolean               change_mode)
{
526 527 528 529 530 531 532
  GtkListStore        *store;
  const GimpLayerMode *modes;
  gint                 n_modes;

  modes = gimp_layer_mode_get_group_array (combo->priv->group, &n_modes);
  store = gimp_enum_store_new_from_array (GIMP_TYPE_LAYER_MODE,
                                          n_modes, (gint *) modes);
533 534 535 536

  switch (combo->priv->group)
    {
    case GIMP_LAYER_MODE_GROUP_DEFAULT:
537
      gimp_layer_mode_combo_box_fix_default_store (combo, store);
538 539 540
      break;

    case GIMP_LAYER_MODE_GROUP_LINEAR:
541
      gimp_layer_mode_combo_box_fix_linear_store (combo, store);
542 543 544
      break;

    case GIMP_LAYER_MODE_GROUP_PERCEPTUAL:
545
      gimp_layer_mode_combo_box_fix_perceptual_store (combo, store);
546 547 548
      break;

    case GIMP_LAYER_MODE_GROUP_LEGACY:
549
      gimp_layer_mode_combo_box_fix_legacy_store (combo, store);
550 551 552 553 554 555
      break;

    default:
      g_return_if_reached ();
    }

556 557
  gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
  g_object_unref (store);
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573

  if (change_mode)
    {
      GimpLayerMode new_mode;

      if (gimp_layer_mode_get_for_group (combo->priv->layer_mode,
                                         combo->priv->group,
                                         &new_mode))
        {
          gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), new_mode);
        }
      else
        {
          GtkTreeIter iter;

          /*  switch to the first mode, which will be one of the "normal"  */
574
          gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
          gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
        }
    }
}

static void
gimp_layer_mode_combo_box_insert_value (GtkListStore *store,
                                        gint          after,
                                        gint          insert_value)
{
  GtkTreeIter iter;

  if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
                                      after, &iter))
    {
      GEnumValue *enum_value;

      enum_value = g_enum_get_value (GIMP_ENUM_STORE (store)->enum_class,
                                     insert_value);

      if (enum_value)
        {
          GtkTreeIter  value_iter;
          const gchar *desc;

          gtk_list_store_insert_after (GTK_LIST_STORE (store),
                                       &value_iter, &iter);

          desc = gimp_enum_value_get_desc (GIMP_ENUM_STORE (store)->enum_class,
                                           enum_value);

          gtk_list_store_set (GTK_LIST_STORE (store), &value_iter,
                              GIMP_INT_STORE_VALUE, enum_value->value,
                              GIMP_INT_STORE_LABEL, desc,
                              -1);
        }
    }
}

static void
gimp_layer_mode_combo_box_insert_separator (GtkListStore *store,
                                            gint          after,
                                            gint          separator_value)
{
  GtkTreeIter iter;

  if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
                                      after, &iter))
    {
      GtkTreeIter sep_iter;

      gtk_list_store_insert_after (GTK_LIST_STORE (store),
                                   &sep_iter, &iter);
      gtk_list_store_set (GTK_LIST_STORE (store), &sep_iter,
                          GIMP_INT_STORE_VALUE, separator_value,
                          -1);
    }
}

static gboolean
gimp_layer_mode_combo_box_separator_func (GtkTreeModel *model,
                                          GtkTreeIter  *iter,
                                          gpointer      data)
{
  gint value;

  gtk_tree_model_get (model, iter, GIMP_INT_STORE_VALUE, &value, -1);

  return value == GPOINTER_TO_INT (data);
}