Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/technology.heckin/imagemap/">
<file preprocess="xml-stripblanks">imap-menu.ui</file>
</gresource>
</gresources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/technology.heckin/imagemap/icons">
<file preprocess="to-pixdata">imagemap-circle.png</file>
<file preprocess="to-pixdata">imagemap-coord.png</file>
<file preprocess="to-pixdata">imagemap-dimension.png</file>
<file preprocess="to-pixdata">imagemap-java.png</file>
<file preprocess="to-pixdata">imagemap-polygon.png</file>
<file preprocess="to-pixdata">imagemap-rectangle.png</file>
<file preprocess="to-pixdata">imagemap-to-back.png</file>
<file preprocess="to-pixdata">imagemap-to-front.png</file>
</gresource>
</gresources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

View File

@ -0,0 +1,16 @@
stock_images = [
'imagemap-circle.png',
'imagemap-coord.png',
'imagemap-dimension.png',
'imagemap-java.png',
'imagemap-polygon.png',
'imagemap-rectangle.png',
'imagemap-to-back.png',
'imagemap-to-front.png',
]
imagemap_icon_sources = gnome.compile_resources(
'imagemap-icon-images',
'imagemap-icon-images.gresource.xml',
# source_dir: meson.current_source_directory(),
)

View File

@ -0,0 +1,372 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="imap-menubar">
<submenu>
<attribute name="label" translatable="yes">File</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Open</attribute>
<attribute name="action">app.open</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save</attribute>
<attribute name="action">app.save</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save As</attribute>
<attribute name="action">app.save-as</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Close</attribute>
<attribute name="action">app.close</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Edit</attribute>
<section id="imap-menubar-edit">
<item>
<attribute name="label" translatable="yes">Undo</attribute>
<attribute name="action">app.undo</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Redo</attribute>
<attribute name="action">app.redo</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Cut</attribute>
<attribute name="action">app.cut</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy</attribute>
<attribute name="action">app.copy</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Paste</attribute>
<attribute name="action">app.paste</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Clear</attribute>
<attribute name="action">app.clear</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Select All</attribute>
<attribute name="action">app.select-all</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Deselect All</attribute>
<attribute name="action">app.deselect-all</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Edit Area Info</attribute>
<attribute name="action">app.edit-area-info</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">View</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Area List</attribute>
<attribute name="action">app.area-list</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Source...</attribute>
<attribute name="action">app.source</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Color</attribute>
<attribute name="action">app.colormode</attribute>
<attribute name="target">color</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Gray</attribute>
<attribute name="action">app.colormode</attribute>
<attribute name="target">gray</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Zoom In</attribute>
<attribute name="action">app.zoom-in</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Zoom Out</attribute>
<attribute name="action">app.zoom-out</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Zoom To</attribute>
<section>
<item>
<attribute name="label" translatable="yes">1:1</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">1</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:2</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">2</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:3</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">3</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:4</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">4</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:5</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">5</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:6</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">6</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:7</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">7</attribute>
</item>
<item>
<attribute name="label" translatable="yes">1:8</attribute>
<attribute name="action">app.zoom</attribute>
<attribute name="target">8</attribute>
</item>
</section>
</submenu>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Mappings</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Arrow</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">arrow</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Rectangle</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">rectangle</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Circle</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">circle</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Polygon</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">polygon</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Edit Map Info...</attribute>
<attribute name="action">app.edit-map-info</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Tools</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Grid</attribute>
<attribute name="action">app.grid</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Grid Settings...</attribute>
<attribute name="action">app.grid-settings</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Use PIKA Guides...</attribute>
<attribute name="action">app.use-pika-guides</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Create Guides...</attribute>
<attribute name="action">app.create-guides</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Help</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Contents</attribute>
<attribute name="action">app.contents</attribute>
</item>
<item>
<attribute name="label" translatable="yes">About</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</submenu>
</menu>
<menu id="imap-selectionbar">
<section>
<item>
<attribute name="label" translatable="yes">Move Up</attribute>
<attribute name="action">app.move-up</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Move Down</attribute>
<attribute name="action">app.move-down</attribute>
</item>
</section>
</menu>
<menu id="imap-main-popup">
<section>
<item>
<attribute name="label" translatable="yes">Edit Map Info...</attribute>
<attribute name="action">app.edit-map-info</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Tools</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Arrow</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">arrow</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Rectangle</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">rectangle</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Circle</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">circle</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Polygon</attribute>
<attribute name="action">app.shape</attribute>
<attribute name="target">polygon</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">Zoom</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Zoom In</attribute>
<attribute name="action">app.zoom-in</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Zoom Out</attribute>
<attribute name="action">app.zoom-out</attribute>
</item>
</section>
</submenu>
<item>
<attribute name="label" translatable="yes">Grid</attribute>
<attribute name="action">app.grid</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Grid Settings...</attribute>
<attribute name="action">app.grid-settings</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Create Guides...</attribute>
<attribute name="action">app.create-guides</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Paste</attribute>
<attribute name="action">app.paste</attribute>
</item>
</section>
</menu>
<menu id="imap-object-popup">
<section>
<item>
<attribute name="label" translatable="yes">Edit Area Info...</attribute>
<attribute name="action">app.edit-area-info</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Delete Area</attribute>
<attribute name="action">app.clear</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Move Up</attribute>
<attribute name="action">app.move-up</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Move Down</attribute>
<attribute name="action">app.move-down</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Cut</attribute>
<attribute name="action">app.cut</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy</attribute>
<attribute name="action">app.copy</attribute>
</item>
</section>
</menu>
<menu id="imap-polygon-popup">
<section>
<item>
<attribute name="label" translatable="yes">Insert Point</attribute>
<attribute name="action">app.insert-point</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Delete Point</attribute>
<attribute name="action">app.delete-point</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Edit Area Info...</attribute>
<attribute name="action">app.edit-area-info</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Delete Area</attribute>
<attribute name="action">app.delete-area</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Move Up</attribute>
<attribute name="action">app.move-up</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Move Down</attribute>
<attribute name="action">app.move-down</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Cut</attribute>
<attribute name="action">app.cut</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy</attribute>
<attribute name="action">app.copy</attribute>
</item>
</section>
</menu>
</interface>

View File

@ -0,0 +1,64 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_about.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
void
do_about_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GtkWidget *dialog;
if (!dialog)
{
const gchar* authors[] = {"Maurits Rijk (m.rijk@chello.nl)", NULL};
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", get_dialog(),
"program-name", _("Image Map Plug-in"),
"version", "2.3",
"authors", authors,
"copyright",
_("Copyright © 1999-2005 by Maurits Rijk"),
"license",
_("Released under the GNU General Public License"),
NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
dialog);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
}
gtk_window_present (GTK_WINDOW (dialog));
}

View File

@ -0,0 +1,30 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_ABOUT_H
#define _IMAP_ABOUT_H
void do_about_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
#endif /* _IMAP_ABOUT_H */

View File

@ -0,0 +1,172 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "libpika/pika.h"
#include "libpika/pikaui.h"
#include "imap_browse.h"
#include "libpika/stdplugins-intl.h"
static const GtkTargetEntry target_table[] =
{
{"STRING", 0, 1 },
{"text/plain", 0, 2 }
};
static void
select_cb (GtkWidget *dialog,
gint response_id,
BrowseWidget_t *browse)
{
if (response_id == GTK_RESPONSE_OK)
{
gchar *p;
gchar *file;
file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
p = (browse->filter ?
browse->filter (file, browse->filter_data) : file);
gtk_entry_set_text (GTK_ENTRY (browse->file), p);
if (browse->filter)
g_free (p);
g_free (file);
}
gtk_widget_hide (dialog);
gtk_widget_grab_focus (browse->file);
}
static void
browse_cb (GtkWidget *widget,
BrowseWidget_t *browse)
{
if (!browse->file_chooser)
{
GtkWidget *dialog;
dialog = browse->file_chooser =
gtk_file_chooser_dialog_new (browse->name,
GTK_WINDOW (gtk_widget_get_toplevel (widget)),
GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
pika_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (select_cb),
browse);
}
gtk_window_present (GTK_WINDOW (browse->file_chooser));
}
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
GtkSelectionData *data, guint info, guint time)
{
gboolean success = FALSE;
if (gtk_selection_data_get_length (data) >= 0 &&
gtk_selection_data_get_format (data) == 8)
{
const gchar *text = (const gchar *) gtk_selection_data_get_data (data);
if (g_utf8_validate (text, -1, NULL))
{
gtk_entry_set_text (GTK_ENTRY (widget), text);
success = TRUE;
}
}
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 *icon;
browse->file_chooser = NULL;
browse->name = name;
browse->filter = NULL;
browse->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 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);
g_signal_connect (browse->file, "drag-data-received",
G_CALLBACK(handle_drop), NULL);
gtk_widget_show (browse->file);
browse->button = button = gtk_button_new ();
icon = gtk_image_new_from_icon_name (PIKA_ICON_DOCUMENT_OPEN,
GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), icon);
gtk_widget_show (icon);
gtk_box_pack_end(GTK_BOX (browse->hbox), button, FALSE, FALSE, 0);
g_signal_connect (button, "clicked",
G_CALLBACK(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 PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_BROWSE_H
#define _IMAP_BROWSE_H
typedef 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_chooser;
} 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 */

View File

@ -0,0 +1,93 @@
%{
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include <string.h>
#include <glib.h>
#include "imap_cern_parse.h"
#ifdef FLEX_SCANNER
#define YY_NO_UNPUT
#endif /* FLEX_SCANNER */
%}
%option noyywrap
%option noinput
%option nounput
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);
cern_lval.id = g_strndup (yytext, yyleng);
return COMMENT;
}
RECT return RECTANGLE;
CIRC return CIRCLE;
POLY return POLYGON;
DEFAULT return DEFAULT;
[^ ,\t\n]+$ {
cern_lval.id = g_strndup (yytext, yyleng);
return LINK;
}
-?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? {
cern_lval.value = g_ascii_strtod (yytext, NULL);
return FLOAT;
}
{WS} ; /* Eat white space */
. return *yytext;
%%

View File

@ -0,0 +1,184 @@
%{
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include <math.h>
#include <glib/gstdio.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(void);
extern int cern_restart(FILE *cern_in);
static void cern_error(char* s);
static Object_t *current_object;
%}
%union {
int val;
double value;
char *id;
}
%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);
g_free ($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);
g_free ($12);
}
;
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);
g_free ($8);
}
;
polygon : POLYGON {current_object = create_polygon(NULL);} coord_list LINK
{
object_set_url(current_object, $4);
add_shape(current_object);
g_free ($4);
}
;
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
{
g_free ($2);
}
;
author_line : AUTHOR COMMENT
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->author, $2);
g_free ($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);
g_free ($2);
}
;
%%
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 = g_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,110 @@
/* A Bison parser, made by GNU Bison 2.6.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
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 3 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, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef CERN_Y_TAB_H
# define CERN_Y_TAB_H
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cern_debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
RECTANGLE = 258,
POLYGON = 259,
CIRCLE = 260,
DEFAULT = 261,
AUTHOR = 262,
DESCRIPTION = 263,
BEGIN_COMMENT = 264,
FLOAT = 265,
COMMENT = 266,
LINK = 267
};
#endif
/* Tokens. */
#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
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2049 of yacc.c */
#line 46 "imap_cern.y"
int val;
double value;
char *id;
/* Line 2049 of yacc.c */
#line 88 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE cern_lval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int cern_parse (void *YYPARSE_PARAM);
#else
int cern_parse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int cern_parse (void);
#else
int cern_parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !CERN_Y_TAB_H */

View File

@ -0,0 +1,405 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <math.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "imap_circle.h"
#include "imap_icons.h"
#include "imap_main.h"
#include "imap_misc.h"
#include "imap_object_popup.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
static gboolean circle_is_valid(Object_t *obj);
static Object_t *circle_clone(Object_t *obj);
static void circle_assign(Object_t *obj, Object_t *des);
static void circle_draw(Object_t* obj, cairo_t *cr);
static void circle_draw_sashes(Object_t* obj, cairo_t *cr);
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_widget(GtkWidget *frame);
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 const gchar* circle_get_icon_name(void);
static ObjectClass_t circle_class = {
N_("C_ircle"),
NULL, /* info_dialog */
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_widget,
circle_fill_info_tab, /* circle_update_info_widget */
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_name
};
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 void
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;
}
static void
circle_draw(Object_t *obj, cairo_t *cr)
{
Circle_t *circle = ObjectToCircle(obj);
draw_circle(cr, circle->x, circle->y, circle->r);
}
static void
circle_draw_sashes(Object_t *obj, cairo_t *cr)
{
Circle_t *circle = ObjectToCircle(obj);
draw_sash(cr, circle->x - circle->r, circle->y - circle->r);
draw_sash(cr, circle->x + circle->r, circle->y - circle->r);
draw_sash(cr, circle->x - circle->r, circle->y + circle->r);
draw_sash(cr, 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 {
Object_t *obj;
GtkWidget *x;
GtkWidget *y;
GtkWidget *r;
} CircleProperties_t;
static void
x_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((CircleProperties_t*) data)->obj;
gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
ObjectToCircle(obj)->x = x;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
y_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((CircleProperties_t*) data)->obj;
gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
ObjectToCircle(obj)->y = y;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
r_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((CircleProperties_t*) data)->obj;
gint r = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
ObjectToCircle(obj)->r = r;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static gpointer
circle_create_info_widget(GtkWidget *frame)
{
CircleProperties_t *props = g_new(CircleProperties_t, 1);
GtkWidget *grid, *label;
gint max_width = get_image_width();
gint max_height = get_image_height();
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER(frame), grid);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_widget_show (grid);
label = create_label_in_grid (grid, 0, 0, _("Center _x:"));
props->x = create_spin_button_in_grid (grid, label, 0, 1, 1, 0,
max_width - 1);
g_signal_connect(props->x, "value-changed",
G_CALLBACK (x_changed_cb), (gpointer) props);
create_label_in_grid (grid, 0, 2, _("pixels"));
label = create_label_in_grid (grid, 1, 0, _("Center _y:"));
props->y = create_spin_button_in_grid (grid, label, 1, 1, 1, 0,
max_height - 1);
g_signal_connect(props->y, "value-changed",
G_CALLBACK (y_changed_cb), (gpointer) props);
create_label_in_grid (grid, 1, 2, _("pixels"));
label = create_label_in_grid (grid, 2, 0, _("_Radius:"));
props->r = create_spin_button_in_grid (grid, label, 2, 1, 1, 1, G_MAXINT);
g_signal_connect(props->r, "value-changed",
G_CALLBACK (r_changed_cb), (gpointer) props);
create_label_in_grid (grid, 2, 2, _("pixels"));
return props;
}
static void
circle_fill_info_tab(Object_t *obj, gpointer data)
{
Circle_t *circle = ObjectToCircle(obj);
CircleProperties_t *props = (CircleProperties_t*) data;
props->obj = obj;
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 const gchar*
circle_get_icon_name(void)
{
return IMAP_CIRCLE;
}
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,40 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#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,72 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t clear_command_execute(Command_t *parent);
static CommandClass_t clear_command_class = {
NULL, /* clear_command_destruct */
clear_command_execute,
NULL, /* clear_command_undo */
NULL /* 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 CmdExecuteValue_t
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);
return CMD_APPEND;
}

View File

@ -0,0 +1,71 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t 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 CmdExecuteValue_t
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 CMD_APPEND;
}
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,84 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void copy_object_command_destruct(Command_t *parent);
static CmdExecuteValue_t 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 CmdExecuteValue_t
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 CMD_APPEND;
}
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,82 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t 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 CmdExecuteValue_t
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));
return CMD_APPEND;
}
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);
}

View File

@ -0,0 +1,92 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void cut_command_destruct(Command_t *parent);
static CmdExecuteValue_t cut_command_execute(Command_t *parent);
static void cut_command_undo(Command_t *parent);
static CommandClass_t cut_command_class = {
cut_command_destruct,
cut_command_execute,
cut_command_undo,
NULL /* 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 CmdExecuteValue_t
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);
return CMD_APPEND;
}
static void
cut_command_undo(Command_t *parent)
{
CutCommand_t *command = (CutCommand_t*) parent;
object_list_copy(get_paste_buffer(), command->paste_buffer);
}

View File

@ -0,0 +1,62 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t cut_object_command_execute(Command_t *parent);
static CommandClass_t cut_object_command_class = {
NULL, /* cut_object_command_destruct */
cut_object_command_execute,
NULL, /* cut_object_command_undo */
NULL /* 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 CmdExecuteValue_t
cut_object_command_execute(Command_t *parent)
{
return CMD_APPEND;
}

View File

@ -0,0 +1,83 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void delete_command_destruct(Command_t *parent);
static CmdExecuteValue_t 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 CmdExecuteValue_t
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 CMD_APPEND;
}
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,86 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "imap_polygon.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t 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 CmdExecuteValue_t
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);
return CMD_APPEND;
}
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,73 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.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);
}

View File

@ -0,0 +1,279 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "libpika/pika.h"
#include "libpika/pikaui.h"
#include "imap_commands.h"
#include "imap_default_dialog.h"
#include "imap_main.h"
#include "imap_rectangle.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.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();
}
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;
gchar *bounds;
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;
bounds = g_strdup_printf (_("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())
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (param->dialog->dialog),
GTK_RESPONSE_OK, FALSE);
}
else
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (param->dialog->dialog),
GTK_RESPONSE_OK, TRUE);
}
gtk_label_set_text(GTK_LABEL(param->guide_bounds), bounds);
g_free (bounds);
}
static GuidesDialog_t*
make_guides_dialog (void)
{
GuidesDialog_t *data = g_new(GuidesDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *grid;
GtkWidget *label;
GtkWidget *hbox;
dialog = data->dialog = make_default_dialog(_("Create Guides"));
default_dialog_set_ok_cb (dialog, guides_ok_cb, data);
hbox = pika_hint_box_new (
_("Guides are pre-defined rectangles covering the image. You define "
"them by their width, height, and spacing from each other. This "
"allows you to rapidly create the most common image map type - "
"image collection of \"thumbnails\", suitable for navigation bars."));
gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
data->image_dimensions = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (data->image_dimensions), 0.0);
gtk_box_pack_start (GTK_BOX (dialog->vbox),
data->image_dimensions, FALSE, FALSE, 0);
gtk_widget_show (data->image_dimensions);
data->guide_bounds = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (data->guide_bounds), 0.0);
gtk_box_pack_start (GTK_BOX (dialog->vbox),
data->guide_bounds, FALSE, FALSE, 0);
gtk_widget_show (data->guide_bounds);
grid = default_dialog_add_grid (dialog);
label = create_label_in_grid (grid, 0, 0, _("_Width:"));
data->width = create_spin_button_in_grid (grid, label, 0, 1, 32, 1, 100);
g_signal_connect (data->width, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 0, 2, _("_Left start at:"));
data->left = create_spin_button_in_grid (grid, label, 0, 3, 0, 0, 100);
g_signal_connect (data->left, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 1, 0, _("_Height:"));
data->height = create_spin_button_in_grid (grid, label, 1, 1, 32, 1, 100);
g_signal_connect (data->height, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 1, 2, _("_Top start at:"));
data->top = create_spin_button_in_grid (grid, label, 1, 3, 0, 0, 100);
g_signal_connect (data->top, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 2, 0, _("_Horz. spacing:"));
data->horz_spacing = create_spin_button_in_grid (grid, label, 2, 1, 0, 0,
100);
g_signal_connect (data->horz_spacing, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 2, 2, _("_No. across:"));
data->no_across = create_spin_button_in_grid (grid, label, 2, 3, 0, 0,
100);
g_signal_connect (data->no_across, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 3, 0, _("_Vert. spacing:"));
data->vert_spacing = create_spin_button_in_grid (grid, label, 3, 1, 0, 0,
100);
g_signal_connect (data->vert_spacing, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
label = create_label_in_grid (grid, 3, 2, _("No. _down:"));
data->no_down = create_spin_button_in_grid (grid, label, 3, 3, 0, 0, 100);
g_signal_connect (data->no_down, "changed",
G_CALLBACK(recalc_bounds), (gpointer) data);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show(hbox);
label = gtk_label_new_with_mnemonic(_("Base _URL:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
data->base_url = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), data->base_url, TRUE, TRUE, 0);
gtk_widget_show(data->base_url);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), data->base_url);
return data;
}
static void
init_guides_dialog(GuidesDialog_t *dialog, ObjectList_t *list)
{
gchar *dimension;
dialog->list = list;
dimension = g_strdup_printf (_("Image dimensions: %d × %d"),
get_image_width(),
get_image_height());
gtk_label_set_text (GTK_LABEL(dialog->image_dimensions), dimension);
g_free (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_local (ObjectList_t *list)
{
static GuidesDialog_t *dialog;
if (!dialog)
dialog = make_guides_dialog();
init_guides_dialog(dialog, list);
default_dialog_show(dialog->dialog);
}
static CmdExecuteValue_t 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 CmdExecuteValue_t
guides_command_execute(Command_t *parent)
{
GuidesCommand_t *command = (GuidesCommand_t*) parent;
do_create_guides_dialog_local (command->list);
return CMD_DESTRUCT;
}

View File

@ -0,0 +1,96 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "imap_main.h"
#include "imap_polygon.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t 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 CmdExecuteValue_t
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;
}
preview_redraw();
return CMD_APPEND;
}
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);
preview_redraw(); /* Fix me! */
}

View File

@ -0,0 +1,166 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libpika/pika.h"
#include "imap_commands.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
static void move_command_destruct(Command_t *parent);
static CmdExecuteValue_t move_command_execute(Command_t *parent);
static CommandClass_t move_command_class = {
move_command_destruct,
move_command_execute,
NULL, /* move_command_undo */
NULL /* move_command_redo */
};
typedef struct {
Command_t parent;
PreferencesData_t *preferences;
Preview_t *preview;
Object_t *obj;
gint start_x;
gint start_y;
gint obj_start_x;
gint obj_start_y;
gint obj_x;
gint obj_y;
gint obj_width;
gint obj_height;
gint image_width;
gint image_height;
GdkCursorType cursor; /* Remember previous cursor */
gboolean moved_first_time;
} MoveCommand_t;
Command_t*
move_command_new(Preview_t *preview, Object_t *obj, gint x, gint y)
{
MoveCommand_t *command = g_new(MoveCommand_t, 1);
command->preferences = get_preferences();
command->preview = preview;
command->obj = object_ref(obj);
command->start_x = x;
command->start_y = y;
object_get_dimensions(obj, &command->obj_x, &command->obj_y,
&command->obj_width, &command->obj_height);
command->obj_start_x = command->obj_x;
command->obj_start_y = command->obj_y;
command->image_width = get_image_width();
command->image_height = get_image_height();
command->moved_first_time = TRUE;
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 void
button_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
MoveCommand_t *command = (MoveCommand_t*) data;
Object_t *obj = command->obj;
gint dx = get_real_coord((gint) event->x) - command->start_x;
gint dy = get_real_coord((gint) event->y) - command->start_y;
if (command->moved_first_time) {
command->moved_first_time = FALSE;
command->cursor = preview_set_cursor(command->preview, GDK_FLEUR);
hide_url();
}
if (command->obj_x + dx < 0)
dx = -command->obj_x;
if (command->obj_x + command->obj_width + dx > command->image_width)
dx = command->image_width - command->obj_width - command->obj_x;
if (command->obj_y + dy < 0)
dy = -command->obj_y;
if (command->obj_y + command->obj_height + dy > command->image_height)
dy = command->image_height - command->obj_height - command->obj_y;
if (dx || dy) {
command->start_x = get_real_coord((gint) event->x);
command->start_y = get_real_coord((gint) event->y);
command->obj_x += dx;
command->obj_y += dy;
object_move(obj, dx, dy);
preview_redraw ();
}
}
static void
button_release(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
MoveCommand_t *command = (MoveCommand_t*) data;
g_signal_handlers_disconnect_by_func (widget,
button_motion, data);
g_signal_handlers_disconnect_by_func (widget,
button_release, data);
if (!command->moved_first_time) {
preview_set_cursor(command->preview, command->cursor);
show_url();
}
command->obj_x -= command->obj_start_x;
command->obj_y -= command->obj_start_y;
if (command->obj_x || command->obj_y)
command_list_add(object_move_command_new(command->obj, command->obj_x,
command->obj_y));
/* preview_thaw(); */
}
static CmdExecuteValue_t
move_command_execute(Command_t *parent)
{
MoveCommand_t *command = (MoveCommand_t*) parent;
GtkWidget *widget = command->preview->preview;
/* preview_freeze(); */
g_signal_connect(widget, "button-release-event",
G_CALLBACK (button_release), command);
g_signal_connect(widget, "motion-notify-event",
G_CALLBACK (button_motion), command);
return CMD_DESTRUCT;
}

View File

@ -0,0 +1,82 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t move_down_command_execute(Command_t *parent);
static CommandClass_t move_down_command_class = {
NULL, /* move_down_command_destruct */
move_down_command_execute,
NULL, /* move_down_command_undo */
NULL /* 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 CmdExecuteValue_t
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);
return CMD_APPEND;
}

View File

@ -0,0 +1,150 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
static void move_sash_command_destruct(Command_t *command);
static CmdExecuteValue_t move_sash_command_execute(Command_t *command);
static void move_sash_command_redo(Command_t *command);
static CommandClass_t move_sash_command_class = {
move_sash_command_destruct,
move_sash_command_execute,
NULL /*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 = object_ref(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 = get_real_coord((gint) event->x);
y = get_real_coord((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;
dx = x - command->x;
dy = y - command->y;
command->x = x;
command->y = y;
command->sash_func(obj, dx, dy);
object_emit_geometry_signal(obj);
preview_redraw ();
}
static void
sash_end(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
MoveSashCommand_t *command = (MoveSashCommand_t*) data;
Object_t *obj = command->obj;
g_signal_handlers_disconnect_by_func(widget,
sash_move, data);
g_signal_handlers_disconnect_by_func(widget,
sash_end, data);
if (obj->class->normalize)
object_normalize(obj);
preview_unset_tmp_obj(command->obj);
preview_redraw();
show_url();
}
static CmdExecuteValue_t
move_sash_command_execute(Command_t *parent)
{
MoveSashCommand_t *command = (MoveSashCommand_t*) parent;
hide_url();
g_signal_connect(command->widget, "button-release-event",
G_CALLBACK (sash_end), command);
g_signal_connect(command->widget, "motion-notify-event",
G_CALLBACK (sash_move), command);
preview_set_tmp_obj(command->obj);
return CMD_APPEND;
}
static void move_sash_command_redo(Command_t *command)
{
/* do nothing, but avoid running execute again which will break event handling */
}

View File

@ -0,0 +1,72 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t move_selected_command_execute(Command_t *parent);
static void move_selected_command_undo(Command_t *parent);
static CommandClass_t move_selected_command_class = {
NULL, /* move_selected_command_destruct */
move_selected_command_execute,
move_selected_command_undo,
NULL /* move_selected_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
gint dx;
gint dy;
} MoveSelectedCommand_t;
Command_t*
move_selected_command_new(ObjectList_t *list, gint dx, gint dy)
{
MoveSelectedCommand_t *command = g_new(MoveSelectedCommand_t, 1);
command->list = list;
command->dx = dx;
command->dy = dy;
return command_init(&command->parent, _("Move Selected Objects"),
&move_selected_command_class);
}
static CmdExecuteValue_t
move_selected_command_execute(Command_t *parent)
{
MoveSelectedCommand_t *command = (MoveSelectedCommand_t*) parent;
object_list_move_selected(command->list, command->dx, command->dy);
return CMD_APPEND;
}
static void
move_selected_command_undo(Command_t *parent)
{
MoveSelectedCommand_t *command = (MoveSelectedCommand_t*) parent;
object_list_move_selected(command->list, -command->dx, -command->dy);
}

View File

@ -0,0 +1,83 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t move_to_front_command_execute(Command_t *parent);
static CommandClass_t move_to_front_command_class = {
NULL, /* move_to_front_command_destruct, */
move_to_front_command_execute,
NULL, /* move_to_front_command_undo */
NULL /* 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 CmdExecuteValue_t
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);
object_list_remove_remove_cb(command->list, id1);
object_list_remove_add_cb(command->list, id2);
return CMD_APPEND;
}

View File

@ -0,0 +1,81 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t move_up_command_execute(Command_t *parent);
static CommandClass_t move_up_command_class = {
NULL, /* move_up_command_destruct */
move_up_command_execute,
NULL, /* move_up_command_undo */
NULL /* 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 CmdExecuteValue_t
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);
return CMD_APPEND;
}

View File

@ -0,0 +1,78 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void object_down_command_destruct(Command_t *parent);
static CmdExecuteValue_t object_down_command_execute(Command_t *parent);
static void object_down_command_undo(Command_t *parent);
static 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 CmdExecuteValue_t
object_down_command_execute(Command_t *parent)
{
ObjectDownCommand_t *command = (ObjectDownCommand_t*) parent;
object_list_move_down(command->list, command->obj);
return CMD_APPEND;
}
static void
object_down_command_undo(Command_t *parent)
{
ObjectDownCommand_t *command = (ObjectDownCommand_t*) parent;
object_list_move_up(command->list, command->obj);
}

View File

@ -0,0 +1,80 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void object_move_command_destruct(Command_t *parent);
static CmdExecuteValue_t object_move_command_execute(Command_t *parent);
static void object_move_command_undo(Command_t *parent);
static CommandClass_t object_move_command_class = {
object_move_command_destruct,
object_move_command_execute,
object_move_command_undo,
NULL /* object_move_command_redo */
};
typedef struct {
Command_t parent;
Object_t *obj;
gint dx;
gint dy;
} ObjectMoveCommand_t;
Command_t*
object_move_command_new(Object_t *obj, gint dx, gint dy)
{
ObjectMoveCommand_t *command = g_new(ObjectMoveCommand_t, 1);
command->obj = object_ref(obj);
command->dx = dx;
command->dy = dy;
return command_init(&command->parent, _("Move"),
&object_move_command_class);
}
static void
object_move_command_destruct(Command_t *parent)
{
ObjectMoveCommand_t *command = (ObjectMoveCommand_t*) parent;
object_unref(command->obj);
}
static CmdExecuteValue_t
object_move_command_execute(Command_t *parent)
{
ObjectMoveCommand_t *command = (ObjectMoveCommand_t*) parent;
object_move(command->obj, command->dx, command->dy);
return CMD_APPEND;
}
static void
object_move_command_undo(Command_t *parent)
{
ObjectMoveCommand_t *command = (ObjectMoveCommand_t*) parent;
object_move(command->obj, -command->dx, -command->dy);
}

View File

@ -0,0 +1,78 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void object_up_command_destruct(Command_t *parent);
static CmdExecuteValue_t object_up_command_execute(Command_t *parent);
static void object_up_command_undo(Command_t *parent);
static 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 CmdExecuteValue_t
object_up_command_execute(Command_t *parent)
{
ObjectUpCommand_t *command = (ObjectUpCommand_t*) parent;
object_list_move_up(command->list, command->obj);
return CMD_APPEND;
}
static void
object_up_command_undo(Command_t *parent)
{
ObjectUpCommand_t *command = (ObjectUpCommand_t*) parent;
object_list_move_down(command->list, command->obj);
}

View File

@ -0,0 +1,71 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t 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 CmdExecuteValue_t
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);
object_list_remove_add_cb(command->list, id);
return CMD_APPEND;
}

View File

@ -0,0 +1,263 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdio.h>
#include <gtk/gtk.h>
#include "libpika/pika.h"
#include "libpikawidgets/pikawidgets.h"
#include "imap_commands.h"
#include "imap_default_dialog.h"
#include "imap_main.h"
#include "imap_rectangle.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
typedef struct {
DefaultDialog_t *dialog;
ObjectList_t *list;
PikaDrawable *drawable;
GtkWidget *alternate;
GtkWidget *all;
GtkWidget *left_border;
GtkWidget *right_border;
GtkWidget *upper_border;
GtkWidget *lower_border;
GtkWidget *url;
} PikaGuidesDialog_t;
static gint
guide_sort_func(gconstpointer a, gconstpointer b)
{
return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b);
}
static void
pika_guides_ok_cb(gpointer data)
{
PikaGuidesDialog_t *param = (PikaGuidesDialog_t*) data;
gint guide_num;
GSList *hguides, *hg;
GSList *vguides, *vg;
gboolean all;
const gchar *url;
PikaImage *image = pika_item_get_image (PIKA_ITEM (param->drawable));
/* First get some dialog values */
all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->all));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->left_border)))
vguides = g_slist_append(NULL, GINT_TO_POINTER(0));
else
vguides = NULL;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->right_border)))
vguides = g_slist_append(vguides,
GINT_TO_POINTER(pika_image_get_width(image)));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->upper_border)))
hguides = g_slist_append(NULL, GINT_TO_POINTER(0));
else
hguides = NULL;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->lower_border)))
hguides = g_slist_append(hguides,
GINT_TO_POINTER(pika_image_get_height(image)));
url = gtk_entry_get_text(GTK_ENTRY(param->url));
/* Next get all the PIKA guides */
guide_num = pika_image_find_next_guide(image, 0);
while (guide_num > 0) {
gint position = pika_image_get_guide_position(image, guide_num);
if (pika_image_get_guide_orientation(image, guide_num)
== PIKA_ORIENTATION_HORIZONTAL) {
hguides = g_slist_insert_sorted(hguides, GINT_TO_POINTER(position),
guide_sort_func);
} else { /* PIKA_ORIENTATION_VERTICAL */
vguides = g_slist_insert_sorted(vguides, GINT_TO_POINTER(position),
guide_sort_func);
}
guide_num = pika_image_find_next_guide(image, guide_num);
}
/* Create the areas */
subcommand_start(_("Use Pika Guides"));
for (hg = hguides; hg && hg->next;
hg = (all) ? hg->next : hg->next->next) {
gint y = GPOINTER_TO_INT(hg->data);
gint height = GPOINTER_TO_INT(hg->next->data) - y;
for (vg = vguides; vg && vg->next;
vg = (all) ? vg->next : vg->next->next) {
gint x = GPOINTER_TO_INT(vg->data);
gint width = GPOINTER_TO_INT(vg->next->data) - x;
Object_t *obj = create_rectangle(x, y, width, height);
Command_t *command = create_command_new(param->list, obj);
object_set_url(obj, url);
command_execute(command);
}
}
subcommand_end();
preview_redraw();
}
static PikaGuidesDialog_t*
make_pika_guides_dialog(void)
{
PikaGuidesDialog_t *data = g_new(PikaGuidesDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *grid, *frame, *hbox, *vbox;
GtkWidget *label;
dialog = data->dialog = make_default_dialog(_("Use Pika Guides"));
default_dialog_set_ok_cb(dialog, pika_guides_ok_cb, data);
grid = default_dialog_add_grid (dialog);
frame = pika_frame_new(_("Create"));
gtk_widget_show(frame);
gtk_grid_attach (GTK_GRID (grid), frame, 0, 0, 1, 1);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
data->alternate =
gtk_radio_button_new_with_mnemonic_from_widget(NULL, _("Al_ternate"));
gtk_box_pack_start(GTK_BOX(hbox), data->alternate, FALSE, FALSE, 0);
gtk_widget_show(data->alternate);
data->all = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(data->alternate), _("A_ll"));
gtk_box_pack_start(GTK_BOX(hbox), data->all, FALSE, FALSE, 0);
gtk_widget_show(data->all);
frame = pika_frame_new(_("Add Additional Guides"));
gtk_widget_show(frame);
gtk_grid_attach (GTK_GRID (grid), frame, 0, 1, 1, 1);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
data->left_border = gtk_check_button_new_with_mnemonic(_("L_eft border"));
gtk_container_add(GTK_CONTAINER(vbox), data->left_border);
gtk_widget_show(data->left_border);
data->right_border = gtk_check_button_new_with_mnemonic(_("_Right border"));
gtk_container_add(GTK_CONTAINER(vbox), data->right_border);
gtk_widget_show(data->right_border);
data->upper_border = gtk_check_button_new_with_mnemonic(_("_Upper border"));
gtk_container_add(GTK_CONTAINER(vbox), data->upper_border);
gtk_widget_show(data->upper_border);
data->lower_border = gtk_check_button_new_with_mnemonic(_("Lo_wer border"));
gtk_container_add(GTK_CONTAINER(vbox), data->lower_border);
gtk_widget_show(data->lower_border);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_grid_attach (GTK_GRID (grid), hbox, 0, 2, 2, 1);
gtk_widget_show(hbox);
label = gtk_label_new_with_mnemonic(_("_Base URL:"));
gtk_widget_show(label);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
data->url = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(hbox), data->url);
gtk_widget_show(data->url);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), data->url);
return data;
}
static void
init_pika_guides_dialog (PikaGuidesDialog_t *dialog,
ObjectList_t *list,
PikaDrawable *drawable)
{
dialog->list = list;
dialog->drawable = drawable;
}
static void
do_create_pika_guides_dialog (ObjectList_t *list,
PikaDrawable *drawable)
{
static PikaGuidesDialog_t *dialog;
if (!dialog)
dialog = make_pika_guides_dialog();
init_pika_guides_dialog(dialog, list, drawable);
default_dialog_show(dialog->dialog);
}
static CmdExecuteValue_t pika_guides_command_execute(Command_t *parent);
static CommandClass_t pika_guides_command_class = {
NULL, /* guides_command_destruct */
pika_guides_command_execute,
NULL, /* guides_command_undo */
NULL /* guides_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
PikaDrawable *drawable;
} PikaGuidesCommand_t;
Command_t*
pika_guides_command_new (ObjectList_t *list,
PikaDrawable *drawable)
{
PikaGuidesCommand_t *command = g_new(PikaGuidesCommand_t, 1);
command->list = list;
command->drawable = drawable;
return command_init(&command->parent, _("Use Pika Guides"),
&pika_guides_command_class);
}
static CmdExecuteValue_t
pika_guides_command_execute(Command_t *parent)
{
PikaGuidesCommand_t *command = (PikaGuidesCommand_t*) parent;
do_create_pika_guides_dialog(command->list, command->drawable);
return CMD_DESTRUCT;
}

View File

@ -0,0 +1,75 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void select_command_destruct(Command_t *parent);
static CmdExecuteValue_t 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 CmdExecuteValue_t
select_command_execute(Command_t *parent)
{
SelectCommand_t *command = (SelectCommand_t*) parent;
object_select(command->obj);
return CMD_APPEND;
}
static void
select_command_undo(Command_t *parent)
{
SelectCommand_t *command = (SelectCommand_t*) parent;
object_unselect(command->obj);
}

View File

@ -0,0 +1,74 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t select_all_command_execute(Command_t *parent);
static CommandClass_t select_all_command_class = {
NULL, /* select_all_command_destruct, */
select_all_command_execute,
NULL, /* select_all_command_undo */
NULL /* 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 CmdExecuteValue_t
select_all_command_execute(Command_t *parent)
{
SelectAllCommand_t *command = (SelectAllCommand_t*) parent;
gpointer id;
CmdExecuteValue_t rvalue;
id = object_list_add_select_cb(command->list, select_one_object, command);
rvalue = (object_list_select_all(command->list))
? CMD_APPEND : CMD_DESTRUCT;
object_list_remove_select_cb(command->list, id);
return rvalue;
}

View File

@ -0,0 +1,76 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t select_next_command_execute(Command_t *parent);
static CommandClass_t select_next_command_class = {
NULL, /* select_next_command_destruct */
select_next_command_execute,
NULL, /* select_next_command_undo */
NULL /* select_next_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} SelectNextCommand_t;
Command_t*
select_next_command_new(ObjectList_t *list)
{
SelectNextCommand_t *command = g_new(SelectNextCommand_t, 1);
command->list = list;
return command_init(&command->parent, _("Select Next"),
&select_next_command_class);
}
static void
select_one_object(Object_t *obj, gpointer data)
{
SelectNextCommand_t *command = (SelectNextCommand_t*) data;
Command_t *sub_command;
sub_command = (obj->selected)
? select_command_new(obj) : unselect_command_new(obj);
command_add_subcommand(&command->parent, sub_command);
}
static CmdExecuteValue_t
select_next_command_execute(Command_t *parent)
{
SelectNextCommand_t *command = (SelectNextCommand_t*) parent;
ObjectList_t *list = command->list;
gpointer id;
id = object_list_add_select_cb(list, select_one_object, command);
object_list_select_next(list);
object_list_remove_select_cb(list, id);
return CMD_APPEND;
}

View File

@ -0,0 +1,76 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t select_prev_command_execute(Command_t *parent);
static CommandClass_t select_prev_command_class = {
NULL, /* select_prev_command_destruct */
select_prev_command_execute,
NULL, /* select_prev_command_undo */
NULL /* select_prev_command_redo */
};
typedef struct {
Command_t parent;
ObjectList_t *list;
} SelectPrevCommand_t;
Command_t*
select_prev_command_new(ObjectList_t *list)
{
SelectPrevCommand_t *command = g_new(SelectPrevCommand_t, 1);
command->list = list;
return command_init(&command->parent, _("Select Previous"),
&select_prev_command_class);
}
static void
select_one_object(Object_t *obj, gpointer data)
{
SelectPrevCommand_t *command = (SelectPrevCommand_t*) data;
Command_t *sub_command;
sub_command = (obj->selected)
? select_command_new(obj) : unselect_command_new(obj);
command_add_subcommand(&command->parent, sub_command);
}
static CmdExecuteValue_t
select_prev_command_execute(Command_t *parent)
{
SelectPrevCommand_t *command = (SelectPrevCommand_t*) parent;
ObjectList_t *list = command->list;
gpointer id;
id = object_list_add_select_cb(list, select_one_object, command);
object_list_select_prev(list);
object_list_remove_select_cb(list, id);
return CMD_APPEND;
}

View File

@ -0,0 +1,142 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "imap_rectangle.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t select_region_command_execute(Command_t *parent);
static CommandClass_t select_region_command_class = {
NULL, /* select_region_command_destruct, */
select_region_command_execute,
NULL, /* select_region_command_undo */
NULL /* select_region_command_redo */
};
typedef struct {
Command_t parent;
GtkWidget *widget;
ObjectList_t *list;
gint x;
gint y;
Object_t *obj;
Command_t *unselect_command;
} 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);
command->unselect_command = 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);
rectangle->width = x - rectangle->x;
rectangle->height = y - rectangle->y;
preview_redraw ();
}
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;
gint count;
g_signal_handlers_disconnect_by_func(widget,
select_motion, data);
g_signal_handlers_disconnect_by_func(widget,
select_release, data);
object_normalize(obj);
id = object_list_add_select_cb(command->list, select_one_object, command);
count = object_list_select_region(command->list, rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
object_list_remove_select_cb(command->list, id);
if (count) {
command_list_add(&command->parent);
} else { /* Nothing selected */
if (command->unselect_command->sub_commands)
command_list_add(&command->parent);
}
preview_unset_tmp_obj (command->obj);
preview_redraw ();
}
static CmdExecuteValue_t
select_region_command_execute(Command_t *parent)
{
SelectRegionCommand_t *command = (SelectRegionCommand_t*) parent;
command->obj = create_rectangle(command->x, command->y, 0, 0);
preview_set_tmp_obj (command->obj);
g_signal_connect(command->widget, "button-release-event",
G_CALLBACK (select_release), command);
g_signal_connect(command->widget, "motion-notify-event",
G_CALLBACK (select_motion), command);
return CMD_IGNORE;
}

View File

@ -0,0 +1,83 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static CmdExecuteValue_t send_to_back_command_execute(Command_t *parent);
static CommandClass_t send_to_back_command_class = {
NULL, /* send_to_back_command_destruct, */
send_to_back_command_execute,
NULL, /* send_to_back_command_undo */
NULL /* 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 CmdExecuteValue_t
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);
object_list_remove_remove_cb(command->list, id1);
object_list_remove_add_cb(command->list, id2);
return CMD_APPEND;
}

View File

@ -0,0 +1,31 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#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,76 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void unselect_command_destruct(Command_t *parent);
static CmdExecuteValue_t 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 CmdExecuteValue_t
unselect_command_execute(Command_t *command)
{
UnselectCommand_t *unselect_command = (UnselectCommand_t*) command;
object_unselect(unselect_command->obj);
return CMD_APPEND;
}
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,31 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#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,90 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "libpika/stdplugins-intl.h"
static void unselect_all_command_destruct(Command_t *command);
static CmdExecuteValue_t unselect_all_command_execute(Command_t *command);
/* COMMAND_PROTO(unselect_all_command); */
static CommandClass_t unselect_all_command_class = {
unselect_all_command_destruct,
unselect_all_command_execute,
NULL, /* unselect_all_command_undo */
NULL /* 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 CmdExecuteValue_t
unselect_all_command_execute(Command_t *parent)
{
UnselectAllCommand_t *command = (UnselectAllCommand_t*) parent;
gpointer id;
CmdExecuteValue_t rvalue;
id = object_list_add_select_cb(command->list, select_one_object,
command);
if (object_list_deselect_all(command->list, command->exception)) {
rvalue = CMD_APPEND;
} else {
rvalue = CMD_DESTRUCT;
}
object_list_remove_select_cb(command->list, id);
return rvalue;
}

View File

@ -0,0 +1,31 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#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 */

View File

@ -0,0 +1,384 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdio.h>
#include <gtk/gtk.h>
#include "imap_command.h"
#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);
}
static void
_command_list_set_undo_level(CommandList_t *list, gint level)
{
gint diff = g_list_length(list->list) - level;
if (diff > 0) {
GList *p, *q;
/* first remove data at the front */
for (p = list->list; diff && p != list->undo; p = q, diff--) {
Command_t *curr = (Command_t*) p->data;
q = p->next;
command_destruct(curr);
list->list = g_list_remove_link(list->list, p);
}
/* If still to long start removing redo levels at the end */
for (p = g_list_last(list->list); diff && p != list->undo; p = q,
diff--) {
Command_t *curr = (Command_t*) p->data;
q = p->prev;
command_destruct(curr);
list->list = g_list_remove_link(list->list, p);
}
command_list_callback_call(&list->update_cb,
(Command_t*) list->undo->data);
}
list->undo_levels = level;
}
void
command_list_set_undo_level(gint level)
{
_command_list_set_undo_level(&_command_list, level);
}
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) {
CmdExecuteValue_t value = command->class->execute(command);
if (value == CMD_APPEND)
command_list_add(command);
else if (value == CMD_DESTRUCT)
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 CmdExecuteValue_t 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 CmdExecuteValue_t
basic_command_execute(Command_t *command)
{
((BasicCommand_t*) command)->func();
return CMD_DESTRUCT;
}

View File

@ -0,0 +1,103 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_COMMAND_H
#define _IMAP_COMMAND_H
#include "imap_object.h"
#define DEFAULT_UNDO_LEVELS 10
typedef struct CommandClass_t CommandClass_t;
typedef struct Command_t Command_t;
typedef struct CommandList_t CommandList_t;
typedef enum {CMD_APPEND, CMD_DESTRUCT, CMD_IGNORE} CmdExecuteValue_t;
struct CommandClass_t {
void (*destruct)(Command_t*);
CmdExecuteValue_t (*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 */

View File

@ -0,0 +1,64 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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.i
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_COMMANDS_H
#define _IMAP_COMMANDS_H
#include "imap_command.h"
#include "imap_object.h"
#include "imap_preview.h"
Command_t *clear_command_new(ObjectList_t *list);
Command_t *copy_command_new(ObjectList_t *list);
Command_t *copy_object_command_new(Object_t *obj);
Command_t *create_command_new(ObjectList_t *list, Object_t *obj);
Command_t *cut_command_new(ObjectList_t *list);
Command_t *cut_object_command_new(Object_t *obj);
Command_t *delete_command_new(ObjectList_t *list, Object_t *obj);
Command_t *delete_point_command_new(Object_t *obj, GdkPoint *point);
Command_t *edit_object_command_new(Object_t *obj);
Command_t *pika_guides_command_new(ObjectList_t *list,
PikaDrawable *drawable);
Command_t *guides_command_new(ObjectList_t *list);
Command_t *insert_point_command_new(Object_t *obj, gint x, gint y, gint edge);
Command_t *move_down_command_new(ObjectList_t *list);
Command_t *move_command_new(Preview_t *preview, Object_t *obj, gint x, gint y);
Command_t *move_sash_command_new(GtkWidget *widget, Object_t *obj,
gint x, gint y, MoveSashFunc_t sash_func);
Command_t *move_selected_command_new(ObjectList_t *list, gint dx, gint dy);
Command_t *move_to_front_command_new(ObjectList_t *list);
Command_t *move_up_command_new(ObjectList_t *list);
Command_t *object_down_command_new(ObjectList_t *list, Object_t *obj);
Command_t *object_move_command_new(Object_t *obj, gint x, gint y);
Command_t *object_up_command_new(ObjectList_t *list, Object_t *obj);
Command_t *paste_command_new(ObjectList_t *list);
Command_t *select_all_command_new(ObjectList_t *list);
Command_t *select_command_new(Object_t *obj);
Command_t *select_next_command_new(ObjectList_t *list);
Command_t *select_prev_command_new(ObjectList_t *list);
Command_t *select_region_command_new(GtkWidget *widget, ObjectList_t *list,
gint x, gint y);
Command_t *send_to_back_command_new(ObjectList_t *list);
Command_t *unselect_all_command_new(ObjectList_t *list, Object_t *exception);
Command_t *unselect_command_new(Object_t *obj);
#endif /* _IMAP_COMMANDS_H */

View File

@ -0,0 +1,143 @@
%{
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2000 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include <string.h>
#include <glib.h>
#include "imap_csim_parse.h"
#ifdef FLEX_SCANNER
#define YY_NO_UNPUT
#endif /* FLEX_SCANNER */
%}
%option noyywrap
%option noinput
%option nounput
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>.*/--\> {
csim_lval.id = g_strndup (yytext, yyleng);
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;
ONCLICK return ONCLICK;
ACCESSKEY return ACCESSKEY;
TABINDEX return TABINDEX;
ALT return ALT;
HREF return HREF;
NOHREF return NOHREF;
\" {
BEGIN(quoted_string);
}
<quoted_string>\" {
BEGIN(INITIAL);
return STRING;
}
<quoted_string>[^\"]* {
csim_lval.id = g_strndup (yytext, yyleng);
}
-?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? {
csim_lval.value = g_ascii_strtod (yytext, NULL);
return FLOAT;
}
{WS} ; /* Eat white space */
. return *yytext;
%%

View File

@ -0,0 +1,420 @@
%{
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.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(void);
extern int csim_restart(FILE *csim_in);
static void csim_error(char* s);
static gchar * unescape_text(gchar *input);
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;
}
%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 ONCLICK
%token<val> ACCESSKEY TABINDEX AUTHOR DESCRIPTION BEGIN_COMMENT END_COMMENT
%token<value> FLOAT
%token<id> STRING
%type<val> integer_value
%%
csim_file : image start_map comment_lines area_list end_map
;
image : '<' IMG SRC '=' STRING image_tags xhtml_close
{
g_strreplace(&_map_info->image_name, $5);
g_free ($5);
}
;
image_tags : /* Empty */
| image_tags image_tag
;
image_tag : image_width
| image_height
| BORDER '=' integer_value {}
| USEMAP '=' STRING { g_free ($3); }
| ALT '=' STRING { g_free ($3); }
;
image_width : WIDTH '=' integer_value
{
_map_info->old_image_width = $3;
}
;
image_height : HEIGHT '=' integer_value
{
_map_info->old_image_height = $3;
}
;
integer_value : FLOAT
{
$$ = (gint) $1;
}
| STRING
{
$$ = (gint) g_ascii_strtod ($1, NULL);
g_free ($1);
}
;
start_map : '<' START_MAP NAME '=' STRING '>'
{
g_strreplace(&_map_info->title, $5);
g_free ($5);
}
;
comment_lines : /* empty */
| comment_lines comment_line
;
comment_line : author_line
| description_line
| real_comment
;
real_comment : BEGIN_COMMENT STRING END_COMMENT
{
g_free ($2);
}
;
author_line : AUTHOR STRING END_COMMENT
{
g_strreplace(&_map_info->author, $2);
g_free ($2);
}
;
description_line: DESCRIPTION STRING END_COMMENT
{
gchar *description;
description = g_strconcat(_map_info->description, $2, "\n",
NULL);
g_strreplace(&_map_info->description, description);
g_free ($2);
}
;
area_list : /* empty */
| area_list area
;
area : '<' AREA tag_list xhtml_close
{
if (current_type != UNDEFINED)
add_shape(current_object);
}
;
xhtml_close : '>'
| '/' '>'
;
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
| onclick_tag
| accesskey_tag
| tabindex_tag
;
shape_tag : SHAPE '=' STRING
{
if (!g_ascii_strcasecmp($3, "RECT")) {
current_object = create_rectangle(0, 0, 0, 0);
current_type = RECTANGLE;
} else if (!g_ascii_strcasecmp($3, "CIRCLE")) {
current_object = create_circle(0, 0, 0);
current_type = CIRCLE;
} else if (!g_ascii_strcasecmp($3, "POLY")) {
current_object = create_polygon(NULL);
current_type = POLYGON;
} else if (!g_ascii_strcasecmp($3, "DEFAULT")) {
current_type = UNDEFINED;
}
g_free ($3);
}
;
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);
points = g_list_append(points, (gpointer) point);
}
/* Remove last point if duplicate */
first = (GdkPoint*) points->data;
polygon->points = points;
if (first->x == point->x && first->y == point->y)
polygon_remove_last_point(polygon);
polygon->points = points;
}
g_free ($3);
}
;
href_tag : HREF '=' STRING
{
if (current_type == UNDEFINED) {
g_strreplace(&_map_info->default_url, $3);
} else {
object_set_url(current_object, unescape_text($3));
}
g_free ($3);
}
;
nohref_tag : NOHREF optional_value
{
}
;
optional_value : /* Empty */
| '=' STRING
{
g_free ($2);
}
;
alt_tag : ALT '=' STRING
{
object_set_comment(current_object, unescape_text($3));
g_free ($3);
}
;
target_tag : TARGET '=' STRING
{
object_set_target(current_object, unescape_text($3));
g_free ($3);
}
;
onmouseover_tag : ONMOUSEOVER '=' STRING
{
object_set_mouse_over(current_object, unescape_text($3));
g_free ($3);
}
;
onmouseout_tag : ONMOUSEOUT '=' STRING
{
object_set_mouse_out(current_object, unescape_text($3));
g_free ($3);
}
;
onfocus_tag : ONFOCUS '=' STRING
{
object_set_focus(current_object, unescape_text($3));
g_free ($3);
}
;
onblur_tag : ONBLUR '=' STRING
{
object_set_blur(current_object, unescape_text($3));
g_free ($3);
}
;
onclick_tag : ONCLICK '=' STRING
{
object_set_click(current_object, unescape_text($3));
g_free ($3);
}
;
accesskey_tag : ACCESSKEY '=' STRING
{
object_set_accesskey(current_object, unescape_text($3));
g_free ($3);
}
;
tabindex_tag : TABINDEX '=' STRING
{
object_set_tabindex(current_object, unescape_text($3));
g_free ($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 = g_fopen(filename, "r");
if (csim_in) {
_map_info = get_map_info();
status = !csim_parse();
fclose(csim_in);
} else {
status = FALSE;
}
return status;
}
static gchar*
unescape_text (gchar *input)
{
/*
* We "unescape" simple things "in place", knowing that unescaped
* strings always are shorter than the original input.
*
* It is a shame there is no g_markup_unescape_text() function, but
* instead you have to create a full GMarkupParser/Context.
*/
struct token {
const char *escaped;
const char unescaped;
};
const struct token tab[] = {
{ "&quot;", '"' },
{ "&apos;", '\'' },
{ "&amp;", '&' },
{ "&lt;", '<' },
{ "&gt;", '>' }
};
size_t i;
for (i = 0; i < (sizeof tab / sizeof tab[0]); i++)
{
const size_t escaped_len = strlen (tab[i].escaped);
char *p;
/* FIXME: The following code does not perform a UTF-8 substring
search. */
for (p = strstr (input, tab[i].escaped);
p != NULL;
p = strstr (p, tab[i].escaped))
{
size_t copy_len;
*p++ = tab[i].unescaped;
copy_len = strlen (p) - escaped_len + 2;
memmove (p, p + escaped_len - 1, copy_len);
if (*p == 0)
break;
}
}
return input;
}

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,148 @@
/* A Bison parser, made by GNU Bison 2.6.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
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 3 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, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef CSIM_Y_TAB_H
# define CSIM_Y_TAB_H
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int csim_debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
IMG = 258,
SRC = 259,
WIDTH = 260,
HEIGHT = 261,
BORDER = 262,
USEMAP = 263,
START_MAP = 264,
END_MAP = 265,
NAME = 266,
AREA = 267,
SHAPE = 268,
COORDS = 269,
ALT = 270,
HREF = 271,
NOHREF = 272,
TARGET = 273,
ONMOUSEOVER = 274,
ONMOUSEOUT = 275,
ONFOCUS = 276,
ONBLUR = 277,
ONCLICK = 278,
ACCESSKEY = 279,
TABINDEX = 280,
AUTHOR = 281,
DESCRIPTION = 282,
BEGIN_COMMENT = 283,
END_COMMENT = 284,
FLOAT = 285,
STRING = 286
};
#endif
/* Tokens. */
#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 ONCLICK 278
#define ACCESSKEY 279
#define TABINDEX 280
#define AUTHOR 281
#define DESCRIPTION 282
#define BEGIN_COMMENT 283
#define END_COMMENT 284
#define FLOAT 285
#define STRING 286
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2049 of yacc.c */
#line 49 "imap_csim.y"
int val;
double value;
char *id;
/* Line 2049 of yacc.c */
#line 120 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE csim_lval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int csim_parse (void *YYPARSE_PARAM);
#else
int csim_parse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int csim_parse (void);
#else
int csim_parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !CSIM_Y_TAB_H */

View File

@ -0,0 +1,184 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "imap_default_dialog.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
static void
dialog_response (GtkWidget *widget,
gint response_id,
DefaultDialog_t *dialog)
{
switch (response_id)
{
case GTK_RESPONSE_APPLY:
if (dialog->apply_cb)
dialog->apply_cb (dialog->apply_cb_data);
else if (dialog->ok_cb)
dialog->ok_cb (dialog->ok_cb_data);
break;
case GTK_RESPONSE_OK:
gtk_widget_hide (dialog->dialog);
if (dialog->ok_cb)
dialog->ok_cb (dialog->ok_cb_data);
break;
default:
gtk_widget_hide (dialog->dialog);
if (dialog->cancel_cb)
dialog->cancel_cb (dialog->cancel_cb_data);
break;
}
}
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_apply_cb(DefaultDialog_t *dialog,
void (*apply_cb)(gpointer),
gpointer apply_cb_data)
{
dialog->apply_cb = apply_cb;
dialog->apply_cb_data = apply_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 = g_new0 (DefaultDialog_t, 1);
data->ok_cb = NULL;
data->apply_cb = NULL;
data->cancel_cb = NULL;
data->dialog = pika_dialog_new (title, PLUG_IN_ROLE,
get_dialog(), 0,
pika_standard_help_func, PLUG_IN_PROC,
NULL);
data->apply = gtk_dialog_add_button (GTK_DIALOG (data->dialog),
_("_Apply"), GTK_RESPONSE_APPLY);
data->cancel = gtk_dialog_add_button (GTK_DIALOG (data->dialog),
_("_Cancel"), GTK_RESPONSE_CANCEL);
data->ok = gtk_dialog_add_button (GTK_DIALOG (data->dialog),
_("_OK"), GTK_RESPONSE_OK);
pika_dialog_set_alternative_button_order (GTK_DIALOG (data->dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_APPLY,
GTK_RESPONSE_CANCEL,
-1);
g_signal_connect (data->dialog, "response",
G_CALLBACK (dialog_response),
data);
g_signal_connect (data->dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&data->dialog);
data->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (data->vbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))),
data->vbox, TRUE, TRUE, 0);
gtk_widget_show (data->vbox);
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_hide_help_button(DefaultDialog_t *dialog)
{
/* gtk_widget_hide(dialog->help); */
}
void
default_dialog_set_title(DefaultDialog_t *dialog, const gchar *title)
{
gtk_window_set_title(GTK_WINDOW(dialog->dialog), title);
}
void
default_dialog_set_label(DefaultDialog_t *dialog, const gchar *text)
{
GtkWidget *label = gtk_label_new(text);
gtk_box_pack_start (GTK_BOX (dialog->vbox), label, TRUE, TRUE, 0);
gtk_widget_show(label);
}
GtkWidget*
default_dialog_add_grid (DefaultDialog_t *dialog)
{
GtkWidget *grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_box_pack_start (GTK_BOX (dialog->vbox), grid, TRUE, TRUE, 0);
gtk_widget_show (grid);
return grid;
}

View File

@ -0,0 +1,58 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_DEFAULT_DIALOG_H
#define _IMAP_DEFAULT_DIALOG_H
typedef struct
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *ok;
GtkWidget *apply;
GtkWidget *cancel;
void (*ok_cb)(gpointer);
gpointer ok_cb_data;
void (*apply_cb)(gpointer);
gpointer apply_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_apply_cb(DefaultDialog_t *dialog,
void (*apply_cb)(gpointer),
gpointer apply_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_hide_help_button(DefaultDialog_t *dialog);
void default_dialog_set_title(DefaultDialog_t *dialog, const gchar *title);
void default_dialog_set_label(DefaultDialog_t *dialog, const gchar *text);
GtkWidget *default_dialog_add_grid (DefaultDialog_t *dialog);
#endif /* _IMAP_DEFAULT_DIALOG_H */

View File

@ -0,0 +1,550 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include "libpika/pika.h"
#include "libpika/pikaui.h"
#include "imap_browse.h"
#include "imap_commands.h"
#include "imap_default_dialog.h"
#include "imap_edit_area_info.h"
#include "imap_icons.h"
#include "imap_main.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
static gboolean callback_lock;
static 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_path_get_basename(name);
return g_strdup (name);
}
static void
url_changed (GtkWidget *widget,
gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
const gchar *url = gtk_entry_get_text (GTK_ENTRY (param->url));
GtkWidget *button;
if (! g_ascii_strncasecmp (url, "http://", sizeof ("http://") - 1) ||
! g_ascii_strncasecmp (url, "https://", sizeof ( "https://") - 1))
button = param->web_site;
else if (! g_ascii_strncasecmp (url, "ftp://", sizeof ("ftp://") - 1))
button = param->ftp_site;
else if (! g_ascii_strncasecmp (url, "gopher://", sizeof ("gopher://") - 1))
button = param->gopher;
else if (! g_ascii_strncasecmp (url, "file:/", sizeof ("file:/") - 1))
button = param->file;
else if (! g_ascii_strncasecmp (url, "wais://", sizeof ("wais://") - 1))
button = param->wais;
else if (! g_ascii_strncasecmp (url, "telnet://", sizeof ("telnet://") - 1))
button = param->telnet;
else if (! g_ascii_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_get_state_flags (widget) & GTK_STATE_FLAG_ACTIVE)
{
char *p;
gchar *url = g_strdup (gtk_entry_get_text (GTK_ENTRY(param->url)));
p = strstr (url, "//"); /* 'https://' */
if (p)
{
p += 2;
}
else
{
p = strchr (url, ':'); /* 'mailto:' */
if (p)
{
p++;
if (*p == '/') /* 'file:/' */
p++;
}
else
{
p = url;
}
}
p = g_strconcat (prefix, p, NULL);
gtk_entry_set_text (GTK_ENTRY(param->url), p);
g_free (p);
g_free (url);
}
}
gtk_widget_grab_focus(param->url);
}
static void
select_web_cb (GtkWidget *widget,
AreaInfoDialog_t *param)
{
set_url (widget, param, "https://");
}
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
append_page (GtkWidget *notebook, GtkWidget *page, const gchar *icon_name,
const gchar *label_name)
{
GtkWidget *hbox, *icon, *label;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
gtk_widget_show(hbox);
icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
gtk_widget_show (icon);
label = gtk_label_new_with_mnemonic (label_name);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_widget_show (label);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, hbox);
}
static void
create_link_tab (AreaInfoDialog_t *dialog,
GtkWidget *notebook)
{
BrowseWidget_t *browse;
GtkWidget *grid;
GtkWidget *label;
GtkWidget *subgrid;
GtkWidget *frame;
GSList *group;
grid = gtk_grid_new ();
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_widget_show (grid);
frame = pika_frame_new (_("Link Type"));
gtk_grid_attach (GTK_GRID (grid), frame, 0, 0, 2, 1);
gtk_widget_show (frame);
subgrid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (frame), subgrid);
gtk_widget_show (subgrid);
dialog->web_site = create_radio_button_in_grid (subgrid, NULL, 0, 0,
_("_Web Site"));
g_signal_connect(dialog->web_site, "toggled",
G_CALLBACK (select_web_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->web_site));
dialog->ftp_site = create_radio_button_in_grid (subgrid, group, 0, 1,
_("_FTP Site"));
g_signal_connect(dialog->ftp_site, "toggled",
G_CALLBACK (select_ftp_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->ftp_site));
dialog->gopher = create_radio_button_in_grid (subgrid, group, 0, 2,
_("_Gopher"));
g_signal_connect(dialog->gopher, "toggled",
G_CALLBACK (select_gopher_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->gopher));
dialog->other = create_radio_button_in_grid (subgrid, group, 0, 3,
_("Ot_her"));
g_signal_connect(dialog->other, "toggled",
G_CALLBACK (select_other_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->other));
dialog->file = create_radio_button_in_grid (subgrid, group, 1, 0,
_("F_ile"));
g_signal_connect(dialog->file, "toggled",
G_CALLBACK (select_file_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->file));
dialog->wais = create_radio_button_in_grid (subgrid, group, 1, 1,
_("WAI_S"));
g_signal_connect(dialog->wais, "toggled",
G_CALLBACK (select_wais_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->wais));
dialog->telnet = create_radio_button_in_grid (subgrid, group, 1, 2,
_("Tel_net"));
g_signal_connect(dialog->telnet, "toggled",
G_CALLBACK (select_telnet_cb), (gpointer) dialog);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dialog->telnet));
dialog->email = create_radio_button_in_grid (subgrid, group, 1, 3,
_("e-_mail"));
g_signal_connect(dialog->email, "toggled",
G_CALLBACK (select_email_cb), (gpointer) dialog);
label = create_label_in_grid (
grid, 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_grid_attach (GTK_GRID (grid), browse->hbox, 0, 3, 1, 1);
dialog->url = browse->file;
g_signal_connect(dialog->url, "changed", G_CALLBACK(url_changed),
dialog);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), dialog->url);
dialog->relative_link = create_check_button_in_grid (grid, 4, 0,
_("Relati_ve link"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->relative_link),
TRUE);
label = create_label_in_grid (
grid, 6, 0,
_("_Target frame name/ID: (optional - used for FRAMES only)"));
dialog->target = create_entry_in_grid (grid, label, 7, 0);
label = create_label_in_grid (grid, 9, 0, _("ALT te_xt: (optional)"));
dialog->comment = create_entry_in_grid (grid, label, 10, 0);
label = create_label_in_grid (grid, 12, 0, _("Access _Key: (optional)"));
dialog->accesskey = create_entry_in_grid (grid, label, 13, 0);
label = create_label_in_grid (grid, 15, 0, _("Ta_b Index: (optional)"));
dialog->tabindex = create_entry_in_grid (grid, label, 16, 0);
append_page (notebook, grid, PIKA_ICON_WEB, _("_Link"));
}
static void
geometry_changed(Object_t *obj, gpointer data)
{
AreaInfoDialog_t *dialog = (AreaInfoDialog_t*) data;
if (dialog->geometry_lock) {
dialog->geometry_lock = FALSE;
} else {
if (dialog->obj == obj) {
object_update_info_widget(obj, dialog->infotab);
obj->class->assign(obj, dialog->clone);
}
}
}
static void
toggle_preview_cb(GtkWidget *widget, AreaInfoDialog_t *param)
{
param->preview = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
edit_area_info_dialog_emit_geometry_signal(param);
}
static void
create_info_tab(AreaInfoDialog_t *dialog, GtkWidget *notebook)
{
GtkWidget *vbox, *frame, *preview;
Object_t *obj = dialog->obj;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
gtk_widget_show(vbox);
frame = pika_frame_new(_("Dimensions"));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
gtk_widget_show(frame);
preview = gtk_check_button_new_with_mnemonic(_("Pre_view"));
g_signal_connect(preview, "toggled",
G_CALLBACK (toggle_preview_cb), (gpointer) dialog);
gtk_box_pack_start(GTK_BOX(vbox), preview, FALSE, FALSE, 0);
gtk_widget_show(preview);
dialog->infotab = obj->class->create_info_widget(frame);
append_page (notebook, vbox, obj->class->get_icon_name (),
gettext (obj->class->name));
}
static void
create_java_script_tab (AreaInfoDialog_t *dialog,
GtkWidget *notebook)
{
GtkWidget *vbox, *grid, *label;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
gtk_widget_show(vbox);
grid = gtk_grid_new ();
gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_widget_show (grid);
label = create_label_in_grid (grid, 0, 0, "o_nMouseover:");
dialog->mouse_over = create_entry_in_grid (grid, label, 1, 0);
label = create_label_in_grid (grid, 3, 0, "on_Mouseout:");
dialog->mouse_out = create_entry_in_grid (grid, label, 4, 0);
label = create_label_in_grid (grid, 6, 0, "on_Focus (HTML 4.0):");
dialog->focus = create_entry_in_grid (grid, label, 7, 0);
label = create_label_in_grid (grid, 9, 0, "on_Blur (HTML 4.0):");
dialog->blur = create_entry_in_grid (grid, label, 10, 0);
label = create_label_in_grid (grid, 12, 0, "onC_lick:");
dialog->click = create_entry_in_grid (grid, label, 13, 0);
append_page (notebook, vbox, IMAP_JAVA, _("_JavaScript"));
}
static gboolean
object_was_changed(AreaInfoDialog_t *dialog)
{
Object_t *clone = dialog->clone;
Object_t *obj = dialog->obj;
gint old_x, old_y, old_width, old_height;
gint new_x, new_y, new_width, new_height;
object_get_dimensions(clone, &old_x, &old_y, &old_width, &old_height);
object_get_dimensions(obj, &new_x, &new_y, &new_width, &new_height);
return new_x != old_x || new_y != old_y || new_width != old_width ||
new_height != old_height || clone->selected != obj->selected;
}
static void
edit_area_apply_cb (gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
Object_t *obj = param->obj;
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_accesskey (obj, gtk_entry_get_text (GTK_ENTRY(param->accesskey)));
object_set_tabindex (obj, gtk_entry_get_text (GTK_ENTRY(param->tabindex)));
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_set_click (obj, gtk_entry_get_text (GTK_ENTRY (param->click)));
object_update (obj, param->infotab);
update_shape (obj);
if (object_was_changed (param))
preview_redraw();
}
static void
edit_area_ok_cb(gpointer data)
{
AreaInfoDialog_t *param = (AreaInfoDialog_t*) data;
Object_t *obj = param->obj;
object_list_remove_geometry_cb(obj->list, param->geometry_cb_id);
/* Fix me: nasty hack */
if (param->add)
command_list_add(edit_object_command_new(obj));
edit_area_apply_cb(data);
object_unlock(obj);
object_unref(param->clone);
}
static void
edit_area_cancel_cb(gpointer data)
{
AreaInfoDialog_t *dialog = (AreaInfoDialog_t*) data;
Object_t *obj = dialog->obj;
gboolean changed = object_was_changed(dialog);
gboolean selected = obj->selected;
object_list_remove_geometry_cb(obj->list, dialog->geometry_cb_id);
object_unlock(obj);
object_assign(dialog->clone, obj);
obj->selected = selected;
object_unref(dialog->clone);
if (changed)
preview_redraw();
}
static void
switch_page(GtkWidget *widget, gpointer 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->geometry_lock = FALSE;
data->preview = FALSE;
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_apply_cb(data->dialog, edit_area_apply_cb, data);
default_dialog_set_cancel_cb(data->dialog, edit_area_cancel_cb, data);
data->notebook = notebook = gtk_notebook_new();
g_signal_connect_after(notebook, "switch-page",
G_CALLBACK(switch_page), (gpointer) data);
gtk_box_pack_start(GTK_BOX(data->dialog->vbox), notebook, TRUE, TRUE, 0);
create_link_tab(data, notebook);
create_info_tab(data, 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)
{
gchar *title;
object_unlock (dialog->obj);
object_lock(obj);
dialog->obj = obj;
dialog->clone = object_clone(obj);
dialog->add = add;
object_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->accesskey), obj->accesskey);
gtk_entry_set_text (GTK_ENTRY (dialog->tabindex), obj->tabindex);
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_entry_set_text (GTK_ENTRY (dialog->click), obj->click);
gtk_widget_grab_focus (dialog->url);
dialog->geometry_cb_id =
object_list_add_geometry_cb (obj->list, geometry_changed, dialog);
title = g_strdup_printf (_("Area #%d Settings"),
object_get_position_in_list(obj) + 1);
default_dialog_set_title (dialog->dialog, title);
g_free (title);
default_dialog_show (dialog->dialog);
}
void
edit_area_info_dialog_emit_geometry_signal(AreaInfoDialog_t *dialog)
{
if (dialog->preview) {
dialog->geometry_lock = TRUE;
object_emit_geometry_signal(dialog->obj);
}
}

View File

@ -0,0 +1,69 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_EDIT_AREA_INFO_H
#define _IMAP_EDIT_AREA_INFO_H
typedef struct AreaInfoDialog_t AreaInfoDialog_t;
#include "imap_default_dialog.h"
#include "imap_object.h"
struct AreaInfoDialog_t {
DefaultDialog_t *dialog;
Object_t *obj;
Object_t *clone;
gboolean add;
gboolean geometry_lock;
gboolean preview;
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 *click;
GtkWidget *accesskey;
GtkWidget *tabindex;
GtkWidget *browse;
gpointer infotab;
gpointer geometry_cb_id;
};
AreaInfoDialog_t *create_edit_area_info_dialog(Object_t *obj);
void edit_area_info_dialog_show(AreaInfoDialog_t *dialog, Object_t *obj,
gboolean add);
void edit_area_info_dialog_emit_geometry_signal(AreaInfoDialog_t *dialog);
#endif /* _IMAP_EDIT_AREA_INFO_H */

View File

@ -0,0 +1,184 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "imap_file.h"
#include "imap_main.h"
#include "libpika/stdplugins-intl.h"
static void
open_cb (GtkWidget *dialog,
gint response_id,
gpointer data)
{
if (response_id == GTK_RESPONSE_OK)
{
gchar *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
if (! g_file_test (filename, G_FILE_TEST_IS_REGULAR))
{
do_file_error_dialog (_("Error opening file"), filename);
g_free (filename);
return;
}
load (filename, data);
g_free (filename);
}
gtk_widget_hide (dialog);
}
void
do_file_open_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GtkWidget *dialog;
if (! dialog)
{
dialog =
gtk_file_chooser_dialog_new (_("Load Image Map"),
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
pika_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (open_cb),
user_data);
}
gtk_window_present (GTK_WINDOW (dialog));
}
static void
save_cb (GtkWidget *dialog,
gint response_id,
gpointer data)
{
if (response_id == GTK_RESPONSE_OK)
{
gchar *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
save_as (filename);
g_free (filename);
}
gtk_widget_hide (dialog);
}
void
do_file_save_as_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GtkWidget *dialog;
if (! dialog)
{
gchar *filename;
dialog = gtk_file_chooser_dialog_new (_("Save Image Map"),
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Save"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
pika_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
TRUE);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (save_cb),
dialog);
/* Suggest a filename based on the image name.
* The image name is in UTF-8 encoding.
*/
filename = g_strconcat (get_image_name(), ".map", NULL);
if (filename)
{
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
filename);
g_free (filename);
}
}
gtk_window_present (GTK_WINDOW (dialog));
}
void
do_file_error_dialog (const char *error,
const char *filename)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new_with_markup
(NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
error,
pika_filename_to_utf8 (filename));
g_signal_connect_swapped (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
}

View File

@ -0,0 +1,39 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_FILE_H
#define _IMAP_FILE_H
void do_file_open_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_file_save_as_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
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,438 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "imap_grid.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_preview.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
typedef enum {GRID_HIDDEN, GRID_LINES, GRID_CROSSES} GridType_t;
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *type_frame;
GtkWidget *granularity_frame;
GtkWidget *offset_frame;
GtkWidget *snap;
GtkWidget *width;
GtkWidget *height;
GtkWidget *chain_width_height;
GtkWidget *left;
GtkWidget *top;
GtkWidget *chain_left_top;
GtkWidget *hidden;
GtkWidget *lines;
GtkWidget *crosses;
GtkWidget *preview;
gboolean enable_preview;
} GridDialog_t;
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)
{
PikaImap *imap = PIKA_IMAP (data);
GridDialog_t *param = (GridDialog_t*) imap->grid_data;
gboolean new_snap;
new_snap = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (param->snap));
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));
if (grid_snap != new_snap)
{
GAction *action;
grid_snap = new_snap;
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "grid");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), grid_snap);
}
preview_redraw();
}
static void
snap_toggled_cb (GtkWidget *widget,
gpointer data)
{
GridDialog_t *param = (GridDialog_t*) data;
gint sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
gtk_widget_set_sensitive(param->type_frame, sensitive);
gtk_widget_set_sensitive(param->granularity_frame, sensitive);
gtk_widget_set_sensitive(param->offset_frame, sensitive);
gtk_widget_set_sensitive(param->preview, sensitive);
}
static void
type_toggled_cb(GtkWidget *widget, gpointer data)
{
if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED)
{
grid_type = GPOINTER_TO_INT (data);
preview_redraw();
}
}
static void
toggle_preview_cb(GtkWidget *widget, GridDialog_t *param)
{
param->enable_preview =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
preview_redraw();
}
static void
grid_assign_value(GtkWidget *widget, gpointer data, gint *value)
{
GridDialog_t *dialog = (GridDialog_t*) data;
if (dialog->enable_preview) {
*value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
preview_redraw(); /* Fix me! */
}
}
static void
width_changed_cb(GtkWidget *widget, gpointer data)
{
GridDialog_t *dialog = (GridDialog_t*) data;
grid_assign_value(widget, data, &grid_width);
if (pika_chain_button_get_active(
PIKA_CHAIN_BUTTON(dialog->chain_width_height))) {
gint value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->height), value);
}
}
static void
height_changed_cb(GtkWidget *widget, gpointer data)
{
GridDialog_t *dialog = (GridDialog_t*) data;
grid_assign_value(widget, data, &grid_height);
if (pika_chain_button_get_active(
PIKA_CHAIN_BUTTON(dialog->chain_width_height))) {
gint value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->width), value);
}
}
static void
left_changed_cb(GtkWidget *widget, gpointer data)
{
GridDialog_t *dialog = (GridDialog_t*) data;
grid_assign_value(widget, data, &grid_left);
if (pika_chain_button_get_active(
PIKA_CHAIN_BUTTON(dialog->chain_left_top))) {
gint value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->top), value);
}
}
static void
top_changed_cb (GtkWidget *widget, gpointer data)
{
GridDialog_t *dialog = (GridDialog_t*) data;
grid_assign_value(widget, data, &grid_top);
if (pika_chain_button_get_active(
PIKA_CHAIN_BUTTON(dialog->chain_left_top))) {
gint value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->left), value);
}
}
static GridDialog_t*
create_grid_settings_dialog (gpointer user_data)
{
PikaImap *imap = PIKA_IMAP (user_data);
GridDialog_t *data = g_new (GridDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *main_grid, *grid, *label;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *chain_button;
data->dialog = dialog = make_default_dialog(_("Grid Settings"));
imap->grid_data = data;
default_dialog_set_ok_cb (dialog, grid_settings_ok_cb, (gpointer) imap);
main_grid = default_dialog_add_grid (dialog);
data->snap = gtk_check_button_new_with_mnemonic(_("_Snap-to grid enabled"));
g_signal_connect(data->snap, "toggled",
G_CALLBACK (snap_toggled_cb), data);
gtk_grid_attach (GTK_GRID (main_grid), data->snap, 0, 0, 1, 1);
gtk_widget_show(data->snap);
data->type_frame = frame = pika_frame_new(_("Grid Visibility and Type"));
gtk_widget_show(frame);
gtk_grid_attach (GTK_GRID (main_grid), frame, 0, 1, 2, 1);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
button = gtk_radio_button_new_with_mnemonic_from_widget(NULL, _("_Hidden"));
data->hidden = button;
g_signal_connect(button, "toggled",
G_CALLBACK (type_toggled_cb), (gpointer) GRID_HIDDEN);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
button = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(button), _("_Lines"));
data->lines = button;
g_signal_connect(button, "toggled",
G_CALLBACK (type_toggled_cb), (gpointer) GRID_LINES);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
button = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(button), _("C_rosses"));
data->crosses = button;
g_signal_connect(button, "toggled",
G_CALLBACK (type_toggled_cb),
(gpointer) GRID_CROSSES);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
gtk_widget_show(button);
data->granularity_frame = frame = pika_frame_new(_("Grid Granularity"));
gtk_grid_attach (GTK_GRID (main_grid), frame, 0, 2, 1, 1);
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_container_add(GTK_CONTAINER(frame), grid);
label = create_label_in_grid (grid, 0, 0, _("_Width"));
data->width = create_spin_button_in_grid (grid, label, 0, 1, 15, 1, 100);
g_signal_connect(data->width, "value-changed",
G_CALLBACK (width_changed_cb), (gpointer) data);
create_label_in_grid (grid, 0, 3, _("pixels"));
label = create_label_in_grid (grid, 1, 0, _("_Height"));
data->height = create_spin_button_in_grid (grid, label, 1, 1, 15, 1, 100);
g_signal_connect(data->height, "value-changed",
G_CALLBACK (height_changed_cb), (gpointer) data);
create_label_in_grid (grid, 1, 3, _("pixels"));
chain_button = pika_chain_button_new(PIKA_CHAIN_RIGHT);
data->chain_width_height = chain_button;
gtk_grid_attach (GTK_GRID (grid), chain_button, 2, 0, 1, 2);
gtk_widget_show(chain_button);
gtk_widget_show(grid);
gtk_widget_show(frame);
data->offset_frame = frame = pika_frame_new(_("Grid Offset"));
gtk_grid_attach (GTK_GRID (main_grid), frame, 1, 2, 1, 1);
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_container_add(GTK_CONTAINER(frame), grid);
label = create_label_in_grid (grid, 0, 2, _("pixels from l_eft"));
data->left = create_spin_button_in_grid (grid, label, 0, 0, 0, 0, 100);
g_signal_connect(data->left, "value-changed",
G_CALLBACK (left_changed_cb), (gpointer) data);
label = create_label_in_grid (grid, 1, 2, _("pixels from _top"));
data->top = create_spin_button_in_grid (grid, label, 1, 0, 0, 0, 100);
g_signal_connect(data->top, "value-changed",
G_CALLBACK (top_changed_cb), (gpointer) data);
chain_button = pika_chain_button_new(PIKA_CHAIN_RIGHT);
data->chain_left_top = chain_button;
gtk_grid_attach (GTK_GRID (grid), chain_button, 1, 0, 1, 2);
gtk_widget_show(chain_button);
data->preview = create_check_button_in_grid (main_grid, 3, 0,
_("_Preview"));
g_signal_connect(data->preview, "toggled",
G_CALLBACK (toggle_preview_cb), (gpointer) data);
gtk_widget_show(data->preview);
snap_toggled_cb (data->snap, data);
gtk_widget_show(grid);
gtk_widget_show(frame);
return data;
}
void
do_grid_settings_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GridDialog_t* dialog;
GtkWidget *type;
if (!dialog)
dialog = create_grid_settings_dialog (user_data);
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(cairo_t *cr, gint width, gint height)
{
gint x, y;
gdouble dash = 4.;
cairo_set_dash (cr, &dash, 1, 0.);
for (x = grid_left % grid_width; x < width; x += grid_width)
draw_line(cr, x, 1, x, height);
for (y = grid_top % grid_height; y < height; y += grid_height)
draw_line(cr, 1, y, width, y);
}
static void
draw_crosses(cairo_t *cr, gint width, gint height)
{
gint x, y;
gdouble dash[4] = { 7., grid_height - 7., 7., grid_width - 7. };
cairo_set_dash (cr, dash, 2, 4.5 - grid_top);
for (x = grid_left % grid_width; x < width; x += grid_width)
draw_line(cr, x, 1, x, height);
cairo_set_dash (cr, dash+2, 2, 4.5 - grid_left);
for (y = grid_top % grid_height; y < height; y += grid_height)
draw_line(cr, 1, y, width, y);
}
void
draw_grid (cairo_t *cr,
gint width,
gint height)
{
if (grid_snap && grid_type != GRID_HIDDEN)
{
cairo_save (cr);
if (grid_type == GRID_LINES)
{
draw_lines(cr, width, height);
}
else
{
draw_crosses(cr, width, height);
}
cairo_restore (cr);
}
}
void
toggle_grid (GSimpleAction *action,
GVariant *new_state,
gpointer user_data)
{
GtkToggleToolButton *grid_toggle;
grid_snap = ! grid_snap;
preview_redraw();
g_simple_action_set_state (action, new_state);
grid_toggle = GTK_TOGGLE_TOOL_BUTTON (PIKA_IMAP (user_data)->grid_toggle);
gtk_toggle_tool_button_set_active (grid_toggle, grid_snap);
}
static gint
grid_nearest_x (gint x)
{
return grid_left + (x - grid_left + grid_width / 2) / grid_width
* grid_width;
}
static gint
grid_nearest_y (gint y)
{
return grid_top + (y - grid_top + grid_height / 2) / grid_height
* grid_height;
}
void
round_to_grid (gint *x,
gint *y)
{
if (grid_snap) {
*x = grid_nearest_x(*x);
*y = grid_nearest_y(*y);
}
}
gboolean
grid_near_x(gint x)
{
return grid_snap && grid_type != GRID_HIDDEN
&& abs(grid_nearest_x(x) - x) <= 1;
}
gboolean
grid_near_y(gint y)
{
return grid_snap && grid_type != GRID_HIDDEN
&& abs(grid_nearest_x(y) - y) <= 1;
}

View File

@ -0,0 +1,41 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_GRID_H
#define _IMAP_GRID_H
void do_grid_settings_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void draw_grid (cairo_t *cr,
gint width,
gint height);
void toggle_grid (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void round_to_grid (gint *x,
gint *y);
gboolean grid_near_x (gint x);
gboolean grid_near_y (gint y);
#endif /* _IMAP_GRID_H */

View File

@ -0,0 +1,46 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_icons.h"
#include "images/imagemap-icon-images.h"
void
init_icons (void)
{
static gboolean initialized = FALSE;
GtkIconTheme *icon_theme;
if (initialized)
return;
initialized = TRUE;
icon_theme = gtk_icon_theme_get_default ();
gtk_icon_theme_add_resource_path (icon_theme, "/technology.heckin/imagemap/icons");
}

View File

@ -0,0 +1,39 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_ICONS_H
#define _IMAP_ICONS_H
#define IMAP_ARROW "imagemap-arrow"
#define IMAP_CIRCLE "imagemap-circle"
#define IMAP_COORD "imagemap-coord"
#define IMAP_DIMENSION "imagemap-dimension"
#define IMAP_JAVA "imagemap-java"
#define IMAP_LINK "imagemap-link"
#define IMAP_POLYGON "imagemap-polygon"
#define IMAP_RECTANGLE "imagemap-rectangle"
#define IMAP_TO_BACK "imagemap-to-back"
#define IMAP_TO_FRONT "imagemap-to-front"
void init_icons (void);
#endif /* _IMAP_ICONS_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,204 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_MAIN_H
#define _IMAP_MAIN_H
#include "imap_mru.h"
#include "imap_grid.h"
#include "imap_object.h"
#include "imap_preferences.h"
#include "imap_preview.h"
struct _PikaImap
{
PikaPlugIn parent_instance;
GtkApplication *app;
GtkWidget *dlg;
GtkWidget *grid_toggle;
gpointer grid_data;
gchar *tmp_filename;
PikaDrawable *drawable;
gboolean success;
GtkBuilder *builder;
};
#define PLUG_IN_PROC "plug-in-imagemap"
#define PLUG_IN_BINARY "imagemap"
#define PLUG_IN_ROLE "pika-imagemap"
#define PIKA_TYPE_IMAP (pika_imap_get_type ())
G_DECLARE_FINAL_TYPE (PikaImap, pika_imap, PIKA, IMAP, PikaPlugIn)
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,
gpointer data);
void save_as (const gchar *filename);
void dump_output (gpointer param, OutputFunc_t output);
GtkWidget *get_dialog (void);
MRU_t *get_mru (void);
MapInfo_t *get_map_info (void);
PreferencesData_t *get_preferences (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(cairo_t *cr, gint x1, gint y1, gint x2,
gint y2);
void draw_rectangle(cairo_t *cr, gboolean filled, gint x, gint y,
gint width, gint height);
void draw_circle(cairo_t *cr, gint x, gint y,
gint r);
void draw_polygon(cairo_t *cr, GList *list);
const char *get_filename(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,
gpointer data);
void draw_shapes(cairo_t *cr);
void show_url(void);
void hide_url(void);
void set_preview_color (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void set_zoom_factor (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void set_func (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void do_edit_selected_shape (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_zoom_in (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_zoom_out (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_close (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_quit (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_undo (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_redo (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_cut (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_copy (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_paste (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_select_all (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_deselect_all (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_clear (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_move_up (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_move_down (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_move_to_front (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_send_to_back (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_use_pika_guides_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_create_guides_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void save (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void imap_help (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void toggle_area_list (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
const gchar * get_image_name (void);
GtkWidget * add_tool_button (GtkWidget *toolbar,
const char *action,
const char *icon,
const char *label,
const char *tooltip);
GtkWidget * add_toggle_button (GtkWidget *toolbar,
const char *action,
const char *icon,
const char *label,
const char *tooltip);
void add_tool_separator (GtkWidget *toolbar,
gboolean expand);
#endif /* _IMAP_MAIN_H */

View File

@ -0,0 +1,191 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2006 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "libpika/pika.h"
#include "libpika/pikaui.h"
#include "imap_about.h"
#include "imap_circle.h"
#include "imap_file.h"
#include "imap_grid.h"
#include "imap_icons.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_menu_funcs.h"
#include "imap_polygon.h"
#include "imap_preferences.h"
#include "imap_rectangle.h"
#include "imap_settings.h"
#include "imap_source.h"
#include "libpika/stdplugins-intl.h"
void
menu_set_zoom_sensitivity (gpointer data,
gint factor)
{
GAction *action;
PikaImap *imap = PIKA_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "zoom-in");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), factor < 8);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "zoom-out");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), factor > 1);
}
void
menu_set_zoom (gpointer data,
gint factor)
{
menu_set_zoom_sensitivity (data, factor);
}
void
menu_shapes_selected (gint count,
gpointer data)
{
PikaImap *imap = PIKA_IMAP (data);
gboolean sensitive = (count > 0);
GAction *action;
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "cut");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "copy");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "clear");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "edit-area-info");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "deselect-all");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
}
static void
command_list_changed (Command_t *command,
gpointer data)
{
GAction *action;
PikaImap *imap;
gchar *label;
imap = PIKA_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "undo");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), command != NULL);
label = g_strdup_printf (_("_Undo %s"),
command && command->name ? command->name : "");
/* TODO: Find a way to change GAction label in menu for undo */
g_free (label);
command = command_list_get_redo_command ();
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "redo");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), command != NULL);
label = g_strdup_printf (_("_Redo %s"),
command && command->name ? command->name : "");
/* TODO: Find a way to change GAction label in menu for redo */
g_free (label);
}
static void
paste_buffer_added (Object_t *obj, gpointer data)
{
GAction *action;
PikaImap *imap = PIKA_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
}
static void
paste_buffer_removed (Object_t *obj, gpointer data)
{
GAction *action;
PikaImap *imap = PIKA_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
Menu_t*
make_menu (PikaImap *imap)
{
GAction *action;
paste_buffer_add_add_cb (paste_buffer_added, imap);
paste_buffer_add_remove_cb (paste_buffer_removed, imap);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
menu_shapes_selected (0, imap);
menu_set_zoom_sensitivity (imap, 1);
command_list_add_update_cb (command_list_changed, imap);
command_list_changed (NULL, imap);
return NULL;
}
void
do_main_popup_menu (GdkEventButton *event,
gpointer data)
{
GtkWidget *menu;
GMenuModel *model;
PikaImap *imap = PIKA_IMAP (data);
model = G_MENU_MODEL (gtk_builder_get_object (imap->builder, "imap-main-popup"));
menu = gtk_menu_new_from_model (model);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (imap->dlg), NULL);
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
}
GtkWidget*
make_selection_toolbar (PikaImap *imap)
{
GtkWidget *toolbar = gtk_toolbar_new ();
add_tool_button (toolbar, "app.move-up", PIKA_ICON_GO_UP,
_("Move Up"), _("Move Up"));
add_tool_button (toolbar, "app.move-down", PIKA_ICON_GO_DOWN,
_("Move Down"), _("Move Down"));
add_tool_button (toolbar, "app.edit-area-info", PIKA_ICON_EDIT,
_("Edit Area Info..."), _("Edit selected area info"));
add_tool_button (toolbar, "app.clear", PIKA_ICON_EDIT_DELETE,
_("Delete"), _("Delete"));
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
GTK_ORIENTATION_VERTICAL);
gtk_container_set_border_width (GTK_CONTAINER (toolbar), 0);
gtk_widget_show (toolbar);
return toolbar;
}

View File

@ -0,0 +1,65 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_MENU_H
#define _IMAP_MENU_H
#include "imap_command.h"
#include "imap_mru.h"
typedef struct {
GtkWidget *file_menu;
GtkWidget *edit_menu;
GtkWidget *open_recent;
GtkWidget *undo;
GtkWidget *redo;
GtkWidget *arrow;
GtkWidget *fuzzy_select;
GtkWidget *rectangle;
GtkWidget *circle;
GtkWidget *polygon;
GtkWidget *grid;
GtkWidget *gray;
GtkWidget *color;
GtkWidget *zoom[8];
GtkWidget *zoom_in;
GtkWidget *zoom_out;
gint nr_off_mru_items;
} Menu_t;
Menu_t *make_menu (PikaImap *imap);
void menu_build_mru_items (MRU_t *mru);
void menu_set_zoom_sensitivity (gpointer data,
gint factor);
void menu_set_zoom (gpointer data,
gint factor);
void menu_shapes_selected (gint count,
gpointer imap);
void do_main_popup_menu (GdkEventButton *event,
gpointer data);
GtkWidget *make_selection_toolbar (PikaImap *imap);
#endif /* _IMAP_MENU_H */

View File

@ -0,0 +1,61 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_command.h"
#include "imap_menu_funcs.h"
static GtkAccelGroup *accelerator_group;
void
init_accel_group(GtkWidget *window)
{
accelerator_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(window), accelerator_group);
}
void
add_accelerator(GtkWidget *widget, guint accelerator_key,
guint8 accelerator_mods)
{
gtk_widget_add_accelerator(widget, "activate", accelerator_group,
accelerator_key, accelerator_mods,
GTK_ACCEL_VISIBLE);
}
GtkWidget*
insert_item_with_label (GtkWidget *parent,
gint position,
gchar *label,
MenuCallback activate,
gpointer data)
{
GtkWidget *item = gtk_menu_item_new_with_mnemonic (label);
gtk_menu_shell_insert (GTK_MENU_SHELL (parent), item, position);
g_signal_connect (item, "activate", G_CALLBACK (activate), data);
gtk_widget_show (item);
return item;
}

View File

@ -0,0 +1,39 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_MENU_FUNCS_H
#define _IMAP_MENU_FUNCS_H
typedef void (*MenuCallback)(GtkWidget *widget, gpointer data);
void init_accel_group(GtkWidget *window);
GtkWidget *insert_item_with_label(GtkWidget *parent, gint position,
gchar *label, MenuCallback activate,
gpointer data);
void menu_command(GtkWidget *widget, gpointer data);
void add_accelerator(GtkWidget *widget, guint accelerator_key,
guint8 accelerator_mods);
#endif /* _IMAP_MENU_FUNCS_H */

View File

@ -0,0 +1,52 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_main.h"
#include "imap_misc.h"
#define SASH_SIZE 8
static gint _sash_size = SASH_SIZE;
void
set_sash_size(gboolean double_size)
{
_sash_size = (double_size) ? 2 * SASH_SIZE : SASH_SIZE;
}
void
draw_sash(cairo_t *cr, gint x, gint y)
{
draw_rectangle(cr, TRUE, x - _sash_size / 2, y - _sash_size / 2,
_sash_size, _sash_size);
}
gboolean
near_sash(gint sash_x, gint sash_y, gint x, gint y)
{
return x >= sash_x - _sash_size / 2 && x <= sash_x + _sash_size / 2 &&
y >= sash_y - _sash_size / 2 && y <= sash_y + _sash_size / 2;
}

View File

@ -0,0 +1,31 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_MISC_H
#define _IMAP_MISC_H
void set_sash_size(gboolean double_size);
void draw_sash(cairo_t *cr, gint x, gint y);
gboolean near_sash(gint sash_x, gint sash_y, gint x, gint y);
#endif /* _IMAP_MISC_H */

View File

@ -0,0 +1,105 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "imap_mru.h"
MRU_t*
mru_create(void)
{
MRU_t *mru = g_new(MRU_t, 1);
mru->list = NULL;
mru->max_size = DEFAULT_MRU_SIZE;
return mru;
}
void
mru_destruct (MRU_t *mru)
{
g_list_free_full (mru->list, (GDestroyNotify) g_free);
g_free (mru);
}
static void
mru_remove_link(MRU_t *mru, GList *link)
{
if (link)
{
g_free(link->data);
mru->list = g_list_remove_link(mru->list, link);
}
}
static GList*
mru_find_link(MRU_t *mru, const gchar *filename)
{
return g_list_find_custom(mru->list, (gpointer) filename,
(GCompareFunc) strcmp);
}
void
mru_add(MRU_t *mru, const gchar *filename)
{
if (g_list_length(mru->list) == mru->max_size)
mru_remove_link(mru, g_list_last(mru->list));
mru->list = g_list_prepend(mru->list, g_strdup(filename));
}
void
mru_remove(MRU_t *mru, const gchar *filename)
{
mru_remove_link(mru, mru_find_link(mru, filename));
}
void
mru_set_first(MRU_t *mru, const gchar *filename)
{
GList *link = mru_find_link(mru, filename);
if (link)
mru->list = g_list_prepend(g_list_remove_link(mru->list, link),
link->data);
else
mru_add(mru, filename);
}
void
mru_set_size(MRU_t *mru, gint size)
{
gint diff;
for (diff = g_list_length(mru->list) - size; diff > 0; diff--)
mru_remove_link(mru, g_list_last(mru->list));
mru->max_size = size;
}
void
mru_write(MRU_t *mru, FILE *out)
{
GList *p;
for (p = mru->list; p; p = p->next)
fprintf(out, "(mru-entry %s)\n", (gchar*) p->data);
}

View File

@ -0,0 +1,45 @@
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_MRU_H
#define _IMAP_MRU_H
#include <stdio.h>
#define DEFAULT_MRU_SIZE 4
typedef struct {
GList *list;
gint max_size;
} MRU_t;
MRU_t* mru_create(void);
void mru_destruct(MRU_t *mru);
void mru_add(MRU_t *mru, const gchar *filename);
void mru_remove(MRU_t *mru, const gchar *filename);
void mru_set_first(MRU_t *mru, const gchar *filename);
void mru_set_size(MRU_t *mru, gint size);
void mru_write(MRU_t *mru, FILE *out);
#define mru_empty(mru) ((mru)->list == NULL)
#endif /* _IMAP_MRU_H */

View File

@ -0,0 +1,112 @@
%{
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include <string.h>
#include <glib.h>
#include "imap_ncsa_parse.h"
#ifdef FLEX_SCANNER
#define YY_NO_UNPUT
#endif /* FLEX_SCANNER */
%}
%option noyywrap
%option noinput
%option nounput
DIGIT [0-9]
ID [a-zA-Z_][a-zA-Z0-9_\-]*
WS [ \t\n]+
%x imap_link
%x comment
%%
#\$AUTHOR: {
BEGIN(comment);
return AUTHOR;
}
#\$TITLE: {
BEGIN(comment);
return TITLE;
}
#\$DESCRIPTION: {
BEGIN(comment);
return DESCRIPTION;
}
# {
BEGIN(comment);
return BEGIN_COMMENT;
}
<comment>.* {
BEGIN(INITIAL);
ncsa_lval.id = g_strndup (yytext, yyleng);
return COMMENT;
}
RECT {
BEGIN(imap_link);
return RECTANGLE;
}
CIRCLE {
BEGIN(imap_link);
return CIRCLE;
}
POLY {
BEGIN(imap_link);
return POLYGON;
}
DEFAULT {
BEGIN(imap_link);
return DEFAULT;
}
<imap_link>[^ ,\t\n]+ {
BEGIN(INITIAL);
ncsa_lval.id = g_strndup (yytext, yyleng);
return LINK;
}
-?{DIGIT}*"."?{DIGIT}*([Ee][-+]?{DIGIT}*)? {
ncsa_lval.value = g_ascii_strtod (yytext, NULL);
return FLOAT;
}
{WS} ; /* Eat white space */
. return *yytext;
%%

View File

@ -0,0 +1,195 @@
%{
/*
* This is a plug-in for PIKA.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include <math.h>
#include <glib/gstdio.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 ncsa_lex(void);
extern int ncsa_restart(FILE *ncsa_in);
static void ncsa_error(char* s);
static Object_t *current_object;
%}
%union {
int val;
double value;
char *id;
}
%token<val> RECTANGLE POLYGON CIRCLE DEFAULT
%token<val> AUTHOR TITLE DESCRIPTION BEGIN_COMMENT
%token<value> FLOAT
%token<id> LINK COMMENT
%%
ncsa_file : comment_lines area_list
;
comment_lines : /* empty */
| comment_lines comment_line
;
comment_line : author_line
| title_line
| description_line
| real_comment
;
real_comment : BEGIN_COMMENT COMMENT
{
g_free ($2);
}
;
author_line : AUTHOR COMMENT
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->author, $2);
g_free ($2);
}
;
title_line : TITLE COMMENT
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->title, $2);
g_free ($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);
g_free ($2);
}
;
area_list : /* Empty */
| area_list area
;
area : default
| rectangle
| circle
| polygon
| real_comment
;
default : DEFAULT LINK
{
MapInfo_t *info = get_map_info();
g_strreplace(&info->default_url, $2);
g_free ($2);
}
;
rectangle : RECTANGLE LINK FLOAT ',' FLOAT FLOAT ',' FLOAT
{
gint x = (gint) $3;
gint y = (gint) $5;
gint width = (gint) fabs($6 - x);
gint height = (gint) fabs($8 - y);
current_object = create_rectangle(x, y, width, height);
object_set_url(current_object, $2);
add_shape(current_object);
g_free ($2);
}
;
circle : CIRCLE LINK FLOAT ',' FLOAT FLOAT ',' FLOAT
{
gint x = (gint) $3;
gint y = (gint) $5;
gint r = (gint) fabs($8 - $5);
current_object = create_circle(x, y, r);
object_set_url(current_object, $2);
add_shape(current_object);
g_free ($2);
}
;
polygon : POLYGON LINK {current_object = create_polygon(NULL);} coord_list
{
object_set_url(current_object, $2);
add_shape(current_object);
g_free ($2);
}
;
coord_list : /* Empty */
| coord_list coord
{
}
;
coord : FLOAT ',' FLOAT
{
Polygon_t *polygon = ObjectToPolygon(current_object);
GdkPoint *point = new_point((gint) $1, (gint) $3);
polygon->points = g_list_append(polygon->points,
(gpointer) point);
}
;
%%
static void
ncsa_error(char* s)
{
extern FILE *ncsa_in;
ncsa_restart(ncsa_in);
}
gboolean
load_ncsa(const char* filename)
{
gboolean status;
extern FILE *ncsa_in;
ncsa_in = g_fopen(filename, "r");
if (ncsa_in) {
status = !ncsa_parse();
fclose(ncsa_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,112 @@
/* A Bison parser, made by GNU Bison 2.6.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
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 3 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, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef NCSA_Y_TAB_H
# define NCSA_Y_TAB_H
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int ncsa_debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
RECTANGLE = 258,
POLYGON = 259,
CIRCLE = 260,
DEFAULT = 261,
AUTHOR = 262,
TITLE = 263,
DESCRIPTION = 264,
BEGIN_COMMENT = 265,
FLOAT = 266,
LINK = 267,
COMMENT = 268
};
#endif
/* Tokens. */
#define RECTANGLE 258
#define POLYGON 259
#define CIRCLE 260
#define DEFAULT 261
#define AUTHOR 262
#define TITLE 263
#define DESCRIPTION 264
#define BEGIN_COMMENT 265
#define FLOAT 266
#define LINK 267
#define COMMENT 268
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2049 of yacc.c */
#line 45 "imap_ncsa.y"
int val;
double value;
char *id;
/* Line 2049 of yacc.c */
#line 90 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE ncsa_lval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int ncsa_parse (void *YYPARSE_PARAM);
#else
int ncsa_parse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int ncsa_parse (void);
#else
int ncsa_parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !NCSA_Y_TAB_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,278 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_OBJECT_H
#define _IMAP_OBJECT_H
typedef struct Object_t Object_t;
typedef struct ObjectClass_t ObjectClass_t;
typedef struct ObjectList_t ObjectList_t;
#include "imap_edit_area_info.h"
#include "imap_menu_funcs.h"
struct Object_t {
ObjectClass_t *class;
ObjectList_t *list;
gint refcount;
gboolean selected;
gboolean locked;
gchar *url;
gchar *target;
gchar *accesskey;
gchar *tabindex;
gchar *comment;
gchar *mouse_over;
gchar *mouse_out;
gchar *focus;
gchar *blur;
gchar *click;
};
typedef void (*MoveSashFunc_t)(Object_t*, gint, gint);
typedef void (*OutputFunc_t)(gpointer, const char*, ...) G_GNUC_PRINTF(2,3);
struct AreaInfoDialog_t;
struct ObjectClass_t {
const gchar *name;
AreaInfoDialog_t *info_dialog;
gboolean (*is_valid)(Object_t *obj);
void (*destruct)(Object_t *obj);
Object_t* (*clone)(Object_t *obj);
void (*assign)(Object_t *obj, Object_t *des);
void (*normalize)(Object_t *obj);
void (*draw)(Object_t *obj, cairo_t *cr);
void (*draw_sashes)(Object_t *obj, cairo_t *cr);
MoveSashFunc_t (*near_sash)(Object_t *obj, gint x, gint y);
gboolean (*point_is_on)(Object_t *obj, gint x, gint y);
void (*get_dimensions)(Object_t *obj, gint *x, gint *y, gint *width,
gint *height);
void (*resize)(Object_t *obj, gint percentage_x, gint percentage_y);
void (*move)(Object_t *obj, gint dx, gint dy);
gpointer (*create_info_widget)(GtkWidget *frame);
void (*update_info_widget)(Object_t *obj, gpointer data);
void (*fill_info_tab)(Object_t *obj, gpointer data);
void (*set_initial_focus)(Object_t *obj, gpointer data);
void (*update)(Object_t *obj, gpointer data);
void (*write_csim)(Object_t *obj, gpointer param, OutputFunc_t output);
void (*write_cern)(Object_t *obj, gpointer param, OutputFunc_t output);
void (*write_ncsa)(Object_t *obj, gpointer param, OutputFunc_t output);
void (*do_popup)(Object_t *obj,
GdkEventButton *event,
gpointer data);
const gchar* (*get_icon_name)(void);
};
Object_t *object_ref(Object_t *obj);
void object_unref(Object_t *obj);
Object_t* object_init(Object_t *obj, ObjectClass_t *class);
Object_t* object_clone(Object_t *obj);
Object_t* object_assign(Object_t *src, Object_t *des);
void object_draw (Object_t *obj,
cairo_t *cr);
void object_edit (Object_t *obj,
gboolean add);
void object_select (Object_t *obj);
void object_unselect (Object_t *obj);
void object_move (Object_t *obj,
gint dx,
gint dy);
void object_move_sash (Object_t *obj,
gint dx,
gint dy);
void object_remove (Object_t *obj);
void object_lock (Object_t *obj);
void object_unlock (Object_t *obj);
void object_set_url (Object_t *obj,
const gchar *url);
void object_set_target (Object_t *obj,
const gchar *target);
void object_set_comment (Object_t *obj,
const gchar *comment);
void object_set_accesskey (Object_t *obj,
const gchar *accesskey);
void object_set_tabindex (Object_t *obj,
const gchar *tabindex);
void object_set_mouse_over (Object_t *obj,
const gchar *mouse_over);
void object_set_mouse_out (Object_t *obj,
const gchar *mouse_out);
void object_set_focus (Object_t *obj,
const gchar *focus);
void object_set_blur (Object_t *obj,
const gchar *blur);
void object_set_click (Object_t *obj,
const gchar *click);
gint object_get_position_in_list (Object_t *obj);
void object_emit_changed_signal(Object_t *obj);
void object_emit_geometry_signal(Object_t *obj);
void object_emit_update_signal(Object_t *obj);
#define object_is_valid(obj) \
((obj)->class->is_valid(obj))
#define object_get_dimensions(obj, x, y, width, height) \
((obj)->class->get_dimensions((obj), (x), (y), (width), (height)))
#define object_normalize(obj) \
((obj)->class->normalize(obj))
#define object_resize(obj, per_x, per_y) \
((obj)->class->resize((obj), (per_x), (per_y)))
#define object_update(obj, data) \
((obj)->class->update((obj), (data)))
#define object_update_info_widget(obj, data) \
((obj)->class->update_info_widget((obj), (data)))
#define object_fill_info_tab(obj, data) \
((obj)->class->fill_info_tab((obj), (data)))
#define object_get_icon_name(obj) \
((obj)->class->get_icon_name())
typedef struct {
Object_t *obj;
gboolean (*finish)(Object_t *obj, gint x, gint y);
gboolean (*cancel)(GdkEventButton *event, Object_t *obj);
Object_t* (*create_object)(gint x, gint y);
void (*set_xy)(Object_t *obj, guint state, gint x, gint y);
} ObjectFactory_t;
gboolean object_on_button_press(GtkWidget *widget, GdkEventButton *event,
gpointer data);
typedef struct {
GList *list;
} ObjectListCallback_t;
struct ObjectList_t {
GList *list;
gboolean changed;
ObjectListCallback_t changed_cb;
ObjectListCallback_t update_cb;
ObjectListCallback_t add_cb;
ObjectListCallback_t remove_cb;
ObjectListCallback_t select_cb;
ObjectListCallback_t move_cb;
ObjectListCallback_t geometry_cb;
};
ObjectList_t *make_object_list (void);
void object_list_destruct(ObjectList_t *list);
ObjectList_t *object_list_copy(ObjectList_t *des, ObjectList_t *src);
ObjectList_t *object_list_append_list(ObjectList_t *des, ObjectList_t *src);
void object_list_append(ObjectList_t *list, Object_t *object);
void object_list_prepend(ObjectList_t *list, Object_t *object);
void object_list_insert(ObjectList_t *list, gint position, Object_t *object);
void object_list_remove(ObjectList_t *list, Object_t *object);
void object_list_remove_link(ObjectList_t *list, GList *link);
void object_list_update(ObjectList_t *list, Object_t *object);
void object_list_draw(ObjectList_t *list, cairo_t *cr);
void object_list_draw_selected(ObjectList_t *list, cairo_t *cr);
Object_t *object_list_find(ObjectList_t *list, gint x, gint y);
Object_t *object_list_near_sash(ObjectList_t *list, gint x, gint y,
MoveSashFunc_t *sash_func);
gint object_list_cut(ObjectList_t *list);
void object_list_copy_to_paste_buffer(ObjectList_t *list);
void object_list_paste(ObjectList_t *list);
void object_list_remove_all(ObjectList_t *list);
void object_list_delete_selected(ObjectList_t *list);
void object_list_edit_selected(ObjectList_t *list);
gint object_list_select_all(ObjectList_t *list);
void object_list_select_next(ObjectList_t *list);
void object_list_select_prev(ObjectList_t *list);
gint object_list_select_region(ObjectList_t *list, gint x, gint y, gint width,
gint height);
gint object_list_deselect_all(ObjectList_t *list, Object_t *exception);
gint object_list_nr_selected(ObjectList_t *list);
void object_list_resize(ObjectList_t *list, gint percentage_x,
gint percentage_y);
void object_list_move_selected(ObjectList_t *list, gint dx, gint dy);
void object_list_move_up(ObjectList_t *list, Object_t *obj);
void object_list_move_down(ObjectList_t *list, Object_t *obj);
void object_list_move_selected_up(ObjectList_t *list);
void object_list_move_selected_down(ObjectList_t *list);
void object_list_move_to_front(ObjectList_t *list);
void object_list_send_to_back(ObjectList_t *list);
void object_list_move_sash_selected(ObjectList_t *list, gint dx, gint dy);
void object_list_write_csim(ObjectList_t *list, gpointer param,
OutputFunc_t output);
void object_list_write_cern(ObjectList_t *list, gpointer param,
OutputFunc_t output);
void object_list_write_ncsa(ObjectList_t *list, gpointer param,
OutputFunc_t output);
typedef void (*ObjectListCallbackFunc_t)(Object_t*, gpointer);
gpointer object_list_add_changed_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func,
gpointer data);
gpointer object_list_add_update_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func,
gpointer data);
gpointer object_list_add_add_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func, gpointer data);
gpointer object_list_add_remove_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func,
gpointer data);
gpointer object_list_add_select_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func,
gpointer data);
gpointer object_list_add_move_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func, gpointer data);
gpointer object_list_add_geometry_cb(ObjectList_t *list,
ObjectListCallbackFunc_t func,
gpointer data);
void object_list_remove_add_cb(ObjectList_t *list, gpointer id);
void object_list_remove_select_cb(ObjectList_t *list, gpointer id);
void object_list_remove_remove_cb(ObjectList_t *list, gpointer id);
void object_list_remove_move_cb(ObjectList_t *list, gpointer id);
void object_list_remove_geometry_cb(ObjectList_t *list, gpointer id);
#define object_list_clear_changed(list) ((list)->changed = FALSE)
#define object_list_set_changed(list, ischanged) \
((list)->changed = (ischanged))
#define object_list_get_changed(list) ((list)->changed)
void clear_paste_buffer(void);
gpointer paste_buffer_add_add_cb(ObjectListCallbackFunc_t func, gpointer data);
gpointer paste_buffer_add_remove_cb(ObjectListCallbackFunc_t func,
gpointer data);
ObjectList_t *get_paste_buffer(void);
void do_object_locked_dialog(void);
#endif /* _IMAP_OBJECT_H */

View File

@ -0,0 +1,69 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <gtk/gtk.h>
#include "imap_commands.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_object_popup.h"
#include "libpika/stdplugins-intl.h"
void
object_handle_popup (ObjectPopup_t *popup,
Object_t *obj,
GdkEventButton *event,
PikaImap *imap)
{
/* int position = object_get_position_in_list(obj) + 1; */
#ifdef _TEMP_
gtk_widget_set_sensitive(popup->up, (position > 1) ? TRUE : FALSE);
gtk_widget_set_sensitive(popup->down,
(position < g_list_length(obj->list->list))
? TRUE : FALSE);
#endif
gtk_menu_attach_to_widget (GTK_MENU (popup->menu), GTK_WIDGET (imap->dlg), NULL);
gtk_menu_popup_at_pointer (GTK_MENU (popup->menu), (GdkEvent *) event);
}
void
object_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data)
{
static ObjectPopup_t *popup;
GMenuModel *model;
PikaImap *imap = PIKA_IMAP (data);
if (! popup)
{
popup = g_new (ObjectPopup_t, 1);
model = G_MENU_MODEL (gtk_builder_get_object
(imap->builder, "imap-object-popup"));
popup->menu = gtk_menu_new_from_model (model);
}
object_handle_popup (popup, obj, event, imap);
}

View File

@ -0,0 +1,43 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_OBJECT_POPUP_H
#define _IMAP_OBJECT_POPUP_H
#include "imap_object.h"
typedef struct {
GtkWidget *menu;
GtkWidget *up;
GtkWidget *down;
Object_t *obj;
} ObjectPopup_t;
void object_handle_popup (ObjectPopup_t *popup,
Object_t *obj,
GdkEventButton *event,
PikaImap *imap);
void object_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data);
#endif /* _IMAP_OBJECT_POPUP_H */

View File

@ -0,0 +1,870 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include "libpika/pika.h"
#include "libpika/pikaui.h"
#include "imap_commands.h"
#include "imap_icons.h"
#include "imap_main.h"
#include "imap_misc.h"
#include "imap_menu.h"
#include "imap_object_popup.h"
#include "imap_polygon.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
#define MAX_POLYGON_POINTS 99
static gboolean polygon_is_valid(Object_t *obj);
static void polygon_destruct(Object_t *obj);
static Object_t *polygon_clone(Object_t *obj);
static void polygon_assign(Object_t *obj, Object_t *des);
static void polygon_draw(Object_t* obj, cairo_t *cr);
static void polygon_draw_sashes(Object_t* obj, cairo_t *cr);
static MoveSashFunc_t polygon_near_sash(Object_t *obj, gint x, gint y);
static gboolean polygon_point_is_on(Object_t *obj, gint x, gint y);
static void polygon_get_dimensions(Object_t *obj, gint *x, gint *y,
gint *width, gint *height);
static void polygon_resize(Object_t *obj, gint percentage_x,
gint percentage_y);
static void polygon_move(Object_t *obj, gint dx, gint dy);
static gpointer polygon_create_info_widget(GtkWidget *frame);
static void polygon_update_info_widget(Object_t *obj, gpointer data);
static void polygon_fill_info_tab(Object_t *obj, gpointer data);
static void polygon_set_initial_focus(Object_t *obj, gpointer data);
static void polygon_update(Object_t* obj, gpointer data);
static void polygon_write_csim(Object_t* obj, gpointer param,
OutputFunc_t output);
static void polygon_write_cern(Object_t* obj, gpointer param,
OutputFunc_t output);
static void polygon_write_ncsa(Object_t* obj, gpointer param,
OutputFunc_t output);
static void polygon_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data);
static const gchar* polygon_get_icon_name(void);
static ObjectClass_t polygon_class = {
N_("_Polygon"),
NULL, /* info_dialog */
polygon_is_valid,
polygon_destruct,
polygon_clone,
polygon_assign,
NULL, /* polygon_normalize */
polygon_draw,
polygon_draw_sashes,
polygon_near_sash,
polygon_point_is_on,
polygon_get_dimensions,
polygon_resize,
polygon_move,
polygon_create_info_widget,
polygon_update_info_widget,
polygon_fill_info_tab,
polygon_set_initial_focus,
polygon_update,
polygon_write_csim,
polygon_write_cern,
polygon_write_ncsa,
polygon_do_popup,
polygon_get_icon_name
};
Object_t*
create_polygon(GList *points)
{
Polygon_t *polygon = g_new(Polygon_t, 1);
polygon->points = points;
return object_init(&polygon->obj, &polygon_class);
}
static void
polygon_free_list (Polygon_t *polygon)
{
g_list_free_full (polygon->points, (GDestroyNotify) g_free);
polygon->points = NULL;
}
static void
polygon_destruct(Object_t *obj)
{
Polygon_t *polygon = ObjectToPolygon(obj);
polygon_free_list(polygon);
}
static gboolean
polygon_is_valid(Object_t *obj)
{
return g_list_length(ObjectToPolygon(obj)->points) > 2;
}
static Object_t*
polygon_clone(Object_t *obj)
{
Polygon_t *polygon = ObjectToPolygon(obj);
Polygon_t *clone = g_new(Polygon_t, 1);
GList *p;
clone->points = NULL;
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
polygon_append_point(clone, point->x, point->y);
}
return &clone->obj;
}
static void
polygon_assign(Object_t *obj, Object_t *des)
{
Polygon_t *src_polygon = ObjectToPolygon(obj);
Polygon_t *des_polygon = ObjectToPolygon(des);
GList *p;
polygon_free_list(des_polygon);
for (p = src_polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
polygon_append_point(des_polygon, point->x, point->y);
}
}
static void
polygon_draw(Object_t *obj, cairo_t *cr)
{
Polygon_t *polygon = ObjectToPolygon(obj);
draw_polygon(cr, polygon->points);
}
static void
polygon_draw_sashes(Object_t *obj, cairo_t *cr)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
draw_sash(cr, point->x, point->y);
}
}
static GdkPoint *_sash_point;
static gint _sash_index;
static void
move_sash(Object_t *obj, gint dx, gint dy)
{
_sash_point->x += dx;
_sash_point->y += dy;
}
static MoveSashFunc_t
polygon_near_sash(Object_t *obj, gint x, gint y)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
_sash_index = 0;
for (p = polygon->points; p; p = p->next, _sash_index++) {
GdkPoint *point = (GdkPoint*) p->data;
if (near_sash(point->x, point->y, x, y)) {
_sash_point = point;
return move_sash;
}
}
return NULL;
}
static gboolean
right_intersect(GdkPoint *p1, GdkPoint *p2, gint x, gint y)
{
gint dx = p2->x - p1->x;
gint dy = p2->y - p1->y;
if ((dy > 0 && y > p1->y && y < p2->y) ||
(dy < 0 && y > p2->y && y < p1->y)) {
gint sx = p1->x + (y - p1->y) * dx / dy;
return sx > x;
}
return FALSE;
}
static gboolean
polygon_point_is_on(Object_t *obj, gint x, gint y)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
int count = 0;
GdkPoint *first, *prev;
p = polygon->points;
first = prev = (GdkPoint*) p->data;
p = p->next;
for (; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
if (right_intersect(prev, point, x, y))
count++;
prev = point;
}
if (right_intersect(prev, first, x, y))
count++;
return count % 2;
}
static void
polygon_get_dimensions(Object_t *obj, gint *x, gint *y,
gint *width, gint *height)
{
Polygon_t *polygon = ObjectToPolygon(obj);
gint min_x = G_MAXINT, min_y = G_MAXINT;
gint max_x = G_MININT, max_y = G_MININT;
GList *p;
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
if (point->x < min_x)
min_x = point->x;
if (point->x > max_x)
max_x = point->x;
if (point->y < min_y)
min_y = point->y;
if (point->y > max_y)
max_y = point->y;
}
*x = min_x;
*y = min_y;
*width = max_x - min_x;
*height = max_y - min_y;
}
static void
polygon_resize(Object_t *obj, gint percentage_x, gint percentage_y)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
point->x = point->x * percentage_x / 100;
point->y = point->y * percentage_y / 100;
}
}
static void
polygon_move(Object_t *obj, gint dx, gint dy)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
point->x += dx;
point->y += dy;
}
}
typedef struct {
Object_t *obj;
GtkListStore *store;
GtkTreeSelection *selection;
GtkWidget *x;
GtkWidget *y;
GtkWidget *update;
GtkWidget *insert;
GtkWidget *append;
GtkWidget *remove;
gint selected_row;
guint timeout;
} PolygonProperties_t;
static void
select_row_cb(GtkTreeSelection *selection, PolygonProperties_t *data)
{
GtkTreeIter iter;
GtkTreeModel *model;
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
GdkPoint *point;
gtk_tree_model_get (model, &iter, 0, &point, -1);
_sash_point = point;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->x), point->x);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->y), point->y);
}
}
static void
update_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(data->store);
if (gtk_tree_selection_get_selected (data->selection, &model, &iter)) {
GdkPoint *point;
gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->x));
gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->y));
gtk_tree_model_get (model, &iter, 0, &point, -1);
point->x = x;
point->y = y;
gtk_list_store_set (data->store, &iter, 0, point, -1);
}
}
static void
set_buttons_sensitivity(PolygonProperties_t *data)
{
gint rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(data->store),
NULL);
gtk_widget_set_sensitive(data->insert, rows != MAX_POLYGON_POINTS);
gtk_widget_set_sensitive(data->append, rows != MAX_POLYGON_POINTS);
gtk_widget_set_sensitive(data->remove, rows > 2);
}
static void
insert_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(data->store);
if (gtk_tree_selection_get_selected (data->selection, &model, &iter)) {
Polygon_t *polygon = ObjectToPolygon(data->obj);
GdkPoint *point;
GList *here;
gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->x));
gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->y));
gtk_tree_model_get (model, &iter, 0, &point, -1);
here = g_list_find(polygon->points, point);
polygon->points = g_list_insert_before(polygon->points, here,
new_point(x, y));
polygon_fill_info_tab(data->obj, data);
}
}
static void
append_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{
gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->x));
gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->y));
polygon_append_point(ObjectToPolygon(data->obj), x, y);
polygon_fill_info_tab(data->obj, data);
}
static void
remove_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(data->store);
if (gtk_tree_selection_get_selected (data->selection, &model, &iter)) {
Polygon_t *polygon = ObjectToPolygon(data->obj);
GdkPoint *point;
gtk_tree_model_get (model, &iter, 0, &point, -1);
polygon->points = g_list_remove(polygon->points, point);
g_free(point);
polygon_fill_info_tab(data->obj, data);
}
}
static void
x_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((PolygonProperties_t*) data)->obj;
gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
_sash_point->x = x;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
y_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((PolygonProperties_t*) data)->obj;
gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
_sash_point->y = y;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
render_x(GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
GdkPoint *point;
gchar scratch[16];
gtk_tree_model_get(tree_model, iter, 0, &point, -1);
sprintf(scratch, "%d", point->x);
g_object_set(cell, "text", scratch, "xalign", 1.0, NULL);
}
static void
render_y(GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
GdkPoint *point;
gchar scratch[16];
gtk_tree_model_get(tree_model, iter, 0, &point, -1);
sprintf(scratch, "%d", point->y);
g_object_set(cell, "text", scratch, "xalign", 1.0, NULL);
}
static gpointer
polygon_create_info_widget(GtkWidget *frame)
{
PolygonProperties_t *props = g_new(PolygonProperties_t, 1);
GtkWidget *hbox, *swin, *grid, *label;
GtkWidget *view;
gint max_width = get_image_width();
gint max_height = get_image_height();
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
swin = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(swin),
GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(hbox), swin, FALSE, FALSE, FALSE);
gtk_widget_show(swin);
props->store = gtk_list_store_new (1, G_TYPE_POINTER);
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (props->store));
g_object_unref (props->store);
gtk_widget_show (view);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("x (pixels)"),
renderer,
NULL);
gtk_tree_view_column_set_cell_data_func(column, renderer,
render_x, props, NULL);
gtk_tree_view_column_set_alignment(column, 0.5);
gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("y (pixels)"),
renderer,
NULL);
gtk_tree_view_column_set_cell_data_func(column, renderer,
render_y, props, NULL);
gtk_tree_view_column_set_alignment(column, 0.5);
gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
gtk_container_add (GTK_CONTAINER (swin), view);
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_box_pack_start (GTK_BOX(hbox), grid, FALSE, FALSE, FALSE);
gtk_widget_show (grid);
label = create_label_in_grid (grid, 0, 0, "_x:");
props->x = create_spin_button_in_grid (grid, label, 0, 1, 1, 0,
max_width - 1);
g_signal_connect(props->x, "changed",
G_CALLBACK(x_changed_cb), (gpointer) props);
gtk_widget_set_size_request(props->x, 64, -1);
create_label_in_grid (grid, 0, 2, _("pixels"));
label = create_label_in_grid (grid, 1, 0, "_y:");
props->y = create_spin_button_in_grid (grid, label, 1, 1, 1, 0,
max_height - 1);
g_signal_connect(props->y, "changed",
G_CALLBACK(y_changed_cb), (gpointer) props);
gtk_widget_set_size_request(props->y, 64, -1);
create_label_in_grid (grid, 1, 2, _("pixels"));
props->update = gtk_button_new_with_mnemonic(_("_Update"));
g_signal_connect(props->update, "clicked",
G_CALLBACK(update_button_clicked), props);
gtk_grid_attach (GTK_GRID (grid), props->update, 1, 2, 1, 1);
gtk_widget_show(props->update);
props->insert = gtk_button_new_with_mnemonic(_("_Insert"));
g_signal_connect(props->insert, "clicked",
G_CALLBACK(insert_button_clicked), props);
gtk_grid_attach (GTK_GRID (grid), props->insert, 1, 3, 1, 1);
gtk_widget_show(props->insert);
props->append = gtk_button_new_with_mnemonic(_("A_ppend"));
g_signal_connect(props->append, "clicked",
G_CALLBACK(append_button_clicked), props);
gtk_grid_attach (GTK_GRID (grid), props->append, 1, 4, 1, 1);
gtk_widget_show(props->append);
props->remove = gtk_button_new_with_mnemonic(_("_Remove"));
g_signal_connect(props->remove, "clicked",
G_CALLBACK(remove_button_clicked), props);
gtk_grid_attach (GTK_GRID (grid), props->remove, 1, 5, 1, 1);
gtk_widget_show(props->remove);
props->timeout = 0;
props->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (view));
gtk_tree_selection_set_mode(props->selection, GTK_SELECTION_SINGLE);
g_signal_connect (props->selection, "changed",
G_CALLBACK (select_row_cb), props);
return props;
}
static gboolean
update_timeout(gpointer data)
{
PolygonProperties_t *props = (PolygonProperties_t*) data;
polygon_fill_info_tab(props->obj, data);
return FALSE;
}
static void
polygon_update_info_widget(Object_t *obj, gpointer data)
{
PolygonProperties_t *props = (PolygonProperties_t*) data;
GtkTreeIter iter;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->x), _sash_point->x);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), _sash_point->y);
if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(props->store), &iter,
NULL, _sash_index)) {
gtk_tree_selection_select_iter(props->selection, &iter);
}
if (props->timeout)
g_source_remove(props->timeout);
props->timeout = g_timeout_add(1000, update_timeout, data);
}
static void
polygon_fill_info_tab(Object_t *obj, gpointer data)
{
Polygon_t *polygon = ObjectToPolygon(obj);
PolygonProperties_t *props = (PolygonProperties_t*) data;
GtkTreeIter iter;
GList *p;
props->obj = obj;
gtk_list_store_clear(props->store);
for (p = polygon->points; p; p = p->next) {
gtk_list_store_append(props->store, &iter);
gtk_list_store_set(props->store, &iter, 0, p->data, -1);
}
if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(props->store), &iter,
NULL, _sash_index)) {
gtk_tree_selection_select_iter(props->selection, &iter);
}
set_buttons_sensitivity(props);
}
static void
polygon_set_initial_focus(Object_t *obj, gpointer data)
{
PolygonProperties_t *props = (PolygonProperties_t*) data;
gtk_widget_grab_focus(props->x);
}
static void
polygon_update(Object_t* obj, gpointer data)
{
/* Nothing to be done! */
}
static void
polygon_write_csim(Object_t *obj, gpointer param, OutputFunc_t output)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
output(param, "\"poly\" coords=\"");
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
output(param, "%d,%d", point->x, point->y);
output(param, "%c", (p->next) ? ',' : '"');
}
}
static void
polygon_write_cern(Object_t *obj, gpointer param, OutputFunc_t output)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
GdkPoint *first = (GdkPoint*) polygon->points->data;
output(param, "poly ");
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
output(param, "(%d,%d) ", point->x, point->y);
}
output(param, "(%d,%d)", first->x, first->y);
}
static void
polygon_write_ncsa(Object_t *obj, gpointer param, OutputFunc_t output)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p;
GdkPoint *first = (GdkPoint*) polygon->points->data;
output(param, "poly %s", obj->url);
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
output(param, " %d,%d", point->x, point->y);
}
output(param, " %d,%d", first->x, first->y);
}
static Object_t *_current_obj;
static gboolean _insert_edge;
static gint _insert_x;
static gint _insert_y;
void
polygon_insert_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data)
{
Command_t *command = insert_point_command_new (_current_obj, _insert_x,
_insert_y, _insert_edge);
command_execute (command);
}
void
polygon_delete_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data)
{
Command_t *command = delete_point_command_new(_current_obj, _sash_point);
command_execute (command);
}
static gboolean
point_near_edge(GdkPoint *first, GdkPoint *second, gint x, gint y)
{
gint den, nom;
gdouble u;
den = (first->x - x) * (first->x - second->x) +
(first->y - y) * (first->y - second->y);
nom = (second->x - first->x) * (second->x - first->x) +
(second->y - first->y) * (second->y - first->y);
u = (gdouble) den / nom;
if (u >= 0.0 && u <= 1.0) {
gint sx = first->x + (gint) (u * (second->x - first->x)) - x;
gint sy = first->y + (gint) (u * (second->y - first->y)) - y;
return sx * sx + sy * sy <= 25; /* Fix me! */
}
return FALSE;
}
static gint
polygon_near_edge(Object_t *obj, gint x, gint y)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *p = polygon->points;
GdkPoint *first = (GdkPoint*) p->data;
GdkPoint *prev = first;
gint n = 1;
for (p = p->next; p; p = p->next, n++) {
GdkPoint *next = (GdkPoint*) p->data;
if (point_near_edge(prev, next, x, y))
return n;
prev = next;
}
return (point_near_edge(prev, first, x, y)) ? n + 1 : 0;
}
static void
polygon_handle_popup (GdkEventButton *event,
PikaImap *imap,
gboolean near_sash,
gboolean near_edge)
{
GtkWidget *menu;
GMenuModel *model;
GAction *action;
model = G_MENU_MODEL (gtk_builder_get_object (imap->builder, "imap-polygon-popup"));
menu = gtk_menu_new_from_model (model);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "insert-point");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), near_edge);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "delete-point");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), near_sash);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (imap->dlg), NULL);
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
}
static void
polygon_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data)
{
gint x = get_real_coord ((gint) event->x);
gint y = get_real_coord ((gint) event->y);
PikaImap *imap = PIKA_IMAP (data);
_current_obj = obj;
if (polygon_near_sash (obj, x, y))
{
polygon_handle_popup (event, imap, TRUE, FALSE);
}
else
{
_insert_edge = polygon_near_edge (obj, x, y);
if (_insert_edge)
{
_insert_x = x;
_insert_y = y;
polygon_handle_popup (event,imap, FALSE, TRUE);
}
else
{
object_do_popup (obj, event, imap);
}
}
}
static const gchar*
polygon_get_icon_name(void)
{
return IMAP_POLYGON;
}
static GList *_prev_link;
static gboolean
polygon_factory_finish(Object_t *obj, gint x, gint y)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GdkPoint *prev_point = (GdkPoint*) _prev_link->data;
if (x == prev_point->x && y == prev_point->y) {
polygon_remove_last_point(polygon);
return TRUE;
} else {
polygon_append_point(polygon, x, y);
_prev_link = _prev_link->next;
}
return FALSE;
}
static gboolean
polygon_factory_cancel(GdkEventButton *event, Object_t *obj)
{
if (event->state & GDK_SHIFT_MASK) {
return TRUE;
} else {
Polygon_t *polygon = ObjectToPolygon(obj);
GList *link = _prev_link;
_prev_link = _prev_link->prev;
g_free((GdkPoint*) link->data);
polygon->points = g_list_remove_link(polygon->points, link);
}
return _prev_link == NULL;
}
static Object_t*
polygon_factory_create_object(gint x, gint y)
{
GList *points;
points = _prev_link = g_list_append(NULL, new_point(x, y));
points = g_list_append(points, new_point(x, y));
return create_polygon(points);
}
static void
polygon_factory_set_xy(Object_t *obj, guint state, gint x, gint y)
{
Polygon_t *polygon = ObjectToPolygon(obj);
GList *last = g_list_last(polygon->points);
GdkPoint *point = (GdkPoint*) last->data;
GdkPoint *prev = (GdkPoint*) last->prev->data;
point->x = x;
point->y = y;
main_set_dimension(x - prev->x, y - prev->y);
}
static ObjectFactory_t polygon_factory = {
NULL, /* Object pointer */
polygon_factory_finish,
polygon_factory_cancel,
polygon_factory_create_object,
polygon_factory_set_xy
};
ObjectFactory_t*
get_polygon_factory(guint state)
{
return &polygon_factory;
}
void
polygon_remove_last_point(Polygon_t *polygon)
{
GList *last = g_list_last(polygon->points);
g_free((GdkPoint*) last->data);
polygon->points = g_list_remove_link(polygon->points, last);
}
GdkPoint*
new_point(gint x, gint y)
{
GdkPoint *point = g_new(GdkPoint, 1);
point->x = x;
point->y = y;
return point;
}
void
polygon_append_point(Polygon_t *polygon, gint x, gint y)
{
polygon->points = g_list_append(polygon->points, new_point(x, y));
}

View File

@ -0,0 +1,53 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_POLYGON_H
#define _IMAP_POLYGON_H
#include "imap_object.h"
typedef struct
{
Object_t obj;
GList *points;
} Polygon_t;
#define ObjectToPolygon(obj) ((Polygon_t*) (obj))
Object_t *create_polygon (GList *points);
ObjectFactory_t *get_polygon_factory (guint state);
void polygon_insert_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void polygon_delete_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void polygon_remove_last_point (Polygon_t *polygon);
void polygon_append_point (Polygon_t *polygon,
gint x,
gint y);
GdkPoint *new_point (gint x,
gint y);
#endif /* _IMAP_POLYGON_H */

View File

@ -0,0 +1,550 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include "libpika/pika.h"
#include "libpika/pikaui.h"
#include "imap_command.h"
#include "imap_file.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_misc.h"
#include "imap_mru.h"
#include "imap_preferences.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *notebook;
GtkWidget *ncsa;
GtkWidget *cern;
GtkWidget *csim;
GtkWidget *prompt_for_area_info;
GtkWidget *require_default_url;
GtkWidget *show_area_handle;
GtkWidget *keep_circles_round;
GtkWidget *show_url_tip;
GtkWidget *use_doublesized;
GtkWidget *undo_levels;
GtkWidget *mru_size;
GtkWidget *normal_fg;
GtkWidget *normal_bg;
GtkWidget *selected_fg;
GtkWidget *selected_bg;
GtkWidget *interactive_fg;
GtkWidget *interactive_bg;
GtkWidget *threshold;
GtkWidget *auto_convert;
PreferencesData_t *old_data;
} PreferencesDialog_t;
static void get_button_colors (PreferencesDialog_t *dialog,
ColorSelData_t *colors);
static gint
parse_map_type(void)
{
char *token = strtok(NULL, " )");
if (!strcmp(token, "ncsa"))
return NCSA;
else if (!strcmp(token, "cern"))
return CERN;
return CSIM;
}
static gint
parse_yes_no(void)
{
char *token = strtok(NULL, " )");
return (gint) strcmp(token, "no");
}
static gint
parse_int(void)
{
char *token = strtok(NULL, " )");
return (gint) atoi(token);
}
static void
parse_color(GdkRGBA *color)
{
color->red = (gdouble) parse_int() / 255.0;
color->green = (gdouble) parse_int() / 255.0;
color->blue = (gdouble) parse_int() / 255.0;
color->alpha = 1.0;
}
static void
parse_mru_entry(void)
{
char *filename = strtok(NULL, " )");
mru_add(get_mru(), filename);
}
static void
parse_line(PreferencesData_t *data, char *line)
{
char *token;
ColorSelData_t *colors = &data->colors;
line++; /* Skip '(' */
token = strtok(line, " ");
if (!strcmp(token, "default-map-type")) {
data->default_map_type = parse_map_type();
}else if (!strcmp(token, "prompt-for-area-info")) {
data->prompt_for_area_info = parse_yes_no();
} else if (!strcmp(token, "require-default-url")) {
data->require_default_url = parse_yes_no();
} else if (!strcmp(token, "show-area-handle")) {
data->show_area_handle = parse_yes_no();
} else if (!strcmp(token, "keep-circles-round")) {
data->keep_circles_round = parse_yes_no();
} else if (!strcmp(token, "show-url-tip")) {
data->show_url_tip = parse_yes_no();
} else if (!strcmp(token, "use-doublesized")) {
data->use_doublesized = parse_yes_no();
} else if (!strcmp(token, "mru-size")) {
data->mru_size = parse_int();
if (data->mru_size < 1)
data->mru_size = 1;
} else if (!strcmp(token, "undo-levels")) {
data->undo_levels = parse_int();
if (data->undo_levels < 1)
data->undo_levels = 1;
} else if (!strcmp(token, "normal-fg-color")) {
parse_color(&colors->normal_fg);
} else if (!strcmp(token, "normal-bg-color")) {
parse_color(&colors->normal_bg);
} else if (!strcmp(token, "selected-fg-color")) {
parse_color(&colors->selected_fg);
} else if (!strcmp(token, "selected-bg-color")) {
parse_color(&colors->selected_bg);
} else if (!strcmp(token, "interactive-fg-color")) {
parse_color(&colors->interactive_fg);
} else if (!strcmp(token, "interactive-bg-color")) {
parse_color(&colors->interactive_bg);
} else if (!strcmp(token, "mru-entry")) {
parse_mru_entry();
} else {
/* Unrecognized, just ignore rest of line */
}
}
gboolean
preferences_load(PreferencesData_t *data)
{
FILE *in;
char buf[256];
GFile *file;
file = pika_directory_file ("imagemaprc", NULL);
in = g_fopen (g_file_peek_path (file), "rb");
g_object_unref (file);
if (in)
{
while (fgets (buf, sizeof (buf), in))
{
if (*buf != '\n' && *buf != '#')
{
parse_line (data, buf);
}
}
fclose (in);
return TRUE;
}
return FALSE;
}
void
preferences_save(PreferencesData_t *data)
{
FILE *out;
GFile *file;
ColorSelData_t *colors = &data->colors;
file = pika_directory_file ("imagemaprc", NULL);
out = g_fopen(g_file_peek_path (file), "wb");
if (out)
{
fprintf(out, "# Image map plug-in resource file\n\n");
if (data->default_map_type == NCSA)
fprintf(out, "(default-map-type ncsa)\n");
else if (data->default_map_type == CERN)
fprintf(out, "(default-map-type cern)\n");
else
fprintf(out, "(default-map-type csim)\n");
fprintf(out, "(prompt-for-area-info %s)\n",
(data->prompt_for_area_info) ? "yes" : "no");
fprintf(out, "(require-default-url %s)\n",
(data->require_default_url) ? "yes" : "no");
fprintf(out, "(show-area-handle %s)\n",
(data->show_area_handle) ? "yes" : "no");
fprintf(out, "(keep-circles-round %s)\n",
(data->keep_circles_round) ? "yes" : "no");
fprintf(out, "(show-url-tip %s)\n",
(data->show_url_tip) ? "yes" : "no");
fprintf(out, "(use-doublesized %s)\n",
(data->use_doublesized) ? "yes" : "no");
fprintf(out, "(undo-levels %d)\n", data->undo_levels);
fprintf(out, "(mru-size %d)\n", data->mru_size);
fprintf(out, "(normal-fg-color %d %d %d)\n",
ROUND (colors->normal_fg.red * 255.0),
ROUND (colors->normal_fg.green * 255.0),
ROUND (colors->normal_fg.blue * 255.0));
fprintf(out, "(normal-bg-color %d %d %d)\n",
ROUND (colors->normal_bg.red * 255.0),
ROUND (colors->normal_bg.green * 255.0),
ROUND (colors->normal_bg.blue * 255.0));
fprintf(out, "(selected-fg-color %d %d %d)\n",
ROUND (colors->selected_fg.red * 255.0),
ROUND (colors->selected_fg.green * 255.0),
ROUND (colors->selected_fg.blue * 255.0));
fprintf(out, "(selected-bg-color %d %d %d)\n",
ROUND (colors->selected_bg.red * 255.0),
ROUND (colors->selected_bg.green * 255.0),
ROUND (colors->selected_bg.blue * 255.0));
fprintf(out, "(interactive-fg-color %d %d %d)\n",
ROUND (colors->interactive_fg.red * 255.0),
ROUND (colors->interactive_fg.green * 255.0),
ROUND (colors->interactive_fg.blue * 255.0));
fprintf(out, "(interactive-bg-color %d %d %d)\n",
ROUND (colors->interactive_bg.red * 255.0),
ROUND (colors->interactive_bg.green * 255.0),
ROUND (colors->interactive_bg.blue * 255.0));
mru_write(get_mru(), out);
fclose(out);
}
else
{
do_file_error_dialog (_("Couldn't save resource file:"),
pika_file_get_utf8_name (file));
}
g_object_unref (file);
}
static void
preferences_ok_cb (gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
PreferencesData_t *old_data = param->old_data;
ColorSelData_t *colors = &old_data->colors;
MRU_t *mru = get_mru();
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->cern)))
old_data->default_map_type = CERN;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->ncsa)))
old_data->default_map_type = NCSA;
else
old_data->default_map_type = CSIM;
old_data->prompt_for_area_info = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->prompt_for_area_info));
old_data->require_default_url = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->require_default_url));
old_data->show_area_handle = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->show_area_handle));
old_data->keep_circles_round = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->keep_circles_round));
old_data->show_url_tip = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->show_url_tip));
old_data->use_doublesized = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(param->use_doublesized));
old_data->mru_size =
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(param->mru_size));
old_data->undo_levels =
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(param->undo_levels));
mru_set_size (mru, old_data->mru_size);
command_list_set_undo_level (old_data->undo_levels);
get_button_colors (param, colors);
set_sash_size(old_data->use_doublesized);
preview_redraw();
}
static void
get_button_color (GtkWidget *button,
GdkRGBA *color)
{
PikaRGB rgb;
pika_color_button_get_color (PIKA_COLOR_BUTTON (button), &rgb);
color->red = rgb.r;
color->green = rgb.g;
color->blue = rgb.b;
color->alpha = 1.0;
}
static void
get_button_colors(PreferencesDialog_t *dialog, ColorSelData_t *colors)
{
get_button_color (dialog->normal_fg, &colors->normal_fg);
get_button_color (dialog->normal_bg, &colors->normal_bg);
get_button_color (dialog->selected_fg, &colors->selected_fg);
get_button_color (dialog->selected_bg, &colors->selected_bg);
get_button_color (dialog->interactive_fg, &colors->interactive_fg);
get_button_color (dialog->interactive_bg, &colors->interactive_bg);
}
static void
set_button_color (GtkWidget *button,
GdkRGBA *color)
{
pika_color_button_set_color (PIKA_COLOR_BUTTON (button),
(PikaRGB *) color);
}
static void
set_button_colors(PreferencesDialog_t *dialog,
ColorSelData_t *colors)
{
set_button_color (dialog->normal_fg, &colors->normal_fg);
set_button_color (dialog->normal_bg, &colors->normal_bg);
set_button_color (dialog->selected_fg, &colors->selected_fg);
set_button_color (dialog->selected_bg, &colors->selected_bg);
set_button_color (dialog->interactive_fg, &colors->interactive_fg);
set_button_color (dialog->interactive_bg, &colors->interactive_bg);
}
static GtkWidget*
create_tab (GtkWidget *notebook, const gchar *label)
{
GtkWidget *grid;
GtkWidget *vbox;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
gtk_widget_show (vbox);
grid = gtk_grid_new ();
gtk_box_pack_start (GTK_BOX (vbox), grid, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER(grid), 12);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_widget_show (grid);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new_with_mnemonic (label));
return grid;
}
static void
create_general_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *grid = create_tab (notebook, _("General"));
GtkWidget *frame;
GtkWidget *hbox;
frame = pika_frame_new( _("Default Map Type"));
gtk_widget_show(frame);
gtk_grid_attach (GTK_GRID (grid), frame, 0, 0, 2, 1);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
data->ncsa = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_NCSA");
gtk_box_pack_start(GTK_BOX(hbox), data->ncsa, TRUE, TRUE, 10);
gtk_widget_show(data->ncsa);
data->cern = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(data->ncsa), "C_ERN");
gtk_box_pack_start(GTK_BOX(hbox), data->cern, TRUE, TRUE, 10);
gtk_widget_show(data->cern);
data->csim = gtk_radio_button_new_with_mnemonic_from_widget(
GTK_RADIO_BUTTON(data->cern), "C_SIM");
gtk_box_pack_start(GTK_BOX(hbox), data->csim, TRUE, TRUE, 10);
gtk_widget_show(data->csim);
data->prompt_for_area_info =
create_check_button_in_grid (grid, 1, 0, _("_Prompt for area info"));
data->require_default_url =
create_check_button_in_grid (grid, 2, 0, _("_Require default URL"));
data->show_area_handle =
create_check_button_in_grid (grid, 3, 0, _("Show area _handles"));
data->keep_circles_round =
create_check_button_in_grid (grid, 4, 0, _("_Keep NCSA circles true"));
data->show_url_tip =
create_check_button_in_grid (grid, 5, 0, _("Show area URL _tip"));
data->use_doublesized =
create_check_button_in_grid (grid, 6, 0,
_("_Use double-sized grab handles"));
gtk_widget_show(frame);
}
static void
create_menu_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *grid = create_tab (notebook, _("Menu"));
GtkWidget *label;
label = create_label_in_grid (grid, 0, 0,
_("Number of _undo levels (1 - 99):"));
data->undo_levels = create_spin_button_in_grid (grid, label, 0, 1, 1, 1,
99);
label = create_label_in_grid (grid, 1, 0,
_("Number of M_RU entries (1 - 16):"));
data->mru_size = create_spin_button_in_grid (grid, label, 1, 1, 1, 1, 16);
}
static GtkWidget*
create_color_field (PreferencesDialog_t *data, GtkWidget *grid, gint row,
gint col)
{
PikaRGB color = {0.0, 0.0, 0.0, 1.0};
GtkWidget *area = pika_color_button_new (_("Select Color"), 16, 8, &color,
PIKA_COLOR_AREA_FLAT);
pika_color_button_set_update (PIKA_COLOR_BUTTON (area), TRUE);
gtk_grid_attach (GTK_GRID (grid), area, col, row, 1, 1);
gtk_widget_show (area);
return area;
}
static void
create_colors_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *grid = create_tab (notebook, _("Colors"));
create_label_in_grid (grid, 0, 0, _("Normal:"));
data->normal_fg = create_color_field(data, grid, 0, 1);
data->normal_bg = create_color_field(data, grid, 0, 2);
create_label_in_grid (grid, 1, 0, _("Selected:"));
data->selected_fg = create_color_field(data, grid, 1, 1);
data->selected_bg = create_color_field(data, grid, 1, 2);
create_label_in_grid (grid, 2, 0, _("Interaction:"));
data->interactive_fg = create_color_field(data, grid, 2, 1);
data->interactive_bg = create_color_field(data, grid, 2, 2);
}
#ifdef _NOT_READY_YET_
static void
create_contiguous_regions_tab(PreferencesDialog_t *data, GtkWidget *notebook)
{
GtkWidget *grid = create_tab (notebook, _("Co_ntiguous Region"));
GtkWidget *label;
label = create_label_in_grid (grid, 0, 0,
_("_Threshold:"));
data->auto_convert =
create_check_button_in_grid (grid, 1, 0, _("_Automatically convert"));
}
#endif
static PreferencesDialog_t*
create_preferences_dialog(void)
{
PreferencesDialog_t *data = g_new(PreferencesDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *notebook;
data->dialog = dialog = make_default_dialog( _("General Preferences"));
default_dialog_set_ok_cb(dialog, preferences_ok_cb, (gpointer) data);
data->notebook = notebook = gtk_notebook_new();
gtk_box_pack_start (GTK_BOX (data->dialog->vbox), notebook, TRUE, TRUE, 0);
create_general_tab(data, notebook);
create_menu_tab(data, notebook);
create_colors_tab(data, notebook);
#ifdef _NOT_READY_YET_
create_contiguous_regions_tab(data, notebook);
#endif
gtk_widget_show(notebook);
return data;
}
void
do_preferences_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static PreferencesDialog_t *dialog;
PreferencesData_t *old_data;
GtkWidget *map_type;
if (!dialog) {
dialog = create_preferences_dialog();
}
gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog->notebook), 0);
dialog->old_data = old_data = get_preferences();
if (old_data->default_map_type == CERN)
map_type = dialog->cern;
else if (old_data->default_map_type == NCSA)
map_type = dialog->ncsa;
else
map_type = dialog->csim;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(map_type), TRUE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(dialog->prompt_for_area_info),
old_data->prompt_for_area_info);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->require_default_url),
old_data->require_default_url);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->show_area_handle),
old_data->show_area_handle);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->keep_circles_round),
old_data->keep_circles_round);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->show_url_tip),
old_data->show_url_tip);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->use_doublesized),
old_data->use_doublesized);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->undo_levels),
old_data->undo_levels);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->mru_size),
old_data->mru_size);
set_button_colors(dialog, &old_data->colors);
default_dialog_show(dialog->dialog);
}

View File

@ -0,0 +1,58 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_PREFERENCES_H
#define _IMAP_PREFERENCES_H
#include "imap_default_dialog.h"
typedef struct {
GdkRGBA normal_fg;
GdkRGBA normal_bg;
GdkRGBA selected_fg;
GdkRGBA selected_bg;
GdkRGBA interactive_bg;
GdkRGBA interactive_fg;
} ColorSelData_t;
typedef struct {
gint default_map_type;
gboolean prompt_for_area_info;
gboolean require_default_url;
gboolean show_area_handle;
gboolean keep_circles_round;
gboolean show_url_tip;
gboolean use_doublesized;
gboolean auto_convert;
gdouble threshold;
gint undo_levels;
gint mru_size;
ColorSelData_t colors;
} PreferencesData_t;
void do_preferences_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
gboolean preferences_load (PreferencesData_t *data);
void preferences_save (PreferencesData_t *data);
#endif /* _IMAP_PREFERENCES_H */

View File

@ -0,0 +1,392 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "imap_commands.h"
#include "imap_grid.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_preview.h"
#define PREVIEW_MASK (GDK_EXPOSURE_MASK | \
GDK_POINTER_MOTION_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_BUTTON_MOTION_MASK | \
GDK_KEY_PRESS_MASK | \
GDK_KEY_RELEASE_MASK | \
GDK_ENTER_NOTIFY_MASK | \
GDK_LEAVE_NOTIFY_MASK)
#define PREVIEW_SIZE 400
/*======================================================================
Preview Rendering Util routine
=======================================================================*/
#define CHECKWIDTH 4
#define LIGHTCHECK 192
#define DARKCHECK 128
#ifndef OPAQUE
#define OPAQUE 255
#endif
static Object_t *_tmp_obj;
static Preview_t*
preview_user_data(GtkWidget *preview)
{
return (Preview_t*) g_object_get_data (G_OBJECT (preview), "preview");
}
gint
preview_get_width(GtkWidget *preview)
{
return preview_user_data(preview)->width;
}
gint
preview_get_height(GtkWidget *preview)
{
return preview_user_data(preview)->height;
}
static void
render_background(Preview_t *preview_base)
{
GtkWidget *preview = preview_base->preview;
pika_preview_area_fill (PIKA_PREVIEW_AREA (preview),
0, 0, G_MAXINT, G_MAXINT,
255, 255, 255);
}
static void
render_rgb_image (Preview_t *preview_base,
PikaDrawable *drawable)
{
GeglBuffer *buffer;
guchar *dest_buffer;
gint dwidth, dheight, pwidth, pheight;
GtkWidget *preview = preview_base->preview;
dwidth = pika_drawable_get_width (drawable);
dheight = pika_drawable_get_height (drawable);
pwidth = preview_base->widget_width;
pheight = preview_base->widget_height;
dest_buffer = g_new (guchar, pwidth * pheight * 4);
buffer = pika_drawable_get_buffer (drawable);
gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, pwidth, pheight),
MIN ((gdouble) pwidth / (gdouble) dwidth,
(gdouble) pheight / (gdouble) dheight),
babl_format ("R'G'B'A u8"), dest_buffer,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
g_object_unref (buffer);
pika_preview_area_draw (PIKA_PREVIEW_AREA (preview),
0, 0, pwidth, pheight,
PIKA_RGBA_IMAGE,
dest_buffer,
pwidth * 4);
g_free (dest_buffer);
}
static void
render_preview (Preview_t *preview_base,
PikaDrawable *drawable)
{
render_background (preview_base);
render_rgb_image (preview_base, drawable);
}
static gboolean
arrow_cb (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
{
if (event->button == 1)
do_main_popup_menu (event, data);
return TRUE;
}
static gboolean
preview_draw (GtkWidget *widget,
cairo_t *cr)
{
gint width = preview_get_width (widget);
gint height = preview_get_height (widget);
cairo_set_line_width (cr, 1.);
draw_grid (cr, width, height);
draw_shapes (cr);
if (_tmp_obj)
{
/* this is a bit of a hack */
gdouble dash = 4.;
_tmp_obj->selected |= 4;
cairo_set_source_rgb (cr, 1., 0., 1.);
cairo_set_dash (cr, &dash, 1, dash);
object_draw (_tmp_obj, cr);
}
return FALSE;
}
void
preview_set_tmp_obj (Object_t *obj)
{
_tmp_obj = obj;
}
void
preview_unset_tmp_obj (Object_t *obj)
{
if (_tmp_obj == obj) _tmp_obj = NULL;
}
void
preview_zoom(Preview_t *preview, gint zoom_factor)
{
preview->widget_width = preview->width * zoom_factor;
preview->widget_height = preview->height * zoom_factor;
gtk_widget_set_size_request (preview->preview, preview->widget_width,
preview->widget_height);
gtk_widget_queue_resize(preview->window);
render_preview(preview, preview->drawable);
preview_redraw();
}
GdkCursorType
preview_set_cursor(Preview_t *preview, GdkCursorType cursor_type)
{
GdkCursorType prev_cursor = preview->cursor;
GdkDisplay *display = gtk_widget_get_display (preview->window);
GdkCursor *cursor = gdk_cursor_new_for_display (display,
cursor_type);
gdk_window_set_cursor(gtk_widget_get_window (preview->window), cursor);
g_object_unref (cursor);
preview->cursor = cursor_type;
return prev_cursor;
}
static const GtkTargetEntry target_table[] =
{
{"STRING", 0, 1 },
{"text/plain", 0, 2 }
};
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
GtkSelectionData *data, guint info, guint time)
{
gboolean success = FALSE;
if (gtk_selection_data_get_length (data) >= 0 &&
gtk_selection_data_get_format (data) == 8)
{
ObjectList_t *list = get_shapes();
Object_t *obj;
x = get_real_coord(x);
y = get_real_coord(y);
obj = object_list_find(list, x, y);
if (obj && !obj->locked)
{
command_list_add(edit_object_command_new(obj));
object_set_url(obj, (const gchar *) gtk_selection_data_get_data (data));
object_emit_update_signal(obj);
success = TRUE;
}
}
gtk_drag_finish(context, success, FALSE, time);
}
static void
preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
gpointer preview_void)
{
Preview_t *preview = preview_void;
render_preview (preview, preview->drawable);
}
static void
scroll_adj_changed (GtkAdjustment *adj,
PikaRuler *ruler)
{
pika_ruler_set_range (ruler,
gtk_adjustment_get_value (adj),
gtk_adjustment_get_value (adj) +
gtk_adjustment_get_page_size (adj),
gtk_adjustment_get_upper (adj));
}
Preview_t *
make_preview (PikaDrawable *drawable,
gpointer imap)
{
Preview_t *data = g_new (Preview_t, 1);
GtkAdjustment *hadj;
GtkAdjustment *vadj;
GtkWidget *preview;
GtkWidget *window;
GtkWidget *viewport;
GtkWidget *button, *arrow;
GtkWidget *ruler;
GtkWidget *grid;
GtkWidget *scrollbar;
gint width, height;
data->drawable = drawable;
data->preview = preview = pika_preview_area_new ();
g_object_set_data (G_OBJECT (preview), "preview", data);
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_MASK);
g_signal_connect_after (preview, "draw",
G_CALLBACK (preview_draw),
data);
g_signal_connect (preview, "size-allocate",
G_CALLBACK (preview_size_allocate),
data);
/* Handle drop of links in preview widget */
gtk_drag_dest_set (preview, GTK_DEST_DEFAULT_ALL, target_table,
2, GDK_ACTION_COPY);
g_signal_connect (preview, "drag-data-received",
G_CALLBACK (handle_drop),
NULL);
data->widget_width = data->width = pika_drawable_get_width (drawable);
data->widget_height = data->height = pika_drawable_get_height (drawable);
gtk_widget_set_size_request (preview, data->widget_width,
data->widget_height);
/* The main grid */
data->window = grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 1);
gtk_grid_set_column_spacing (GTK_GRID (grid), 1);
/* Create button with arrow */
button = gtk_button_new ();
gtk_widget_set_can_focus (button, FALSE);
gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
// GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_set_events (button,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_widget_show (button);
g_signal_connect (button, "button-press-event",
G_CALLBACK (arrow_cb),
imap);
arrow = gtk_image_new_from_icon_name (PIKA_ICON_GO_NEXT,
GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), arrow);
gtk_widget_show (arrow);
/* Create horizontal ruler */
data->hruler = ruler = pika_ruler_new (GTK_ORIENTATION_HORIZONTAL);
g_signal_connect_swapped (preview, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (ruler)->motion_notify_event),
ruler);
gtk_widget_set_hexpand (ruler, TRUE);
gtk_grid_attach (GTK_GRID (grid), ruler, 1, 0, 1, 1);
gtk_widget_show (ruler);
/* Create vertical ruler */
data->vruler = ruler = pika_ruler_new (GTK_ORIENTATION_VERTICAL);
g_signal_connect_swapped (preview, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (ruler)->motion_notify_event),
ruler);
gtk_widget_set_vexpand (ruler, TRUE);
gtk_grid_attach (GTK_GRID (grid), ruler, 0, 1, 1, 1);
gtk_widget_show (ruler);
window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window),
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
width = (data->width > 600) ? 600 : data->width;
height = (data->height > 400) ? 400 : data->height;
gtk_widget_set_size_request (window, width, height);
gtk_grid_attach (GTK_GRID (grid), window, 1, 1, 1, 1);
gtk_widget_show (window);
viewport = gtk_viewport_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (window), viewport);
gtk_widget_show (viewport);
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (window));
g_signal_connect (hadj, "changed",
G_CALLBACK (scroll_adj_changed),
data->hruler);
g_signal_connect (hadj, "value-changed",
G_CALLBACK (scroll_adj_changed),
data->hruler);
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (window));
g_signal_connect (vadj, "changed",
G_CALLBACK (scroll_adj_changed),
data->vruler);
g_signal_connect (vadj, "value-changed",
G_CALLBACK (scroll_adj_changed),
data->vruler);
gtk_container_add (GTK_CONTAINER (viewport), preview);
scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, hadj);
gtk_grid_attach (GTK_GRID (grid), scrollbar, 1, 2, 1, 1);
// GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0);
gtk_widget_show (scrollbar);
scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, vadj);
gtk_grid_attach (GTK_GRID (grid), scrollbar, 2, 1, 1, 1);
// GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0);
gtk_widget_show (scrollbar);
gtk_widget_show (preview);
render_preview (data, drawable);
gtk_widget_show (grid);
return data;
}

View File

@ -0,0 +1,56 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _IMAP_PREVIEW_H
#define _IMAP_PREVIEW_H
#include <libpika/pika.h>
typedef struct {
PikaDrawable *drawable;
GtkWidget *window;
GtkWidget *preview;
GtkWidget *hruler;
GtkWidget *vruler;
gint width;
gint height;
gint widget_width;
gint widget_height;
GdkCursorType cursor;
} Preview_t;
Preview_t *make_preview (PikaDrawable *drawable,
gpointer imap);
void preview_redraw (void);
void preview_unset_tmp_obj (Object_t *obj);
void preview_set_tmp_obj (Object_t *obj);
gint preview_get_width(GtkWidget *preview);
gint preview_get_height(GtkWidget *preview);
void preview_zoom(Preview_t *preview, gint zoom_factor);
GdkCursorType preview_set_cursor(Preview_t *preview,
GdkCursorType cursor_type);
#endif /* _IMAP_PREVIEW_H */

View File

@ -0,0 +1,537 @@
/*
* This is a plug-in for PIKA.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <stdlib.h> /* abs */
#include <gtk/gtk.h>
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "imap_icons.h"
#include "imap_main.h"
#include "imap_misc.h"
#include "imap_object_popup.h"
#include "imap_rectangle.h"
#include "imap_ui_grid.h"
#include "libpika/stdplugins-intl.h"
static gboolean rectangle_is_valid(Object_t *obj);
static Object_t *rectangle_clone(Object_t *obj);
static void rectangle_assign(Object_t *obj, Object_t *des);
static void rectangle_normalize(Object_t *obj);
static void rectangle_draw(Object_t *obj, cairo_t *cr);
static void rectangle_draw_sashes(Object_t *obj, cairo_t *cr);
static MoveSashFunc_t rectangle_near_sash(Object_t *obj, gint x, gint y);
static gboolean rectangle_point_is_on(Object_t *obj, gint x, gint y);
static void rectangle_get_dimensions(Object_t *obj, gint *x, gint *y,
gint *width, gint *height);
static void rectangle_resize(Object_t *obj, gint percentage_x,
gint percentage_y);
static void rectangle_move(Object_t *obj, gint dx, gint dy);
static gpointer rectangle_create_info_widget(GtkWidget *frame);
static void rectangle_fill_info_tab(Object_t *obj, gpointer data);
static void rectangle_set_initial_focus(Object_t *obj, gpointer data);
static void rectangle_update(Object_t *obj, gpointer data);
static void rectangle_write_csim(Object_t *obj, gpointer param,
OutputFunc_t output);
static void rectangle_write_cern(Object_t *obj, gpointer param,
OutputFunc_t output);
static void rectangle_write_ncsa(Object_t *obj, gpointer param,
OutputFunc_t output);
static const gchar* rectangle_get_icon_name(void);
static ObjectClass_t rectangle_class = {
N_("_Rectangle"),
NULL, /* info_dialog */
rectangle_is_valid,
NULL, /* rectangle_destruct */
rectangle_clone,
rectangle_assign,
rectangle_normalize,
rectangle_draw,
rectangle_draw_sashes,
rectangle_near_sash,
rectangle_point_is_on,
rectangle_get_dimensions,
rectangle_resize,
rectangle_move,
rectangle_create_info_widget,
rectangle_fill_info_tab, /* rectangle_update_info_widget */
rectangle_fill_info_tab,
rectangle_set_initial_focus,
rectangle_update,
rectangle_write_csim,
rectangle_write_cern,
rectangle_write_ncsa,
object_do_popup,
rectangle_get_icon_name
};
Object_t*
create_rectangle(gint x, gint y, gint width, gint height)
{
Rectangle_t *rectangle = g_new(Rectangle_t, 1);
rectangle->x = x;
rectangle->y = y;
rectangle->width = width;
rectangle->height = height;
return object_init(&rectangle->obj, &rectangle_class);
}
static void
draw_any_rectangle(cairo_t *cr, gint x, gint y, gint w, gint h)
{
if (w < 0) {
x += w;
w = -w;
}
if (h < 0) {
y += h;
h = -h;
}
draw_rectangle(cr, FALSE, x, y, w, h);
}
static gboolean
rectangle_is_valid(Object_t *obj)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
return rectangle->width && rectangle->height;
}
static Object_t*
rectangle_clone(Object_t *obj)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
Rectangle_t *clone = g_new(Rectangle_t, 1);
clone->x = rectangle->x;
clone->y = rectangle->y;
clone->width = rectangle->width;
clone->height = rectangle->height;
return &clone->obj;
}
static void
rectangle_assign(Object_t *obj, Object_t *des)
{
Rectangle_t *src_rectangle = ObjectToRectangle(obj);
Rectangle_t *des_rectangle = ObjectToRectangle(des);
des_rectangle->x = src_rectangle->x;
des_rectangle->y = src_rectangle->y;
des_rectangle->width = src_rectangle->width;
des_rectangle->height = src_rectangle->height;
}
static void
rectangle_normalize(Object_t *obj)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
if (rectangle->width < 0) {
rectangle->x += rectangle->width;
rectangle->width = -rectangle->width;
}
if (rectangle->height < 0) {
rectangle->y += rectangle->height;
rectangle->height = -rectangle->height;
}
}
static void
rectangle_draw(Object_t *obj, cairo_t *cr)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
draw_any_rectangle(cr, rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
}
static void
rectangle_draw_sashes(Object_t *obj, cairo_t *cr)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
draw_sash(cr, rectangle->x, rectangle->y);
draw_sash(cr, rectangle->x + rectangle->width / 2, rectangle->y);
draw_sash(cr, rectangle->x + rectangle->width, rectangle->y);
draw_sash(cr, rectangle->x, rectangle->y + rectangle->height / 2);
draw_sash(cr, rectangle->x + rectangle->width,
rectangle->y + rectangle->height / 2);
draw_sash(cr, rectangle->x, rectangle->y + rectangle->height);
draw_sash(cr, rectangle->x + rectangle->width / 2,
rectangle->y + rectangle->height);
draw_sash(cr, rectangle->x + rectangle->width,
rectangle->y + rectangle->height);
}
static void
MoveUpperSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->y += dy;
rectangle->height -= dy;
}
static void
MoveLeftSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->x += dx;
rectangle->width -= dx;
}
static void
MoveRightSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->width += dx;
}
static void
MoveLowerSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->height += dy;
}
static void
MoveUpperLeftSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->x += dx;
rectangle->y += dy;
rectangle->width -= dx;
rectangle->height -= dy;
}
static void
MoveUpperRightSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->y += dy;
rectangle->width += dx;
rectangle->height -= dy;
}
static void
MoveLowerLeftSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->x += dx;
rectangle->width -= dx;
rectangle->height += dy;
}
static void
MoveLowerRightSash(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->width += dx;
rectangle->height += dy;
}
static MoveSashFunc_t
rectangle_near_sash(Object_t *obj, gint x, gint y)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
if (near_sash(rectangle->x, rectangle->y, x, y))
return MoveUpperLeftSash;
else if (near_sash(rectangle->x + rectangle->width / 2, rectangle->y, x, y))
return MoveUpperSash;
else if (near_sash(rectangle->x + rectangle->width, rectangle->y, x, y))
return MoveUpperRightSash;
else if (near_sash(rectangle->x, rectangle->y + rectangle->height / 2,
x, y))
return MoveLeftSash;
else if (near_sash(rectangle->x + rectangle->width,
rectangle->y + rectangle->height / 2, x, y))
return MoveRightSash;
else if (near_sash(rectangle->x, rectangle->y + rectangle->height, x, y))
return MoveLowerLeftSash;
else if (near_sash(rectangle->x + rectangle->width / 2,
rectangle->y + rectangle->height, x, y))
return MoveLowerSash;
else if (near_sash(rectangle->x + rectangle->width,
rectangle->y + rectangle->height, x, y))
return MoveLowerRightSash;
return NULL;
}
static gboolean
rectangle_point_is_on(Object_t *obj, gint x, gint y)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
return x >= rectangle->x && x <= rectangle->x + rectangle->width &&
y >= rectangle->y && y <= rectangle->y + rectangle->height;
}
static void
rectangle_get_dimensions(Object_t *obj, gint *x, gint *y,
gint *width, gint *height)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
*x = rectangle->x;
*y = rectangle->y;
*width = rectangle->width;
*height = rectangle->height;
}
static void
rectangle_resize(Object_t *obj, gint percentage_x, gint percentage_y)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->x = rectangle->x * percentage_x / 100;
rectangle->y = rectangle->y * percentage_y / 100;
rectangle->width = rectangle->width * percentage_x / 100;
rectangle->height = rectangle->height * percentage_y / 100;
}
static void
rectangle_move(Object_t *obj, gint dx, gint dy)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->x += dx;
rectangle->y += dy;
}
typedef struct {
Object_t *obj;
GtkWidget *x;
GtkWidget *y;
GtkWidget *width;
GtkWidget *height;
GtkWidget *chain_button;
} RectangleProperties_t;
static void
x_changed_cb(GtkWidget *widget, gpointer data)
{
RectangleProperties_t *props = (RectangleProperties_t*) data;
Object_t *obj = props->obj;
gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
if (pika_chain_button_get_active(PIKA_CHAIN_BUTTON(props->chain_button)))
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), x);
ObjectToRectangle(obj)->x = x;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
y_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((RectangleProperties_t*) data)->obj;
gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
ObjectToRectangle(obj)->y = y;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
width_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((RectangleProperties_t*) data)->obj;
gint width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
ObjectToRectangle(obj)->width = width;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static void
height_changed_cb(GtkWidget *widget, gpointer data)
{
Object_t *obj = ((RectangleProperties_t*) data)->obj;
gint height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
ObjectToRectangle(obj)->height = height;
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
static gpointer
rectangle_create_info_widget(GtkWidget *frame)
{
RectangleProperties_t *props = g_new(RectangleProperties_t, 1);
GtkWidget *grid, *label, *chain_button;
gint max_width = get_image_width();
gint max_height = get_image_height();
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_widget_show(grid);
label = create_label_in_grid (grid, 0, 0, _("Upper left _x:"));
props->x = create_spin_button_in_grid (grid, label, 0, 1, 1, 0,
max_width - 1);
g_signal_connect(props->x, "value-changed",
G_CALLBACK(x_changed_cb), (gpointer) props);
create_label_in_grid (grid, 0, 3, _("pixels"));
label = create_label_in_grid (grid, 1, 0, _("Upper left _y:"));
props->y = create_spin_button_in_grid (grid, label, 1, 1, 1, 0,
max_height - 1);
g_signal_connect(props->y, "value-changed",
G_CALLBACK(y_changed_cb), (gpointer) props);
create_label_in_grid (grid, 1, 3, _("pixels"));
label = create_label_in_grid (grid, 2, 0, _("_Width:"));
props->width = create_spin_button_in_grid (grid, label, 2, 1, 1, 1,
max_width);
g_signal_connect(props->width, "value-changed",
G_CALLBACK(width_changed_cb), (gpointer) props);
create_label_in_grid (grid, 2, 3, _("pixels"));
label = create_label_in_grid (grid, 3, 0, _("_Height:"));
props->height = create_spin_button_in_grid (grid, label, 3, 1, 1, 1,
max_height);
g_signal_connect(props->height, "value-changed",
G_CALLBACK(height_changed_cb), (gpointer) props);
create_label_in_grid (grid, 3, 3, _("pixels"));
chain_button = pika_chain_button_new(PIKA_CHAIN_RIGHT);
props->chain_button = chain_button;
gtk_grid_attach (GTK_GRID (grid), chain_button, 2, 2, 1, 2);
gtk_widget_show(chain_button);
return props;
}
static void
rectangle_fill_info_tab(Object_t *obj, gpointer data)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
RectangleProperties_t *props = (RectangleProperties_t*) data;
props->obj = obj;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->x), rectangle->x);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), rectangle->y);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->width), rectangle->width);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->height),
rectangle->height);
}
static void
rectangle_set_initial_focus(Object_t *obj, gpointer data)
{
RectangleProperties_t *props = (RectangleProperties_t*) data;
gtk_widget_grab_focus(props->x);
}
static void
rectangle_update(Object_t* obj, gpointer data)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
RectangleProperties_t *props = (RectangleProperties_t*) data;
rectangle->x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->x));
rectangle->y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->y));
rectangle->width = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(props->width));
rectangle->height = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(props->height));
}
static void
rectangle_write_csim(Object_t *obj, gpointer param, OutputFunc_t output)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
output(param, "\"rect\" coords=\"%d,%d,%d,%d\"", rectangle->x, rectangle->y,
rectangle->x + rectangle->width, rectangle->y + rectangle->height);
}
static void
rectangle_write_cern(Object_t *obj, gpointer param, OutputFunc_t output)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
output(param, "rect (%d,%d) (%d,%d)", rectangle->x, rectangle->y,
rectangle->x + rectangle->width, rectangle->y + rectangle->height);
}
static void
rectangle_write_ncsa(Object_t *obj, gpointer param, OutputFunc_t output)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
output(param, "rect %s %d,%d %d,%d", obj->url,
rectangle->x, rectangle->y,
rectangle->x + rectangle->width, rectangle->y + rectangle->height);
}
static const gchar*
rectangle_get_icon_name(void)
{
return IMAP_RECTANGLE;
}
static gboolean
rectangle_factory_finish(Object_t *obj, gint x, gint y)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->width = x - rectangle->x;
rectangle->height = y - rectangle->y;
rectangle_normalize(obj);
return TRUE;
}
static Object_t*
rectangle_factory_create_object(gint x, gint y)
{
return create_rectangle(x, y, 0, 0);
}
static void
rectangle_factory_set_xy(Object_t *obj, guint state, gint x, gint y)
{
Rectangle_t *rectangle = ObjectToRectangle(obj);
rectangle->width = x - rectangle->x;
rectangle->height = y - rectangle->y;
if (state & GDK_SHIFT_MASK){
gint width = abs(rectangle->width);
gint height = abs(rectangle->height);
if (width < height)
rectangle->height = (rectangle->height < 0) ? -width : width;
else
rectangle->width = (rectangle->width < 0) ? -height : height;
}
main_set_dimension(rectangle->width, rectangle->height);
}
static ObjectFactory_t rectangle_factory = {
NULL, /* Object pointer */
rectangle_factory_finish,
NULL, /* Cancel func */
rectangle_factory_create_object,
rectangle_factory_set_xy
};
ObjectFactory_t*
get_rectangle_factory(guint state)
{
return &rectangle_factory;
}

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