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

« back to all changes in this revision

Viewing changes to plug-ins/imagemap/imap_popup.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
 
/*
2
 
 * This is a plug-in for the GIMP.
3
 
 *
4
 
 * Generates clickable image maps.
5
 
 *
6
 
 * Copyright (C) 1998-2002 Maurits Rijk  lpeek.mrijk@consunet.nl
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or modify
9
 
 * it under the terms of the GNU General Public License as published by
10
 
 * the Free Software Foundation; either version 2 of the License, or
11
 
 * (at your option) any later version.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program; if not, write to the Free Software
20
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
 
 *
22
 
 */
23
 
 
24
 
#include "config.h"
25
 
 
26
 
#include <gtk/gtk.h>
27
 
 
28
 
#include "imap_edit_area_info.h"
29
 
#include "imap_grid.h"
30
 
#include "imap_main.h"
31
 
#include "imap_menu.h"
32
 
#include "imap_menu_funcs.h"
33
 
#include "imap_popup.h"
34
 
#include "imap_stock.h"
35
 
#include "imap_tools.h"
36
 
 
37
 
#include "libgimp/stdplugins-intl.h"
38
 
 
39
 
static gint _popup_callback_lock;
40
 
static PopupMenu_t _popup;
41
 
 
42
 
void
43
 
popup_set_zoom_sensitivity(gint factor)
44
 
{
45
 
   gtk_widget_set_sensitive(_popup.zoom_in, factor < 8);
46
 
   gtk_widget_set_sensitive(_popup.zoom_out, factor > 1);
47
 
}
48
 
 
49
 
static void
50
 
popup_rectangle(GtkWidget *widget, gpointer data)
51
 
{
52
 
   if (_popup_callback_lock) {
53
 
      _popup_callback_lock = FALSE;
54
 
   } else {
55
 
      set_rectangle_func();
56
 
      tools_select_rectangle();
57
 
      menu_select_rectangle();
58
 
   }
59
 
}
60
 
 
61
 
static void
62
 
popup_circle(GtkWidget *widget, gpointer data)
63
 
{
64
 
   if (_popup_callback_lock) {
65
 
      _popup_callback_lock = FALSE;
66
 
   } else {
67
 
      set_circle_func();
68
 
      tools_select_circle();
69
 
      menu_select_circle();
70
 
   }
71
 
}
72
 
 
73
 
static void
74
 
popup_polygon(GtkWidget *widget, gpointer data)
75
 
{
76
 
   if (_popup_callback_lock) {
77
 
      _popup_callback_lock = FALSE;
78
 
   } else {
79
 
      set_polygon_func();
80
 
      tools_select_polygon();
81
 
      menu_select_polygon();
82
 
   }
83
 
}
84
 
 
85
 
static void
86
 
popup_arrow(GtkWidget *widget, gpointer data)
87
 
{
88
 
   if (_popup_callback_lock) {
89
 
      _popup_callback_lock = FALSE;
90
 
   } else {
91
 
      set_arrow_func();
92
 
      tools_select_arrow();
93
 
      menu_select_arrow();
94
 
   }
95
 
}
96
 
 
97
 
static void
98
 
popup_grid(GtkWidget *widget, gpointer data)
99
 
{
100
 
   if (_popup_callback_lock) {
101
 
      _popup_callback_lock = FALSE;
102
 
   } else {
103
 
      gint grid = toggle_grid();
104
 
      menu_check_grid(grid);
105
 
      main_toolbar_set_grid(grid);
106
 
   }
107
 
}
108
 
 
109
 
static void
110
 
paste_buffer_added(Object_t *obj, gpointer data)
111
 
{
112
 
   gtk_widget_set_sensitive((GtkWidget*) data, TRUE);
113
 
}
114
 
 
115
 
static void
116
 
paste_buffer_removed(Object_t *obj, gpointer data)
117
 
{
118
 
   gtk_widget_set_sensitive((GtkWidget*) data, TRUE);
119
 
}
120
 
 
121
 
PopupMenu_t*
122
 
create_main_popup_menu(void)
123
 
{
124
 
   GtkWidget *popup_menu, *sub_menu;
125
 
   GtkWidget *paste;
126
 
   GSList    *group;
127
 
 
128
 
   _popup.main = popup_menu = gtk_menu_new();
129
 
 
130
 
   make_item_with_image(popup_menu, IMAP_STOCK_MAP_INFO, menu_command,
131
 
                        &_popup.cmd_edit_map_info);
132
 
 
133
 
   sub_menu = make_sub_menu(popup_menu, _("Tools"));
134
 
   _popup.arrow = make_radio_item(sub_menu, NULL, _("Arrow"), popup_arrow,
135
 
                                  NULL);
136
 
   group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(_popup.arrow));
137
 
   _popup.rectangle = make_radio_item(sub_menu, group, _("Rectangle"),
138
 
                                      popup_rectangle, NULL);
139
 
   group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(_popup.rectangle));
140
 
   _popup.circle = make_radio_item(sub_menu, group, _("Circle"),
141
 
                                   popup_circle, NULL);
142
 
   group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(_popup.circle));
143
 
   _popup.polygon = make_radio_item(sub_menu, group, _("Polygon"),
144
 
                                    popup_polygon, NULL);
145
 
 
146
 
   sub_menu = make_sub_menu(popup_menu, _("Zoom"));
147
 
   _popup.zoom_in = make_item_with_image(sub_menu, GTK_STOCK_ZOOM_IN,
148
 
                                         menu_command, &_popup.cmd_zoom_in);
149
 
   _popup.zoom_out = make_item_with_image(sub_menu, GTK_STOCK_ZOOM_OUT,
150
 
                                          menu_command, &_popup.cmd_zoom_out);
151
 
   gtk_widget_set_sensitive(_popup.zoom_out, FALSE);
152
 
 
153
 
   _popup.grid = make_check_item(popup_menu, _("Grid"), popup_grid, NULL);
154
 
   make_item_with_label(popup_menu, _("Grid Settings..."), menu_command,
155
 
                        &_popup.cmd_grid_settings);
156
 
   make_item_with_label(popup_menu, _("Guides..."), menu_command,
157
 
                        &_popup.cmd_create_guides);
158
 
   paste = make_item_with_image(popup_menu, GTK_STOCK_PASTE, menu_command,
159
 
                                &_popup.cmd_paste);
160
 
   gtk_widget_set_sensitive(paste, FALSE);
161
 
   paste_buffer_add_add_cb(paste_buffer_added, (gpointer) paste);
162
 
   paste_buffer_add_remove_cb(paste_buffer_removed, (gpointer) paste);
163
 
 
164
 
   return &_popup;
165
 
}
166
 
 
167
 
void
168
 
do_main_popup_menu(GdkEventButton *event)
169
 
{
170
 
   gtk_menu_popup(GTK_MENU(_popup.main), NULL, NULL, NULL, NULL,
171
 
                  event->button, event->time);
172
 
}
173
 
 
174
 
static void
175
 
popup_select(GtkWidget *item)
176
 
{
177
 
   _popup_callback_lock = TRUE;
178
 
   gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
179
 
}
180
 
 
181
 
void
182
 
popup_select_arrow(void)
183
 
{
184
 
   popup_select(_popup.arrow);
185
 
}
186
 
 
187
 
void
188
 
popup_select_rectangle(void)
189
 
{
190
 
   popup_select(_popup.rectangle);
191
 
}
192
 
 
193
 
void
194
 
popup_select_circle(void)
195
 
{
196
 
   popup_select(_popup.circle);
197
 
}
198
 
 
199
 
void
200
 
popup_select_polygon(void)
201
 
{
202
 
   popup_select(_popup.polygon);
203
 
}
204
 
 
205
 
void
206
 
popup_check_grid(gboolean check)
207
 
{
208
 
   _popup_callback_lock = TRUE;
209
 
   gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_popup.grid), check);
210
 
}