~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/actions/quick-mask-commands.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "libgimpcolor/gimpcolor.h"
 
24
#include "libgimpwidgets/gimpwidgets.h"
 
25
 
 
26
#include "actions-types.h"
 
27
 
 
28
#include "core/gimp.h"
 
29
#include "core/gimpchannel.h"
 
30
#include "core/gimpimage.h"
 
31
#include "core/gimpimage-quick-mask.h"
 
32
 
 
33
#include "widgets/gimphelp-ids.h"
 
34
 
 
35
#include "dialogs/channel-options-dialog.h"
 
36
 
 
37
#include "actions.h"
 
38
#include "quick-mask-commands.h"
 
39
 
 
40
#include "gimp-intl.h"
 
41
 
 
42
 
 
43
/*  local function prototypes  */
 
44
 
 
45
static void   quick_mask_configure_response (GtkWidget            *widget,
 
46
                                             gint                  response_id,
 
47
                                             ChannelOptionsDialog *options);
 
48
 
 
49
 
 
50
/*  public functionss */
 
51
 
 
52
void
 
53
quick_mask_toggle_cmd_callback (GtkAction *action,
 
54
                                gpointer   data)
 
55
{
 
56
  GimpImage *image;
 
57
  gboolean   active;
 
58
  return_if_no_image (image, data);
 
59
 
 
60
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
61
 
 
62
  if (active != gimp_image_get_quick_mask_state (image))
 
63
    {
 
64
      gimp_image_set_quick_mask_state (image, active);
 
65
      gimp_image_flush (image);
 
66
    }
 
67
}
 
68
 
 
69
void
 
70
quick_mask_invert_cmd_callback (GtkAction *action,
 
71
                                GtkAction *current,
 
72
                                gpointer   data)
 
73
{
 
74
  GimpImage *image;
 
75
  gint       value;
 
76
  return_if_no_image (image, data);
 
77
 
 
78
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
79
 
 
80
  if (value != image->quick_mask_inverted)
 
81
    {
 
82
      gimp_image_quick_mask_invert (image);
 
83
      gimp_image_flush (image);
 
84
    }
 
85
}
 
86
 
 
87
void
 
88
quick_mask_configure_cmd_callback (GtkAction *action,
 
89
                                   gpointer   data)
 
90
{
 
91
  ChannelOptionsDialog *options;
 
92
  GimpImage            *image;
 
93
  GtkWidget            *widget;
 
94
  GimpRGB               color;
 
95
  return_if_no_image (image, data);
 
96
  return_if_no_widget (widget, data);
 
97
 
 
98
  gimp_image_get_quick_mask_color (image, &color);
 
99
 
 
100
  options = channel_options_dialog_new (image, NULL,
 
101
                                        action_data_get_context (data),
 
102
                                        widget,
 
103
                                        &color,
 
104
                                        NULL,
 
105
                                        _("Quick Mask Attributes"),
 
106
                                        "gimp-quick-mask-edit",
 
107
                                        GIMP_STOCK_QUICK_MASK_ON,
 
108
                                        _("Edit Quick Mask Attributes"),
 
109
                                        GIMP_HELP_QUICK_MASK_EDIT,
 
110
                                        _("Edit Quick Mask Color"),
 
111
                                        _("_Mask opacity:"),
 
112
                                        FALSE);
 
113
 
 
114
  g_signal_connect (options->dialog, "response",
 
115
                    G_CALLBACK (quick_mask_configure_response),
 
116
                    options);
 
117
 
 
118
  gtk_widget_show (options->dialog);
 
119
}
 
120
 
 
121
 
 
122
/*  private functions  */
 
123
 
 
124
static void
 
125
quick_mask_configure_response (GtkWidget            *widget,
 
126
                               gint                  response_id,
 
127
                               ChannelOptionsDialog *options)
 
128
{
 
129
  if (response_id == GTK_RESPONSE_OK)
 
130
    {
 
131
      GimpRGB old_color;
 
132
      GimpRGB new_color;
 
133
 
 
134
      gimp_image_get_quick_mask_color (options->image, &old_color);
 
135
      gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
 
136
                                   &new_color);
 
137
 
 
138
      if (gimp_rgba_distance (&old_color, &new_color) > 0.0001)
 
139
        {
 
140
          gimp_image_set_quick_mask_color (options->image, &new_color);
 
141
 
 
142
          gimp_image_flush (options->image);
 
143
        }
 
144
    }
 
145
 
 
146
  gtk_widget_destroy (options->dialog);
 
147
}