gimpclonetool.c 4.24 KB
Newer Older
Michael Natterer's avatar
Michael Natterer committed
1
/* The GIMP -- an image manipulation program
Elliot Lee's avatar
Elliot Lee committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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 2 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, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17
 */
Sven Neumann's avatar
Sven Neumann committed
18

Michael Natterer's avatar
Michael Natterer committed
19 20
#include "config.h"

Sven Neumann's avatar
Sven Neumann committed
21 22
#include <gtk/gtk.h>

23 24
#include "libgimpwidgets/gimpwidgets.h"

25
#include "tools-types.h"
Sven Neumann's avatar
Sven Neumann committed
26

27
#include "paint/gimpclone.h"
28
#include "paint/gimpcloneoptions.h"
29

30
#include "widgets/gimphelp-ids.h"
31 32
#include "widgets/gimpviewablebox.h"
#include "widgets/gimpwidgets-utils.h"
33

34 35
#include "display/gimpdisplay.h"

36
#include "gimpclonetool.h"
37
#include "gimppaintoptions-gui.h"
38
#include "gimptoolcontrol.h"
39

40
#include "gimp-intl.h"
41

42

43
static GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options);
Elliot Lee's avatar
Elliot Lee committed
44

Michael Natterer's avatar
Michael Natterer committed
45

46
G_DEFINE_TYPE (GimpCloneTool, gimp_clone_tool, GIMP_TYPE_SOURCE_TOOL)
47

48
#define parent_class gimp_clone_tool_parent_class
49

Elliot Lee's avatar
Elliot Lee committed
50

51
void
Nate Summers's avatar
Nate Summers committed
52
gimp_clone_tool_register (GimpToolRegisterCallback  callback,
53
                          gpointer                  data)
54
{
Nate Summers's avatar
Nate Summers committed
55
  (* callback) (GIMP_TYPE_CLONE_TOOL,
56 57
                GIMP_TYPE_CLONE_OPTIONS,
                gimp_clone_options_gui,
58
                GIMP_PAINT_OPTIONS_CONTEXT_MASK |
59
                GIMP_CONTEXT_PATTERN_MASK,
60
                "gimp-clone-tool",
61 62
                _("Clone"),
                _("Paint using Patterns or Image Regions"),
63
                N_("_Clone"), "C",
64
                NULL, GIMP_HELP_TOOL_CLONE,
Nate Summers's avatar
Nate Summers committed
65
                GIMP_STOCK_TOOL_CLONE,
66
                data);
67
}
68

69 70
static void
gimp_clone_tool_class_init (GimpCloneToolClass *klass)
Elliot Lee's avatar
Elliot Lee committed
71
{
72
}
Elliot Lee's avatar
Elliot Lee committed
73

74 75 76
static void
gimp_clone_tool_init (GimpCloneTool *clone)
{
77 78 79
  GimpTool       *tool        = GIMP_TOOL (clone);
  GimpPaintTool  *paint_tool  = GIMP_PAINT_TOOL (tool);
  GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
80

81 82 83 84
  gimp_tool_control_set_tool_cursor     (tool->control,
                                         GIMP_TOOL_CURSOR_CLONE);
  gimp_tool_control_set_action_object_2 (tool->control,
                                         "context/context-pattern-select-set");
85

86
  paint_tool->status      = _("Click to clone");
87
  paint_tool->status_ctrl = _("%s to set a new clone source");
88

89 90 91
  source_tool->status_paint           = _("Click to clone.");
  source_tool->status_set_source      = _("Click to set a new clone source");
  source_tool->status_set_source_ctrl = _("%s to set a new clone source");
Elliot Lee's avatar
Elliot Lee committed
92 93
}

94

95
/*  tool options stuff  */
96

97
static GtkWidget *
98
gimp_clone_options_gui (GimpToolOptions *tool_options)
99
{
100
  GObject   *config = G_OBJECT (tool_options);
101
  GtkWidget *vbox   = gimp_paint_options_gui (tool_options);
102
  GtkWidget *frame;
103
  GtkWidget *button;
104 105 106
  GtkWidget *hbox;
  GtkWidget *table;
  GtkWidget *combo;
107

108
  frame = gimp_prop_enum_radio_frame_new (config, "clone-type",
109
                                          _("Source"), 0, 0);
110 111 112
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

113
  button = gimp_prop_check_button_new (config, "sample-merged",
114
                                       _("Sample merged"));
115 116
  gimp_enum_radio_frame_add (GTK_FRAME (frame), button, GIMP_IMAGE_CLONE);

117 118
  hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
                                    "pattern-view-type", "pattern-view-size");
119 120
  gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox, GIMP_PATTERN_CLONE);

121 122 123 124 125 126 127 128 129
  table = gtk_table_new (1, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
  gtk_widget_show (table);

  combo = gimp_prop_enum_combo_box_new (config, "align-mode", 0, 0);
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
                             _("Alignment:"), 0.0, 0.5,
                             combo, 1, FALSE);
130 131

  return vbox;
132
}