2001-05-24 23:57:08 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
#include <gtk/gtk.h>
|
2004-10-01 15:15:14 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-24 23:57:08 +00:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2003-11-11 13:09:50 +00:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpcontext.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2003-06-05 18:47:23 +00:00
|
|
|
#include "core/gimpimage-pick-color.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
#include "core/gimpimagemap.h"
|
2004-07-13 23:04:05 +00:00
|
|
|
#include "core/gimppickable.h"
|
2004-07-13 16:36:29 +00:00
|
|
|
#include "core/gimpprojection.h"
|
GimpViewableDialogs everywhere, cleanup:
2002-09-01 Michael Natterer <mitch@gimp.org>
GimpViewableDialogs everywhere, cleanup:
* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
and CROP stock items.
* app/widgets/gimpviewabledialog.c: update the title when the
viewable's name changes.
* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
which creates a GimpViewableDialog.
* app/widgets/gimpgradienteditor.[ch]
* app/gui/colormap-editor-commands.c
* app/gui/file-new-dialog.c
* app/gui/gradient-editor-commands.c
* app/gui/palette-editor-commands.c
* app/undo_history.c: use GimpViewableDialogs and the new
color_notebook constructor.
* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"
* app/gui/image-commands.c
* app/gui/info-dialog.c
* app/gui/resize-dialog.c: minor cleanups.
* app/gui/info-window.c: cleaned up the whole thing, esp. the
"Extended" page. Added HSV color display to the color picker
frame. Set the icons as frame titles, stuff...
* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
"shell_name" and "stock_id" from the GimpImageMapTool struct
because they can be obtained from the tool's GimpToolInfo object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* app/tools/gimphistogramtool.c: same here: take values from
tool->tool_info instead of hardcoding them.
* app/tools/gimpcroptool.[ch]: removed the static crop dialog
variables and added them to the GimpCropTool struct. Feels safer
and makes the callback code much simpler. Use stock items for the
dialog's "Resize" and "Crop" buttons.
* app/tools/gimpmeasuretool.c
* app/tools/gimprotatetool.c: for consistency don't name the tools
"Blah Tool", also the dialog titles need to match the menu
entries.
Unrelated:
* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
comment was correct, as gtk-doc takes the parameter names from
the header, not the .c file.
* app/tools/gimptransformtool.c: set the transform tool's state to
TRANSFORM_CREATING after changing displays, so the initial matrix
components are saved correctly for the "Reset" function.
2002-09-01 08:44:57 +00:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2004-02-22 14:28:53 +00:00
|
|
|
#include "widgets/gimppropwidgets.h"
|
2003-10-20 21:27:34 +00:00
|
|
|
#include "widgets/gimptooldialog.h"
|
2002-08-30 21:00:42 +00:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
2004-10-22 19:44:03 +00:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2003-06-05 18:47:23 +00:00
|
|
|
#include "gimpcoloroptions.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
#include "gimpimagemaptool.h"
|
2003-04-15 16:05:52 +00:00
|
|
|
#include "gimptoolcontrol.h"
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static void gimp_image_map_tool_class_init (GimpImageMapToolClass *klass);
|
|
|
|
static void gimp_image_map_tool_init (GimpImageMapTool *image_map_tool);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static void gimp_image_map_tool_finalize (GObject *object);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static gboolean gimp_image_map_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_image_map_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *gdisp);
|
2004-10-01 15:15:14 +00:00
|
|
|
static gboolean gimp_image_map_tool_key_press (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *gdisp);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static gboolean gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpImageType *sample_type,
|
|
|
|
GimpRGB *color,
|
|
|
|
gint *color_index);
|
|
|
|
static void gimp_image_map_tool_map (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_image_map_tool_dialog (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_image_map_tool_reset (GimpImageMapTool *image_map_tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static void gimp_image_map_tool_flush (GimpImageMap *image_map,
|
|
|
|
GimpImageMapTool *image_map_tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static void gimp_image_map_tool_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
GimpImageMapTool *image_map_tool);
|
2003-11-06 15:27:05 +00:00
|
|
|
|
2004-10-22 19:44:03 +00:00
|
|
|
static void gimp_image_map_tool_load_clicked (GtkWidget *widget,
|
|
|
|
GimpImageMapTool *tool);
|
|
|
|
static void gimp_image_map_tool_load_ext_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpImageMapTool *tool);
|
|
|
|
static void gimp_image_map_tool_save_clicked (GtkWidget *widget,
|
|
|
|
GimpImageMapTool *tool);
|
|
|
|
static void gimp_image_map_tool_save_ext_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpImageMapTool *tool);
|
|
|
|
|
|
|
|
static void gimp_image_map_tool_settings_dialog (GimpImageMapTool *image_map_tool,
|
|
|
|
const gchar *title,
|
|
|
|
gboolean save);
|
2004-02-25 13:55:45 +00:00
|
|
|
|
2004-02-22 14:28:53 +00:00
|
|
|
static void gimp_image_map_tool_notify_preview (GObject *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpImageMapTool *image_map_tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
static GimpToolClass *parent_class = NULL;
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2001-05-24 23:57:08 +00:00
|
|
|
gimp_image_map_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static GType tool_type = 0;
|
2001-05-24 23:57:08 +00:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-05-24 23:57:08 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpImageMapToolClass),
|
2004-07-29 14:16:21 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_image_map_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpImageMapTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_image_map_tool_init,
|
2001-05-24 23:57:08 +00:00
|
|
|
};
|
|
|
|
|
2003-06-05 18:47:23 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_COLOR_TOOL,
|
2004-07-29 14:16:21 +00:00
|
|
|
"GimpImageMapTool",
|
2001-08-14 14:53:55 +00:00
|
|
|
&tool_info, 0);
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
|
|
|
{
|
2004-07-13 23:04:05 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
object_class->finalize = gimp_image_map_tool_finalize;
|
|
|
|
|
|
|
|
tool_class->initialize = gimp_image_map_tool_initialize;
|
|
|
|
tool_class->control = gimp_image_map_tool_control;
|
2004-10-01 15:15:14 +00:00
|
|
|
tool_class->key_press = gimp_image_map_tool_key_press;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-06-05 18:47:23 +00:00
|
|
|
color_tool_class->pick = gimp_image_map_tool_pick_color;
|
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
klass->shell_desc = NULL;
|
|
|
|
klass->settings_name = NULL;
|
|
|
|
klass->load_dialog_title = NULL;
|
2004-10-22 19:44:03 +00:00
|
|
|
klass->load_button_tip = NULL;
|
2004-02-25 13:55:45 +00:00
|
|
|
klass->save_dialog_title = NULL;
|
2004-10-22 19:44:03 +00:00
|
|
|
klass->save_button_tip = NULL;
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
klass->map = NULL;
|
|
|
|
klass->dialog = NULL;
|
|
|
|
klass->reset = NULL;
|
|
|
|
klass->settings_load = NULL;
|
|
|
|
klass->settings_save = NULL;
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_init (GimpImageMapTool *image_map_tool)
|
|
|
|
{
|
2003-11-06 15:27:05 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (image_map_tool);
|
2001-05-24 23:57:08 +00:00
|
|
|
|
2002-06-16 17:13:39 +00:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
2004-07-29 14:16:21 +00:00
|
|
|
gimp_tool_control_set_dirty_mask (tool->control,
|
|
|
|
GIMP_DIRTY_IMAGE |
|
|
|
|
GIMP_DIRTY_IMAGE_STRUCTURE |
|
|
|
|
GIMP_DIRTY_DRAWABLE |
|
|
|
|
GIMP_DIRTY_SELECTION);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
image_map_tool->drawable = NULL;
|
|
|
|
image_map_tool->image_map = NULL;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
image_map_tool->shell = NULL;
|
|
|
|
image_map_tool->main_vbox = NULL;
|
|
|
|
image_map_tool->load_button = NULL;
|
|
|
|
image_map_tool->save_button = NULL;
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_finalize (GObject *object)
|
|
|
|
{
|
2003-11-06 15:27:05 +00:00
|
|
|
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (object);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
if (image_map_tool->shell)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (image_map_tool->shell);
|
2004-02-25 13:55:45 +00:00
|
|
|
image_map_tool->shell = NULL;
|
|
|
|
image_map_tool->main_vbox = NULL;
|
|
|
|
image_map_tool->load_button = NULL;
|
|
|
|
image_map_tool->save_button = NULL;
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
#define RESPONSE_RESET 1
|
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
static gboolean
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_image_map_tool_initialize (GimpTool *tool,
|
2004-07-29 14:16:21 +00:00
|
|
|
GimpDisplay *gdisp)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2004-01-21 16:07:48 +00:00
|
|
|
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
2003-02-14 14:14:29 +00:00
|
|
|
GimpToolInfo *tool_info;
|
2002-08-26 11:35:56 +00:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
2003-02-14 14:14:29 +00:00
|
|
|
tool_info = tool->tool_info;
|
|
|
|
|
2002-11-14 11:08:40 +00:00
|
|
|
/* set gdisp so the dialog can be hidden on display destruction */
|
|
|
|
tool->gdisp = gdisp;
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
if (! image_map_tool->shell)
|
|
|
|
{
|
2004-02-25 13:55:45 +00:00
|
|
|
GimpImageMapToolClass *klass;
|
|
|
|
GtkWidget *shell;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *toggle;
|
|
|
|
const gchar *stock_id;
|
|
|
|
|
|
|
|
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
|
2003-02-26 18:08:26 +00:00
|
|
|
|
|
|
|
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
image_map_tool->shell = shell =
|
2004-03-14 22:16:12 +00:00
|
|
|
gimp_tool_dialog_new (tool_info,
|
|
|
|
NULL /* gdisp->shell */,
|
2004-02-25 13:55:45 +00:00
|
|
|
klass->shell_desc,
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
GIMP_STOCK_RESET, RESPONSE_RESET,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-10-20 21:27:34 +00:00
|
|
|
NULL);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
g_signal_connect_object (shell, "response",
|
|
|
|
G_CALLBACK (gimp_image_map_tool_response),
|
|
|
|
G_OBJECT (image_map_tool), 0);
|
|
|
|
|
2004-05-05 00:01:19 +00:00
|
|
|
image_map_tool->main_vbox = vbox = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox);
|
|
|
|
|
|
|
|
/* The preview toggle */
|
2004-02-22 14:28:53 +00:00
|
|
|
toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
|
|
|
|
"preview",
|
|
|
|
_("_Preview"));
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 15:25:15 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox), toggle,
|
|
|
|
FALSE, FALSE, 0);
|
2002-08-26 11:35:56 +00:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
2004-03-11 12:36:10 +00:00
|
|
|
g_signal_connect_object (tool_info->tool_options, "notify::preview",
|
|
|
|
G_CALLBACK (gimp_image_map_tool_notify_preview),
|
|
|
|
image_map_tool, 0);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
if (klass->load_dialog_title)
|
|
|
|
{
|
|
|
|
image_map_tool->load_button =
|
2004-10-22 19:44:03 +00:00
|
|
|
g_object_new (GIMP_TYPE_BUTTON,
|
|
|
|
"label", GTK_STOCK_OPEN,
|
|
|
|
"use_stock", TRUE,
|
|
|
|
"use_underline", TRUE,
|
|
|
|
NULL);
|
2004-02-25 13:55:45 +00:00
|
|
|
|
|
|
|
g_signal_connect (image_map_tool->load_button, "clicked",
|
|
|
|
G_CALLBACK (gimp_image_map_tool_load_clicked),
|
|
|
|
image_map_tool);
|
2004-10-22 19:44:03 +00:00
|
|
|
|
|
|
|
g_signal_connect (image_map_tool->load_button, "extended_clicked",
|
|
|
|
G_CALLBACK (gimp_image_map_tool_load_ext_clicked),
|
|
|
|
image_map_tool);
|
|
|
|
|
|
|
|
if (klass->load_button_tip)
|
|
|
|
{
|
|
|
|
gchar *str = g_strdup_printf ("%s\n"
|
|
|
|
"%s %s",
|
|
|
|
klass->load_button_tip,
|
|
|
|
gimp_get_mod_string (GDK_SHIFT_MASK),
|
|
|
|
_("Quick Load"));
|
|
|
|
|
|
|
|
gimp_help_set_help_data (image_map_tool->load_button, str, NULL);
|
|
|
|
g_free (str);
|
|
|
|
}
|
2004-02-25 13:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (klass->save_dialog_title)
|
|
|
|
{
|
|
|
|
image_map_tool->save_button =
|
2004-10-22 19:44:03 +00:00
|
|
|
g_object_new (GIMP_TYPE_BUTTON,
|
|
|
|
"label", GTK_STOCK_SAVE,
|
|
|
|
"use_stock", TRUE,
|
|
|
|
"use_underline", TRUE,
|
|
|
|
NULL);
|
2004-02-25 13:55:45 +00:00
|
|
|
|
|
|
|
g_signal_connect (image_map_tool->save_button, "clicked",
|
|
|
|
G_CALLBACK (gimp_image_map_tool_save_clicked),
|
|
|
|
image_map_tool);
|
2004-10-22 19:44:03 +00:00
|
|
|
|
|
|
|
g_signal_connect (image_map_tool->save_button, "extended_clicked",
|
|
|
|
G_CALLBACK (gimp_image_map_tool_save_ext_clicked),
|
|
|
|
image_map_tool);
|
|
|
|
|
|
|
|
if (klass->save_button_tip)
|
|
|
|
{
|
|
|
|
gchar *str = g_strdup_printf ("%s\n"
|
|
|
|
"%s %s",
|
|
|
|
klass->save_button_tip,
|
|
|
|
gimp_get_mod_string (GDK_SHIFT_MASK),
|
|
|
|
_("Quick Save"));
|
|
|
|
|
|
|
|
gimp_help_set_help_data (image_map_tool->save_button, str, NULL);
|
|
|
|
g_free (str);
|
|
|
|
}
|
2004-02-25 13:55:45 +00:00
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
/* Fill in subclass widgets */
|
|
|
|
gimp_image_map_tool_dialog (image_map_tool);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
}
|
|
|
|
|
2002-08-28 19:47:07 +00:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
|
|
|
|
2002-08-30 21:00:42 +00:00
|
|
|
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (image_map_tool->shell),
|
|
|
|
GIMP_VIEWABLE (drawable));
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
gtk_widget_show (image_map_tool->shell);
|
|
|
|
|
|
|
|
image_map_tool->drawable = drawable;
|
2004-07-29 14:16:21 +00:00
|
|
|
image_map_tool->image_map = gimp_image_map_new (drawable, tool_info->blurb);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (image_map_tool->image_map, "flush",
|
2002-08-26 11:35:56 +00:00
|
|
|
G_CALLBACK (gimp_image_map_tool_flush),
|
|
|
|
image_map_tool);
|
|
|
|
|
2004-01-21 16:07:48 +00:00
|
|
|
return TRUE;
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_control (GimpTool *tool,
|
2004-07-29 14:16:21 +00:00
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *gdisp)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2003-06-05 18:47:23 +00:00
|
|
|
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case HALT:
|
|
|
|
if (image_map_tool->shell)
|
2003-11-06 15:27:05 +00:00
|
|
|
gtk_dialog_response (GTK_DIALOG (image_map_tool->shell),
|
|
|
|
GTK_RESPONSE_CANCEL);
|
2002-08-26 11:35:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
|
|
|
}
|
|
|
|
|
2004-10-01 15:15:14 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_image_map_tool_key_press (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
|
|
|
|
|
|
|
if (gdisp == tool->gdisp)
|
|
|
|
{
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
case GDK_KP_Enter:
|
|
|
|
case GDK_Return:
|
|
|
|
gimp_image_map_tool_response (NULL, GTK_RESPONSE_OK, image_map_tool);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case GDK_Delete:
|
|
|
|
case GDK_BackSpace:
|
|
|
|
gimp_image_map_tool_response (NULL, RESPONSE_RESET, image_map_tool);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case GDK_Escape:
|
|
|
|
gimp_image_map_tool_response (NULL, GTK_RESPONSE_CANCEL, image_map_tool);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-05 18:47:23 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpImageType *sample_type,
|
|
|
|
GimpRGB *color,
|
|
|
|
gint *color_index)
|
|
|
|
{
|
|
|
|
GimpImageMapTool *tool = GIMP_IMAGE_MAP_TOOL (color_tool);
|
|
|
|
|
|
|
|
*sample_type = gimp_drawable_type (tool->drawable);
|
|
|
|
|
2004-07-13 23:04:05 +00:00
|
|
|
return gimp_pickable_pick_color (GIMP_PICKABLE (tool->image_map), x, y,
|
|
|
|
color_tool->options->sample_average,
|
|
|
|
color_tool->options->average_radius,
|
|
|
|
color, color_index);
|
2003-06-05 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
2002-08-26 11:35:56 +00:00
|
|
|
static void
|
2004-02-25 10:23:43 +00:00
|
|
|
gimp_image_map_tool_map (GimpImageMapTool *tool)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2004-02-25 10:23:43 +00:00
|
|
|
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-02-25 10:23:43 +00:00
|
|
|
gimp_image_map_tool_dialog (GimpImageMapTool *tool)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2004-02-25 10:23:43 +00:00
|
|
|
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->dialog (tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-02-25 10:23:43 +00:00
|
|
|
gimp_image_map_tool_reset (GimpImageMapTool *tool)
|
|
|
|
{
|
|
|
|
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-07-29 14:16:21 +00:00
|
|
|
gimp_image_map_tool_settings_load (GimpImageMapTool *tool,
|
|
|
|
gpointer file)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2004-02-25 15:56:50 +00:00
|
|
|
GimpImageMapToolClass *tool_class = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (tool_class->settings_load != NULL, FALSE);
|
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
if (tool_class->settings_load (tool, file))
|
|
|
|
{
|
|
|
|
gimp_image_map_tool_preview (tool);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2004-02-25 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-07-29 14:16:21 +00:00
|
|
|
gimp_image_map_tool_settings_save (GimpImageMapTool *tool,
|
|
|
|
gpointer file)
|
2004-02-25 10:23:43 +00:00
|
|
|
{
|
2004-02-25 15:56:50 +00:00
|
|
|
GimpImageMapToolClass *tool_class = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (tool_class->settings_save != NULL, FALSE);
|
|
|
|
|
|
|
|
return tool_class->settings_save (tool, file);
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_flush (GimpImageMap *image_map,
|
|
|
|
GimpImageMapTool *image_map_tool)
|
|
|
|
{
|
2003-11-06 15:27:05 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (image_map_tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-07-13 16:36:29 +00:00
|
|
|
gimp_projection_flush_now (tool->gdisp->gimage->projection);
|
2002-08-26 11:35:56 +00:00
|
|
|
gimp_display_flush_now (tool->gdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-06 15:27:05 +00:00
|
|
|
gimp_image_map_tool_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
GimpImageMapTool *image_map_tool)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2004-11-11 10:16:57 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (image_map_tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
switch (response_id)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2003-11-06 15:27:05 +00:00
|
|
|
case RESPONSE_RESET:
|
|
|
|
gimp_image_map_tool_reset (image_map_tool);
|
|
|
|
gimp_image_map_tool_preview (image_map_tool);
|
|
|
|
break;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
case GTK_RESPONSE_OK:
|
|
|
|
gtk_widget_hide (image_map_tool->shell);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-11-11 10:16:57 +00:00
|
|
|
if (image_map_tool->image_map)
|
|
|
|
{
|
|
|
|
GimpImageMapOptions *options;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-11-11 10:16:57 +00:00
|
|
|
options = GIMP_IMAGE_MAP_OPTIONS (tool->tool_info->tool_options);
|
2004-02-22 14:28:53 +00:00
|
|
|
|
2004-11-11 10:16:57 +00:00
|
|
|
gimp_tool_control_set_preserve (tool->control, TRUE);
|
|
|
|
|
|
|
|
if (! options->preview)
|
|
|
|
gimp_image_map_tool_map (image_map_tool);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
gimp_image_map_commit (image_map_tool->image_map);
|
|
|
|
image_map_tool->image_map = NULL;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-11-11 10:16:57 +00:00
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
|
|
|
|
|
|
|
gimp_image_flush (tool->gdisp->gimage);
|
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
tool->gdisp = NULL;
|
|
|
|
tool->drawable = NULL;
|
|
|
|
break;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
default:
|
|
|
|
gtk_widget_hide (image_map_tool->shell);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
if (image_map_tool->image_map)
|
|
|
|
{
|
|
|
|
gimp_tool_control_set_preserve (tool->control, TRUE);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
gimp_image_map_abort (image_map_tool->image_map);
|
|
|
|
image_map_tool->image_map = NULL;
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
2003-01-10 17:55:53 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
gimp_image_flush (tool->gdisp->gimage);
|
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2003-11-06 15:27:05 +00:00
|
|
|
tool->gdisp = NULL;
|
|
|
|
tool->drawable = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-02-22 14:28:53 +00:00
|
|
|
gimp_image_map_tool_notify_preview (GObject *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpImageMapTool *image_map_tool)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
2004-02-22 14:28:53 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (image_map_tool);
|
|
|
|
GimpImageMapOptions *options = GIMP_IMAGE_MAP_OPTIONS (config);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-02-22 14:28:53 +00:00
|
|
|
if (options->preview)
|
2002-08-26 11:35:56 +00:00
|
|
|
{
|
|
|
|
gimp_tool_control_set_preserve (tool->control, TRUE);
|
|
|
|
|
|
|
|
gimp_image_map_tool_map (image_map_tool);
|
|
|
|
|
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (image_map_tool->image_map)
|
2004-07-29 14:16:21 +00:00
|
|
|
{
|
|
|
|
gimp_tool_control_set_preserve (tool->control, TRUE);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-07-29 14:16:21 +00:00
|
|
|
gimp_image_map_clear (image_map_tool->image_map);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-07-29 14:16:21 +00:00
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
2002-08-26 11:35:56 +00:00
|
|
|
|
2004-07-29 14:16:21 +00:00
|
|
|
gimp_image_flush (tool->gdisp->gimage);
|
|
|
|
}
|
2002-08-26 11:35:56 +00:00
|
|
|
}
|
2001-05-24 23:57:08 +00:00
|
|
|
}
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_image_map_tool_preview (GimpImageMapTool *image_map_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpImageMapOptions *options;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (image_map_tool));
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (image_map_tool);
|
|
|
|
|
|
|
|
options = GIMP_IMAGE_MAP_OPTIONS (tool->tool_info->tool_options);
|
|
|
|
|
|
|
|
if (options->preview)
|
|
|
|
{
|
|
|
|
gimp_tool_control_set_preserve (tool->control, TRUE);
|
|
|
|
|
|
|
|
gimp_image_map_tool_map (image_map_tool);
|
|
|
|
|
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-22 19:44:03 +00:00
|
|
|
static void
|
|
|
|
gimp_image_map_tool_load_save (GimpImageMapTool *tool,
|
|
|
|
const gchar *filename,
|
|
|
|
gboolean save)
|
|
|
|
{
|
|
|
|
FILE *file = fopen (filename, save ? "wt" : "rt");
|
|
|
|
|
|
|
|
if (! file)
|
|
|
|
{
|
|
|
|
g_message (save ?
|
|
|
|
_("Could not open '%s' for writing: %s") :
|
|
|
|
_("Could not open '%s' for reading: %s"),
|
|
|
|
gimp_filename_to_utf8 (filename),
|
|
|
|
g_strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set (GIMP_TOOL (tool)->tool_info->tool_options,
|
|
|
|
"settings", filename,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (save)
|
|
|
|
{
|
|
|
|
gimp_image_map_tool_settings_save (tool, file);
|
|
|
|
}
|
|
|
|
else if (! gimp_image_map_tool_settings_load (tool, file))
|
|
|
|
{
|
|
|
|
g_message ("Error in reading file '%s'.",
|
|
|
|
gimp_filename_to_utf8 (filename));
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose (file);
|
|
|
|
}
|
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
static void
|
|
|
|
settings_dialog_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpImageMapTool *tool)
|
|
|
|
{
|
2004-02-25 15:56:50 +00:00
|
|
|
gboolean save;
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
save = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "save"));
|
|
|
|
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
2004-04-15 16:28:26 +00:00
|
|
|
gchar *filename;
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-10-22 19:44:03 +00:00
|
|
|
gimp_image_map_tool_load_save (tool, filename, save);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
g_free (filename);
|
2004-02-25 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
if (save)
|
|
|
|
gtk_widget_set_sensitive (tool->load_button, TRUE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (tool->save_button, TRUE);
|
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
static void
|
|
|
|
gimp_image_map_tool_load_clicked (GtkWidget *widget,
|
2004-10-22 19:44:03 +00:00
|
|
|
GimpImageMapTool *tool)
|
|
|
|
{
|
|
|
|
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
|
|
|
|
|
|
|
|
gimp_image_map_tool_settings_dialog (tool, klass->load_dialog_title, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_load_ext_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpImageMapTool *tool)
|
2004-02-25 13:55:45 +00:00
|
|
|
{
|
2004-10-22 19:44:03 +00:00
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
g_object_get (GIMP_TOOL (tool)->tool_info->tool_options,
|
|
|
|
"settings", &filename,
|
|
|
|
NULL);
|
2004-02-25 13:55:45 +00:00
|
|
|
|
2004-10-22 19:44:03 +00:00
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
gimp_image_map_tool_load_save (tool, filename, FALSE);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_map_tool_load_clicked (widget, tool);
|
|
|
|
}
|
|
|
|
}
|
2004-02-25 13:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_save_clicked (GtkWidget *widget,
|
2004-10-22 19:44:03 +00:00
|
|
|
GimpImageMapTool *tool)
|
|
|
|
{
|
|
|
|
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
|
|
|
|
|
|
|
|
gimp_image_map_tool_settings_dialog (tool, klass->save_dialog_title, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_map_tool_save_ext_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpImageMapTool *tool)
|
2004-02-25 13:55:45 +00:00
|
|
|
{
|
2004-10-22 19:44:03 +00:00
|
|
|
if (state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
2004-02-25 13:55:45 +00:00
|
|
|
|
2004-10-22 19:44:03 +00:00
|
|
|
g_object_get (GIMP_TOOL (tool)->tool_info->tool_options,
|
|
|
|
"settings", &filename,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
gimp_image_map_tool_load_save (tool, filename, TRUE);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_map_tool_save_clicked (widget, tool);
|
|
|
|
}
|
|
|
|
}
|
2004-02-25 13:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-02-25 10:23:43 +00:00
|
|
|
gimp_image_map_tool_settings_dialog (GimpImageMapTool *tool,
|
|
|
|
const gchar *title,
|
|
|
|
gboolean save)
|
|
|
|
{
|
|
|
|
GimpImageMapOptions *options;
|
2004-04-15 16:28:26 +00:00
|
|
|
GtkFileChooser *chooser;
|
2004-09-28 08:23:25 +00:00
|
|
|
const gchar *settings_name;
|
2004-09-27 22:44:28 +00:00
|
|
|
gchar *folder;
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool));
|
|
|
|
|
2004-09-28 08:23:25 +00:00
|
|
|
settings_name = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->settings_name;
|
|
|
|
g_return_if_fail (settings_name != NULL);
|
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
if (tool->settings_dialog)
|
|
|
|
{
|
|
|
|
gtk_window_present (GTK_WINDOW (tool->settings_dialog));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-25 13:55:45 +00:00
|
|
|
if (save)
|
|
|
|
gtk_widget_set_sensitive (tool->load_button, FALSE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (tool->save_button, FALSE);
|
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
tool->settings_dialog =
|
|
|
|
gtk_file_chooser_dialog_new (title, GTK_WINDOW (tool->shell),
|
|
|
|
save ?
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE :
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
save ? GTK_STOCK_SAVE : GTK_STOCK_OPEN,
|
|
|
|
GTK_RESPONSE_OK,
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
NULL);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
chooser = GTK_FILE_CHOOSER (tool->settings_dialog);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
g_object_set_data (G_OBJECT (chooser), "save", GINT_TO_POINTER (save));
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
gtk_window_set_role (GTK_WINDOW (chooser), "gimp-load-save-settings");
|
|
|
|
gtk_window_set_position (GTK_WINDOW (chooser), GTK_WIN_POS_MOUSE);
|
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (chooser),
|
2004-02-25 10:23:43 +00:00
|
|
|
(gpointer) &tool->settings_dialog);
|
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-04-15 16:28:26 +00:00
|
|
|
g_signal_connect (chooser, "response",
|
2004-02-25 10:23:43 +00:00
|
|
|
G_CALLBACK (settings_dialog_response),
|
|
|
|
tool);
|
2004-04-15 16:28:26 +00:00
|
|
|
g_signal_connect (chooser, "delete_event",
|
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-09-28 08:23:25 +00:00
|
|
|
folder = g_build_filename (gimp_directory (), settings_name, NULL);
|
|
|
|
gtk_file_chooser_add_shortcut_folder (chooser, folder, NULL);
|
2004-09-27 22:44:28 +00:00
|
|
|
|
2004-02-25 10:23:43 +00:00
|
|
|
options = GIMP_IMAGE_MAP_OPTIONS (GIMP_TOOL (tool)->tool_info->tool_options);
|
|
|
|
|
|
|
|
if (options->settings)
|
2004-09-27 22:44:28 +00:00
|
|
|
gtk_file_chooser_set_filename (chooser, options->settings);
|
|
|
|
else
|
|
|
|
gtk_file_chooser_set_current_folder (chooser, folder);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
2004-09-27 22:44:28 +00:00
|
|
|
g_free (folder);
|
2004-02-25 10:23:43 +00:00
|
|
|
|
|
|
|
gimp_help_connect (tool->settings_dialog, gimp_standard_help_func,
|
|
|
|
GIMP_TOOL (tool)->tool_info->help_id, NULL);
|
|
|
|
|
|
|
|
gtk_widget_show (tool->settings_dialog);
|
|
|
|
}
|