Added Imagemap plug-in.

--Sven
This commit is contained in:
Sven Neumann 1999-09-07 00:03:20 +00:00
parent 9ebe7bbe09
commit d9ab679079
155 changed files with 24606 additions and 0 deletions

View file

@ -1,3 +1,10 @@
Tue Sep 7 02:03:18 MEST 1999 Sven Neumann <sven@gimp.org>
* configure.in
* plug-ins/Makefile.am
* plug-ins/imagemap/*: new files
Added the ImageMap plug-in by Maurits Rijk <lpeek.mrijk@consunet.nl>.
Tue Sep 7 00:35:19 CEST 1999 Marc Lehmann <pcg@goof.com>
* plug-ins/gflare: new directory, lotsa files!

View file

@ -699,6 +699,7 @@ plug-ins/gimpressionist/Brushes/Makefile
plug-ins/gimpressionist/Paper/Makefile
plug-ins/gimpressionist/Presets/Makefile
plug-ins/ifscompose/Makefile
plug-ins/imagemap/Makefile
plug-ins/maze/Makefile
plug-ins/mosaic/Makefile
plug-ins/pagecurl/Makefile

View file

@ -52,6 +52,7 @@ SUBDIRS = \
gfli \
gimpressionist \
ifscompose \
imagemap \
maze \
mosaic \
pagecurl \

View file

@ -0,0 +1,6 @@
Makefile.in
Makefile
.deps
_libs
.libs
imagemap

View file

@ -0,0 +1 @@
Maurits Rijk <lpeek.mrijk@consunet.nl>

213
plug-ins/imagemap/ChangeLog Normal file
View file

@ -0,0 +1,213 @@
Sat Aug 28 16:32:03 1999 Maurits Rijk <maurits@frop.edu>
* release version 1.2
Sun Aug 15 16:54:43 1999 Maurits Rijk <maurits@frop.edu>
* imap_cmd_select_region.h: created
* imap_cmd_move_sash.c: created
Mon Aug 9 22:33:12 1999 Maurits Rijk <maurits@frop.edu>
* imap_cmd_cut_object.c: created
* imap_cmd_cut_object.h: created
Sun Aug 8 12:54:44 1999 Maurits Rijk <maurits@frop.edu>
* imap_cmd_cut.c: created
* imap_cmd_insert_point.c: created
* imap_cmd_insert_point.h: created
* imap_cmd_delete_point.c: created
* imap_object_popup.h: created
Sat Jul 31 12:34:00 1999 Maurits Rijk <maurits@frop.edu>
* imap_toolbar.c: Added redo and undo button to toolbar.
Wed Jul 28 22:17:09 1999 Maurits Rijk <maurits@frop.edu>
* imap_object.c (object_on_button_press): fixed 'round to grid' bug
for polygons.
Tue Jul 27 23:19:00 1999 Maurits Rijk <maurits@frop.edu>
* imap_edit_area_info.c: use BrowseWidget_t for URL.
Mon Jul 26 22:00:58 1999 Maurits Rijk <maurits@frop.edu>
* imap_browse.c: created
* imap_object.c (object_list_move_selected_up): fixed move up/down bug.
Mon Jun 28 18:05:24 1999 Maurits Rijk <maurits@frop.edu>
* imap_main.c (dialog): fixed annoying bug
Sat Jun 26 16:25:33 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 1.1
Wed Jun 9 21:45:04 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_menu_funcs.c: created
Tue Jun 8 23:02:31 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_popup.c: created
Fri May 28 21:48:40 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 1.0
Wed May 26 22:16:20 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_object.c (do_object_locked_dialog): removed apply button in
message locked dialog.
* imap_default_dialog.c (make_default_dialog): handle delete event
Wed May 19 20:47:52 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_polygon.c (polygon_write_csim): Don't write last duplicate
point.
Fri May 14 16:10:39 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_main.c (close_current): freeze/thaw on selection
* imap_circle.c (circle_update): bug fix second props->x should be
props->y.
Thu May 13 13:54:45 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_main.c: issue warning when closing unsaved data.
* release version 0.9
Sun May 9 16:25:23 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_default_dialog.c: added 'apply' button.
* imap_polygon.c: replaced text entries by spinbuttons.
* imap_circle.c: replaced text entries by spinbuttons.
* imap_rectangle.c: replaced text entries by spinbuttons.
Sun Apr 25 21:55:36 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.7
Thu Apr 8 20:19:27 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.6
Sun Apr 4 20:52:57 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* Moved to GIMP 1.0.4 and GTK 1.2.1
Sun Mar 21 13:18:25 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_main.c (dialog): Changed auto_shrink to FALSE in
gtk_window_set_policy.
Sat Mar 20 11:50:34 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_main.c (do_data_changed_dialog): replaced some code with
default_dialog_set_label call.
Thu Mar 18 18:27:23 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.5
Sat Mar 13 13:36:00 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_settings.c (do_settings_dialog): set initial focus
Thu Mar 11 20:01:17 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_edit_area_info.c: show area number in dialog.
Tue Mar 9 22:26:49 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_table.c (create_spin_button_in_table): make spinbuttons always
numeric.
* imap_guides.c (make_guides_dialog): show image dimensions in dialog
Thu Mar 4 23:15:43 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_toolbar.c : added cut/copy/paste icons
Sun Feb 28 15:29:14 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.4
Sun Jan 31 17:09:52 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* Makefile (CC): removed C++ stuff
Sat Jan 30 21:55:10 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.3
Sun Jan 24 18:04:33 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_main.c (save_as): write width and height off image to file.
* imap_selection.c : finished 'selection' operations.
* imap_object.c : implemented 'move to front' and 'send to back'.
Thu Jan 21 20:02:43 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_edit_area_info.c : added Browse functionality for URL field.
Tue Jan 19 19:41:26 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_about.c : use DefaultDialog_t
Sat Jan 16 13:33:17 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_edit_area_info.c : new JavaScript tab
* imap_main.c : implemented title in main dialog
* imap_file.c : added file error dialog
Thu Jan 14 20:27:43 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.2
Wed Jan 13 21:21:17 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_toolbar.c : added move to front/send to back icons
Tue Jan 12 19:33:00 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_grid.c : implemented 'round to grid'
Mon Jan 11 22:35:29 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_grid.c: completed implementation
Tue Jan 5 22:48:34 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imap_polygon.c: completed polygon info tab
* imap_tools.c (make_tools): implemented radio behaviour
Mon Jan 3 20:18:57 1999 Maurits Rijk <lpeek.mrijk@consunet.nl>
* release version 0.1
Sun Dec 27 12:13:51 1998 Maurits Rijk <lpeek.mrijk@consunet.nl>
* imagemap.c: started coding

View file

@ -0,0 +1,115 @@
## Process this file with automake to produce Makefile.in
libexecdir = $(gimpplugindir)/plug-ins
libexec_PROGRAMS = imagemap
EXTRA_DIST = \
arrow.xpm \
arrow_down.xpm \
arrow_up.xpm \
circle.xpm \
coord.xpm \
copy.xpm \
cut.xpm \
delete.xpm \
dimension.xpm \
edit.xpm \
grid.xpm \
map_info.xpm \
open.xpm \
paste.xpm \
polygon.xpm \
preferences.xpm \
rectangle.xpm \
redo.xpm \
save.xpm \
to_back.xpm \
to_front.xpm \
undo.xpm \
zoom_in.xpm \
zoom_out.xpm \
ChangeLog \
AUTHORS \
NEWS \
README \
TODO
imagemap_SOURCES = \
imap_about.c \
imap_browse.c \
imap_circle.c \
imap_cern_lex.c \
imap_cern_parse.c \
imap_cmd_clear.c \
imap_cmd_copy.c \
imap_cmd_copy_object.c \
imap_cmd_create.c \
imap_cmd_cut.c \
imap_cmd_cut_object.c \
imap_cmd_delete.c \
imap_cmd_delete_point.c \
imap_cmd_edit_object.c \
imap_cmd_guides.c \
imap_cmd_insert_point.c \
imap_cmd_move.c \
imap_cmd_move_down.c \
imap_cmd_move_sash.c \
imap_cmd_move_to_front.c \
imap_cmd_move_up.c \
imap_cmd_object_down.c \
imap_cmd_object_up.c \
imap_cmd_paste.c \
imap_cmd_select.c \
imap_cmd_select_all.c \
imap_cmd_select_region.c \
imap_cmd_send_to_back.c \
imap_cmd_unselect.c \
imap_cmd_unselect_all.c \
imap_command.c \
imap_csim_lex.c \
imap_csim_parse.c \
imap_default_dialog.c \
imap_edit_area_info.c \
imap_file.c \
imap_grid.c \
imap_main.c \
imap_menu.c \
imap_menu_funcs.c \
imap_misc.c \
imap_mru.c \
imap_ncsa_lex.c \
imap_ncsa_parse.c \
imap_object.c \
imap_object_popup.c \
imap_polygon.c \
imap_popup.c \
imap_preferences.c \
imap_preview.c \
imap_rectangle.c \
imap_selection.c \
imap_settings.c \
imap_source.c \
imap_statusbar.c \
imap_string.c \
imap_table.c \
imap_toolbar.c \
imap_tools.c
INCLUDES = \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
-I$(includedir)
LDADD = \
$(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS) \
$(INTLLIBS)
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done

114
plug-ins/imagemap/NEWS Normal file
View file

@ -0,0 +1,114 @@
What's new in GIMP Imagemap plug-in 1.2
* Implemented Undo/Redo
* User defineable image URL in settings dialog.
* A few bug fixes.
What's new in GIMP Imagemap plug-in 1.1
* Rescale objects after rescaling of image.
* Added 2 new HTML 4.0 tags (ONFOCUS, ONBLUR)
* Option to make image gray to allow easier editing of images with lots of
colors.
* Most recently used list.
* Rectangular selection of objects.
* Drag and drop of links (e.g. from Netscape) to URL field.
* Usage of shift + left mousebutton during rectangle drawing makes width and
height equal.
* Usage of shift + left mousebutton at start of circle drawing defines 2 points
on circle side.
What's new in GIMP Imagemap plug-in 1.0
* Code cleanup
* Memory leaks fixed.
* All (?) bugs fixed.
* Use right mousebutton to cancel drawing operation of circle, rectangle or
polygon.
What's new in GIMP Imagemap plug-in 0.9
* Added list of standard prefixes (http://, news:, ftp://, gopher://, etc.)
before URL in settings dialog.
* Invalid input in dialogs (area settings, numeric values) is now handled
correctly.
* Add 'Apply' button to some dialogs.
* Default author field in settings dialog with user name.
* Show resulting source in 'View Source' dialog to allow copy/paste of
generated code to other programs.
What's new in GIMP Imagemap plug-in 0.7
* Plug-in now works correctly for GIF and grayscale images.
* Finished implementation of NCSA and CERN mapfiles.
* Implemented 'Close'.
* The usual bug fixes.
What's new in GIMP Imagemap plug-in 0.6
* Implemented 'Preferences' dialog:
* Dropped support for GTK 1.0.6. Support for GTK 1.2 and GIMP 1.1.x or
GIMP 1.0.4 has greatly improved.
* Synchronized Mapping menu items and toolbar items (arrow, rectangle, circle
and polygon)
* Synchronized zoom icon and 'Zoom To' menu item.
* synchronize grid icon and 'snap to grid' toggle button in 'grid settings'
dialog.
* Warn against overwriting of existing files.
* Lots of serious and cosmetic bug fixes.
What's new in GIMP Imagemap plug-in 0.5
* New better looking icons (thanks Mete Cirali!)
* Implemented 'Map Info' dialog.
* Add/remove polygon points by clicking with right mousebutton on edges/sashes.
* Added icon showing type (arrow, rectangle, circle) in selection.
* Implemented pop-up menu when right-button is pressed.
* Restrict size of preview window for large images.
* Shapes cannot be moved outside the picture anymore.
* Use hourglass cursor for lengthy operations (e.g. zooming, saving, loading).
* Show resulting dimension in 'guides' dialog.
* Added "cut/copy/paste/select all" functionality.
* You can now select multiple objects.
* Lots of bug fixes.
What's new in GIMP Imagemap plug-in 0.4
* Ported to Gimp 1.1.x and GTK 1.2
* Implemented zooming
* Removed C++ stuff. The binary immediately shrunk from 140 to 90k!
* Objects that are currently being edited cannot be deleted anymore.
* Show area info in statusbar when moving mouse over areas.
* Added warning dialog for unsaved changes when quiting.
What's new in GIMP Imagemap plug-in 0.3
* You can now load a CSIM file that was saved by this plug-in. Files saved by
other programs may cause problems. I haven't tested this yet.
* Accelerators in menus
* Selection operations (move up/down, delete, edit).
* Warning/error dialog for file operations
* Map-name in title in main dialog
* 'target frame name' in area settings.
* JavaScript (onMouseover, onMouseout) in area settings.
* Doubleclick on shape pops up area settings dialog.
* Browse button in URL field in area settings dialog.
* Fixed size of statusbar fields.
* Move to front/send to back
* Write image size in HTML file
* Deselect all if clicked in area with no object.
* Implement statusbar dimension field
* Added 4 extra handles to rectangular selection.
What's new in GIMP Imagemap plug-in 0.2
* Implementation of grid
* Properties tabs for rectangles, circles and polygons.
* Resizing of objects
* Moving objects
* Guide creation
* GUI for 'Map info' dialog
* 'Save' menu now popups 'Save As' dialog if no file is selected yet.
* Several minor cosmetic changes
GIMP Imagemap plug-in 0.1 released.

10
plug-ins/imagemap/README Normal file
View file

@ -0,0 +1,10 @@
This is the GIMP Imagemap plug-in version 1.2. See the INSTALL file for
build instructions.
More information can be found on my homepage at
http://home-2.consunet.nl/~cb007736/imagemap.html
Have fun,
Maurits Rijk (lpeek.mrijk@consunet.nl)

50
plug-ins/imagemap/TODO Normal file
View file

@ -0,0 +1,50 @@
Version 1.3
* 'Follow' mode to dynamically update object dimensions.
* Configuration script
* Handle double-click in selection
* Movement/resizing of objects with cursor keys.
* implement dynamically adjustable grid.
* Snap to grid during resize.
Version 1.4
* 'Divider' object.
* Move polygon sides.
* Gimp style guides.
Version 1.5
* Standalone version
* Warning icon for area's without URL.
* Add HTML 4.0 tags (TABINDEX, ACCESKEY)
* User-definable tags
* Use shift mousebutton to restrict polygon drawing direction.
Version 1.9
* Freehand drawing of polygon
* 'Morph to' functions (Polygon <-> circle <-> Rectangle)
* Write manual
Version 2.0
* Same as 1.9 with bugs fixed
* Code cleanup
BUGS
* Polygon not limited to 100 points (Is this really neccessary?)
* Rulers move when scrolling in preview window (see interface.c in Gimp).
* 'Move' only moves current object.
Miscellaneous
* Zooming performance is poor
* Compare image-name in HTML file with loaded image and issue warning
if different.
* Restrict to screen size for large images.
* Internationalization
* Drag & drop within selection

View file

@ -0,0 +1,22 @@
/* XPM */
static char * arrow_xpm[] = {
"16 16 3 1",
" c None",
". c #000000",
"+ c #808080",
" ",
" . ",
" .. ",
" ... ",
" .... ",
" ..... ",
" ...... ",
" ....... ",
" ........ ",
" ..... ",
" .. ..+ ",
" . +.. ",
" ..+ ",
" +.. ",
" .. ",
" "};

View file

@ -0,0 +1,26 @@
/* XPM */
static char * arrow_down_xpm[] = {
"16 16 7 1",
" c None",
". c #000000",
"+ c #248124",
"@ c #489F48",
"# c #6DBD6D",
"$ c #6DBC6D",
"% c #91DA91",
" ",
" ",
" ............. ",
" .++++++++@. ",
" .+@@@@@@#@. ",
" .@$####@. ",
" .@$%%%#@. ",
" .@$%#@. ",
" .@$%#@. ",
" .@$@. ",
" .@$@. ",
" .@. ",
" .@. ",
" . ",
" . ",
" "};

View file

@ -0,0 +1,27 @@
/* XPM */
static char * arrow_up_xpm[] = {
"16 16 8 1",
" c None",
". c #000000",
"+ c #1D7B1D",
"@ c #3A933A",
"# c #57AB57",
"$ c #74C274",
"% c #91DA91",
"& c #74C374",
" ",
" . ",
" . ",
" .+. ",
" .@. ",
" .@#@. ",
" .@#@. ",
" .@#$#@. ",
" .@#$#@. ",
" .@#$%&#@. ",
" .@#&&&#@. ",
" .+#######@. ",
" .@@@@@@@@@. ",
" ............. ",
" ",
" "};

View file

@ -0,0 +1,33 @@
/* XPM */
static char * circle_xpm[] = {
"16 16 14 1",
" c None",
". c #000000",
"+ c #7A99D5",
"@ c #7BA2DC",
"# c #729EDB",
"$ c #72A0DC",
"% c #7DB0E7",
"& c #7DB2E8",
"* c #7BA0DB",
"= c #7EB7EC",
"- c #7EB9EE",
"; c #7EB6EB",
"> c #7EBAEE",
", c #7FBAEF",
" ",
" .... ",
" ..++++.. ",
" .@@@@@@@@. ",
" .@##$$$$##@. ",
" .@#%&&&&%#*. ",
" .+@$&===-;%#@. ",
" .+@$&=>,-;%#@. ",
" .+@$&=,,-;%#@. ",
" .+@$&----;%#@. ",
" .@#%;;;;%#@. ",
" .@#$%%%%#$@. ",
" .@@####@@. ",
" ..@@@@.. ",
" .... ",
" "};

View file

@ -0,0 +1,22 @@
/* XPM */
static char * coord_xpm[] = {
"16 16 3 1",
" c None",
". c red",
"X c black",
" ",
" . ",
" . ",
" . ",
"... ... X X X X ",
" . ",
" . X ",
" . ",
" X ",
" X ",
" X ",
" X ",
" X ",
" X ",
" X ",
" X X X X X X "};

View file

@ -0,0 +1,23 @@
/* XPM */
static char * copy_xpm[] = {
"16 16 4 1",
" c black",
". c None",
"X c blue",
"o c white",
" .....X..",
" oooooo ....X..",
" o o .XXXXX",
" oooooooo ...X..",
" o o ...X..",
" ooooo ..",
" o o oooooo .",
" ooooo o o ",
" o o oooooooo ",
" ooooo o o ",
" oooooooo ",
"...... o o ",
"...... oooooooo ",
"...... o o ",
"...... oooooooo ",
"...... "};

24
plug-ins/imagemap/cut.xpm Normal file
View file

@ -0,0 +1,24 @@
/* XPM */
static char * cut_xpm[] = {
"16 16 5 1",
" c None",
". c #808080",
"X c #000080",
"o c #7B0000",
"O c #670000",
" ",
" . . ",
" . . ",
" X X ",
" X. .X ",
" XX XX ",
" .X X. ",
" XXX ",
" .X. ",
" ooo ",
" o ooo ",
" ooo o Oo ",
" oO o o o ",
" o o oO o ",
" o Oo oo ",
" oo "};

View file

@ -0,0 +1,105 @@
/* XPM */
static char * delete_xpm[] = {
"16 16 86 1",
" c None",
". c #9D3E3E",
"+ c #882323",
"@ c #CC2F31",
"# c #642728",
"$ c #F57474",
"% c #F91F1F",
"& c #9F2D2E",
"* c #D76467",
"= c #F66D6D",
"- c #FEA9A9",
"; c #F41212",
"> c #6B3333",
", c #CA3739",
"' c #FE2C2C",
") c #F60203",
"! c #973338",
"~ c #DC3033",
"{ c #FD1111",
"] c #FE0D0D",
"^ c #FC0101",
"/ c #C20405",
"( c #3B1215",
"_ c #C91616",
": c #FE0101",
"< c #E90505",
"[ c #783E40",
"} c #E22627",
"| c #FF0000",
"1 c #FE0000",
"2 c #F30000",
"3 c #8E0004",
"4 c #360B36",
"5 c #CD1111",
"6 c #DD080A",
"7 c #E22020",
"8 c #DF0001",
"9 c #691417",
"0 c #D40405",
"a c #C10003",
"b c #500221",
"c c #760303",
"d c #F50000",
"e c #F40000",
"f c #C30003",
"g c #513740",
"h c #D90610",
"i c #DB000F",
"j c #D1000F",
"k c #CC0014",
"l c #A30A1A",
"m c #CF0017",
"n c #6E0010",
"o c #71323D",
"p c #B30221",
"q c #9F082B",
"r c #732233",
"s c #B7001F",
"t c #720016",
"u c #221E21",
"v c #AB3B7C",
"w c #97002E",
"x c #790A46",
"y c #980B35",
"z c #71021E",
"A c #271C21",
"B c #9A3474",
"C c #770333",
"D c #551530",
"E c #7A002A",
"F c #241218",
"G c #732962",
"H c #510549",
"I c #6C0D37",
"J c #351427",
"K c #2E3030",
"L c #582462",
"M c #73567D",
"N c #331926",
"O c #4E1A41",
"P c #1C1F20",
"Q c #3C0F56",
"R c #59415F",
"S c #524D52",
"T c #261333",
"U c #3A1753",
" ",
" .+ @ ",
" #$%& *=-;> ",
" ,')! ~{]^/( ",
" _:<[ }|1234 ",
" 51671|89 ",
" 0111ab ",
" cdefg ",
" hijk ",
" lmnopq ",
" rstu vwx ",
" yzA BC ",
" DEF GH ",
" IJK LM ",
" NOP Q ",
" RS TU "};

View file

@ -0,0 +1,22 @@
/* XPM */
static char * dimension_xpm[] = {
"16 16 3 1",
" c None",
". c red",
"X c black",
" . . ",
" X ",
" . XXXXX . ",
" X ",
" . . ",
" . . .XXXXXXXXX ",
" X X ",
" X X X ",
" X X X ",
" X X X ",
" X X X ",
" XXX X X ",
" X X X ",
" X X ",
" . . .XXXXXXXXX ",
" "};

View file

@ -0,0 +1,23 @@
/* XPM */
static char * edit_xpm[] = {
"16 16 4 1",
" c None",
". c #000000",
"+ c #FF0000",
"@ c #FFFF00",
" ",
" .. ",
" . .+. ",
" .@. ",
" . .@. ",
" . ..@. ",
" .@. ",
" .@.. ",
" .@. . ",
" .@. ",
" .@. . ",
" .@. ",
" .@. . ",
" .. . ",
" . . ",
" "};

View file

@ -0,0 +1,21 @@
/* XPM */
static char * grid_xpm[] = {
"16 16 2 1",
" c None",
". c black",
" . . . . ",
"............... ",
" . . . . ",
" . . . . ",
" . . . . ",
"............... ",
" . . . . ",
" . . . . ",
" . . . . ",
"............... ",
" . . . . ",
" . . . . ",
" . . . . ",
"............... ",
" . . . . ",
" "};

View file

@ -0,0 +1,43 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_about.h"
#include "imap_default_dialog.h"
void
do_about_dialog(void)
{
static DefaultDialog_t *dialog;
if (!dialog) {
dialog = make_default_dialog("About");
default_dialog_hide_cancel_button(dialog);
default_dialog_hide_apply_button(dialog);
default_dialog_set_label(
dialog,
"Imagemap plug-in 1.2\n\n"
"Copyright(c) 1999 by Maurits Rijk\n"
"lpeek.mrijk@consunet.nl \n\n"
" Released under the GNU General Public License ");
}
default_dialog_show(dialog);
}

View file

@ -0,0 +1,29 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_ABOUT_H
#define _IMAP_ABOUT_H
void do_about_dialog(void);
#endif /* _IMAP_ABOUT_H */

View file

@ -0,0 +1,138 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_browse.h"
#include "imap_main.h"
#include "open.xpm"
static GtkTargetEntry target_table[] = {
{"STRING", 0, 1 },
{"text/plain", 0, 2 }
};
static void
select_cb(GtkWidget *widget, gpointer data)
{
BrowseWidget_t *browse = (BrowseWidget_t*) data;
const gchar *p;
gchar *file;
file = gtk_file_selection_get_filename(
GTK_FILE_SELECTION(browse->file_selection));
p = (browse->filter) ? browse->filter(file, browse->filter_data) : file;
gtk_entry_set_text(GTK_ENTRY(browse->file), p);
gtk_widget_hide(browse->file_selection);
gtk_widget_grab_focus(browse->file);
}
static void
browse_cb(GtkWidget *widget, gpointer data)
{
BrowseWidget_t *browse = (BrowseWidget_t*) data;
if (!browse->file_selection) {
GtkWidget *dialog;
dialog = browse->file_selection = gtk_file_selection_new(browse->name);
gtk_signal_connect_object(
GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button),
"clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(dialog));
gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
"clicked", GTK_SIGNAL_FUNC(select_cb), data);
}
gtk_widget_show(browse->file_selection);
}
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
GtkSelectionData *data, guint info, guint time)
{
gboolean success;
if (data->length >= 0 && data->format == 8) {
gtk_entry_set_text(GTK_ENTRY(widget), data->data);
success = TRUE;
} else {
success = FALSE;
}
gtk_drag_finish(context, success, FALSE, time);
}
BrowseWidget_t*
browse_widget_new(const gchar *name)
{
BrowseWidget_t *browse = g_new(BrowseWidget_t, 1);
GtkWidget *button;
GtkWidget *iconw;
GdkPixmap *icon;
GdkBitmap *mask;
GtkStyle *style;
GtkWidget *top = get_top_widget();
browse->file_selection = NULL;
browse->name = name;
browse->filter = NULL;
browse->hbox = gtk_hbox_new(FALSE, 1);
gtk_widget_show(browse->hbox);
browse->file = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(browse->hbox), browse->file, TRUE, TRUE, 0);
gtk_drag_dest_set(browse->file, GTK_DEST_DEFAULT_ALL, target_table,
2, GDK_ACTION_COPY);
gtk_signal_connect(GTK_OBJECT(browse->file), "drag_data_received",
GTK_SIGNAL_FUNC(handle_drop), NULL);
gtk_widget_show(browse->file);
browse->button = button = gtk_button_new();
style = gtk_widget_get_style(top);
icon = gdk_pixmap_create_from_xpm_d(top->window, &mask,
&style->bg[GTK_STATE_NORMAL],
open_xpm);
iconw = gtk_pixmap_new(icon, mask);
gtk_widget_show(iconw);
gtk_container_add(GTK_CONTAINER(button), iconw);
gtk_box_pack_end(GTK_BOX(browse->hbox), button, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(browse_cb), (gpointer) browse);
gtk_widget_show(button);
return browse;
}
void
browse_widget_set_filename(BrowseWidget_t *browse, const gchar *filename)
{
gtk_entry_set_text(GTK_ENTRY(browse->file), filename);
}
void
browse_widget_set_filter(BrowseWidget_t *browse, BrowseFilter_t filter,
gpointer data)
{
browse->filter = filter;
browse->filter_data = data;
}

View file

@ -0,0 +1,46 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_BROWSE_H
#define _IMAP_BROWSE_H
#include "gtk/gtk.h"
typedef const gchar* (*BrowseFilter_t)(const gchar*, gpointer data);
typedef struct {
const gchar *name;
BrowseFilter_t filter;
gpointer filter_data;
GtkWidget *hbox;
GtkWidget *file;
GtkWidget *button;
GtkWidget *file_selection;
} BrowseWidget_t;
BrowseWidget_t *browse_widget_new(const gchar *name);
void browse_widget_set_filename(BrowseWidget_t *browse, const gchar *filename);
void browse_widget_set_filter(BrowseWidget_t *browse, BrowseFilter_t filter,
gpointer data);
#endif /* _IMAP_BROWSE_H */

83
plug-ins/imagemap/imap_cern.l Executable file
View file

@ -0,0 +1,83 @@
%{
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cern_parse.h"
%}
%option noyywrap
DIGIT [0-9]
ID [a-zA-Z_][a-zA-Z0-9_\-]*
WS [ \t\n]+
%x comment
%%
RECT{WS}\(4096,4096\){WS}\(4096,4096\).*#\$AUTHOR: {
BEGIN(comment);
return AUTHOR;
}
RECT{WS}\(4096,4096\){WS}\(4096,4096\).*#\$DESCRIPTION: {
BEGIN(comment);
return DESCRIPTION;
}
RECT{WS}\(4096,4096\){WS}\(4096,4096\) {
BEGIN(comment);
return BEGIN_COMMENT;
}
<comment>.*$ {
BEGIN(INITIAL);
strcpy(cern_lval.id, yytext);
return COMMENT;
}
RECT return RECTANGLE;
CIRC return CIRCLE;
POLY return POLYGON;
DEFAULT return DEFAULT;
[^ ,\t\n]+$ {
strcpy(cern_lval.id, yytext);
return LINK;
}
-?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? {
cern_lval.value = atof(yytext);
return FLOAT;
}
{WS} ; /* Eat white space */
. return *yytext;
%%

177
plug-ins/imagemap/imap_cern.y Executable file
View file

@ -0,0 +1,177 @@
%{
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <math.h>
#include "gtk/gtk.h"
#include "imap_circle.h"
#include "imap_file.h"
#include "imap_main.h"
#include "imap_polygon.h"
#include "imap_rectangle.h"
#include "imap_string.h"
extern int cern_lex();
extern int cern_restart();
static void cern_error(char* s);
static Object_t *current_object;
%}
%union {
int val;
double value;
char id[256];
}
%token<val> RECTANGLE POLYGON CIRCLE DEFAULT
%token<val> AUTHOR DESCRIPTION BEGIN_COMMENT
%token<value> FLOAT
%token<id> COMMENT LINK
%%
cern_file : area_list
;
area_list : /* Empty */
| area_list area
;
area : default
| rectangle
| circle
| polygon
| comment_line
;
default : DEFAULT LINK
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->default_url, $2);
}
;
rectangle : RECTANGLE '(' FLOAT ',' FLOAT ')' '(' FLOAT ',' FLOAT ')' LINK
{
gint x = (gint) $3;
gint y = (gint) $5;
gint width = (gint) fabs($8 - x);
gint height = (gint) fabs($10 - y);
current_object = create_rectangle(x, y, width, height);
object_set_url(current_object, $12);
add_shape(current_object);
}
;
circle : CIRCLE '(' FLOAT ',' FLOAT ')' FLOAT LINK
{
gint x = (gint) $3;
gint y = (gint) $5;
gint r = (gint) $7;
current_object = create_circle(x, y, r);
object_set_url(current_object, $8);
add_shape(current_object);
}
;
polygon : POLYGON {current_object = create_polygon(NULL);} coord_list LINK
{
object_set_url(current_object, $4);
add_shape(current_object);
}
;
coord_list : /* Empty */
| coord_list coord
{
}
;
coord : '(' FLOAT ',' FLOAT ')'
{
Polygon_t *polygon = ObjectToPolygon(current_object);
GdkPoint *point = new_point((gint) $2, (gint) $4);
polygon->points = g_list_append(polygon->points,
(gpointer) point);
}
;
comment_line : author_line
| description_line
| real_comment
;
real_comment : BEGIN_COMMENT COMMENT
{
}
;
author_line : AUTHOR COMMENT
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->author, $2);
}
;
description_line: DESCRIPTION COMMENT
{
MapInfo_t *info = get_map_info();
gchar *description;
description = g_strconcat(info->description, $2, "\n",
NULL);
g_strreplace(&info->description, description);
}
;
%%
static void
cern_error(char* s)
{
extern FILE *cern_in;
cern_restart(cern_in);
}
gboolean
load_cern(const char* filename)
{
gboolean status;
extern FILE *cern_in;
cern_in = fopen(filename, "r");
if (cern_in) {
status = !cern_parse();
fclose(cern_in);
} else {
status = FALSE;
}
return status;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
typedef union {
int val;
double value;
char id[256];
} YYSTYPE;
#define RECTANGLE 258
#define POLYGON 259
#define CIRCLE 260
#define DEFAULT 261
#define AUTHOR 262
#define DESCRIPTION 263
#define BEGIN_COMMENT 264
#define FLOAT 265
#define COMMENT 266
#define LINK 267
extern YYSTYPE cern_lval;

View file

@ -0,0 +1,371 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <math.h>
#include "imap_circle.h"
#include "imap_main.h"
#include "imap_misc.h"
#include "imap_object_popup.h"
#include "imap_table.h"
#include "circle.xpm"
static gboolean circle_is_valid(Object_t *obj);
static Object_t *circle_clone(Object_t *obj);
static Object_t *circle_assign(Object_t *obj, Object_t *des);
static void circle_draw(Object_t* obj, GdkWindow *window, GdkGC* gc);
static void circle_draw_sashes(Object_t* obj, GdkWindow *window, GdkGC* gc);
static MoveSashFunc_t circle_near_sash(Object_t *obj, gint x, gint y);
static gboolean circle_point_is_on(Object_t *obj, gint x, gint y);
static void circle_get_dimensions(Object_t *obj, gint *x, gint *y,
gint *width, gint *height);
static void circle_resize(Object_t *obj, gint percentage_x, gint percentage_y);
static void circle_move(Object_t *obj, gint dx, gint dy);
static gpointer circle_create_info_tab(GtkWidget *notebook);
static void circle_fill_info_tab(Object_t *obj, gpointer data);
static void circle_set_initial_focus(Object_t *obj, gpointer data);
static void circle_update(Object_t* obj, gpointer data);
static void circle_write_csim(Object_t* obj, gpointer param,
OutputFunc_t output);
static void circle_write_cern(Object_t* obj, gpointer param,
OutputFunc_t output);
static void circle_write_ncsa(Object_t* obj, gpointer param,
OutputFunc_t output);
static char** circle_get_icon_data(void);
static ObjectClass_t circle_class = {
NULL, /* info_dialog */
NULL, /* icon */
NULL, /* mask */
circle_is_valid,
NULL, /* circle_destruct */
circle_clone,
circle_assign,
NULL, /* circle_normalize */
circle_draw,
circle_draw_sashes,
circle_near_sash,
circle_point_is_on,
circle_get_dimensions,
circle_resize,
circle_move,
circle_create_info_tab,
circle_fill_info_tab,
circle_set_initial_focus,
circle_update,
circle_write_csim,
circle_write_cern,
circle_write_ncsa,
object_do_popup,
circle_get_icon_data
};
Object_t*
create_circle(gint x, gint y, gint r)
{
Circle_t *circle = g_new(Circle_t, 1);
circle->x = x;
circle->y = y;
circle->r = r;
return object_init(&circle->obj, &circle_class);
}
static gboolean
circle_is_valid(Object_t *obj)
{
return ObjectToCircle(obj)->r > 0;
}
static Object_t*
circle_clone(Object_t *obj)
{
Circle_t *circle = ObjectToCircle(obj);
Circle_t *clone = g_new(Circle_t, 1);
clone->x = circle->x;
clone->y = circle->y;
clone->r = circle->r;
return &clone->obj;
}
static Object_t*
circle_assign(Object_t *obj, Object_t *des)
{
Circle_t *src_circle = ObjectToCircle(obj);
Circle_t *des_circle = ObjectToCircle(des);
des_circle->x = src_circle->x;
des_circle->y = src_circle->y;
des_circle->r = src_circle->r;
return object_copy(obj, des);
}
static void
circle_draw(Object_t *obj, GdkWindow *window, GdkGC *gc)
{
Circle_t *circle = ObjectToCircle(obj);
draw_circle(window, gc, FALSE, circle->x, circle->y, circle->r);
}
static void
circle_draw_sashes(Object_t *obj, GdkWindow *window, GdkGC *gc)
{
Circle_t *circle = ObjectToCircle(obj);
draw_sash(window, gc, circle->x - circle->r, circle->y - circle->r);
draw_sash(window, gc, circle->x + circle->r, circle->y - circle->r);
draw_sash(window, gc, circle->x - circle->r, circle->y + circle->r);
draw_sash(window, gc, circle->x + circle->r, circle->y + circle->r);
}
static gint sash_x;
static gint sash_y;
static void
move_sash(Object_t *obj, gint dx, gint dy)
{
Circle_t *circle = ObjectToCircle(obj);
gint rx, ry;
sash_x += dx;
sash_y += dy;
rx = abs(circle->x - sash_x);
ry = abs(circle->y - sash_y);
circle->r = (rx > ry) ? rx : ry;
}
static void
circle_resize(Object_t *obj, gint percentage_x, gint percentage_y)
{
Circle_t *circle = ObjectToCircle(obj);
circle->x = circle->x * percentage_x / 100;
circle->y = circle->y * percentage_y / 100;
circle->r = circle->r * ((percentage_x < percentage_y)
? percentage_x : percentage_y) / 100;
}
static MoveSashFunc_t
circle_near_sash(Object_t *obj, gint x, gint y)
{
Circle_t *circle = ObjectToCircle(obj);
sash_x = x;
sash_y = y;
if (near_sash(circle->x - circle->r, circle->y - circle->r, x, y) ||
near_sash(circle->x + circle->r, circle->y - circle->r, x, y) ||
near_sash(circle->x - circle->r, circle->y + circle->r, x, y) ||
near_sash(circle->x + circle->r, circle->y + circle->r, x, y))
return move_sash;
return NULL;
}
static gboolean
circle_point_is_on(Object_t *obj, gint x, gint y)
{
Circle_t *circle = ObjectToCircle(obj);
x -= circle->x;
y -= circle->y;
return x * x + y * y <= circle->r * circle->r;
}
static void
circle_get_dimensions(Object_t *obj, gint *x, gint *y,
gint *width, gint *height)
{
Circle_t *circle = ObjectToCircle(obj);
*x = circle->x - circle->r;
*y = circle->y - circle->r;
*width = *height = 2 * circle->r;
}
static void
circle_move(Object_t *obj, gint dx, gint dy)
{
Circle_t *circle = ObjectToCircle(obj);
circle->x += dx;
circle->y += dy;
}
typedef struct {
GtkWidget *x;
GtkWidget *y;
GtkWidget *r;
} CircleProperties_t;
static gpointer
circle_create_info_tab(GtkWidget *notebook)
{
CircleProperties_t *props = g_new(CircleProperties_t, 1);
GtkWidget *vbox, *table, *label;
gint max_width = get_image_width();
gint max_height = get_image_height();
vbox = gtk_vbox_new(FALSE, 1);
gtk_widget_show(vbox);
table = gtk_table_new(3, 3, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_widget_show(table);
create_label_in_table(table, 0, 0, "Center x:");
props->x = create_spin_button_in_table(table, 0, 1, 1, 0, max_width - 1);
create_label_in_table(table, 0, 2, "pixels");
create_label_in_table(table, 1, 0, "Center y:");
props->y = create_spin_button_in_table(table, 1, 1, 1, 0, max_height - 1);
create_label_in_table(table, 1, 2, "pixels");
create_label_in_table(table, 2, 0, "Radius:");
props->r = create_spin_button_in_table(table, 2, 1, 1, 1, G_MAXINT);
create_label_in_table(table, 2, 2, "pixels");
label = gtk_label_new("Circle");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
return props;
}
static void
circle_fill_info_tab(Object_t *obj, gpointer data)
{
Circle_t *circle = ObjectToCircle(obj);
CircleProperties_t *props = (CircleProperties_t*) data;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->x), circle->x);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), circle->y);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->r), circle->r);
}
static void
circle_set_initial_focus(Object_t *obj, gpointer data)
{
CircleProperties_t *props = (CircleProperties_t*) data;
gtk_widget_grab_focus(props->x);
}
static void
circle_update(Object_t* obj, gpointer data)
{
Circle_t *circle = ObjectToCircle(obj);
CircleProperties_t *props = (CircleProperties_t*) data;
circle->x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->x));
circle->y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->y));
circle->r = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->r));
}
static void
circle_write_csim(Object_t *obj, gpointer param, OutputFunc_t output)
{
Circle_t *circle = ObjectToCircle(obj);
output(param, "\"CIRCLE\" COORDS=\"%d,%d,%d\"", circle->x, circle->y,
circle->r);
}
static void
circle_write_cern(Object_t *obj, gpointer param, OutputFunc_t output)
{
Circle_t *circle = ObjectToCircle(obj);
output(param, "circ (%d,%d) %d", circle->x, circle->y, circle->r);
}
static void
circle_write_ncsa(Object_t *obj, gpointer param, OutputFunc_t output)
{
Circle_t *circle = ObjectToCircle(obj);
output(param, "circle %s %d,%d %d,%d", obj->url,
circle->x, circle->y, circle->x, circle->y + circle->r);
}
static char**
circle_get_icon_data(void)
{
return circle_xpm;
}
static gint _start_x, _start_y;
static Object_t*
circle_factory_create_object1(gint x, gint y)
{
_start_x = x;
_start_y = y;
return create_circle(x, y, 0);
}
static void
circle_factory_set_xy1(Object_t *obj, guint state, gint x, gint y)
{
Circle_t *circle = ObjectToCircle(obj);
circle->x = (_start_x + x) / 2;
circle->y = (_start_y + y) / 2;
x -= _start_x;
y -= _start_y;
circle->r = (gint) sqrt(x * x + y * y) / 2;
main_set_dimension(circle->r, circle->r);
}
static ObjectFactory_t circle_factory1 = {
NULL, /* Object pointer */
NULL, /* Finish func */
NULL, /* Cancel func */
circle_factory_create_object1,
circle_factory_set_xy1
};
static Object_t*
circle_factory_create_object2(gint x, gint y)
{
return create_circle(x, y, 0);
}
static void
circle_factory_set_xy2(Object_t *obj, guint state, gint x, gint y)
{
Circle_t *circle = ObjectToCircle(obj);
x -= circle->x;
y -= circle->y;
circle->r = (gint) sqrt(x * x + y * y);
main_set_dimension(circle->r, circle->r);
}
static ObjectFactory_t circle_factory2 = {
NULL, /* Object pointer */
NULL, /* Finish func */
NULL, /* Cancel func */
circle_factory_create_object2,
circle_factory_set_xy2
};
ObjectFactory_t*
get_circle_factory(guint state)
{
return (state & GDK_SHIFT_MASK) ? &circle_factory1 : &circle_factory2;
}

View file

@ -0,0 +1,41 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CIRCLE_H
#define _IMAP_CIRCLE_H
#include "imap_object.h"
typedef struct {
Object_t obj;
gint x;
gint y;
gint r;
} Circle_t;
#define ObjectToCircle(obj) ((Circle_t*) (obj))
Object_t *create_circle(gint x, gint y, gint r);
ObjectFactory_t *get_circle_factory(guint state);
#endif /* _IMAP_CIRCLE_H */

View file

@ -0,0 +1,86 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_clear.h"
#include "imap_cmd_delete.h"
#include "imap_main.h"
static gboolean clear_command_execute(Command_t *parent);
static void clear_command_undo(Command_t *parent);
static void clear_command_redo(Command_t *parent);
static CommandClass_t clear_command_class = {
NULL, /* clear_command_destruct */
clear_command_execute,
clear_command_undo,
clear_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} ClearCommand_t;
Command_t*
clear_command_new(ObjectList_t *list)
{
ClearCommand_t *command = g_new(ClearCommand_t, 1);
command->list = list;
return command_init(&command->parent, "Clear", &clear_command_class);
}
static void
remove_one_object(Object_t *obj, gpointer data)
{
ClearCommand_t *command = (ClearCommand_t*) data;
command_add_subcommand(&command->parent,
delete_command_new(command->list, obj));
}
static gboolean
clear_command_execute(Command_t *parent)
{
ClearCommand_t *command = (ClearCommand_t*) parent;
gpointer id;
id = object_list_add_remove_cb(command->list, remove_one_object, command);
object_list_delete_selected(command->list);
object_list_remove_remove_cb(command->list, id);
redraw_preview(); /* Fix me! */
return TRUE;
}
static void
clear_command_undo(Command_t *parent)
{
redraw_preview(); /* Fix me! */
}
static void
clear_command_redo(Command_t *parent)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_CLEAR_H
#define _IMAP_CMD_CLEAR_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *clear_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_CLEAR_H */

View file

@ -0,0 +1,67 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <stdio.h>
#include "imap_cmd_copy.h"
static gboolean copy_command_execute(Command_t *parent);
static void copy_command_undo(Command_t *parent);
static CommandClass_t copy_command_class = {
NULL, /* copy_command_destruct */
copy_command_execute,
copy_command_undo,
NULL /* copy_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
ObjectList_t *paste_buffer;
} CopyCommand_t;
Command_t*
copy_command_new(ObjectList_t *list)
{
CopyCommand_t *command = g_new(CopyCommand_t, 1);
command->list = list;
command->paste_buffer = NULL;
return command_init(&command->parent, "Copy", &copy_command_class);
}
static gboolean
copy_command_execute(Command_t *parent)
{
CopyCommand_t *command = (CopyCommand_t*) parent;
command->paste_buffer = object_list_copy(command->paste_buffer,
get_paste_buffer());
object_list_copy_to_paste_buffer(command->list);
return TRUE;
}
static void
copy_command_undo(Command_t *parent)
{
CopyCommand_t *command = (CopyCommand_t*) parent;
object_list_copy(get_paste_buffer(), command->paste_buffer);
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_COPY_H
#define _IMAP_CMD_COPY_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *copy_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_COPY_H */

View file

@ -0,0 +1,78 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy_object.h"
static void copy_object_command_destruct(Command_t *parent);
static gboolean copy_object_command_execute(Command_t *parent);
static void copy_object_command_undo(Command_t *parent);
static CommandClass_t copy_object_command_class = {
copy_object_command_destruct,
copy_object_command_execute,
copy_object_command_undo,
NULL /* copy_object_command_redo */
};
typedef struct {
Command_t parent;
Object_t *obj;
ObjectList_t *paste_buffer;
} CopyObjectCommand_t;
Command_t*
copy_object_command_new(Object_t *obj)
{
CopyObjectCommand_t *command = g_new(CopyObjectCommand_t, 1);
command->obj = object_ref(obj);
command->paste_buffer = NULL;
return command_init(&command->parent, "Copy", &copy_object_command_class);
}
static void
copy_object_command_destruct(Command_t *parent)
{
CopyObjectCommand_t *command = (CopyObjectCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
copy_object_command_execute(Command_t *parent)
{
CopyObjectCommand_t *command = (CopyObjectCommand_t*) parent;
ObjectList_t *paste_buffer = get_paste_buffer();
command->paste_buffer = object_list_copy(command->paste_buffer,
paste_buffer);
clear_paste_buffer();
object_list_append(paste_buffer, object_clone(command->obj));
return TRUE;
}
static void
copy_object_command_undo(Command_t *parent)
{
CopyObjectCommand_t *command = (CopyObjectCommand_t*) parent;
object_list_copy(get_paste_buffer(), command->paste_buffer);
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_COPY_OBJECT_H
#define _IMAP_CMD_COPY_OBJECT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *copy_object_command_new(Object_t *obj);
#endif /* _IMAP_CMD_COPY_OBJECT_H */

View file

@ -0,0 +1,78 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_create.h"
#include "imap_main.h"
static gboolean create_command_execute(Command_t *parent);
static void create_command_destruct(Command_t *parent);
static void create_command_undo(Command_t *parent);
static CommandClass_t create_command_class = {
create_command_destruct,
create_command_execute,
create_command_undo,
NULL /* create_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
Object_t *obj;
gboolean changed;
} CreateCommand_t;
Command_t*
create_command_new(ObjectList_t *list, Object_t *obj)
{
CreateCommand_t *command = g_new(CreateCommand_t, 1);
command->list = list;
command->obj = object_ref(obj);
return command_init(&command->parent, "Create", &create_command_class);
}
static void
create_command_destruct(Command_t *parent)
{
CreateCommand_t *command = (CreateCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
create_command_execute(Command_t *parent)
{
CreateCommand_t *command = (CreateCommand_t*) parent;
command->changed = object_list_get_changed(command->list);
object_list_append(command->list, object_ref(command->obj));
redraw_preview(); /* fix me! */
return TRUE;
}
static void
create_command_undo(Command_t *parent)
{
CreateCommand_t *command = (CreateCommand_t*) parent;
object_list_remove(command->list, command->obj);
object_list_set_changed(command->list, command->changed);
redraw_preview(); /* fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_CREATE_H
#define _IMAP_CMD_CREATE_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *create_command_new(ObjectList_t *list, Object_t *obj);
#endif /* _IMAP_CMD_CREATE_H */

View file

@ -0,0 +1,98 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_delete.h"
#include "imap_cmd_cut.h"
#include "imap_main.h"
static void cut_command_destruct(Command_t *parent);
static gboolean cut_command_execute(Command_t *parent);
static void cut_command_undo(Command_t *parent);
static void cut_command_redo(Command_t *parent);
static CommandClass_t cut_command_class = {
cut_command_destruct,
cut_command_execute,
cut_command_undo,
cut_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
ObjectList_t *paste_buffer;
} CutCommand_t;
Command_t*
cut_command_new(ObjectList_t *list)
{
CutCommand_t *command = g_new(CutCommand_t, 1);
command->list = list;
command->paste_buffer = NULL;
return command_init(&command->parent, "Cut", &cut_command_class);
}
static void
cut_command_destruct(Command_t *parent)
{
CutCommand_t *command = (CutCommand_t*) parent;
object_list_destruct(command->paste_buffer);
}
static void
remove_one_object(Object_t *obj, gpointer data)
{
CutCommand_t *command = (CutCommand_t*) data;
command_add_subcommand(&command->parent,
delete_command_new(command->list, obj));
}
static gboolean
cut_command_execute(Command_t *parent)
{
CutCommand_t *command = (CutCommand_t*) parent;
gpointer id;
command->paste_buffer = object_list_copy(command->paste_buffer,
get_paste_buffer());
id = object_list_add_remove_cb(command->list, remove_one_object, command);
object_list_cut(command->list);
object_list_remove_remove_cb(command->list, id);
redraw_preview(); /* Fix me! */
return TRUE;
}
static void
cut_command_undo(Command_t *parent)
{
CutCommand_t *command = (CutCommand_t*) parent;
object_list_copy(get_paste_buffer(), command->paste_buffer);
redraw_preview(); /* Fix me! */
}
static void
cut_command_redo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_CUT_H
#define _IMAP_CMD_CUT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *cut_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_CUT_H */

View file

@ -0,0 +1,77 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy_object.h"
#include "imap_cmd_cut_object.h"
#include "imap_cmd_delete.h"
#include "imap_main.h"
static gboolean cut_object_command_execute(Command_t *parent);
static void cut_object_command_undo(Command_t *parent);
static void cut_object_command_redo(Command_t *parent);
static CommandClass_t cut_object_command_class = {
NULL, /* cut_object_command_destruct */
cut_object_command_execute,
cut_object_command_undo,
cut_object_command_redo
};
typedef struct {
Command_t parent;
} CutObjectCommand_t;
Command_t*
cut_object_command_new(Object_t *obj)
{
CutObjectCommand_t *command = g_new(CutObjectCommand_t, 1);
Command_t *parent;
parent = command_init(&command->parent, "Cut", &cut_object_command_class);
command_add_subcommand(parent, copy_object_command_new(obj));
command_add_subcommand(parent, delete_command_new(obj->list, obj));
return parent;
}
static gboolean
cut_object_command_execute(Command_t *parent)
{
redraw_preview(); /* fix me! */
return TRUE;
}
static void
cut_object_command_undo(Command_t *parent)
{
redraw_preview(); /* fix me! */
}
static void
cut_object_command_redo(Command_t *parent)
{
redraw_preview(); /* fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_CUT_OBJECT_H
#define _IMAP_CMD_CUT_OBJECT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *cut_object_command_new(Object_t *obj);
#endif /* _IMAP_CMD_CUT_OBJECT_H */

View file

@ -0,0 +1,80 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_delete.h"
#include "imap_main.h"
static void delete_command_destruct(Command_t *parent);
static gboolean delete_command_execute(Command_t *parent);
static void delete_command_undo(Command_t *parent);
static CommandClass_t delete_command_class = {
delete_command_destruct,
delete_command_execute,
delete_command_undo,
NULL /* delete_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
Object_t *obj;
gint position;
gboolean changed;
} DeleteCommand_t;
Command_t*
delete_command_new(ObjectList_t *list, Object_t *obj)
{
DeleteCommand_t *command = g_new(DeleteCommand_t, 1);
command->list = list;
command->obj = object_ref(obj);
return command_init(&command->parent, "Delete",
&delete_command_class);
}
static void
delete_command_destruct(Command_t *parent)
{
DeleteCommand_t *command = (DeleteCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
delete_command_execute(Command_t *parent)
{
DeleteCommand_t *command = (DeleteCommand_t*) parent;
command->changed = object_list_get_changed(command->list);
command->position = object_get_position_in_list(command->obj);
object_list_remove(command->list, command->obj);
return TRUE;
}
static void
delete_command_undo(Command_t *parent)
{
DeleteCommand_t *command = (DeleteCommand_t*) parent;
object_list_insert(command->list, command->position, command->obj);
object_list_set_changed(command->list, command->changed);
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_DELETE_H
#define _IMAP_CMD_DELETE_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *delete_command_new(ObjectList_t *list, Object_t *obj);
#endif /* _IMAP_CMD_DELETE_H */

View file

@ -0,0 +1,84 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_delete_point.h"
#include "imap_main.h"
#include "imap_polygon.h"
static gboolean delete_point_command_execute(Command_t *parent);
static void delete_point_command_undo(Command_t *parent);
static CommandClass_t delete_point_command_class = {
NULL, /* delete_point_command_destruct */
delete_point_command_execute,
delete_point_command_undo,
NULL /* delete_point_command_redo */
};
typedef struct {
Command_t parent;
Polygon_t *polygon;
GdkPoint *point;
GdkPoint copy;
gint position;
} DeletePointCommand_t;
Command_t*
delete_point_command_new(Object_t *obj, GdkPoint *point)
{
DeletePointCommand_t *command = g_new(DeletePointCommand_t, 1);
command->polygon = ObjectToPolygon(obj);
command->point = point;
command->copy = *point;
command->position = g_list_index(command->polygon->points,
(gpointer) point);
return command_init(&command->parent, "Delete Point",
&delete_point_command_class);
}
static gboolean
delete_point_command_execute(Command_t *parent)
{
DeletePointCommand_t *command = (DeletePointCommand_t*) parent;
Polygon_t *polygon = command->polygon;
GList *p = g_list_find(polygon->points, (gpointer) command->point);
g_free(p->data);
polygon->points = g_list_remove_link(polygon->points, p);
redraw_preview(); /* Fix me! */
return TRUE;
}
static void
delete_point_command_undo(Command_t *parent)
{
DeletePointCommand_t *command = (DeletePointCommand_t*) parent;
Polygon_t *polygon = command->polygon;
GdkPoint *point = &command->copy;
command->point = new_point(point->x, point->y);
polygon->points = g_list_insert(polygon->points, (gpointer) command->point,
command->position);
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_DELETE_POINT_H
#define _IMAP_CMD_DELETE_POINT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *delete_point_command_new(Object_t *obj, GdkPoint *point);
#endif /* _IMAP_CMD_DELETE_POINT_H */

View file

@ -0,0 +1,73 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_edit_object.h"
#include "imap_main.h"
static void edit_object_command_destruct(Command_t *parent);
static void edit_object_command_undo(Command_t *parent);
static CommandClass_t edit_object_command_class = {
edit_object_command_destruct,
NULL, /* edit_object_command_execute */
edit_object_command_undo,
edit_object_command_undo
};
typedef struct {
Command_t parent;
Object_t *obj;
Object_t *copy;
} EditObjectCommand_t;
Command_t*
edit_object_command_new(Object_t *obj)
{
EditObjectCommand_t *command = g_new(EditObjectCommand_t, 1);
command->obj = object_ref(obj);
command->copy = object_clone(obj);
return command_init(&command->parent, "Edit Object",
&edit_object_command_class);
}
static void
edit_object_command_destruct(Command_t *parent)
{
EditObjectCommand_t *command = (EditObjectCommand_t*) parent;
object_unref(command->copy);
object_unref(command->obj);
}
static void
edit_object_command_undo(Command_t *parent)
{
EditObjectCommand_t *command = (EditObjectCommand_t*) parent;
Object_t *copy = object_clone(command->obj);
object_assign(command->copy, command->obj);
object_assign(copy, command->copy);
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_EDIT_OBJECT_H
#define _IMAP_CMD_EDIT_OBJECT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *edit_object_command_new(Object_t *obj);
#endif /* _IMAP_CMD_EDIT_OBJECT_H */

View file

@ -0,0 +1,269 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <stdio.h>
#include "imap_cmd_create.h"
#include "imap_default_dialog.h"
#include "imap_cmd_guides.h"
#include "imap_main.h"
#include "imap_rectangle.h"
#include "imap_table.h"
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *image_dimensions;
GtkWidget *guide_bounds;
GtkWidget *width;
GtkWidget *height;
GtkWidget *left;
GtkWidget *top;
GtkWidget *horz_spacing;
GtkWidget *vert_spacing;
GtkWidget *no_across;
GtkWidget *no_down;
GtkWidget *base_url;
ObjectList_t *list;
} GuidesDialog_t;
static void
guides_ok_cb(gpointer data)
{
GuidesDialog_t *param = (GuidesDialog_t*) data;
gint y;
int i, j;
gint width, height, left, top, hspace, vspace, rows, cols;
width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->width));
height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->height));
left = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->left));
top = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->top));
hspace = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->horz_spacing));
vspace = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->vert_spacing));
rows = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->no_down));
cols = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->no_across));
subcommand_start("Create Guides");
y = top;
for (i = 0; i < rows; i++) {
gint x = left;
for (j = 0; j < cols; j++) {
Object_t *obj = create_rectangle(x, y, width, height);
Command_t *command = create_command_new(param->list, obj);
object_set_url(obj, gtk_entry_get_text(GTK_ENTRY(param->base_url)));
command_execute(command);
x += width + hspace;
}
y += height + vspace;
}
subcommand_end();
redraw_preview();
}
static void
recalc_bounds(GtkWidget *widget, gpointer data)
{
GuidesDialog_t *param = (GuidesDialog_t*) data;
gint width, height, left, top, hspace, vspace, rows, cols;
gint bound_w, bound_h;
char bounds[128];
width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->width));
height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->height));
left = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->left));
top = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->top));
hspace = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->horz_spacing));
vspace = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->vert_spacing));
rows = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->no_down));
cols = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->no_across));
bound_w = (width + hspace) * cols - hspace;
bound_h = (height + vspace) * rows - vspace;
sprintf(bounds, "Resulting Guide Bounds: %d,%d to %d,%d (%d areas)",
left, top, left + bound_w, top + bound_h, rows * cols);
if (left + bound_w > get_image_width() ||
top + bound_h > get_image_height()) {
default_dialog_set_ok_sensitivity(param->dialog, FALSE);
} else {
default_dialog_set_ok_sensitivity(param->dialog, TRUE);
}
gtk_label_set_text(GTK_LABEL(param->guide_bounds), bounds);
}
static GuidesDialog_t*
make_guides_dialog()
{
GuidesDialog_t *data = g_new(GuidesDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *table;
GtkWidget *label;
GtkWidget *hbox;
dialog = data->dialog = make_default_dialog("Create Guides");
default_dialog_set_ok_cb(dialog, guides_ok_cb, data);
label = gtk_label_new(
"Guides are pre-defined rectangles covering the image. You define\n"
"them by their width, height, and spacing from each other. This\n"
"allows you to rapidly create the most common image map type -\n"
"image collection of \"thumbnails\", suitable for navigation bars.");
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_container_set_border_width(
GTK_CONTAINER(GTK_DIALOG(dialog->dialog)->vbox), 10);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), label,
TRUE, TRUE, 10);
gtk_widget_show(label);
data->image_dimensions = gtk_label_new("");
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog->dialog)->vbox),
data->image_dimensions);
gtk_widget_show(data->image_dimensions);
data->guide_bounds = gtk_label_new("");
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog->dialog)->vbox),
data->guide_bounds);
gtk_widget_show(data->guide_bounds);
table = gtk_table_new(4, 4, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog->dialog)->vbox), table);
gtk_widget_show(table);
create_label_in_table(table, 0, 0, "Width");
data->width = create_spin_button_in_table(table, 0, 1, 32, 1, 100);
gtk_signal_connect(GTK_OBJECT(data->width), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 0, 2, "Left Start at");
data->left = create_spin_button_in_table(table, 0, 3, 0, 0, 100);
gtk_signal_connect(GTK_OBJECT(data->left), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 1, 0, "Height");
data->height = create_spin_button_in_table(table, 1, 1, 32, 1, 100);
gtk_signal_connect(GTK_OBJECT(data->height), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 1, 2, "Top Start at");
data->top = create_spin_button_in_table(table, 1, 3, 0, 0, 100);
gtk_signal_connect(GTK_OBJECT(data->top), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 2, 0, "Horz. Spacing");
data->horz_spacing = create_spin_button_in_table(table, 2, 1, 0, 0, 100);
gtk_signal_connect(GTK_OBJECT(data->horz_spacing), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 2, 2, "No. Across");
data->no_across = create_spin_button_in_table(table, 2, 3, 0, 0, 100);
gtk_signal_connect(GTK_OBJECT(data->no_across), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 3, 0, "Vert. Spacing");
data->vert_spacing = create_spin_button_in_table(table, 3, 1, 0, 0, 100);
gtk_signal_connect(GTK_OBJECT(data->vert_spacing), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
create_label_in_table(table, 3, 2, "No. Down");
data->no_down = create_spin_button_in_table(table, 3, 3, 0, 0, 100);
gtk_signal_connect(GTK_OBJECT(data->no_down), "changed",
GTK_SIGNAL_FUNC(recalc_bounds), (gpointer) data);
hbox = gtk_hbox_new(FALSE, 1);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog->dialog)->vbox), hbox);
label = gtk_label_new("Base URL:");
gtk_widget_show(label);
gtk_container_add(GTK_CONTAINER(hbox), label);
data->base_url = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(hbox), data->base_url);
gtk_widget_show(data->base_url);
gtk_widget_show(hbox);
return data;
}
static void
init_guides_dialog(GuidesDialog_t *dialog, ObjectList_t *list)
{
char dimension[128];
dialog->list = list;
sprintf(dimension, "Image dimensions: %d x %d", get_image_width(),
get_image_height());
gtk_label_set_text(GTK_LABEL(dialog->image_dimensions), dimension);
gtk_label_set_text(GTK_LABEL(dialog->guide_bounds),
"Resulting Guide Bounds: 0,0 to 0,0 (0 areas)");
gtk_widget_grab_focus(dialog->width);
}
static void
do_create_guides_dialog(ObjectList_t *list)
{
static GuidesDialog_t *dialog;
if (!dialog)
dialog = make_guides_dialog();
init_guides_dialog(dialog, list);
default_dialog_show(dialog->dialog);
}
static gboolean guides_command_execute(Command_t *parent);
static CommandClass_t guides_command_class = {
NULL, /* guides_command_destruct */
guides_command_execute,
NULL, /* guides_command_undo */
NULL /* guides_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} GuidesCommand_t;
Command_t*
guides_command_new(ObjectList_t *list)
{
GuidesCommand_t *command = g_new(GuidesCommand_t, 1);
command->list = list;
return command_init(&command->parent, "Guides", &guides_command_class);
}
static gboolean
guides_command_execute(Command_t *parent)
{
GuidesCommand_t *command = (GuidesCommand_t*) parent;
do_create_guides_dialog(command->list);
return FALSE;
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_GUIDES_H
#define _IMAP_CMD_GUIDES_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *guides_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_GUIDES_H */

View file

@ -0,0 +1,92 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_insert_point.h"
#include "imap_main.h"
#include "imap_polygon.h"
static gboolean insert_point_command_execute(Command_t *parent);
static void insert_point_command_undo(Command_t *parent);
static CommandClass_t insert_point_command_class = {
NULL, /* insert_point_command_destruct */
insert_point_command_execute,
insert_point_command_undo,
NULL /* insert_point_command_redo */
};
typedef struct {
Command_t parent;
Polygon_t *polygon;
gint x;
gint y;
gint edge;
gint position;
} InsertPointCommand_t;
Command_t*
insert_point_command_new(Object_t *obj, gint x, gint y, gint edge)
{
InsertPointCommand_t *command = g_new(InsertPointCommand_t, 1);
command->polygon = ObjectToPolygon(obj);
command->x = x;
command->y = y;
command->edge = edge;
return command_init(&command->parent, "Insert Point",
&insert_point_command_class);
}
static gboolean
insert_point_command_execute(Command_t *parent)
{
InsertPointCommand_t *command = (InsertPointCommand_t*) parent;
Polygon_t *polygon = command->polygon;
GdkPoint *point = new_point(command->x, command->y);
if (g_list_length(polygon->points) == command->edge - 1) {
polygon->points = g_list_append(polygon->points, (gpointer) point);
command->position = command->edge - 1;
} else {
polygon->points = g_list_insert(polygon->points, (gpointer) point,
command->edge);
command->position = command->edge;
}
redraw_preview();
return TRUE;
}
static void
insert_point_command_undo(Command_t *parent)
{
InsertPointCommand_t *command = (InsertPointCommand_t*) parent;
Polygon_t *polygon = command->polygon;
GList *p = g_list_nth(polygon->points, command->position);
g_free(p->data);
polygon->points = g_list_remove_link(polygon->points, p);
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_INSERT_POINT_H
#define _IMAP_CMD_INSERT_POINT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *insert_point_command_new(Object_t *obj, gint x, gint y, gint edge);
#endif /* _IMAP_CMD_INSERT_POINT_H */

View file

@ -0,0 +1,78 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy.h"
#include "imap_main.h"
static void move_command_destruct(Command_t *parent);
static gboolean move_command_execute(Command_t *parent);
static void move_command_undo(Command_t *parent);
CommandClass_t move_command_class = {
move_command_destruct,
move_command_execute,
move_command_undo,
NULL /* move_command_redo */
};
typedef struct {
Command_t parent;
Object_t *obj;
gint dx;
gint dy;
} MoveCommand_t;
Command_t*
move_command_new(Object_t *obj, gint dx, gint dy)
{
MoveCommand_t *command = g_new(MoveCommand_t, 1);
command->obj = object_ref(obj);
command->dx = dx;
command->dy = dy;
return command_init(&command->parent, "Move", &move_command_class);
}
static void
move_command_destruct(Command_t *parent)
{
MoveCommand_t *command = (MoveCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
move_command_execute(Command_t *parent)
{
MoveCommand_t *command = (MoveCommand_t*) parent;
object_move(command->obj, command->dx, command->dy);
redraw_preview(); /* fix me! */
return TRUE;
}
static void
move_command_undo(Command_t *parent)
{
MoveCommand_t *command = (MoveCommand_t*) parent;
object_move(command->obj, -command->dx, -command->dy);
redraw_preview(); /* fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_MOVE_H
#define _IMAP_CMD_MOVE_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *move_command_new(Object_t *obj, gint x, gint y);
#endif /* _IMAP_CMD_MOVE_H */

View file

@ -0,0 +1,96 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy.h"
#include "imap_cmd_object_down.h"
#include "imap_main.h"
static gboolean move_down_command_execute(Command_t *parent);
static void move_down_command_undo(Command_t *parent);
static void move_down_command_redo(Command_t *parent);
CommandClass_t move_down_command_class = {
NULL, /* move_down_command_destruct */
move_down_command_execute,
move_down_command_undo,
move_down_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
gboolean add;
} MoveDownCommand_t;
Command_t*
move_down_command_new(ObjectList_t *list)
{
MoveDownCommand_t *command = g_new(MoveDownCommand_t, 1);
command->list = list;
command->add = FALSE;
return command_init(&command->parent, "Move Down",
&move_down_command_class);
}
static void
move_down_one_object(Object_t *obj, gpointer data)
{
MoveDownCommand_t *command = (MoveDownCommand_t*) data;
if (command->add) {
command_add_subcommand(&command->parent,
object_down_command_new(command->list, obj));
command->add = FALSE;
}
else {
command->add = TRUE;
}
}
static gboolean
move_down_command_execute(Command_t *parent)
{
MoveDownCommand_t *command = (MoveDownCommand_t*) parent;
gpointer id;
id = object_list_add_move_cb(command->list, move_down_one_object, command);
object_list_move_selected_down(command->list);
object_list_remove_move_cb(command->list, id);
redraw_preview(); /* fix me! */
return TRUE;
}
static void
move_down_command_undo(Command_t *parent)
{
redraw_preview(); /* fix me! */
}
static void
move_down_command_redo(Command_t *parent)
{
redraw_preview(); /* fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_MOVE_DOWN_H
#define _IMAP_CMD_MOVE_DOWN_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *move_down_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_MOVE_DOWN_H */

View file

@ -0,0 +1,152 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy.h"
#include "imap_cmd_edit_object.h"
#include "imap_main.h"
COMMAND_PROTO(move_sash_command);
CommandClass_t move_sash_command_class = {
move_sash_command_destruct,
move_sash_command_execute,
move_sash_command_undo,
move_sash_command_redo
};
typedef struct {
Command_t parent;
GtkWidget *widget;
Object_t *obj;
gint x;
gint y;
gint image_width;
gint image_height;
MoveSashFunc_t sash_func;
} MoveSashCommand_t;
Command_t*
move_sash_command_new(GtkWidget *widget, Object_t *obj,
gint x, gint y, MoveSashFunc_t sash_func)
{
MoveSashCommand_t *command = g_new(MoveSashCommand_t, 1);
Command_t *parent;
command->widget = widget;
command->obj = obj;
command->x = x;
command->y = y;
command->image_width = get_image_width();
command->image_height = get_image_height();
command->sash_func = sash_func;
parent = command_init(&command->parent, "Move Sash",
&move_sash_command_class);
command_add_subcommand(parent, edit_object_command_new(obj));
return parent;
}
static void
move_sash_command_destruct(Command_t *parent)
{
MoveSashCommand_t *command = (MoveSashCommand_t*) parent;
object_unref(command->obj);
}
static void
sash_move(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
MoveSashCommand_t *command = (MoveSashCommand_t*) data;
Object_t *obj = command->obj;
gint x, y, dx, dy;
x = (gint) event->x;
y = (gint) event->y;
if (x < 0)
x = 0;
if (x > command->image_width)
x = command->image_width;
if (y < 0)
y = 0;
if (y > command->image_height)
y = command->image_height;
x = get_real_coord(x);
y = get_real_coord(y);
dx = x - command->x;
dy = y - command->y;
command->x = x;
command->y = y;
object_draw(obj, widget->window);
command->sash_func(obj, dx, dy);
object_draw(obj, widget->window);
}
static void
sash_end(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
MoveSashCommand_t *command = (MoveSashCommand_t*) data;
Object_t *obj = command->obj;
gtk_signal_disconnect_by_func(GTK_OBJECT(widget),
(GtkSignalFunc) sash_move, data);
gtk_signal_disconnect_by_func(GTK_OBJECT(widget),
(GtkSignalFunc) sash_end, data);
if (obj->class->normalize)
object_normalize(obj);
gdk_gc_set_function(get_preferences()->selected_gc, GDK_COPY);
redraw_preview();
show_url();
}
static gboolean
move_sash_command_execute(Command_t *parent)
{
MoveSashCommand_t *command = (MoveSashCommand_t*) parent;
hide_url();
gtk_signal_connect(GTK_OBJECT(command->widget), "button_release_event",
(GtkSignalFunc) sash_end, command);
gtk_signal_connect(GTK_OBJECT(command->widget), "motion_notify_event",
(GtkSignalFunc) sash_move, command);
gdk_gc_set_function(get_preferences()->selected_gc, GDK_EQUIV);
return TRUE;
}
static void
move_sash_command_undo(Command_t *parent)
{
}
static void
move_sash_command_redo(Command_t *parent)
{
}

View file

@ -0,0 +1,47 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_MOVE_SASH_H
#define _IMAP_CMD_MOVE_SASH_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *move_sash_command_new(GtkWidget *widget, Object_t *obj,
gint x, gint y, MoveSashFunc_t sash_func);
#endif /* _IMAP_CMD_MOVE_SASH_H */

View file

@ -0,0 +1,98 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_create.h"
#include "imap_cmd_delete.h"
#include "imap_cmd_move_to_front.h"
#include "imap_main.h"
static gboolean move_to_front_command_execute(Command_t *parent);
static void move_to_front_command_undo(Command_t *parent);
static void move_to_front_command_redo(Command_t *parent);
static CommandClass_t move_to_front_command_class = {
NULL, /* move_to_front_command_destruct, */
move_to_front_command_execute,
move_to_front_command_undo,
move_to_front_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} MoveToFrontCommand_t;
Command_t*
move_to_front_command_new(ObjectList_t *list)
{
MoveToFrontCommand_t *command = g_new(MoveToFrontCommand_t, 1);
command->list = list;
return command_init(&command->parent, "Move To Front",
&move_to_front_command_class);
}
static void
remove_one_object(Object_t *obj, gpointer data)
{
MoveToFrontCommand_t *command = (MoveToFrontCommand_t*) data;
command_add_subcommand(&command->parent,
delete_command_new(command->list, obj));
}
static void
add_one_object(Object_t *obj, gpointer data)
{
MoveToFrontCommand_t *command = (MoveToFrontCommand_t*) data;
command_add_subcommand(&command->parent,
create_command_new(command->list, obj));
}
static gboolean
move_to_front_command_execute(Command_t *parent)
{
MoveToFrontCommand_t *command = (MoveToFrontCommand_t*) parent;
gpointer id1, id2;
id1 = object_list_add_remove_cb(command->list, remove_one_object, command);
id2 = object_list_add_add_cb(command->list, add_one_object, command);
object_list_move_to_front(command->list);
redraw_preview(); /* Fix me! */
object_list_remove_remove_cb(command->list, id1);
object_list_remove_add_cb(command->list, id2);
return TRUE;
}
static void
move_to_front_command_undo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}
static void
move_to_front_command_redo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_MOVE_TO_FRONT_H
#define _IMAP_CMD_MOVE_TO_FRONT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *move_to_front_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_MOVE_TO_FRONT_H */

View file

@ -0,0 +1,92 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_move_up.h"
#include "imap_cmd_object_up.h"
#include "imap_main.h"
static gboolean move_up_command_execute(Command_t *parent);
static void move_up_command_undo(Command_t *parent);
static void move_up_command_redo(Command_t *parent);
CommandClass_t move_up_command_class = {
NULL, /* move_up_command_destruct */
move_up_command_execute,
move_up_command_undo,
move_up_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
gboolean add;
} MoveUpCommand_t;
Command_t*
move_up_command_new(ObjectList_t *list)
{
MoveUpCommand_t *command = g_new(MoveUpCommand_t, 1);
command->list = list;
command->add = FALSE;
return command_init(&command->parent, "Move Up", &move_up_command_class);
}
static void
move_up_one_object(Object_t *obj, gpointer data)
{
MoveUpCommand_t *command = (MoveUpCommand_t*) data;
if (command->add) {
command_add_subcommand(&command->parent,
object_up_command_new(command->list, obj));
command->add = FALSE;
}
else {
command->add = TRUE;
}
}
static gboolean
move_up_command_execute(Command_t *parent)
{
MoveUpCommand_t *command = (MoveUpCommand_t*) parent;
gpointer id;
id = object_list_add_move_cb(command->list, move_up_one_object, command);
object_list_move_selected_up(command->list);
object_list_remove_move_cb(command->list, id);
redraw_preview(); /* fix me! */
return TRUE;
}
static void
move_up_command_undo(Command_t *parent)
{
}
static void
move_up_command_redo(Command_t *parent)
{
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_MOVE_UP_H
#define _IMAP_CMD_MOVE_UP_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *move_up_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_MOVE_UP_H */

View file

@ -0,0 +1,76 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy.h"
#include "imap_main.h"
static void object_down_command_destruct(Command_t *parent);
static gboolean object_down_command_execute(Command_t *parent);
static void object_down_command_undo(Command_t *parent);
CommandClass_t object_down_command_class = {
object_down_command_destruct,
object_down_command_execute,
object_down_command_undo,
NULL /* object_down_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
Object_t *obj;
} ObjectDownCommand_t;
Command_t*
object_down_command_new(ObjectList_t *list, Object_t *obj)
{
ObjectDownCommand_t *command = g_new(ObjectDownCommand_t, 1);
command->list = list;
command->obj = object_ref(obj);
return command_init(&command->parent, "Move Down",
&object_down_command_class);
}
static void
object_down_command_destruct(Command_t *parent)
{
ObjectDownCommand_t *command = (ObjectDownCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
object_down_command_execute(Command_t *parent)
{
ObjectDownCommand_t *command = (ObjectDownCommand_t*) parent;
object_list_move_down(command->list, command->obj);
redraw_preview(); /* fix me! */
return TRUE;
}
static void
object_down_command_undo(Command_t *parent)
{
ObjectDownCommand_t *command = (ObjectDownCommand_t*) parent;
object_list_move_up(command->list, command->obj);
redraw_preview(); /* fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_OBJECT_DOWN_H
#define _IMAP_CMD_OBJECT_DOWN_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *object_down_command_new(ObjectList_t *list, Object_t *obj);
#endif /* _IMAP_CMD_OBJECT_DOWN_H */

View file

@ -0,0 +1,77 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_copy.h"
#include "imap_main.h"
static void object_up_command_destruct(Command_t *parent);
static gboolean object_up_command_execute(Command_t *parent);
static void object_up_command_undo(Command_t *parent);
CommandClass_t object_up_command_class = {
object_up_command_destruct,
object_up_command_execute,
object_up_command_undo,
NULL /* object_up_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
Object_t *obj;
} ObjectUpCommand_t;
Command_t*
object_up_command_new(ObjectList_t *list, Object_t *obj)
{
ObjectUpCommand_t *command = g_new(ObjectUpCommand_t, 1);
command->list = list;
command->obj = object_ref(obj);
return command_init(&command->parent, "Move Up",
&object_up_command_class);
}
static void
object_up_command_destruct(Command_t *parent)
{
ObjectUpCommand_t *command = (ObjectUpCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
object_up_command_execute(Command_t *parent)
{
ObjectUpCommand_t *command = (ObjectUpCommand_t*) parent;
object_list_move_up(command->list, command->obj);
redraw_preview(); /* fix me! */
return TRUE;
}
static void
object_up_command_undo(Command_t *parent)
{
ObjectUpCommand_t *command = (ObjectUpCommand_t*) parent;
object_list_move_down(command->list, command->obj);
redraw_preview(); /* fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_OBJECT_UP_H
#define _IMAP_CMD_OBJECT_UP_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *object_up_command_new(ObjectList_t *list, Object_t *obj);
#endif /* _IMAP_CMD_OBJECT_UP_H */

View file

@ -0,0 +1,72 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_create.h"
#include "imap_cmd_paste.h"
#include "imap_main.h"
static gboolean paste_command_execute(Command_t *parent);
static CommandClass_t paste_command_class = {
NULL, /* paste_command_destruct, */
paste_command_execute,
NULL, /* paste_command_undo */
NULL /* paste_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} PasteCommand_t;
Command_t*
paste_command_new(ObjectList_t *list)
{
PasteCommand_t *command = g_new(PasteCommand_t, 1);
command->list = list;
return command_init(&command->parent, "Paste", &paste_command_class);
}
static void
paste_one_object(Object_t *obj, gpointer data)
{
PasteCommand_t *command = (PasteCommand_t*) data;
command_add_subcommand(&command->parent,
create_command_new(command->list, obj));
}
static gboolean
paste_command_execute(Command_t *parent)
{
PasteCommand_t *command = (PasteCommand_t*) parent;
gpointer id;
id = object_list_add_add_cb(command->list, paste_one_object, command);
object_list_paste(command->list);
redraw_preview(); /* Fix me! */
object_list_remove_add_cb(command->list, id);
return TRUE;
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_PASTE_H
#define _IMAP_CMD_PASTE_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *paste_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_PASTE_H */

View file

@ -0,0 +1,74 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_select.h"
#include "imap_main.h"
static void select_command_destruct(Command_t *parent);
static gboolean select_command_execute(Command_t *parent);
static void select_command_undo(Command_t *parent);
static CommandClass_t select_command_class = {
select_command_destruct,
select_command_execute,
select_command_undo,
NULL /* select_command_redo */
};
typedef struct {
Command_t parent;
Object_t *obj;
} SelectCommand_t;
Command_t*
select_command_new(Object_t *obj)
{
SelectCommand_t *command = g_new(SelectCommand_t, 1);
command->obj = object_ref(obj);
return command_init(&command->parent, "Select", &select_command_class);
}
static void
select_command_destruct(Command_t *parent)
{
SelectCommand_t *command = (SelectCommand_t*) parent;
object_unref(command->obj);
}
static gboolean
select_command_execute(Command_t *parent)
{
SelectCommand_t *command = (SelectCommand_t*) parent;
object_select(command->obj);
return TRUE;
}
static void
select_command_undo(Command_t *parent)
{
SelectCommand_t *command = (SelectCommand_t*) parent;
object_unselect(command->obj);
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_SELECT_H
#define _IMAP_CMD_SELECT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *select_command_new(Object_t *obj);
#endif /* _IMAP_CMD_SELECT_H */

View file

@ -0,0 +1,91 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_select.h"
#include "imap_cmd_select_all.h"
#include "imap_main.h"
static gboolean select_all_command_execute(Command_t *parent);
static void select_all_command_undo(Command_t *parent);
static void select_all_command_redo(Command_t *parent);
static CommandClass_t select_all_command_class = {
NULL, /* select_all_command_destruct, */
select_all_command_execute,
select_all_command_undo,
select_all_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} SelectAllCommand_t;
Command_t*
select_all_command_new(ObjectList_t *list)
{
SelectAllCommand_t *command = g_new(SelectAllCommand_t, 1);
command->list = list;
return command_init(&command->parent, "Select All",
&select_all_command_class);
}
static void
select_one_object(Object_t *obj, gpointer data)
{
SelectAllCommand_t *command = (SelectAllCommand_t*) data;
command_add_subcommand(&command->parent, select_command_new(obj));
}
static gboolean
select_all_command_execute(Command_t *parent)
{
SelectAllCommand_t *command = (SelectAllCommand_t*) parent;
gpointer id;
gboolean rvalue;
id = object_list_add_select_cb(command->list, select_one_object, command);
if (object_list_select_all(command->list)) {
redraw_preview(); /* Fix me! */
rvalue = TRUE;
} else {
rvalue = FALSE;
}
object_list_remove_select_cb(command->list, id);
return rvalue;
}
static void
select_all_command_undo(Command_t *parent)
{
redraw_preview(); /* Fix me! */
}
static void
select_all_command_redo(Command_t *parent)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_SELECT_ALL_H
#define _IMAP_CMD_SELECT_ALL_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *select_all_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_SELECT_ALL_H */

View file

@ -0,0 +1,152 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_rectangle.h"
#include "imap_cmd_select.h"
#include "imap_cmd_select_region.h"
#include "imap_cmd_unselect_all.h"
#include "imap_main.h"
static gboolean select_region_command_execute(Command_t *parent);
static void select_region_command_undo(Command_t *parent);
static void select_region_command_redo(Command_t *parent);
static CommandClass_t select_region_command_class = {
NULL, /* select_region_command_destruct, */
select_region_command_execute,
select_region_command_undo,
select_region_command_redo
};
typedef struct {
Command_t parent;
GtkWidget *widget;
ObjectList_t *list;
gint x;
gint y;
Object_t *obj;
} SelectRegionCommand_t;
Command_t*
select_region_command_new(GtkWidget *widget, ObjectList_t *list, gint x,
gint y)
{
SelectRegionCommand_t *command = g_new(SelectRegionCommand_t, 1);
Command_t *sub_command;
command->widget = widget;
command->list = list;
command->x = x;
command->y = y;
(void) command_init(&command->parent, "Select Region",
&select_region_command_class);
sub_command = unselect_all_command_new(list, NULL);
command_add_subcommand(&command->parent, sub_command);
return &command->parent;
}
static void
select_one_object(Object_t *obj, gpointer data)
{
SelectRegionCommand_t *command = (SelectRegionCommand_t*) data;
command_add_subcommand(&command->parent, select_command_new(obj));
}
static void
select_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
SelectRegionCommand_t *command = (SelectRegionCommand_t*) data;
Object_t *obj = command->obj;
Rectangle_t *rectangle = ObjectToRectangle(obj);
gint x = get_real_coord((gint) event->x);
gint y = get_real_coord((gint) event->y);
object_draw(obj, widget->window);
rectangle->width = x - rectangle->x;
rectangle->height = y - rectangle->y;
object_draw(obj, widget->window);
}
static void
select_release(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
SelectRegionCommand_t *command = (SelectRegionCommand_t*) data;
Object_t *obj = command->obj;
Rectangle_t *rectangle = ObjectToRectangle(obj);
gpointer id;
gtk_signal_disconnect_by_func(GTK_OBJECT(widget),
(GtkSignalFunc) select_motion, data);
gtk_signal_disconnect_by_func(GTK_OBJECT(widget),
(GtkSignalFunc) select_release, data);
object_draw(obj, widget->window);
object_normalize(obj);
gdk_gc_set_function(get_preferences()->normal_gc, GDK_COPY);
id = object_list_add_select_cb(command->list, select_one_object, command);
if (object_list_select_region(command->list, rectangle->x, rectangle->y,
rectangle->width, rectangle->height))
redraw_preview();
object_list_remove_select_cb(command->list, id);
object_unref(obj);
}
static gboolean
select_region_command_execute(Command_t *parent)
{
SelectRegionCommand_t *command = (SelectRegionCommand_t*) parent;
/* Command_t *sub_command; */
command->obj = create_rectangle(command->x, command->y, 0, 0);
gtk_signal_connect(GTK_OBJECT(command->widget), "button_release_event",
(GtkSignalFunc) select_release, command);
gtk_signal_connect(GTK_OBJECT(command->widget), "motion_notify_event",
(GtkSignalFunc) select_motion, command);
#ifdef _OLD_
sub_command = unselect_all_command_new(command->list, NULL);
command_add_subcommand(parent, sub_command);
command_execute(sub_command);
#endif
gdk_gc_set_function(get_preferences()->normal_gc, GDK_EQUIV);
return TRUE;
}
static void
select_region_command_undo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}
static void
select_region_command_redo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,33 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_SELECT_REGION_H
#define _IMAP_CMD_SELECT_REGION_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *select_region_command_new(GtkWidget *widget, ObjectList_t *list,
gint x, gint y);
#endif /* _IMAP_CMD_SELECT_REGION_H */

View file

@ -0,0 +1,98 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_create.h"
#include "imap_cmd_delete.h"
#include "imap_cmd_send_to_back.h"
#include "imap_main.h"
static gboolean send_to_back_command_execute(Command_t *parent);
static void send_to_back_command_undo(Command_t *parent);
static void send_to_back_command_redo(Command_t *parent);
static CommandClass_t send_to_back_command_class = {
NULL, /* send_to_back_command_destruct, */
send_to_back_command_execute,
send_to_back_command_undo,
send_to_back_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} SendToBackCommand_t;
Command_t*
send_to_back_command_new(ObjectList_t *list)
{
SendToBackCommand_t *command = g_new(SendToBackCommand_t, 1);
command->list = list;
return command_init(&command->parent, "Send To Back",
&send_to_back_command_class);
}
static void
remove_one_object(Object_t *obj, gpointer data)
{
SendToBackCommand_t *command = (SendToBackCommand_t*) data;
command_add_subcommand(&command->parent,
delete_command_new(command->list, obj));
}
static void
add_one_object(Object_t *obj, gpointer data)
{
SendToBackCommand_t *command = (SendToBackCommand_t*) data;
command_add_subcommand(&command->parent,
create_command_new(command->list, obj));
}
static gboolean
send_to_back_command_execute(Command_t *parent)
{
SendToBackCommand_t *command = (SendToBackCommand_t*) parent;
gpointer id1, id2;
id1 = object_list_add_remove_cb(command->list, remove_one_object, command);
id2 = object_list_add_add_cb(command->list, add_one_object, command);
object_list_send_to_back(command->list);
redraw_preview(); /* Fix me! */
object_list_remove_remove_cb(command->list, id1);
object_list_remove_add_cb(command->list, id2);
return TRUE;
}
static void
send_to_back_command_undo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}
static void
send_to_back_command_redo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_SEND_TO_BACK_H
#define _IMAP_CMD_SEND_TO_BACK_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *send_to_back_command_new(ObjectList_t *list);
#endif /* _IMAP_CMD_SEND_TO_BACK_H */

View file

@ -0,0 +1,73 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_unselect.h"
#include "imap_main.h"
static void unselect_command_destruct(Command_t *parent);
static gboolean unselect_command_execute(Command_t *parent);
static void unselect_command_undo(Command_t *parent);
static CommandClass_t unselect_command_class = {
unselect_command_destruct,
unselect_command_execute,
unselect_command_undo,
NULL /* unselect_command_redo */
};
typedef struct {
Command_t parent;
Object_t *obj;
} UnselectCommand_t;
Command_t*
unselect_command_new(Object_t *obj)
{
UnselectCommand_t *command = g_new(UnselectCommand_t, 1);
command->obj = object_ref(obj);
return command_init(&command->parent, "Unselect",
&unselect_command_class);
}
static void
unselect_command_destruct(Command_t *command)
{
UnselectCommand_t *unselect_command = (UnselectCommand_t*) command;
object_unref(unselect_command->obj);
}
static gboolean
unselect_command_execute(Command_t *command)
{
UnselectCommand_t *unselect_command = (UnselectCommand_t*) command;
object_unselect(unselect_command->obj);
return TRUE;
}
static void
unselect_command_undo(Command_t *command)
{
UnselectCommand_t *unselect_command = (UnselectCommand_t*) command;
object_select(unselect_command->obj);
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_UNSELECT_H
#define _IMAP_CMD_UNSELECT_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *unselect_command_new(Object_t *obj);
#endif /* _IMAP_CMD_UNSELECT_H */

View file

@ -0,0 +1,99 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_cmd_unselect.h"
#include "imap_cmd_unselect_all.h"
#include "imap_main.h"
COMMAND_PROTO(unselect_all_command);
static CommandClass_t unselect_all_command_class = {
unselect_all_command_destruct,
unselect_all_command_execute,
unselect_all_command_undo,
unselect_all_command_redo
};
typedef struct {
Command_t parent;
ObjectList_t *list;
Object_t *exception;
} UnselectAllCommand_t;
Command_t*
unselect_all_command_new(ObjectList_t *list, Object_t *exception)
{
UnselectAllCommand_t *command = g_new(UnselectAllCommand_t, 1);
command->list = list;
command->exception = (exception) ? object_ref(exception) : exception;
return command_init(&command->parent, "Unselect All",
&unselect_all_command_class);
}
static void
unselect_all_command_destruct(Command_t *parent)
{
UnselectAllCommand_t *command = (UnselectAllCommand_t*) parent;
if (command->exception)
object_unref(command->exception);
}
static void
select_one_object(Object_t *obj, gpointer data)
{
UnselectAllCommand_t *command = (UnselectAllCommand_t*) data;
command_add_subcommand(&command->parent, unselect_command_new(obj));
}
static gboolean
unselect_all_command_execute(Command_t *parent)
{
UnselectAllCommand_t *command = (UnselectAllCommand_t*) parent;
gpointer id;
gboolean rvalue;
id = object_list_add_select_cb(command->list, select_one_object,
command);
if (object_list_deselect_all(command->list, command->exception)) {
redraw_preview(); /* Fix me! */
rvalue = TRUE;
} else {
rvalue = FALSE;
}
object_list_remove_select_cb(command->list, id);
return rvalue;
}
static void
unselect_all_command_undo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}
static void
unselect_all_command_redo(Command_t *command)
{
redraw_preview(); /* Fix me! */
}

View file

@ -0,0 +1,32 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_CMD_UNSELECT_ALL_H
#define _IMAP_CMD_UNSELECT_ALL_H
#include "imap_command.h"
#include "imap_object.h"
Command_t *unselect_all_command_new(ObjectList_t *list, Object_t *exception);
#endif /* _IMAP_CMD_UNSELECT_ALL_H */

357
plug-ins/imagemap/imap_command.c Executable file
View file

@ -0,0 +1,357 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <stdio.h>
#include "imap_command.h"
#define DEFAULT_UNDO_LEVELS 10
#define INFINITE_UNDO_LEVELS -1
static void command_destruct(Command_t *command);
static CommandList_t _command_list = {NULL, DEFAULT_UNDO_LEVELS};
static CommandList_t *_current_command_list = &_command_list;
static void
command_list_callback_add(CommandListCallback_t *list,
CommandListCallbackFunc_t func, gpointer data)
{
CommandListCB_t *cb = g_new(CommandListCB_t, 1);
cb->func = func;
cb->data = data;
list->list = g_list_append(list->list, cb);
}
static void
command_list_callback_call(CommandListCallback_t *list, Command_t *command)
{
GList *p;
for (p = list->list; p; p = p->next) {
CommandListCB_t *cb = (CommandListCB_t*) p->data;
cb->func(command, cb->data);
}
}
CommandList_t*
command_list_new(gint undo_levels)
{
CommandList_t *list = g_new(CommandList_t, 1);
list->parent = NULL;
list->undo_levels = undo_levels;
list->list = NULL;
list->undo = NULL;
list->redo = NULL;
list->update_cb.list = NULL;
return list;
}
static void
command_list_clear(CommandList_t *list)
{
GList *p;
for (p = list->list; p; p = p->next)
command_destruct((Command_t*) p->data);
g_list_free(list->list);
list->list = NULL;
list->undo = NULL;
list->redo = NULL;
command_list_callback_call(&list->update_cb, NULL);
}
void
command_list_destruct(CommandList_t *list)
{
command_list_clear(list);
g_free(list);
}
void
command_list_remove_all(void)
{
command_list_clear(&_command_list);
}
static void
_command_list_add(CommandList_t *list, Command_t *command)
{
GList *p, *q;
/* Remove rest */
for (p = list->redo; p; p = q) {
Command_t *curr = (Command_t*) p->data;
q = p->next;
command_destruct(curr);
list->list = g_list_remove_link(list->list, p);
}
if (g_list_length(list->list) == list->undo_levels) {
GList *first = g_list_first(list->list);
Command_t *curr = (Command_t*) first->data;
command_destruct(curr);
list->list = g_list_remove_link(list->list, first);
}
list->list = g_list_append(list->list, (gpointer) command);
list->undo = g_list_last(list->list);
list->redo = NULL;
command_list_callback_call(&list->update_cb, command);
}
void
command_list_add(Command_t *command)
{
_command_list_add(_current_command_list, command);
}
/* Fix me! */
void
subcommand_list_add(CommandList_t *list, Command_t *command)
{
_command_list_add(list, command);
}
static CommandClass_t parent_command_class = {
NULL, /* parent_command_destruct */
NULL, /* parent_command_execute */
NULL, /* parent_command_undo */
NULL /* parent_command_redo */
};
static Command_t*
command_list_start(CommandList_t *list, const gchar *name)
{
Command_t *command = g_new(Command_t, 1);
command_init(command, name, &parent_command_class);
command->sub_commands = command_list_new(INFINITE_UNDO_LEVELS);
command_list_add(command);
command->sub_commands->parent = _current_command_list;
_current_command_list = command->sub_commands;
return command;
}
static void
command_list_end(CommandList_t *list)
{
_current_command_list = list->parent;
}
Command_t*
subcommand_start(const gchar *name)
{
return command_list_start(_current_command_list, name);
}
void
subcommand_end(void)
{
command_list_end(_current_command_list);
}
void
command_list_set_undo_level(gint level)
{
/* Fix me */
}
Command_t*
command_list_get_redo_command(void)
{
return (_command_list.redo) ? (Command_t*) _command_list.redo->data :
NULL;
}
void
command_list_add_update_cb(CommandListCallbackFunc_t func, gpointer data)
{
command_list_callback_add(&_command_list.update_cb, func, data);
}
static void
command_destruct(Command_t *command)
{
if (command->sub_commands)
command_list_destruct(command->sub_commands);
if (command->class->destruct)
command->class->destruct(command);
}
static void
command_list_execute(CommandList_t *list)
{
GList *p;
for (p = list->list; p; p = p->next) {
Command_t *command = (Command_t*) p->data;
if (command->sub_commands)
command_list_execute(command->sub_commands);
if (command->class->execute)
(void) command->class->execute(command);
}
}
void
command_execute(Command_t *command)
{
if (command->locked) {
command->locked = FALSE;
} else {
if (command->sub_commands)
command_list_execute(command->sub_commands);
if (command->class->execute) {
if (command->class->execute(command))
command_list_add(command);
else
command_destruct(command);
}
}
}
void
command_redo(Command_t *command)
{
if (command->sub_commands)
command_list_redo_all(command->sub_commands);
if (command->class->redo)
command->class->redo(command);
else if (command->class->execute)
(void) command->class->execute(command);
}
void
command_undo(Command_t *command)
{
if (command->sub_commands)
command_list_undo_all(command->sub_commands);
if (command->class->undo)
command->class->undo(command);
}
void
command_set_name(Command_t *command, const gchar *name)
{
command->name = name;
command_list_callback_call(&_command_list.update_cb, command);
}
void
command_list_undo(CommandList_t *list)
{
Command_t *command = (Command_t*) list->undo->data;
command_undo(command);
list->redo = list->undo;
list->undo = list->undo->prev;
if (list->undo)
command = (Command_t*) list->undo->data;
else
command = NULL;
command_list_callback_call(&list->update_cb, command);
}
void
command_list_undo_all(CommandList_t *list)
{
while (list->undo)
command_list_undo(list);
}
void
last_command_undo(void)
{
command_list_undo(&_command_list);
}
void
command_list_redo(CommandList_t *list)
{
Command_t *command = (Command_t*) list->redo->data;
command_redo(command);
list->undo = list->redo;
list->redo = list->redo->next;
command_list_callback_call(&list->update_cb, command);
}
void
command_list_redo_all(CommandList_t *list)
{
while (list->redo)
command_list_redo(list);
}
void
last_command_redo(void)
{
command_list_redo(&_command_list);
}
Command_t*
command_init(Command_t *command, const gchar *name, CommandClass_t *class)
{
command->sub_commands = NULL;
command->name = name;
command->class = class;
command->locked = FALSE;
return command;
}
void
command_add_subcommand(Command_t *command, Command_t *sub_command)
{
if (!command->sub_commands)
command->sub_commands = command_list_new(INFINITE_UNDO_LEVELS);
subcommand_list_add(command->sub_commands, sub_command);
}
static gboolean basic_command_execute(Command_t *command);
static CommandClass_t basic_command_class = {
NULL, /* basic_command_destruct */
basic_command_execute,
NULL,
NULL /* basic_command_redo */
};
typedef struct {
Command_t parent;
void (*func)(void);
} BasicCommand_t;
Command_t*
command_new(void (*func)(void))
{
BasicCommand_t *command = g_new(BasicCommand_t, 1);
command->func = func;
return command_init(&command->parent, "Unknown", &basic_command_class);
}
static gboolean
basic_command_execute(Command_t *command)
{
((BasicCommand_t*) command)->func();
return FALSE;
}

106
plug-ins/imagemap/imap_command.h Executable file
View file

@ -0,0 +1,106 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_COMMAND_H
#define _IMAP_COMMAND_H
#include "imap_object.h"
typedef struct CommandClass_t CommandClass_t;
typedef struct Command_t Command_t;
typedef struct CommandList_t CommandList_t;
#define COMMAND_PROTO(class) \
static void class##_destruct(Command_t *command); \
static gboolean class##_execute(Command_t *command); \
static void class##_undo(Command_t *command); \
static void class##_redo(Command_t *command)
struct CommandClass_t {
void (*destruct)(Command_t*);
gboolean (*execute)(Command_t*);
void (*undo)(Command_t*);
void (*redo)(Command_t*);
};
struct Command_t {
CommandClass_t *class;
CommandList_t *sub_commands;
const gchar *name;
gboolean locked;
};
typedef Command_t* (*CommandFactory_t)(void);
typedef void (*CommandListCallbackFunc_t)(Command_t*, gpointer);
typedef struct {
CommandListCallbackFunc_t func;
gpointer data;
} CommandListCB_t;
typedef struct {
GList *list;
} CommandListCallback_t;
struct CommandList_t {
CommandList_t *parent;
gint undo_levels;
GList *list;
GList *undo; /* Pointer to current undo command */
GList *redo; /* Pointer to current redo command */
CommandListCallback_t update_cb;
};
CommandList_t *command_list_new(gint undo_levels);
void command_list_destruct(CommandList_t *list);
void command_list_set_undo_level(gint level);
void command_list_add(Command_t *command);
void command_list_remove_all(void);
void command_list_undo(CommandList_t *list);
void command_list_undo_all(CommandList_t *list);
void command_list_redo(CommandList_t *list);
void command_list_redo_all(CommandList_t *list);
void command_list_add_update_cb(CommandListCallbackFunc_t func, gpointer data);
Command_t *command_list_get_redo_command(void);
Command_t *command_new(void (*func)(void));
Command_t *command_init(Command_t *command, const gchar *name,
CommandClass_t *class);
void command_execute(Command_t *command);
void command_undo(Command_t *command);
void command_redo(Command_t *command);
void command_set_name(Command_t *command, const gchar *name);
void command_add_subcommand(Command_t *command, Command_t *sub_command);
void last_command_undo(void);
void last_command_redo(void);
void subcommand_list_add(CommandList_t *list, Command_t *command);
Command_t *subcommand_start(const gchar *name);
void subcommand_end(void);
#define command_lock(command) ((command)->locked = TRUE)
#endif /* _IMAP_COMMAND_H */

127
plug-ins/imagemap/imap_csim.l Executable file
View file

@ -0,0 +1,127 @@
%{
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_csim_parse.h"
%}
%option noyywrap
DIGIT [0-9]
ID [a-zA-Z_][a-zA-Z0-9_\-]*
WS [ \t\n]+
%x quoted_string
%x comment
%%
\<!--\ #$AUTHOR: {
BEGIN(comment);
return AUTHOR;
}
\<!--\ #$DESCRIPTION: {
BEGIN(comment);
return DESCRIPTION;
}
\<!-- {
BEGIN(comment);
return BEGIN_COMMENT;
}
<comment>--\> {
BEGIN(INITIAL);
return END_COMMENT;
}
<comment>.*/--\> {
strcpy(csim_lval.id, yytext);
csim_lval.id[yyleng - 1] = '\0';
return STRING;
}
IMG return IMG;
SRC return SRC;
WIDTH return WIDTH;
HEIGHT return HEIGHT;
BORDER return BORDER;
USEMAP return USEMAP;
MAP return START_MAP;
\/MAP return END_MAP;
NAME return NAME;
AREA return AREA;
SHAPE return SHAPE;
COORDS return COORDS;
TARGET return TARGET;
ONMOUSEOVER return ONMOUSEOVER;
ONMOUSEOUT return ONMOUSEOUT;
ONFOCUS return ONFOCUS;
ONBLUR return ONBLUR;
ALT return ALT;
HREF return HREF;
NOHREF return NOHREF;
\" {
BEGIN(quoted_string);
*csim_lval.id = 0;
}
<quoted_string>\" {
BEGIN(INITIAL);
return STRING;
}
<quoted_string>[^\"]* strcpy(csim_lval.id, yytext);
-?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? {
csim_lval.value = atof(yytext);
return FLOAT;
}
{WS} ; /* Eat white space */
. return *yytext;
%%

309
plug-ins/imagemap/imap_csim.y Executable file
View file

@ -0,0 +1,309 @@
%{
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <stdlib.h>
#include <strings.h>
#include "gtk/gtk.h"
#include "imap_circle.h"
#include "imap_file.h"
#include "imap_main.h"
#include "imap_polygon.h"
#include "imap_rectangle.h"
#include "imap_string.h"
extern int csim_lex();
extern int csim_restart();
static void csim_error(char* s);
static enum {UNDEFINED, RECTANGLE, CIRCLE, POLYGON} current_type;
static Object_t *current_object;
static MapInfo_t *_map_info;
%}
%union {
int val;
double value;
char id[256];
}
%token<val> IMG SRC WIDTH HEIGHT BORDER USEMAP
%token<val> START_MAP END_MAP NAME AREA SHAPE COORDS ALT HREF NOHREF
%token<val> TARGET ONMOUSEOVER ONMOUSEOUT ONFOCUS ONBLUR
%token<val> AUTHOR DESCRIPTION BEGIN_COMMENT END_COMMENT
%token<value> FLOAT
%token<id> STRING
%%
csim_file : image start_map comment_lines area_list end_map
;
image : '<' IMG SRC '=' STRING image_tags '>'
{
g_strreplace(&_map_info->image_name, $5);
}
;
image_tags : /* Empty */
| image_tags image_tag
;
image_tag : image_width
| image_height
| BORDER '=' FLOAT {}
| USEMAP '=' STRING {}
| ALT '=' STRING {}
;
image_width : WIDTH '=' FLOAT
{
_map_info->old_image_width = (gint) $3;
}
;
image_height : HEIGHT '=' FLOAT
{
_map_info->old_image_height = (gint) $3;
}
;
start_map : '<' START_MAP NAME '=' STRING '>'
{
g_strreplace(&_map_info->title, $5);
}
;
comment_lines : /* empty */
| comment_lines comment_line
;
comment_line : author_line
| description_line
| real_comment
;
real_comment : BEGIN_COMMENT STRING END_COMMENT
{
}
;
author_line : AUTHOR STRING END_COMMENT
{
g_strreplace(&_map_info->author, $2);
}
;
description_line: DESCRIPTION STRING END_COMMENT
{
gchar *description;
description = g_strconcat(_map_info->description, $2, "\n",
NULL);
g_strreplace(&_map_info->description, description);
}
;
area_list : /* empty */
| area_list area
;
area : '<' AREA tag_list '>'
{
if (current_type != UNDEFINED)
add_shape(current_object);
}
;
tag_list : /* Empty */
| tag_list tag
;
tag : shape_tag
| coords_tag
| href_tag
| nohref_tag
| alt_tag
| target_tag
| onmouseover_tag
| onmouseout_tag
| onfocus_tag
| onblur_tag
;
shape_tag : SHAPE '=' STRING
{
if (!strcasecmp($3, "RECT")) {
current_object = create_rectangle(0, 0, 0, 0);
current_type = RECTANGLE;
} else if (!strcasecmp($3, "CIRCLE")) {
current_object = create_circle(0, 0, 0);
current_type = CIRCLE;
} else if (!strcasecmp($3, "POLY")) {
current_object = create_polygon(NULL);
current_type = POLYGON;
} else if (!strcasecmp($3, "DEFAULT")) {
current_type = UNDEFINED;
}
}
;
coords_tag : COORDS '=' STRING
{
char *p;
if (current_type == RECTANGLE) {
Rectangle_t *rectangle;
rectangle = ObjectToRectangle(current_object);
p = strtok($3, ",");
rectangle->x = atoi(p);
p = strtok(NULL, ",");
rectangle->y = atoi(p);
p = strtok(NULL, ",");
rectangle->width = atoi(p) - rectangle->x;
p = strtok(NULL, ",");
rectangle->height = atoi(p) - rectangle->y;
} else if (current_type == CIRCLE) {
Circle_t *circle;
circle = ObjectToCircle(current_object);
p = strtok($3, ",");
circle->x = atoi(p);
p = strtok(NULL, ",");
circle->y = atoi(p);
p = strtok(NULL, ",");
circle->r = atoi(p);
} else if (current_type == POLYGON) {
Polygon_t *polygon = ObjectToPolygon(current_object);
GList *points;
GdkPoint *point, *first;
gint x, y;
p = strtok($3, ",");
x = atoi(p);
p = strtok(NULL, ",");
y = atoi(p);
point = new_point(x, y);
points = g_list_append(NULL, (gpointer) point);
while(1) {
p = strtok(NULL, ",");
if (!p)
break;
x = atoi(p);
p = strtok(NULL, ",");
y = atoi(p);
point = new_point(x, y);
g_list_append(points, (gpointer) point);
}
/* Remove last point if duplicate */
first = (GdkPoint*) points->data;
if (first->x == point->x && first->y == point->y)
polygon_remove_last_point(polygon);
polygon->points = points;
}
}
;
href_tag : HREF '=' STRING
{
if (current_type == UNDEFINED) {
g_strreplace(&_map_info->default_url, $3);
} else {
object_set_url(current_object, $3);
}
}
;
nohref_tag : NOHREF
{
}
;
alt_tag : ALT '=' STRING
{
object_set_comment(current_object, $3);
}
;
target_tag : TARGET '=' STRING
{
object_set_target(current_object, $3);
}
;
onmouseover_tag : ONMOUSEOVER '=' STRING
{
object_set_mouse_over(current_object, $3);
}
;
onmouseout_tag : ONMOUSEOUT '=' STRING
{
object_set_mouse_out(current_object, $3);
}
;
onfocus_tag : ONFOCUS '=' STRING
{
object_set_focus(current_object, $3);
}
;
onblur_tag : ONBLUR '=' STRING
{
object_set_blur(current_object, $3);
}
;
end_map : '<' END_MAP '>'
;
%%
static void
csim_error(char* s)
{
extern FILE *csim_in;
csim_restart(csim_in);
}
gboolean
load_csim(const char* filename)
{
gboolean status;
extern FILE *csim_in;
csim_in = fopen(filename, "r");
if (csim_in) {
_map_info = get_map_info();
status = !csim_parse();
fclose(csim_in);
} else {
status = FALSE;
}
return status;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
typedef union {
int val;
double value;
char id[256];
} YYSTYPE;
#define IMG 258
#define SRC 259
#define WIDTH 260
#define HEIGHT 261
#define BORDER 262
#define USEMAP 263
#define START_MAP 264
#define END_MAP 265
#define NAME 266
#define AREA 267
#define SHAPE 268
#define COORDS 269
#define ALT 270
#define HREF 271
#define NOHREF 272
#define TARGET 273
#define ONMOUSEOVER 274
#define ONMOUSEOUT 275
#define ONFOCUS 276
#define ONBLUR 277
#define AUTHOR 278
#define DESCRIPTION 279
#define BEGIN_COMMENT 280
#define END_COMMENT 281
#define FLOAT 282
#define STRING 283
extern YYSTYPE csim_lval;

View file

@ -0,0 +1,152 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_default_dialog.h"
static void
dialog_cancel(GtkWidget *widget, gpointer data)
{
DefaultDialog_t *dialog = (DefaultDialog_t*) data;
gtk_widget_hide(dialog->dialog);
if (dialog->cancel_cb)
dialog->cancel_cb(dialog->cancel_cb_data);
}
static void
dialog_destroy(GtkWidget *widget, GdkEvent *event, gpointer data)
{
dialog_cancel(widget, data);
}
static void
dialog_apply(GtkWidget *widget, gpointer data)
{
DefaultDialog_t *dialog = (DefaultDialog_t*) data;
if (dialog->ok_cb)
dialog->ok_cb(dialog->ok_cb_data);
}
static void
dialog_ok(GtkWidget *widget, gpointer data)
{
DefaultDialog_t *dialog = (DefaultDialog_t*) data;
gtk_widget_hide(dialog->dialog);
if (dialog->ok_cb)
dialog->ok_cb(dialog->ok_cb_data);
}
void
default_dialog_set_ok_cb(DefaultDialog_t *dialog, void (*ok_cb)(gpointer),
gpointer ok_cb_data)
{
dialog->ok_cb = ok_cb;
dialog->ok_cb_data = ok_cb_data;
}
void
default_dialog_set_cancel_cb(DefaultDialog_t *dialog,
void (*cancel_cb)(gpointer),
gpointer cancel_cb_data)
{
dialog->cancel_cb = cancel_cb;
dialog->cancel_cb_data = cancel_cb_data;
}
DefaultDialog_t*
make_default_dialog(const gchar *title)
{
DefaultDialog_t *data = (DefaultDialog_t*) g_new(DefaultDialog_t, 1);
GtkWidget *dialog;
data->ok_cb = NULL;
data->cancel_cb = NULL;
data->dialog = dialog = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(dialog), title);
gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
GTK_SIGNAL_FUNC(dialog_destroy), (gpointer) data);
data->ok = gtk_button_new_with_label("OK");
GTK_WIDGET_SET_FLAGS(data->ok, GTK_CAN_DEFAULT);
gtk_signal_connect(GTK_OBJECT(data->ok), "clicked",
GTK_SIGNAL_FUNC(dialog_ok), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), data->ok, TRUE,
TRUE, 0);
gtk_widget_grab_default(data->ok);
gtk_widget_show(data->ok);
data->apply = gtk_button_new_with_label("Apply");
gtk_signal_connect(GTK_OBJECT(data->apply), "clicked",
GTK_SIGNAL_FUNC(dialog_apply), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), data->apply,
TRUE, TRUE, 0);
gtk_widget_show(data->apply);
data->cancel = gtk_button_new_with_label("Cancel");
gtk_signal_connect(GTK_OBJECT(data->cancel), "clicked",
GTK_SIGNAL_FUNC(dialog_cancel), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), data->cancel,
TRUE, TRUE, 0);
gtk_widget_show(data->cancel);
return data;
}
void
default_dialog_show(DefaultDialog_t *dialog)
{
gtk_widget_show(dialog->dialog);
}
void
default_dialog_hide_cancel_button(DefaultDialog_t *dialog)
{
gtk_widget_hide(dialog->cancel);
}
void
default_dialog_hide_apply_button(DefaultDialog_t *dialog)
{
gtk_widget_hide(dialog->apply);
}
void
default_dialog_set_title(DefaultDialog_t *dialog, const gchar *title)
{
gtk_window_set_title(GTK_WINDOW(dialog->dialog), title);
}
void
default_dialog_set_ok_sensitivity(DefaultDialog_t *dialog, gint sensitive)
{
gtk_widget_set_sensitive(dialog->ok, sensitive);
}
void
default_dialog_set_label(DefaultDialog_t *dialog, gchar *text)
{
GtkWidget *label = gtk_label_new(text);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), label,
TRUE, TRUE, 10);
gtk_widget_show(label);
}

View file

@ -0,0 +1,54 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_DEFAULT_DIALOG_H
#define _IMAP_DEFAULT_DIALOG_H
#include "gtk/gtk.h"
typedef struct {
GtkWidget *dialog;
GtkWidget *ok;
GtkWidget *apply;
GtkWidget *cancel;
void (*ok_cb)(gpointer);
gpointer ok_cb_data;
void (*cancel_cb)(gpointer);
gpointer cancel_cb_data;
} DefaultDialog_t;
DefaultDialog_t *make_default_dialog(const gchar *title);
void default_dialog_set_ok_cb(DefaultDialog_t *dialog, void (*ok_cb)(gpointer),
gpointer ok_cb_data);
void default_dialog_set_cancel_cb(DefaultDialog_t *dialog,
void (*ok_cb)(gpointer),
gpointer ok_cb_data);
void default_dialog_show(DefaultDialog_t *dialog);
void default_dialog_hide_cancel_button(DefaultDialog_t *dialog);
void default_dialog_hide_apply_button(DefaultDialog_t *dialog);
void default_dialog_set_title(DefaultDialog_t *dialog, const gchar *title);
void default_dialog_set_ok_sensitivity(DefaultDialog_t *dialog,
gint sensitive);
void default_dialog_set_label(DefaultDialog_t *dialog, gchar *text);
#endif /* _IMAP_DEFAULT_DIALOG_H */

View file

@ -0,0 +1,384 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <stdio.h>
#include <string.h>
#include "imap_browse.h"
#include "imap_cmd_edit_object.h"
#include "imap_default_dialog.h"
#include "imap_edit_area_info.h"
#include "imap_main.h"
#include "imap_table.h"
static gint callback_lock;
static const gchar*
relative_filter(const char *name, gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->relative_link)))
return g_basename(name);
return name;
}
static void
url_changed(GtkWidget *widget, gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
gchar *url = gtk_entry_get_text(GTK_ENTRY(param->url));
GtkWidget *button;
if (!g_strncasecmp(url, "http://", sizeof("http://") - 1))
button = param->web_site;
else if (!g_strncasecmp(url, "ftp://", sizeof("ftp://") - 1))
button = param->ftp_site;
else if (!g_strncasecmp(url, "gopher://", sizeof("gopher://") - 1))
button = param->gopher;
else if (!g_strncasecmp(url, "file:/", sizeof("file:/") - 1))
button = param->file;
else if (!g_strncasecmp(url, "wais://", sizeof("wais://") - 1))
button = param->wais;
else if (!g_strncasecmp(url, "telnet://", sizeof("telnet://") - 1))
button = param->telnet;
else if (!g_strncasecmp(url, "mailto:", sizeof("mailto:") - 1))
button = param->email;
else
button = param->other;
callback_lock = TRUE;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
}
static void
set_url(GtkWidget *widget, AreaInfoDialog_t *param, const gchar *prefix)
{
if (callback_lock) {
callback_lock = FALSE;
} else {
if (GTK_WIDGET_STATE(widget) & GTK_STATE_SELECTED) {
char *p;
gchar *url = g_strdup(gtk_entry_get_text(GTK_ENTRY(param->url)));
p = strstr(url, "//"); /* 'http://' */
if (p) {
p += 2;
} else {
p = strchr(url, ':'); /* 'mailto:' */
if (p) {
p++;
if (*p == '/') /* 'file:/' */
p++;
} else {
p = url;
}
}
gtk_entry_set_text(GTK_ENTRY(param->url), prefix);
gtk_entry_append_text(GTK_ENTRY(param->url), p);
g_free(url);
}
}
gtk_widget_grab_focus(param->url);
}
static void
select_web_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "http://");
}
static void
select_ftp_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "ftp://");
}
static void
select_gopher_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "gopher://");
}
static void
select_other_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "");
}
static void
select_file_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "file:/");
}
static void
select_wais_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "wais://");
}
static void
select_telnet_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "telnet://");
}
static void
select_email_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
set_url(widget, param, "mailto:");
}
static void
create_link_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
{
BrowseWidget_t *browse;
GtkWidget *table, *label;
GtkWidget *subtable, *frame;
GSList *group;
table = gtk_table_new(11, 1, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_widget_show(table);
frame = gtk_frame_new("Link Type");
gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 2, 0, 1);
gtk_widget_show(frame);
subtable = gtk_table_new(2, 4, FALSE);
gtk_container_add(GTK_CONTAINER(frame), subtable);
gtk_widget_show(subtable);
dialog->web_site = create_radio_button_in_table(subtable, NULL, 0, 0,
"Web Site");
gtk_signal_connect(GTK_OBJECT(dialog->web_site), "toggled",
(GtkSignalFunc) select_web_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->web_site));
dialog->ftp_site = create_radio_button_in_table(subtable, group, 0, 1,
"Ftp Site");
gtk_signal_connect(GTK_OBJECT(dialog->ftp_site), "toggled",
(GtkSignalFunc) select_ftp_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->ftp_site));
dialog->gopher = create_radio_button_in_table(subtable, group, 0, 2,
"Gopher");
gtk_signal_connect(GTK_OBJECT(dialog->gopher), "toggled",
(GtkSignalFunc) select_gopher_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->gopher));
dialog->other = create_radio_button_in_table(subtable, group, 0, 3,
"Other");
gtk_signal_connect(GTK_OBJECT(dialog->other), "toggled",
(GtkSignalFunc) select_other_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->other));
dialog->file = create_radio_button_in_table(subtable, group, 1, 0, "File");
gtk_signal_connect(GTK_OBJECT(dialog->file), "toggled",
(GtkSignalFunc) select_file_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->file));
dialog->wais = create_radio_button_in_table(subtable, group, 1, 1, "WAIS");
gtk_signal_connect(GTK_OBJECT(dialog->wais), "toggled",
(GtkSignalFunc) select_wais_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->wais));
dialog->telnet = create_radio_button_in_table(subtable, group, 1, 2,
"Telnet");
gtk_signal_connect(GTK_OBJECT(dialog->telnet), "toggled",
(GtkSignalFunc) select_telnet_cb, (gpointer) dialog);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(dialog->telnet));
dialog->email = create_radio_button_in_table(subtable, group, 1, 3,
"e-mail");
gtk_signal_connect(GTK_OBJECT(dialog->email), "toggled",
(GtkSignalFunc) select_email_cb, (gpointer) dialog);
create_label_in_table(
table, 2, 0,
"URL to activate when this area is clicked: (required)");
browse = browse_widget_new("Select HTML file");
browse_widget_set_filter(browse, relative_filter, (gpointer) dialog);
gtk_table_attach_defaults(GTK_TABLE(table), browse->hbox, 0, 1, 3, 4);
dialog->url = browse->file;
gtk_signal_connect(GTK_OBJECT(dialog->url), "changed",
GTK_SIGNAL_FUNC(url_changed), dialog);
dialog->relative_link = create_check_button_in_table(table, 4, 0,
"Relative link");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->relative_link),
TRUE);
create_label_in_table(
table, 6, 0,
"Target frame name/ID: (optional - used for FRAMES only)");
dialog->target = create_entry_in_table(table, 7, 0);
create_label_in_table(table, 9, 0,
"Comment about this area: (optional)");
dialog->comment = create_entry_in_table(table, 10, 0);
label = gtk_label_new("Link");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
}
static void
create_java_script_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
{
GtkWidget *vbox, *table, *label;
vbox = gtk_vbox_new(FALSE, 1);
gtk_widget_show(vbox);
table = gtk_table_new(11, 1, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_widget_show(table);
create_label_in_table(table, 0, 0, "onMouseover:");
dialog->mouse_over = create_entry_in_table(table, 1, 0);
create_label_in_table(table, 3, 0, "onMouseout:");
dialog->mouse_out = create_entry_in_table(table, 4, 0);
create_label_in_table(table, 6, 0, "onFocus (HTML 4.0):");
dialog->focus = create_entry_in_table(table, 7, 0);
create_label_in_table(table, 9, 0, "onBlur (HTML 4.0):");
dialog->blur = create_entry_in_table(table, 10, 0);
label = gtk_label_new("JavaScript");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
}
static void
edit_area_ok_cb(gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
Object_t *obj = param->obj;
gint old_x, old_y, old_width, old_height;
gint new_x, new_y, new_width, new_height;
/* Fix me: nasty hack */
if (param->add)
command_list_add(edit_object_command_new(obj));
object_get_dimensions(obj, &old_x, &old_y, &old_width, &old_height);
object_set_url(obj, gtk_entry_get_text(GTK_ENTRY(param->url)));
object_set_target(obj, gtk_entry_get_text(GTK_ENTRY(param->target)));
object_set_comment(obj, gtk_entry_get_text(GTK_ENTRY(param->comment)));
object_set_mouse_over(obj,
gtk_entry_get_text(GTK_ENTRY(param->mouse_over)));
object_set_mouse_out(obj, gtk_entry_get_text(GTK_ENTRY(param->mouse_out)));
object_set_focus(obj, gtk_entry_get_text(GTK_ENTRY(param->focus)));
object_set_blur(obj, gtk_entry_get_text(GTK_ENTRY(param->blur)));
object_update(obj, param->infotab);
update_shape(obj);
object_unlock(obj);
object_get_dimensions(obj, &new_x, &new_y, &new_width, &new_height);
if (new_x != old_x || new_y != old_y || new_width != old_width ||
new_height != old_height)
redraw_preview();
}
static void
edit_area_cancel_cb(gpointer data)
{
Object_t *obj = ((AreaInfoDialog_t*) data)->obj;
object_unlock(obj);
}
static void
switch_page(GtkWidget *widget, GtkNotebookPage *page, gint page_num,
gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
if (page_num == 0) {
gtk_widget_grab_focus(param->url);
} else if (page_num == 1) {
Object_t *obj = param->obj;
obj->class->set_initial_focus(obj, param->infotab);
} else {
gtk_widget_grab_focus(param->mouse_over);
}
}
AreaInfoDialog_t*
create_edit_area_info_dialog(Object_t *obj)
{
AreaInfoDialog_t *data = g_new(AreaInfoDialog_t, 1);
GtkWidget *notebook;
data->obj = obj;
data->browse = NULL;
data->dialog = make_default_dialog("Area Settings");
default_dialog_set_ok_cb(data->dialog, edit_area_ok_cb, data);
default_dialog_set_cancel_cb(data->dialog, edit_area_cancel_cb, data);
data->notebook = notebook = gtk_notebook_new();
gtk_container_set_border_width(GTK_CONTAINER(notebook), 10);
gtk_signal_connect_after(GTK_OBJECT(notebook), "switch_page",
GTK_SIGNAL_FUNC(switch_page), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(data->dialog->dialog)->vbox),
notebook, TRUE, TRUE, 10);
create_link_tab(data, notebook);
data->infotab = obj->class->create_info_tab(notebook);
create_java_script_tab(data, notebook);
gtk_widget_show(notebook);
return data;
}
void
edit_area_info_dialog_show(AreaInfoDialog_t *dialog, Object_t *obj,
gboolean add)
{
char title[64];
object_unlock(dialog->obj);
object_lock(obj);
dialog->obj = obj;
dialog->add = add;
obj->class->fill_info_tab(obj, dialog->infotab);
gtk_entry_set_text(GTK_ENTRY(dialog->url), obj->url);
gtk_entry_set_text(GTK_ENTRY(dialog->target), obj->target);
gtk_entry_set_text(GTK_ENTRY(dialog->comment), obj->comment);
gtk_entry_set_text(GTK_ENTRY(dialog->mouse_over), obj->mouse_over);
gtk_entry_set_text(GTK_ENTRY(dialog->mouse_out), obj->mouse_out);
gtk_entry_set_text(GTK_ENTRY(dialog->focus), obj->focus);
gtk_entry_set_text(GTK_ENTRY(dialog->blur), obj->blur);
gtk_widget_grab_focus(dialog->url);
sprintf(title, "Area #%d Settings", object_get_position_in_list(obj) + 1);
default_dialog_set_title(dialog->dialog, title);
default_dialog_show(dialog->dialog);
}

View file

@ -0,0 +1,64 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_EDIT_AREA_INFO_H
#define _IMAP_EDIT_AREA_INFO_H
typedef struct AreaInfoDialog_t AreaInfoDialog_t;
#include "gtk/gtk.h"
#include "imap_default_dialog.h"
#include "imap_object.h"
struct AreaInfoDialog_t {
DefaultDialog_t *dialog;
Object_t *obj;
gboolean add;
GtkWidget *notebook;
GtkWidget *web_site;
GtkWidget *ftp_site;
GtkWidget *gopher;
GtkWidget *other;
GtkWidget *file;
GtkWidget *wais;
GtkWidget *telnet;
GtkWidget *email;
GtkWidget *url;
GtkWidget *relative_link;
GtkWidget *target;
GtkWidget *comment;
GtkWidget *mouse_over;
GtkWidget *mouse_out;
GtkWidget *focus;
GtkWidget *blur;
GtkWidget *browse;
gpointer infotab;
};
AreaInfoDialog_t *create_edit_area_info_dialog(Object_t *obj);
void edit_area_info_dialog_show(AreaInfoDialog_t *dialog, Object_t *obj,
gboolean add);
#endif /* _IMAP_EDIT_AREA_INFO_H */

View file

@ -0,0 +1,166 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <sys/stat.h>
#include "imap_default_dialog.h"
#include "imap_file.h"
#include "imap_main.h"
#include "imap_table.h"
static void
open_cb(GtkWidget *widget, gpointer data)
{
char *filename;
struct stat buf;
int err;
filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data));
err = stat(filename, &buf);
if (!err && (buf.st_mode & S_IFREG)) {
gtk_widget_hide((GtkWidget*) data);
load(filename);
} else {
do_file_error_dialog("Error opening file", filename);
}
}
void
do_file_open_dialog(void)
{
static GtkWidget *dialog;
if (!dialog) {
dialog = gtk_file_selection_new("Load Imagemap");
gtk_signal_connect_object(
GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button),
"clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(dialog));
gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
"clicked", GTK_SIGNAL_FUNC(open_cb), dialog);
}
gtk_widget_show(dialog);
}
static void
really_overwrite(gpointer data)
{
gtk_widget_hide((GtkWidget*) data);
save_as(gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)));
}
static void
do_file_exists_dialog(gpointer data)
{
static DefaultDialog_t *dialog;
if (!dialog) {
dialog = make_default_dialog("File exists!");
default_dialog_hide_apply_button(dialog);
default_dialog_set_ok_cb(dialog, really_overwrite, data);
default_dialog_set_label(
dialog,
"File already exists.\n"
" Do you really want to overwrite? ");
}
default_dialog_show(dialog);
}
static void
save_cb(GtkWidget *widget, gpointer data)
{
char *filename;
struct stat buf;
int err;
filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data));
err = stat(filename, &buf);
if (err) {
gtk_widget_hide((GtkWidget*) data);
save_as(filename);
} else { /* File exists */
if (buf.st_mode & S_IFREG) {
do_file_exists_dialog(data);
} else {
/* Fix me! */
}
}
}
void
do_file_save_as_dialog(void)
{
static GtkWidget *dialog;
if (!dialog) {
dialog = gtk_file_selection_new("Save Imagemap");
gtk_signal_connect_object(
GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button),
"clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(dialog));
gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
"clicked", GTK_SIGNAL_FUNC(save_cb), dialog);
}
gtk_widget_show(dialog);
}
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *error;
GtkWidget *filename;
} FileErrorDialog_t;
static FileErrorDialog_t*
create_file_error_dialog()
{
FileErrorDialog_t *file_dialog = g_new(FileErrorDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *table;
file_dialog->dialog = dialog = make_default_dialog("Error");
default_dialog_hide_apply_button(dialog);
default_dialog_hide_cancel_button(dialog);
table = gtk_table_new(2, 1, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), table,
TRUE, TRUE, 10);
gtk_widget_show(table);
file_dialog->error = create_label_in_table(table, 0, 0, "");
file_dialog->filename = create_label_in_table(table, 1, 0, "");
return file_dialog;
}
void
do_file_error_dialog(const char *error, const char *filename)
{
static FileErrorDialog_t *dialog;
if (!dialog)
dialog = create_file_error_dialog();
gtk_label_set_text(GTK_LABEL(dialog->error), error);
gtk_label_set_text(GTK_LABEL(dialog->filename), filename);
default_dialog_show(dialog->dialog);
}

View file

@ -0,0 +1,37 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_FILE_H
#define _IMAP_FILE_H
#include "gtk/gtk.h"
void do_file_open_dialog(void);
void do_file_save_as_dialog(void);
void do_file_error_dialog(const char *error, const char *filename);
gboolean load_csim(const char* filename);
gboolean load_cern(const char* filename);
gboolean load_ncsa(const char* filename);
#endif /* _IMAP_FILE_H */

View file

@ -0,0 +1,266 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 "imap_grid.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_popup.h"
#include "imap_preview.h"
#include "imap_table.h"
#include "imap_toolbar.h"
typedef enum {GRID_HIDDEN, GRID_LINES, GRID_CROSSES} GridType_t;
static GdkGC *grid_gc;
static gboolean grid_snap = FALSE;
static gint grid_width = 15;
static gint grid_height = 15;
static gint grid_left = 0;
static gint grid_top = 0;
static GridType_t grid_type = GRID_LINES;
static void
grid_settings_ok_cb(gpointer data)
{
GridDialog_t *param = (GridDialog_t*) data;
grid_snap = GTK_TOGGLE_BUTTON(param->snap)->active;
grid_width = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->width));
grid_height = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->height));
grid_left = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->left));
grid_top = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->top));
main_toolbar_set_grid(grid_snap);
popup_check_grid(grid_snap);
menu_check_grid(grid_snap);
redraw_preview();
}
static void
snap_toggled_cb(GtkWidget *widget, gpointer data)
{
GridDialog_t *param = (GridDialog_t*) data;
gint sensitive = GTK_TOGGLE_BUTTON(widget)->active;
gtk_widget_set_sensitive(param->type_frame, sensitive);
gtk_widget_set_sensitive(param->granularity_frame, sensitive);
gtk_widget_set_sensitive(param->offset_frame, sensitive);
}
static void
type_toggled_cb(GtkWidget *widget, gpointer data)
{
if (GTK_WIDGET_STATE(widget) & GTK_STATE_SELECTED)
grid_type = (gint) data;
}
static GridDialog_t*
create_grid_settings_dialog()
{
GridDialog_t *data = g_new(GridDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *main_table, *table;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GSList* group;
data->dialog = dialog = make_default_dialog("Grid Settings");
default_dialog_set_ok_cb(dialog, grid_settings_ok_cb, (gpointer) data);
main_table = gtk_table_new(3, 2, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(main_table), 10);
gtk_table_set_row_spacings(GTK_TABLE(main_table), 10);
gtk_table_set_col_spacings(GTK_TABLE(main_table), 10);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox),
main_table, TRUE, TRUE, 10);
gtk_widget_show(main_table);
data->snap = gtk_check_button_new_with_label("Snap-To Grid Enabled");
gtk_signal_connect(GTK_OBJECT(data->snap), "toggled",
(GtkSignalFunc) snap_toggled_cb, data);
gtk_table_attach_defaults(GTK_TABLE(main_table), data->snap, 0, 1, 0, 1);
gtk_widget_show(data->snap);
data->type_frame = frame = gtk_frame_new("Grid Visibility and Type");
gtk_widget_show(frame);
gtk_table_attach_defaults(GTK_TABLE(main_table), frame, 0, 2, 1, 2);
hbox = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
data->hidden = button = gtk_radio_button_new_with_label(NULL, "Hidden");
gtk_signal_connect(GTK_OBJECT(button), "toggled",
(GtkSignalFunc) type_toggled_cb, (gpointer) GRID_HIDDEN);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10);
gtk_widget_show(button);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
data->lines = button = gtk_radio_button_new_with_label(group, "Lines");
gtk_signal_connect(GTK_OBJECT(button), "toggled",
(GtkSignalFunc) type_toggled_cb, (gpointer) GRID_LINES);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10);
gtk_widget_show(button);
group = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
data->crosses = button = gtk_radio_button_new_with_label(group, "Crosses");
gtk_signal_connect(GTK_OBJECT(button), "toggled",
(GtkSignalFunc) type_toggled_cb,
(gpointer) GRID_CROSSES);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10);
gtk_widget_show(button);
data->granularity_frame = frame = gtk_frame_new("Grid Granularity");
gtk_table_attach_defaults(GTK_TABLE(main_table), frame, 0, 1, 2, 3);
table = gtk_table_new(2, 3, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_container_add(GTK_CONTAINER(frame), table);
create_label_in_table(table, 0, 0, "Width");
data->width = create_spin_button_in_table(table, 0, 1, 15, 1, 100);
create_label_in_table(table, 0, 2, "pixels");
create_label_in_table(table, 1, 0, "Height");
data->height = create_spin_button_in_table(table, 1, 1, 15, 1, 100);
create_label_in_table(table, 1, 2, "pixels");
gtk_widget_show(table);
gtk_widget_show(frame);
data->offset_frame = frame = gtk_frame_new("Grid Offset");
gtk_table_attach_defaults(GTK_TABLE(main_table), frame, 1, 2, 2, 3);
table = gtk_table_new(2, 2, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_table_set_row_spacings(GTK_TABLE(table), 10);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
gtk_container_add(GTK_CONTAINER(frame), table);
data->left = create_spin_button_in_table(table, 0, 0, 0, 0, 100);
create_label_in_table(table, 0, 1, "pixels from left");
data->top = create_spin_button_in_table(table, 1, 0, 0, 0, 100);
create_label_in_table(table, 1, 1, "pixels from top");
snap_toggled_cb(data->snap, data);
gtk_widget_show(table);
gtk_widget_show(frame);
return data;
}
void
do_grid_settings_dialog(void)
{
static GridDialog_t* dialog;
GtkWidget *type;
if (!dialog)
dialog = create_grid_settings_dialog();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->snap), grid_snap);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->width), grid_width);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->height), grid_height);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->left), grid_left);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->top), grid_top);
if (grid_type == GRID_HIDDEN)
type = dialog->hidden;
else if (grid_type == GRID_LINES)
type = dialog->lines;
else
type = dialog->crosses;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(type), TRUE);
default_dialog_show(dialog->dialog);
}
static void
draw_lines(GdkWindow *window, GdkGC* gc, gint width, gint height)
{
gint x, y;
for (x = grid_left; x < width; x += grid_width)
draw_line(window, grid_gc, x, 1, x, height);
for (y = grid_top; y < height; y += grid_height)
draw_line(window, grid_gc, 1, y, width, y);
}
static void
draw_crosses(GdkWindow *window, GdkGC* gc, gint width, gint height)
{
gint x, y;
for (x = grid_left; x < width; x += grid_width) {
for (y = grid_top; y < height; y += grid_height) {
draw_line(window, gc, x - 3, y, x + 3, y);
draw_line(window, gc, x, y - 3, x, y + 3);
}
}
}
void
draw_grid(GtkWidget *preview)
{
if (grid_snap && grid_type != GRID_HIDDEN) {
gint width = preview_get_width(preview);
gint height = preview_get_height(preview);
if (!grid_gc) {
grid_gc = gdk_gc_new(preview->window);
gdk_gc_set_line_attributes(grid_gc, 1, GDK_LINE_ON_OFF_DASH,
GDK_CAP_BUTT, GDK_JOIN_BEVEL);
}
gdk_gc_set_function(preview->style->black_gc, GDK_INVERT);
if (grid_type == GRID_LINES)
draw_lines(preview->window, preview->style->black_gc, width, height);
else
draw_crosses(preview->window, preview->style->black_gc, width,
height);
gdk_gc_set_function(preview->style->black_gc, GDK_COPY);
}
}
gboolean
toggle_grid(void)
{
grid_snap = !grid_snap;
redraw_preview();
return grid_snap;
}
void
round_to_grid(gint *x, gint *y)
{
if (grid_snap) {
*x = grid_left + (*x - grid_left + grid_width / 2) / grid_width
* grid_width;
*y = grid_top + (*y - grid_top + grid_height / 2) / grid_height
* grid_height;
}
}

View file

@ -0,0 +1,49 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_GRID_H
#define _IMAP_GRID_H
#include "imap_default_dialog.h"
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *type_frame;
GtkWidget *granularity_frame;
GtkWidget *offset_frame;
GtkWidget *snap;
GtkWidget *width;
GtkWidget *height;
GtkWidget *left;
GtkWidget *top;
GtkWidget *hidden;
GtkWidget *lines;
GtkWidget *crosses;
} GridDialog_t;
void do_grid_settings_dialog();
void draw_grid(GtkWidget *preview);
gboolean toggle_grid();
void round_to_grid(gint *x, gint *y);
#endif /* _IMAP_GRID_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,99 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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.
*
*/
#ifndef _IMAP_MAIN_H
#define _IMAP_MAIN_H
#include "gtk/gtk.h"
#include "imap_mru.h"
#include "imap_object.h"
#include "imap_preferences.h"
#include "imap_preview.h"
typedef enum {NCSA, CERN, CSIM} MapFormat_t;
typedef struct {
MapFormat_t map_format;
gchar *image_name;
gchar *title;
gchar *author;
gchar *default_url;
gchar *description;
gint old_image_width;
gint old_image_height;
gboolean color; /* Color (TRUE) or Gray (FALSE) */
gboolean show_gray;
} MapInfo_t;
void main_set_dimension(gint width, gint height);
void main_clear_dimension(void);
void load(const gchar *filename);
void save_as(const gchar *filename);
void dump_output(gpointer param, OutputFunc_t output);
GdkColor *get_yellow(void);
MRU_t *get_mru(void);
MapInfo_t *get_map_info(void);
PreferencesData_t *get_preferences(void);
GtkWidget *get_top_widget(void);
gint get_image_width(void);
gint get_image_height(void);
void set_busy_cursor(void);
void remove_busy_cursor(void);
void main_toolbar_set_grid(gboolean active);
void set_zoom(gint zoom_factor);
gint get_real_coord(gint coord);
void draw_line(GdkWindow *window, GdkGC *gc, gint x1, gint y1, gint x2,
gint y2);
void draw_rectangle(GdkWindow *window, GdkGC *gc, gint filled, gint x, gint y,
gint width, gint height);
void draw_arc(GdkWindow *window, GdkGC *gc, gint filled, gint x, gint y,
gint width, gint height, gint angle1, gint angle2);
void draw_circle(GdkWindow *window, GdkGC *gc, gint filled, gint x, gint y,
gint r);
void draw_polygon(GdkWindow *window, GdkGC *gc, GList *list);
const char *get_filename(void);
void set_arrow_func(void);
void set_rectangle_func(void);
void set_circle_func(void);
void set_polygon_func(void);
ObjectList_t *get_shapes(void);
void add_shape(Object_t *obj);
void update_shape(Object_t *obj);
void select_shape(GtkWidget *widget, GdkEventButton *event);
void edit_shape(gint x, gint y);
void do_popup_menu(GdkEventButton *event);
void draw_shapes(GtkWidget *preview);
void redraw_preview(void);
void show_url(void);
void hide_url(void);
#endif /* _IMAP_MAIN_H */

View file

@ -0,0 +1,497 @@
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
*
* 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 <sys/stat.h>
#include "imap_circle.h"
#include "imap_file.h"
#include "imap_grid.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_menu_funcs.h"
#include "imap_polygon.h"
#include "imap_popup.h"
#include "imap_preferences.h"
#include "imap_rectangle.h"
#include "imap_settings.h"
#include "imap_source.h"
#include "imap_tools.h"
static gint _menu_callback_lock;
static Menu_t _menu;
static void
menu_select(GtkWidget *item)
{
_menu_callback_lock = TRUE;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
}
static void
menu_mru(GtkWidget *widget, gpointer data)
{
MRU_t *mru = get_mru();
char *filename = (char*) data;
struct stat buf;
int err;
err = stat(filename, &buf);
if (!err && (buf.st_mode & S_IFREG)) {
load(filename);
} else {
do_file_error_dialog("Error opening file", filename);
mru_remove(mru, filename);
menu_build_mru_items(mru);
}
}
void
menu_set_zoom_sensitivity(gint factor)
{
gtk_widget_set_sensitive(_menu.zoom_in, factor < 8);
gtk_widget_set_sensitive(_menu.zoom_out, factor > 1);
}
void
menu_shapes_selected(gint count)
{
gint sensitive = (count > 0);
gtk_widget_set_sensitive(_menu.cut, sensitive);
gtk_widget_set_sensitive(_menu.copy, sensitive);
gtk_widget_set_sensitive(_menu.clear, sensitive);
gtk_widget_set_sensitive(_menu.edit, sensitive);
}
static void
menu_zoom_to(gint factor)
{
if (_menu_callback_lock) {
_menu_callback_lock--;
} else {
set_zoom(factor);
}
menu_set_zoom_sensitivity(factor);
}
static void
menu_zoom_to_1(GtkWidget *widget, gpointer data)
{
menu_zoom_to(1);
}
static void
menu_zoom_to_2(GtkWidget *widget, gpointer data)
{
menu_zoom_to(2);
}
static void
menu_zoom_to_3(GtkWidget *widget, gpointer data)
{
menu_zoom_to(3);
}
static void
menu_zoom_to_4(GtkWidget *widget, gpointer data)
{
menu_zoom_to(4);
}
static void
menu_zoom_to_5(GtkWidget *widget, gpointer data)
{
menu_zoom_to(5);
}
static void
menu_zoom_to_6(GtkWidget *widget, gpointer data)
{
menu_zoom_to(6);
}
static void
menu_zoom_to_7(GtkWidget *widget, gpointer data)
{
menu_zoom_to(7);
}
static void
menu_zoom_to_8(GtkWidget *widget, gpointer data)
{
menu_zoom_to(8);
}
static void
menu_rectangle(GtkWidget *widget, gpointer data)
{
if (_menu_callback_lock) {
_menu_callback_lock = FALSE;
} else {
set_rectangle_func();
tools_select_rectangle();
popup_select_rectangle();
}
}
static void
menu_circle(GtkWidget *widget, gpointer data)
{
if (_menu_callback_lock) {
_menu_callback_lock = FALSE;
} else {
set_circle_func();
tools_select_circle();
popup_select_circle();
}
}
static void
menu_polygon(GtkWidget *widget, gpointer data)
{
if (_menu_callback_lock) {
_menu_callback_lock = FALSE;
} else {
set_polygon_func();
tools_select_polygon();
popup_select_polygon();
}
}
static void
menu_arrow(GtkWidget *widget, gpointer data)
{
if (_menu_callback_lock) {
_menu_callback_lock = FALSE;
} else {
set_arrow_func();
tools_select_arrow();
popup_select_arrow();
}
}
static void
menu_grid(GtkWidget *widget, gpointer data)
{
if (_menu_callback_lock) {
_menu_callback_lock = FALSE;
} else {
gint grid = toggle_grid();
popup_check_grid(grid);
main_toolbar_set_grid(grid);
}
}
static void
make_file_menu(GtkWidget *menu_bar)
{
GtkWidget *file_menu = make_menu_bar_item(menu_bar, "File");
GtkWidget *item;
_menu.file_menu = file_menu;
item = make_item_with_label(file_menu, "Open...", menu_command,
&_menu.cmd_open);
add_accelerator(item, 'O', GDK_CONTROL_MASK);
item = make_item_with_label(file_menu, "Save", menu_command,
&_menu.cmd_save);
add_accelerator(item, 'S', GDK_CONTROL_MASK);
make_item_with_label(file_menu, "Save As...", menu_command,
&_menu.cmd_save_as);
make_separator(file_menu);
make_item_with_label(file_menu, "Preferences...", menu_command,
&_menu.cmd_preferences);
make_separator(file_menu);
item = make_item_with_label(file_menu, "Close", menu_command,
&_menu.cmd_close);
add_accelerator(item, 'W', GDK_CONTROL_MASK);
item = make_item_with_label(file_menu, "Quit", menu_command,
&_menu.cmd_quit);
add_accelerator(item, 'Q', GDK_CONTROL_MASK);
}
static void
command_list_changed(Command_t *command, gpointer data)
{
char scratch[64];
/* Set undo entry */
if (_menu.undo)
gtk_widget_destroy(_menu.undo);
sprintf(scratch, "Undo %s", (command) ? command->name : "");
_menu.undo = insert_item_with_label(_menu.edit_menu, 0, scratch,
menu_command, &_menu.cmd_undo);
add_accelerator(_menu.undo, 'Z', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(_menu.undo, (command != NULL));
/* Set redo entry */
command = command_list_get_redo_command();
if (_menu.redo)
gtk_widget_destroy(_menu.redo);
sprintf(scratch, "Redo %s", (command) ? command->name : "");
_menu.redo = insert_item_with_label(_menu.edit_menu, 1, scratch,
menu_command, &_menu.cmd_redo);
add_accelerator(_menu.redo, 'R', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(_menu.redo, (command != NULL));
}
static void
paste_buffer_added(Object_t *obj, gpointer data)
{
gtk_widget_set_sensitive((GtkWidget*) data, TRUE);
}
static void
paste_buffer_removed(Object_t *obj, gpointer data)
{
gtk_widget_set_sensitive((GtkWidget*) data, FALSE);
}
static void
make_edit_menu(GtkWidget *menu_bar)
{
GtkWidget *edit_menu = make_menu_bar_item(menu_bar, "Edit");
GtkWidget *item, *paste;
_menu.edit_menu = edit_menu;
command_list_changed(NULL, NULL);
make_separator(edit_menu);
_menu.cut = make_item_with_label(edit_menu, "Cut", menu_command,
&_menu.cmd_cut);
add_accelerator(_menu.cut, 'X', GDK_CONTROL_MASK);
_menu.copy = make_item_with_label(edit_menu, "Copy", menu_command,
&_menu.cmd_copy);
add_accelerator(_menu.copy, 'C', GDK_CONTROL_MASK);
paste = make_item_with_label(edit_menu, "Paste", menu_command,
&_menu.cmd_paste);
add_accelerator(paste, 'V', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(paste, FALSE);
item = make_item_with_label(edit_menu, "Select All", menu_command,
&_menu.cmd_select_all);
add_accelerator(item, 'A', GDK_CONTROL_MASK);
make_separator(edit_menu);
_menu.clear = make_item_with_label(edit_menu, "Clear", menu_command,
&_menu.cmd_clear);
add_accelerator(_menu.clear, 'K', GDK_CONTROL_MASK);
_menu.edit = make_item_with_label(edit_menu, "Edit Area Info...",
menu_command, &_menu.cmd_edit_area_info);
paste_buffer_add_add_cb(paste_buffer_added, (gpointer) paste);
paste_buffer_add_remove_cb(paste_buffer_removed, (gpointer) paste);
command_list_add_update_cb(command_list_changed, NULL);
}
static void
make_view_menu(GtkWidget *menu_bar)
{
GtkWidget *view_menu = make_menu_bar_item(menu_bar, "View");
GtkWidget *zoom_menu, *item;
GSList *group = NULL;
item = make_check_item(view_menu, "Area List", menu_command,
&_menu.cmd_area_list);
GTK_CHECK_MENU_ITEM(item)->active = TRUE;
make_item_with_label(view_menu, "Source...", menu_command,
&_menu.cmd_source);
make_separator(view_menu);
_menu.color = make_radio_item(view_menu, NULL, "Color", menu_command,
&_menu.cmd_color);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.color));
_menu.gray = make_radio_item(view_menu, group, "Grayscale", menu_command,
&_menu.cmd_gray);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.gray));
if (!get_map_info()->color) { /* Gray image */
gtk_widget_set_sensitive(_menu.color, FALSE);
GTK_CHECK_MENU_ITEM(_menu.color)->active = FALSE;
GTK_CHECK_MENU_ITEM(_menu.gray)->active = TRUE;
}
make_separator(view_menu);
_menu.zoom_in = make_item_with_label(view_menu, "Zoom In", menu_command,
&_menu.cmd_zoom_in);
add_accelerator(_menu.zoom_in, '=', 0);
_menu.zoom_out = make_item_with_label(view_menu, "Zoom Out", menu_command,
&_menu.cmd_zoom_out);
add_accelerator(_menu.zoom_out, '-', 0);
gtk_widget_set_sensitive(_menu.zoom_out, FALSE);
zoom_menu = make_sub_menu(view_menu, "Zoom To");
_menu.zoom[0] = make_radio_item(zoom_menu, NULL, "1:1", menu_zoom_to_1,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[0]));
_menu.zoom[1] = make_radio_item(zoom_menu, group, "1:2", menu_zoom_to_2,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[1]));
_menu.zoom[2] = make_radio_item(zoom_menu, group, "1:3", menu_zoom_to_3,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[2]));
_menu.zoom[3] = make_radio_item(zoom_menu, group, "1:4", menu_zoom_to_4,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[3]));
_menu.zoom[4] = make_radio_item(zoom_menu, group, "1:5", menu_zoom_to_5,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[4]));
_menu.zoom[5] = make_radio_item(zoom_menu, group, "1:6", menu_zoom_to_6,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[5]));
_menu.zoom[6] = make_radio_item(zoom_menu, group, "1:7", menu_zoom_to_7,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[6]));
_menu.zoom[7] = make_radio_item(zoom_menu, group, "1:8", menu_zoom_to_8,
NULL);
}
static void
make_mapping_menu(GtkWidget *menu_bar)
{
GtkWidget *menu = make_menu_bar_item(menu_bar, "Mapping");
GSList *group;
_menu.arrow = make_radio_item(menu, NULL, "Arrow", menu_arrow, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.arrow));
_menu.rectangle = make_radio_item(menu, group, "Rectangle",
menu_rectangle, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.rectangle));
_menu.circle = make_radio_item(menu, group, "Circle", menu_circle, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.circle));
_menu.polygon = make_radio_item(menu, group, "Polygon", menu_polygon,
NULL);
make_separator(menu);
make_item_with_label(menu, "Edit Map Info...", menu_command,
&_menu.cmd_edit_map_info);
}
static void
make_goodies_menu(GtkWidget *menu_bar)
{
GtkWidget *goodies_menu = make_menu_bar_item(menu_bar, "Goodies");
_menu.grid = make_check_item(goodies_menu, "Grid", menu_grid, NULL);
make_item_with_label(goodies_menu, "Grid Settings...", menu_command,
&_menu.cmd_grid_settings);
make_item_with_label(goodies_menu, "Create Guides...", menu_command,
&_menu.cmd_create_guides);
}
static void
make_help_menu(GtkWidget *menu_bar)
{
GtkWidget *help_menu = make_menu_bar_item(menu_bar, "Help");
gtk_menu_item_right_justify(GTK_MENU_ITEM(gtk_menu_get_attach_widget(
GTK_MENU(help_menu))));
make_item_with_label(help_menu, "About ImageMap...", menu_command,
&_menu.cmd_about);
}
Menu_t*
make_menu(GtkWidget *main_vbox, GtkWidget *window)
{
GtkWidget *menu_bar = gtk_menu_bar_new();
gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, TRUE, 0);
gtk_widget_show(menu_bar);
init_accel_group(window);
make_file_menu(menu_bar);
make_edit_menu(menu_bar);
make_view_menu(menu_bar);
make_mapping_menu(menu_bar);
make_goodies_menu(menu_bar);
make_help_menu(menu_bar);
menu_shapes_selected(0);
return &_menu;
}
void
menu_build_mru_items(MRU_t *mru)
{
GList *p;
gint position = 6; /* Position of 'Close' entry */
int i;
if (_menu.nr_off_mru_items) {
GList *children = gtk_container_children(GTK_CONTAINER(_menu.file_menu));
p = g_list_nth(children, position);
for (i = 0; i < _menu.nr_off_mru_items; i++, p = p->next) {
gtk_widget_destroy((GtkWidget*) p->data);
}
g_list_free(children);
}
i = 0;
for (p = mru->list; p; p = p->next, i++)
insert_item_with_label(_menu.file_menu, position++, (gchar*) p->data,
menu_mru, p->data);
insert_separator(_menu.file_menu, position);
_menu.nr_off_mru_items = i + 1;
}
void
menu_select_arrow(void)
{
menu_select(_menu.arrow);
}
void
menu_select_rectangle(void)
{
menu_select(_menu.rectangle);
}
void
menu_select_circle(void)
{
menu_select(_menu.circle);
}
void
menu_select_polygon(void)
{
menu_select(_menu.polygon);
}
void
menu_check_grid(gint check)
{
_menu_callback_lock = TRUE;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu.grid), check);
}
void
menu_set_zoom(gint factor)
{
_menu_callback_lock = 2;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu.zoom[factor - 1]),
TRUE);
menu_set_zoom_sensitivity(factor);
}

Some files were not shown because too many files have changed in this diff Show more