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 31 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 160 161 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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 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 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 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 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
|
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcolorselector.c
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
*
* based on:
* Colour selector module
* Copyright (C) 1999 Austin Donnelly <austin@greenend.org.uk>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "gimpwidgetstypes.h"
#include "gimpcolorselector.h"
#include "gimpicons.h"
#include "gimpwidgetsmarshal.h"
/**
* SECTION: gimpcolorselector
* @title: GimpColorSelector
* @short_description: Pluggable GIMP color selector modules.
* @see_also: #GModule, #GTypeModule, #GimpModule
*
* Functions and definitions for creating pluggable GIMP color
* selector modules.
**/
enum
{
COLOR_CHANGED,
CHANNEL_CHANGED,
MODEL_VISIBLE_CHANGED,
SIMULATION,
LAST_SIGNAL
};
typedef struct _GimpColorSelectorPrivate
{
gboolean toggles_visible;
gboolean toggles_sensitive;
gboolean show_alpha;
gboolean model_visible[3];
GimpColorSelectorChannel channel;
GeglColor *color;
gboolean simulation;
GimpColorProfile *simulation_profile;
GimpColorRenderingIntent simulation_intent;
gboolean simulation_bpc;
} GimpColorSelectorPrivate;
static void gimp_color_selector_dispose (GObject *object);
static void gimp_color_selector_emit_color_changed (GimpColorSelector *selector);
static void gimp_color_selector_emit_channel_changed (GimpColorSelector *selector);
static void gimp_color_selector_emit_model_visible_changed (GimpColorSelector *selector,
GimpColorSelectorModel model);
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GimpColorSelector, gimp_color_selector, GTK_TYPE_BOX)
#define parent_class gimp_color_selector_parent_class
static guint selector_signals[LAST_SIGNAL] = { 0 };
static void
gimp_color_selector_class_init (GimpColorSelectorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gimp_color_selector_dispose;
selector_signals[COLOR_CHANGED] =
g_signal_new ("color-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColorSelectorClass, color_changed),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
GEGL_TYPE_COLOR);
selector_signals[CHANNEL_CHANGED] =
g_signal_new ("channel-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColorSelectorClass, channel_changed),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
GIMP_TYPE_COLOR_SELECTOR_CHANNEL);
selector_signals[MODEL_VISIBLE_CHANGED] =
g_signal_new ("model-visible-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColorSelectorClass, model_visible_changed),
NULL, NULL,
_gimp_widgets_marshal_VOID__ENUM_BOOLEAN,
G_TYPE_NONE, 2,
GIMP_TYPE_COLOR_SELECTOR_MODEL,
G_TYPE_BOOLEAN);
selector_signals[SIMULATION] =
g_signal_new ("simulation",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColorSelectorClass, simulation),
NULL, NULL, NULL,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
klass->name = "Unnamed";
klass->help_id = NULL;
klass->icon_name = GIMP_ICON_PALETTE;
klass->set_toggles_visible = NULL;
klass->set_toggles_sensitive = NULL;
klass->set_show_alpha = NULL;
klass->set_color = NULL;
klass->set_channel = NULL;
klass->set_model_visible = NULL;
klass->color_changed = NULL;
klass->channel_changed = NULL;
klass->model_visible_changed = NULL;
klass->set_config = NULL;
}
static void
gimp_color_selector_init (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
priv = gimp_color_selector_get_instance_private (selector);
priv->toggles_visible = TRUE;
priv->toggles_sensitive = TRUE;
priv->show_alpha = TRUE;
gtk_orientable_set_orientation (GTK_ORIENTABLE (selector),
GTK_ORIENTATION_VERTICAL);
priv->channel = GIMP_COLOR_SELECTOR_RED;
priv->color = gegl_color_new ("black");
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_RGB] = TRUE;
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_LCH] = TRUE;
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_HSV] = FALSE;
priv->simulation = FALSE;
priv->simulation_profile = NULL;
priv->simulation_intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
priv->simulation_bpc = FALSE;
}
static void
gimp_color_selector_dispose (GObject *object)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (object);
GimpColorSelectorPrivate *priv;
priv = gimp_color_selector_get_instance_private (selector);
gimp_color_selector_set_config (selector, NULL);
g_clear_object (&priv->color);
g_clear_object (&priv->simulation_profile);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
/* public functions */
/**
* gimp_color_selector_new: (skip)
* @selector_type: The #GType of the selector to create.
* @color: The initial color to be edited.
* @channel: The selector's initial channel.
*
* Creates a new #GimpColorSelector widget of type @selector_type.
*
* Note that this is mostly internal API to be used by other widgets.
*
* Please use gimp_color_selection_new() for the "GIMP-typical" color
* selection widget. Also see gimp_color_button_new().
*
* Returns: the new #GimpColorSelector widget.
**/
GtkWidget *
gimp_color_selector_new (GType selector_type,
GeglColor *color,
GimpColorSelectorChannel channel)
{
GimpColorSelector *selector;
g_return_val_if_fail (g_type_is_a (selector_type, GIMP_TYPE_COLOR_SELECTOR), NULL);
g_return_val_if_fail (GEGL_IS_COLOR (color), NULL);
selector = g_object_new (selector_type, NULL);
gimp_color_selector_set_color (selector, color);
gimp_color_selector_set_channel (selector, channel);
return GTK_WIDGET (selector);
}
/**
* gimp_color_selector_set_toggles_visible:
* @selector: A #GimpColorSelector widget.
* @visible: The new @visible setting.
*
* Sets the @visible property of the @selector's toggles.
*
* This function has no effect if this @selector instance has no
* toggles to switch channels.
**/
void
gimp_color_selector_set_toggles_visible (GimpColorSelector *selector,
gboolean visible)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
if (priv->toggles_visible != visible)
{
GimpColorSelectorClass *selector_class;
priv->toggles_visible = visible ? TRUE : FALSE;
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_toggles_visible)
selector_class->set_toggles_visible (selector, visible);
}
}
/**
* gimp_color_selector_get_toggles_visible:
* @selector: A #GimpColorSelector widget.
*
* Returns the @visible property of the @selector's toggles.
*
* Returns: %TRUE if the #GimpColorSelector's toggles are visible.
*
* Since: 2.10
**/
gboolean
gimp_color_selector_get_toggles_visible (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
priv = gimp_color_selector_get_instance_private (selector);
return priv->toggles_visible;
}
/**
* gimp_color_selector_set_toggles_sensitive:
* @selector: A #GimpColorSelector widget.
* @sensitive: The new @sensitive setting.
*
* Sets the @sensitive property of the @selector's toggles.
*
* This function has no effect if this @selector instance has no
* toggles to switch channels.
**/
void
gimp_color_selector_set_toggles_sensitive (GimpColorSelector *selector,
gboolean sensitive)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
if (priv->toggles_sensitive != sensitive)
{
GimpColorSelectorClass *selector_class;
priv->toggles_sensitive = sensitive ? TRUE : FALSE;
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_toggles_sensitive)
selector_class->set_toggles_sensitive (selector, sensitive);
}
}
/**
* gimp_color_selector_get_toggles_sensitive:
* @selector: A #GimpColorSelector widget.
*
* Returns the @sensitive property of the @selector's toggles.
*
* Returns: %TRUE if the #GimpColorSelector's toggles are sensitive.
*
* Since: 2.10
**/
gboolean
gimp_color_selector_get_toggles_sensitive (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
priv = gimp_color_selector_get_instance_private (selector);
return priv->toggles_sensitive;
}
/**
* gimp_color_selector_set_show_alpha:
* @selector: A #GimpColorSelector widget.
* @show_alpha: The new @show_alpha setting.
*
* Sets the @show_alpha property of the @selector widget.
**/
void
gimp_color_selector_set_show_alpha (GimpColorSelector *selector,
gboolean show_alpha)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
if (show_alpha != priv->show_alpha)
{
GimpColorSelectorClass *selector_class;
priv->show_alpha = show_alpha ? TRUE : FALSE;
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_show_alpha)
selector_class->set_show_alpha (selector, show_alpha);
}
}
/**
* gimp_color_selector_get_show_alpha:
* @selector: A #GimpColorSelector widget.
*
* Returns the @selector's @show_alpha property.
*
* Returns: %TRUE if the #GimpColorSelector has alpha controls.
*
* Since: 2.10
**/
gboolean
gimp_color_selector_get_show_alpha (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
priv = gimp_color_selector_get_instance_private (selector);
return priv->show_alpha;
}
/**
* gimp_color_selector_set_color:
* @selector: A #GimpColorSelector widget.
* @color: The new color.
*
* Sets the color shown in the @selector widget.
**/
void
gimp_color_selector_set_color (GimpColorSelector *selector,
GeglColor *color)
{
GimpColorSelectorClass *selector_class;
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
g_return_if_fail (GEGL_IS_COLOR (color));
priv = gimp_color_selector_get_instance_private (selector);
g_object_unref (priv->color);
priv->color = gegl_color_duplicate (color);
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_color)
selector_class->set_color (selector, priv->color);
gimp_color_selector_emit_color_changed (selector);
}
/**
* gimp_color_selector_get_color:
* @selector: A #GimpColorSelector widget.
*
* Retrieves the color shown in the @selector widget.
*
* Returns: (transfer full): a copy of the selected color.
* Since: 2.10
**/
GeglColor *
gimp_color_selector_get_color (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), NULL);
priv = gimp_color_selector_get_instance_private (selector);
return gegl_color_duplicate (priv->color);
}
/**
* gimp_color_selector_set_channel:
* @selector: A #GimpColorSelector widget.
* @channel: The new @channel setting.
*
* Sets the @channel property of the @selector widget.
*
* Changes between displayed channels if this @selector instance has
* the ability to show different channels.
* This will also update the color model if needed.
**/
void
gimp_color_selector_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
if (channel != priv->channel)
{
GimpColorSelectorClass *selector_class;
GimpColorSelectorModel model = -1;
priv->channel = channel;
switch (channel)
{
case GIMP_COLOR_SELECTOR_RED:
case GIMP_COLOR_SELECTOR_GREEN:
case GIMP_COLOR_SELECTOR_BLUE:
model = GIMP_COLOR_SELECTOR_MODEL_RGB;
break;
case GIMP_COLOR_SELECTOR_HUE:
case GIMP_COLOR_SELECTOR_SATURATION:
case GIMP_COLOR_SELECTOR_VALUE:
model = GIMP_COLOR_SELECTOR_MODEL_HSV;
break;
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
case GIMP_COLOR_SELECTOR_LCH_HUE:
model = GIMP_COLOR_SELECTOR_MODEL_LCH;
break;
case GIMP_COLOR_SELECTOR_ALPHA:
/* Alpha channel does not change the color model. */
break;
default:
/* Should not happen. */
g_return_if_reached ();
break;
}
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_channel)
selector_class->set_channel (selector, channel);
gimp_color_selector_emit_channel_changed (selector);
if (model != -1)
{
/* make visibility of LCH and HSV mutuallky exclusive */
if (model == GIMP_COLOR_SELECTOR_MODEL_HSV)
{
gimp_color_selector_set_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_LCH,
FALSE);
}
else if (model == GIMP_COLOR_SELECTOR_MODEL_LCH)
{
gimp_color_selector_set_model_visible (selector,
GIMP_COLOR_SELECTOR_MODEL_HSV,
FALSE);
}
gimp_color_selector_set_model_visible (selector, model, TRUE);
}
}
}
/**
* gimp_color_selector_get_channel:
* @selector: A #GimpColorSelector widget.
*
* Returns the @selector's current channel.
*
* Returns: The #GimpColorSelectorChannel currently shown by the
* @selector.
*
* Since: 2.10
**/
GimpColorSelectorChannel
gimp_color_selector_get_channel (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector),
GIMP_COLOR_SELECTOR_RED);
priv = gimp_color_selector_get_instance_private (selector);
return priv->channel;
}
/**
* gimp_color_selector_set_model_visible:
* @selector: A #GimpColorSelector widget.
* @model: The affected #GimpColorSelectorModel.
* @visible: The new visible setting.
*
* Sets the @model visible/invisible on the @selector widget.
*
* Toggles visibility of displayed models if this @selector instance
* has the ability to show different color models.
*
* Since: 2.10
**/
void
gimp_color_selector_set_model_visible (GimpColorSelector *selector,
GimpColorSelectorModel model,
gboolean visible)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
visible = visible ? TRUE : FALSE;
if (visible != priv->model_visible[model])
{
GimpColorSelectorClass *selector_class;
priv->model_visible[model] = visible;
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_model_visible)
selector_class->set_model_visible (selector, model, visible);
gimp_color_selector_emit_model_visible_changed (selector, model);
}
}
/**
* gimp_color_selector_get_model_visible:
* @selector: A #GimpColorSelector widget.
* @model: The #GimpColorSelectorModel.
*
* Returns: whether @model is visible in @selector.
*
* Since: 2.10
**/
gboolean
gimp_color_selector_get_model_visible (GimpColorSelector *selector,
GimpColorSelectorModel model)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
priv = gimp_color_selector_get_instance_private (selector);
return priv->model_visible[model];
}
/**
* gimp_color_selector_set_config:
* @selector: a #GimpColorSelector widget.
* @config: a #GimpColorConfig object.
*
* Sets the color management configuration to use with this color selector.
*
* Since: 2.4
*/
void
gimp_color_selector_set_config (GimpColorSelector *selector,
GimpColorConfig *config)
{
GimpColorSelectorClass *selector_class;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_config)
selector_class->set_config (selector, config);
}
/**
* gimp_color_selector_set_format
* @selector: a #GimpColorSelector widget.
* @format: a Babl format, with space.
*
* Sets the babl format representing the color model and the space this
* @selector is supposed to display values for. Depending on the type of color
* selector, it may trigger various UX changes, or none at all.
*
* Since: 3.0
*/
void
gimp_color_selector_set_format (GimpColorSelector *selector,
const Babl *format)
{
GimpColorSelectorClass *selector_class;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
if (selector_class->set_format)
selector_class->set_format (selector, format);
}
/**
* gimp_color_selector_set_simulation
* @selector: a #GimpColorSelector widget.
* @profile: a #GimpColorProfile object.
* @intent: a #GimpColorRenderingIntent enum.
* @bpc: a gboolean.
*
* Sets the simulation options to use with this color selector.
*
* Since: 3.0
*/
void
gimp_color_selector_set_simulation (GimpColorSelector *selector,
GimpColorProfile *profile,
GimpColorRenderingIntent intent,
gboolean bpc)
{
GimpColorSelectorClass *selector_class;
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
priv = gimp_color_selector_get_instance_private (selector);
if ((profile && ! priv->simulation_profile) ||
(! profile && priv->simulation_profile) ||
(profile && ! gimp_color_profile_is_equal (profile, priv->simulation_profile)) ||
intent != priv->simulation_intent ||
bpc != priv->simulation_bpc)
{
g_set_object (&priv->simulation_profile, profile);
priv->simulation_intent = intent;
priv->simulation_bpc = bpc;
if (selector_class->set_simulation)
selector_class->set_simulation (selector, profile, intent, bpc);
}
}
gboolean
gimp_color_selector_get_simulation (GimpColorSelector *selector,
GimpColorProfile **profile,
GimpColorRenderingIntent *intent,
gboolean *bpc)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
priv = gimp_color_selector_get_instance_private (selector);
if (profile)
*profile = priv->simulation_profile;
if (intent)
*intent = priv->simulation_intent;
if (bpc)
*bpc = priv->simulation_bpc;
return priv->simulation;
}
gboolean
gimp_color_selector_enable_simulation (GimpColorSelector *selector,
gboolean enabled)
{
GimpColorSelectorPrivate *priv;
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
priv = gimp_color_selector_get_instance_private (selector);
if (priv->simulation != enabled)
{
if (! enabled || priv->simulation_profile)
{
priv->simulation = enabled;
g_signal_emit (selector, selector_signals[SIMULATION], 0, enabled);
}
}
return priv->simulation;
}
/* Private functions. */
/**
* gimp_color_selector_emit_color_changed:
* @selector: A #GimpColorSelector widget.
*
* Emits the "color-changed" signal.
*/
static void
gimp_color_selector_emit_color_changed (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
g_signal_emit (selector, selector_signals[COLOR_CHANGED], 0, priv->color);
}
/**
* gimp_color_selector_emit_channel_changed:
* @selector: A #GimpColorSelector widget.
*
* Emits the "channel-changed" signal.
*/
static void
gimp_color_selector_emit_channel_changed (GimpColorSelector *selector)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
g_signal_emit (selector, selector_signals[CHANNEL_CHANGED], 0,
priv->channel);
}
/**
* gimp_color_selector_emit_model_visible_changed:
* @selector: A #GimpColorSelector widget.
* @model: The #GimpColorSelectorModel where visibility changed.
*
* Emits the "model-visible-changed" signal.
*
* Since: 2.10
*/
static void
gimp_color_selector_emit_model_visible_changed (GimpColorSelector *selector,
GimpColorSelectorModel model)
{
GimpColorSelectorPrivate *priv;
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
priv = gimp_color_selector_get_instance_private (selector);
g_signal_emit (selector, selector_signals[MODEL_VISIBLE_CHANGED], 0,
model, priv->model_visible[model]);
}
|