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

« back to all changes in this revision

Viewing changes to app/actions/qmask-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
 
/* The GIMP -- an 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-qmask.h"
32
 
 
33
 
#include "widgets/gimphelp-ids.h"
34
 
 
35
 
#include "dialogs/channel-options-dialog.h"
36
 
 
37
 
#include "actions.h"
38
 
#include "qmask-commands.h"
39
 
 
40
 
#include "gimp-intl.h"
41
 
 
42
 
 
43
 
/*  local function prototypes  */
44
 
 
45
 
static void   qmask_configure_response (GtkWidget            *widget,
46
 
                                        gint                  response_id,
47
 
                                        ChannelOptionsDialog *options);
48
 
 
49
 
 
50
 
/*  public functionss */
51
 
 
52
 
void
53
 
qmask_toggle_cmd_callback (GtkAction *action,
54
 
                           gpointer   data)
55
 
{
56
 
  GimpImage *gimage;
57
 
  gboolean   active;
58
 
  return_if_no_image (gimage, data);
59
 
 
60
 
  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
61
 
 
62
 
  if (active != gimp_image_get_qmask_state (gimage))
63
 
    {
64
 
      gimp_image_set_qmask_state (gimage, active);
65
 
      gimp_image_flush (gimage);
66
 
    }
67
 
}
68
 
 
69
 
void
70
 
qmask_invert_cmd_callback (GtkAction *action,
71
 
                           GtkAction *current,
72
 
                           gpointer   data)
73
 
{
74
 
  GimpImage *gimage;
75
 
  gint       value;
76
 
  return_if_no_image (gimage, data);
77
 
 
78
 
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
79
 
 
80
 
  if (value != gimage->qmask_inverted)
81
 
    {
82
 
      gimp_image_qmask_invert (gimage);
83
 
      gimp_image_flush (gimage);
84
 
    }
85
 
}
86
 
 
87
 
void
88
 
qmask_configure_cmd_callback (GtkAction *action,
89
 
                              gpointer   data)
90
 
{
91
 
  ChannelOptionsDialog *options;
92
 
  GimpImage            *gimage;
93
 
  GtkWidget            *widget;
94
 
  GimpRGB               color;
95
 
  return_if_no_image (gimage, data);
96
 
  return_if_no_widget (widget, data);
97
 
 
98
 
  gimp_image_get_qmask_color (gimage, &color);
99
 
 
100
 
  options = channel_options_dialog_new (gimage,
101
 
                                        action_data_get_context (data),
102
 
                                        NULL,
103
 
                                        widget,
104
 
                                        &color,
105
 
                                        NULL,
106
 
                                        _("Quick Mask Attributes"),
107
 
                                        "gimp-qmask-edit",
108
 
                                        GIMP_STOCK_QMASK_ON,
109
 
                                        _("Edit Quick Mask Attributes"),
110
 
                                        GIMP_HELP_QMASK_EDIT,
111
 
                                        _("Edit Quick Mask Color"),
112
 
                                        _("Mask Opacity:"));
113
 
 
114
 
  g_signal_connect (options->dialog, "response",
115
 
                    G_CALLBACK (qmask_configure_response),
116
 
                    options);
117
 
 
118
 
  gtk_widget_show (options->dialog);
119
 
}
120
 
 
121
 
 
122
 
/*  private functions  */
123
 
 
124
 
static void
125
 
qmask_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_qmask_color (options->gimage, &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_qmask_color (options->gimage, &new_color);
141
 
 
142
 
          gimp_image_flush (options->gimage);
143
 
        }
144
 
    }
145
 
 
146
 
  gtk_widget_destroy (options->dialog);
147
 
}