1999-09-07 08:03:20 +08:00
|
|
|
/*
|
2007-06-06 16:44:52 +08:00
|
|
|
* This is a plug-in for GIMP.
|
1999-09-07 08:03:20 +08:00
|
|
|
*
|
|
|
|
* Generates clickable image maps.
|
|
|
|
*
|
2006-07-14 21:37:56 +08:00
|
|
|
* Copyright (C) 1998-2006 Maurits Rijk m.rijk@chello.nl
|
1999-09-07 08:03:20 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1999-09-07 08:03:20 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1999-09-07 08:03:20 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1999-09-07 08:03:20 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-11-05 10:47:39 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-02 05:13:05 +08:00
|
|
|
#include "libgimp/gimp.h"
|
|
|
|
#include "libgimp/gimpui.h"
|
2007-01-03 19:05:04 +08:00
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
#include "imap_about.h"
|
1999-09-07 08:03:20 +08:00
|
|
|
#include "imap_circle.h"
|
|
|
|
#include "imap_file.h"
|
|
|
|
#include "imap_grid.h"
|
2019-07-22 01:47:39 +08:00
|
|
|
#include "imap_icons.h"
|
1999-09-07 08:03:20 +08:00
|
|
|
#include "imap_main.h"
|
|
|
|
#include "imap_menu.h"
|
|
|
|
#include "imap_menu_funcs.h"
|
|
|
|
#include "imap_polygon.h"
|
|
|
|
#include "imap_preferences.h"
|
|
|
|
#include "imap_rectangle.h"
|
|
|
|
#include "imap_settings.h"
|
|
|
|
#include "imap_source.h"
|
|
|
|
|
2001-11-05 10:47:39 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
2005-01-02 16:07:03 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
void
|
|
|
|
menu_set_zoom_sensitivity (gpointer data,
|
|
|
|
gint factor)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GAction *action;
|
|
|
|
GimpImap *imap = GIMP_IMAP (data);
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "zoom-in");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), factor < 8);
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "zoom-out");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), factor > 1);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
2006-07-14 21:37:56 +08:00
|
|
|
void
|
2023-02-15 12:29:39 +08:00
|
|
|
menu_set_zoom (gpointer data,
|
|
|
|
gint factor)
|
2006-07-14 21:37:56 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
menu_set_zoom_sensitivity (data, factor);
|
2006-07-14 21:37:56 +08:00
|
|
|
}
|
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
void
|
2023-02-15 12:29:39 +08:00
|
|
|
menu_shapes_selected (gint count,
|
|
|
|
gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GimpImap *imap = GIMP_IMAP (data);
|
2005-01-02 16:07:03 +08:00
|
|
|
gboolean sensitive = (count > 0);
|
2023-02-15 12:29:39 +08:00
|
|
|
GAction *action;
|
2007-05-11 03:29:47 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "cut");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "copy");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "clear");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "edit-area-info");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "deselect-all");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-02-15 12:29:39 +08:00
|
|
|
command_list_changed (Command_t *command,
|
|
|
|
gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GAction *action;
|
|
|
|
GimpImap *imap;
|
|
|
|
gchar *label;
|
2007-05-11 03:29:47 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
imap = GIMP_IMAP (data);
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "undo");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), command != NULL);
|
2007-05-11 03:29:47 +08:00
|
|
|
|
|
|
|
label = g_strdup_printf (_("_Undo %s"),
|
|
|
|
command && command->name ? command->name : "");
|
2023-02-15 12:29:39 +08:00
|
|
|
/* TODO: Find a way to change GAction label in menu for undo */
|
2007-05-11 03:29:47 +08:00
|
|
|
g_free (label);
|
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
command = command_list_get_redo_command ();
|
2007-05-11 03:29:47 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "redo");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), command != NULL);
|
2007-05-11 03:29:47 +08:00
|
|
|
|
|
|
|
label = g_strdup_printf (_("_Redo %s"),
|
|
|
|
command && command->name ? command->name : "");
|
2023-02-15 12:29:39 +08:00
|
|
|
/* TODO: Find a way to change GAction label in menu for redo */
|
2007-05-11 03:29:47 +08:00
|
|
|
g_free (label);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-02-15 12:29:39 +08:00
|
|
|
paste_buffer_added (Object_t *obj, gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GAction *action;
|
|
|
|
GimpImap *imap = GIMP_IMAP (data);
|
|
|
|
|
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-02-15 12:29:39 +08:00
|
|
|
paste_buffer_removed (Object_t *obj, gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GAction *action;
|
|
|
|
GimpImap *imap = GIMP_IMAP (data);
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
|
|
|
|
}
|
1999-09-07 08:03:20 +08:00
|
|
|
|
|
|
|
Menu_t*
|
2023-02-15 12:29:39 +08:00
|
|
|
make_menu (GimpImap *imap)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GAction *action;
|
2005-01-02 16:07:03 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
paste_buffer_add_add_cb (paste_buffer_added, imap);
|
|
|
|
paste_buffer_add_remove_cb (paste_buffer_removed, imap);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
|
|
|
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
menu_shapes_selected (0, imap);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
menu_set_zoom_sensitivity (imap, 1);
|
2005-01-02 16:07:03 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
command_list_add_update_cb (command_list_changed, imap);
|
2005-01-02 16:07:03 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
command_list_changed (NULL, imap);
|
2005-01-02 16:07:03 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
return NULL;
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-15 12:29:39 +08:00
|
|
|
do_main_popup_menu (GdkEventButton *event,
|
|
|
|
gpointer data)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2023-02-15 12:29:39 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GMenuModel *model;
|
|
|
|
GimpImap *imap = GIMP_IMAP (data);
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
model = G_MENU_MODEL (gtk_builder_get_object (imap->builder, "imap-main-popup"));
|
|
|
|
menu = gtk_menu_new_from_model (model);
|
2018-05-02 05:21:04 +08:00
|
|
|
|
2023-02-15 12:29:39 +08:00
|
|
|
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (imap->dlg), NULL);
|
|
|
|
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
|
2005-01-23 19:21:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
2023-02-15 12:29:39 +08:00
|
|
|
make_selection_toolbar (GimpImap *imap)
|
|
|
|
{
|
|
|
|
GtkWidget *toolbar = gtk_toolbar_new ();
|
|
|
|
|
|
|
|
add_tool_button (toolbar, "app.move-up", GIMP_ICON_GO_UP,
|
|
|
|
_("Move Up"), _("Move Up"));
|
|
|
|
add_tool_button (toolbar, "app.move-down", GIMP_ICON_GO_DOWN,
|
|
|
|
_("Move Down"), _("Move Down"));
|
|
|
|
add_tool_button (toolbar, "app.edit-area-info", GIMP_ICON_EDIT,
|
|
|
|
_("Edit Area Info..."), _("Edit selected area info"));
|
|
|
|
add_tool_button (toolbar, "app.clear", GIMP_ICON_EDIT_DELETE,
|
|
|
|
_("Delete"), _("Delete"));
|
2005-01-23 19:21:01 +08:00
|
|
|
|
2009-05-25 01:41:18 +08:00
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (toolbar), 0);
|
2005-01-23 19:21:01 +08:00
|
|
|
|
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
return toolbar;
|
|
|
|
}
|