Commit d37d2da3 authored by Sven Neumann's avatar Sven Neumann

an update of the imagemap plug-in


--Sven
parent b6d773dc
Sat Dec 18 20:40:44 CET 1999 Sven Neumann <sven@gimp.org>
* plug-ins/imagemap/imap_about.c
* plug-ins/imagemap/imap_circle.c
* plug-ins/imagemap/imap_default_dialog.c
* plug-ins/imagemap/imap_default_dialog.h
* plug-ins/imagemap/imap_main.c
* plug-ins/imagemap/imap_menu.c
* plug-ins/imagemap/imap_menu_funcs.c
* plug-ins/imagemap/imap_popup.c
* plug-ins/imagemap/imap_preview.c
* plug-ins/imagemap/imap_rectangle.c
* plug-ins/imagemap/imap_selection.c
* plug-ins/imagemap/imap_table.c
* po-plug-ins/POTFILES.in: applied a patch to the ImageMap plug-ins
provided by its author Maurits Rijk <lpeek.mrijk@consunet.nl>.
Contains some internationalization fixes, compliance to the standard
Gimp dialog layout and some minor stuff (like the use of tear-off
menus).
1999-12-18 Michael Natterer <mitch@gimp.org>
* app/preferences_dialog.c: Added a special help function which
......
......@@ -33,6 +33,7 @@ do_about_dialog(void)
dialog = make_default_dialog(_("About"));
default_dialog_hide_cancel_button(dialog);
default_dialog_hide_apply_button(dialog);
default_dialog_hide_help_button(dialog);
default_dialog_set_label(
dialog,
_("Imagemap plug-in 1.3\n\n"
......
......@@ -56,7 +56,7 @@ static void circle_write_ncsa(Object_t* obj, gpointer param,
static char** circle_get_icon_data(void);
static ObjectClass_t circle_class = {
"Circle",
N_("Circle"),
NULL, /* info_dialog */
NULL, /* icon */
NULL, /* mask */
......
......@@ -21,6 +21,8 @@
*
*/
#include "libgimp/stdplugins-intl.h"
#include "imap_default_dialog.h"
static void
......@@ -76,7 +78,7 @@ DefaultDialog_t*
make_default_dialog(const gchar *title)
{
DefaultDialog_t *data = (DefaultDialog_t*) g_new(DefaultDialog_t, 1);
GtkWidget *dialog;
GtkWidget *dialog, *hbbox;
data->ok_cb = NULL;
data->cancel_cb = NULL;
......@@ -86,29 +88,44 @@ make_default_dialog(const gchar *title)
gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
GTK_SIGNAL_FUNC(dialog_destroy), (gpointer) data);
data->ok = gtk_button_new_with_label("OK");
/* Action area */
gtk_container_set_border_width(GTK_CONTAINER(
GTK_DIALOG(dialog)->action_area), 2);
gtk_box_set_homogeneous(GTK_BOX(GTK_DIALOG(dialog)->action_area), FALSE);
hbbox = gtk_hbutton_box_new();
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 4);
gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbbox, FALSE,
FALSE, 0);
gtk_widget_show (hbbox);
data->ok = gtk_button_new_with_label(_("OK"));
GTK_WIDGET_SET_FLAGS(data->ok, GTK_CAN_DEFAULT);
gtk_signal_connect(GTK_OBJECT(data->ok), "clicked",
GTK_SIGNAL_FUNC(dialog_ok), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), data->ok, TRUE,
TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbbox), data->ok, FALSE, FALSE, 0);
gtk_widget_grab_default(data->ok);
gtk_widget_show(data->ok);
data->apply = gtk_button_new_with_label("Apply");
data->apply = gtk_button_new_with_label(_("Apply"));
GTK_WIDGET_SET_FLAGS(data->apply, GTK_CAN_DEFAULT);
gtk_signal_connect(GTK_OBJECT(data->apply), "clicked",
GTK_SIGNAL_FUNC(dialog_apply), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), data->apply,
TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbbox), data->apply, FALSE, FALSE, 0);
gtk_widget_show(data->apply);
data->cancel = gtk_button_new_with_label("Cancel");
data->cancel = gtk_button_new_with_label(_("Cancel"));
GTK_WIDGET_SET_FLAGS(data->cancel, GTK_CAN_DEFAULT);
gtk_signal_connect(GTK_OBJECT(data->cancel), "clicked",
GTK_SIGNAL_FUNC(dialog_cancel), (gpointer) data);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), data->cancel,
TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbbox), data->cancel, FALSE, FALSE, 0);
gtk_widget_show(data->cancel);
data->help = gtk_button_new_with_label(_("Help..."));
GTK_WIDGET_SET_FLAGS(data->help, GTK_CAN_DEFAULT);
/* Fix me: no action yet */
gtk_box_pack_start(GTK_BOX(hbbox), data->help, FALSE, FALSE, 0);
gtk_widget_show(data->help);
return data;
}
......@@ -130,6 +147,12 @@ 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)
{
......
......@@ -31,6 +31,7 @@ typedef struct {
GtkWidget *ok;
GtkWidget *apply;
GtkWidget *cancel;
GtkWidget *help;
void (*ok_cb)(gpointer);
gpointer ok_cb_data;
void (*cancel_cb)(gpointer);
......@@ -46,6 +47,7 @@ void default_dialog_set_cancel_cb(DefaultDialog_t *dialog,
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_ok_sensitivity(DefaultDialog_t *dialog,
gint sensitive);
......
......@@ -383,7 +383,8 @@ draw_polygon(GdkWindow *window, GdkGC *gc, GList *list)
g_free(points);
}
static gboolean _preview_redraw_blocked;
static gboolean _preview_redraw_blocked = FALSE;
static gboolean _pending_redraw = FALSE;
void
preview_freeze(void)
......@@ -395,13 +396,18 @@ void
preview_thaw(void)
{
_preview_redraw_blocked = FALSE;
redraw_preview();
if (_pending_redraw) {
_pending_redraw = FALSE;
redraw_preview();
}
}
void
redraw_preview(void)
{
if (!_preview_redraw_blocked)
if (_preview_redraw_blocked)
_pending_redraw = TRUE;
else
preview_redraw(_preview);
}
......
......@@ -24,6 +24,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "libgimp/stdplugins-intl.h"
#include "imap_circle.h"
#include "imap_file.h"
#include "imap_grid.h"
......@@ -60,7 +62,7 @@ menu_mru(GtkWidget *widget, gpointer data)
if (!err && (buf.st_mode & S_IFREG)) {
load(filename);
} else {
do_file_error_dialog("Error opening file", filename);
do_file_error_dialog(_("Error opening file"), filename);
mru_remove(mru, filename);
menu_build_mru_items(mru);
}
......@@ -205,23 +207,23 @@ menu_grid(GtkWidget *widget, gpointer data)
static void
make_file_menu(GtkWidget *menu_bar)
{
GtkWidget *file_menu = make_menu_bar_item(menu_bar, "File");
GtkWidget *file_menu = make_menu_bar_item(menu_bar, _("File"));
GtkWidget *item;
_menu.file_menu = file_menu;
item = make_item_with_label(file_menu, "Open...", menu_command,
item = make_item_with_label(file_menu, _("Open..."), menu_command,
&_menu.cmd_open);
add_accelerator(item, 'O', GDK_CONTROL_MASK);
item = make_item_with_label(file_menu, "Save", menu_command,
item = make_item_with_label(file_menu, _("Save"), menu_command,
&_menu.cmd_save);
add_accelerator(item, 'S', GDK_CONTROL_MASK);
make_item_with_label(file_menu, "Save As...", menu_command,
make_item_with_label(file_menu, _("Save As..."), menu_command,
&_menu.cmd_save_as);
make_separator(file_menu);
make_item_with_label(file_menu, "Preferences...", menu_command,
make_item_with_label(file_menu, _("Preferences..."), menu_command,
&_menu.cmd_preferences);
make_separator(file_menu);
item = make_item_with_label(file_menu, "Close", menu_command,
item = make_item_with_label(file_menu, _("Close"), menu_command,
&_menu.cmd_close);
add_accelerator(item, 'W', GDK_CONTROL_MASK);
item = make_item_with_label(file_menu, "Quit", menu_command,
......@@ -237,8 +239,8 @@ command_list_changed(Command_t *command, gpointer data)
/* Set undo entry */
if (_menu.undo)
gtk_widget_destroy(_menu.undo);
sprintf(scratch, "Undo %s", (command) ? command->name : "");
_menu.undo = insert_item_with_label(_menu.edit_menu, 0, scratch,
sprintf(scratch, _("Undo %s"), (command) ? command->name : "");
_menu.undo = insert_item_with_label(_menu.edit_menu, 1, scratch,
menu_command, &_menu.cmd_undo);
add_accelerator(_menu.undo, 'Z', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(_menu.undo, (command != NULL));
......@@ -247,8 +249,8 @@ command_list_changed(Command_t *command, gpointer data)
command = command_list_get_redo_command();
if (_menu.redo)
gtk_widget_destroy(_menu.redo);
sprintf(scratch, "Redo %s", (command) ? command->name : "");
_menu.redo = insert_item_with_label(_menu.edit_menu, 1, scratch,
sprintf(scratch, _("Redo %s"), (command) ? command->name : "");
_menu.redo = insert_item_with_label(_menu.edit_menu, 2, scratch,
menu_command, &_menu.cmd_redo);
add_accelerator(_menu.redo, 'R', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(_menu.redo, (command != NULL));
......@@ -269,32 +271,32 @@ paste_buffer_removed(Object_t *obj, gpointer data)
static void
make_edit_menu(GtkWidget *menu_bar)
{
GtkWidget *edit_menu = make_menu_bar_item(menu_bar, "Edit");
GtkWidget *edit_menu = make_menu_bar_item(menu_bar, _("Edit"));
GtkWidget *item, *paste;
_menu.edit_menu = edit_menu;
command_list_changed(NULL, NULL);
make_separator(edit_menu);
_menu.cut = make_item_with_label(edit_menu, "Cut", menu_command,
_menu.cut = make_item_with_label(edit_menu, _("Cut"), menu_command,
&_menu.cmd_cut);
add_accelerator(_menu.cut, 'X', GDK_CONTROL_MASK);
_menu.copy = make_item_with_label(edit_menu, "Copy", menu_command,
_menu.copy = make_item_with_label(edit_menu, _("Copy"), menu_command,
&_menu.cmd_copy);
add_accelerator(_menu.copy, 'C', GDK_CONTROL_MASK);
paste = make_item_with_label(edit_menu, "Paste", menu_command,
paste = make_item_with_label(edit_menu, _("Paste"), menu_command,
&_menu.cmd_paste);
add_accelerator(paste, 'V', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(paste, FALSE);
item = make_item_with_label(edit_menu, "Select All", menu_command,
item = make_item_with_label(edit_menu, _("Select All"), menu_command,
&_menu.cmd_select_all);
add_accelerator(item, 'A', GDK_CONTROL_MASK);
make_separator(edit_menu);
_menu.clear = make_item_with_label(edit_menu, "Clear", menu_command,
_menu.clear = make_item_with_label(edit_menu, _("Clear"), menu_command,
&_menu.cmd_clear);
add_accelerator(_menu.clear, 'K', GDK_CONTROL_MASK);
_menu.edit = make_item_with_label(edit_menu, "Edit Area Info...",
menu_command, &_menu.cmd_edit_area_info);
_menu.edit = make_item_with_label(edit_menu, _("Edit Area Info..."),
menu_command, &_menu.cmd_edit_area_info);
paste_buffer_add_add_cb(paste_buffer_added, (gpointer) paste);
paste_buffer_add_remove_cb(paste_buffer_removed, (gpointer) paste);
......@@ -305,23 +307,23 @@ make_edit_menu(GtkWidget *menu_bar)
static void
make_view_menu(GtkWidget *menu_bar)
{
GtkWidget *view_menu = make_menu_bar_item(menu_bar, "View");
GtkWidget *view_menu = make_menu_bar_item(menu_bar, _("View"));
GtkWidget *zoom_menu, *item;
GSList *group = NULL;
item = make_check_item(view_menu, "Area List", menu_command,
item = make_check_item(view_menu, _("Area List"), menu_command,
&_menu.cmd_area_list);
GTK_CHECK_MENU_ITEM(item)->active = TRUE;
make_item_with_label(view_menu, "Source...", menu_command,
make_item_with_label(view_menu, _("Source..."), menu_command,
&_menu.cmd_source);
make_separator(view_menu);
_menu.color = make_radio_item(view_menu, NULL, "Color", menu_command,
_menu.color = make_radio_item(view_menu, NULL, _("Color"), menu_command,
&_menu.cmd_color);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.color));
_menu.gray = make_radio_item(view_menu, group, "Grayscale", menu_command,
_menu.gray = make_radio_item(view_menu, group, _("Grayscale"), menu_command,
&_menu.cmd_gray);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.gray));
......@@ -333,79 +335,79 @@ make_view_menu(GtkWidget *menu_bar)
make_separator(view_menu);
_menu.zoom_in = make_item_with_label(view_menu, "Zoom In", menu_command,
_menu.zoom_in = make_item_with_label(view_menu, _("Zoom In"), menu_command,
&_menu.cmd_zoom_in);
add_accelerator(_menu.zoom_in, '=', 0);
_menu.zoom_out = make_item_with_label(view_menu, "Zoom Out", menu_command,
&_menu.cmd_zoom_out);
_menu.zoom_out = make_item_with_label(view_menu, _("Zoom Out"),
menu_command, &_menu.cmd_zoom_out);
add_accelerator(_menu.zoom_out, '-', 0);
gtk_widget_set_sensitive(_menu.zoom_out, FALSE);
zoom_menu = make_sub_menu(view_menu, "Zoom To");
_menu.zoom[0] = make_radio_item(zoom_menu, NULL, "1:1", menu_zoom_to_1,
zoom_menu = make_sub_menu(view_menu, _("Zoom To"));
_menu.zoom[0] = make_radio_item(zoom_menu, NULL, "1:1", menu_zoom_to_1,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[0]));
_menu.zoom[1] = make_radio_item(zoom_menu, group, "1:2", menu_zoom_to_2,
_menu.zoom[1] = make_radio_item(zoom_menu, group, "1:2", menu_zoom_to_2,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[1]));
_menu.zoom[2] = make_radio_item(zoom_menu, group, "1:3", menu_zoom_to_3,
_menu.zoom[2] = make_radio_item(zoom_menu, group, "1:3", menu_zoom_to_3,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[2]));
_menu.zoom[3] = make_radio_item(zoom_menu, group, "1:4", menu_zoom_to_4,
_menu.zoom[3] = make_radio_item(zoom_menu, group, "1:4", menu_zoom_to_4,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[3]));
_menu.zoom[4] = make_radio_item(zoom_menu, group, "1:5", menu_zoom_to_5,
_menu.zoom[4] = make_radio_item(zoom_menu, group, "1:5", menu_zoom_to_5,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[4]));
_menu.zoom[5] = make_radio_item(zoom_menu, group, "1:6", menu_zoom_to_6,
_menu.zoom[5] = make_radio_item(zoom_menu, group, "1:6", menu_zoom_to_6,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[5]));
_menu.zoom[6] = make_radio_item(zoom_menu, group, "1:7", menu_zoom_to_7,
_menu.zoom[6] = make_radio_item(zoom_menu, group, "1:7", menu_zoom_to_7,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.zoom[6]));
_menu.zoom[7] = make_radio_item(zoom_menu, group, "1:8", menu_zoom_to_8,
_menu.zoom[7] = make_radio_item(zoom_menu, group, "1:8", menu_zoom_to_8,
NULL);
}
static void
make_mapping_menu(GtkWidget *menu_bar)
{
GtkWidget *menu = make_menu_bar_item(menu_bar, "Mapping");
GtkWidget *menu = make_menu_bar_item(menu_bar, _("Mapping"));
GSList *group;
_menu.arrow = make_radio_item(menu, NULL, "Arrow", menu_arrow, NULL);
_menu.arrow = make_radio_item(menu, NULL, _("Arrow"), menu_arrow, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.arrow));
_menu.rectangle = make_radio_item(menu, group, "Rectangle",
_menu.rectangle = make_radio_item(menu, group, _("Rectangle"),
menu_rectangle, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.rectangle));
_menu.circle = make_radio_item(menu, group, "Circle", menu_circle, NULL);
_menu.circle = make_radio_item(menu, group, _("Circle"), menu_circle, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_menu.circle));
_menu.polygon = make_radio_item(menu, group, "Polygon", menu_polygon,
_menu.polygon = make_radio_item(menu, group, _("Polygon"), menu_polygon,
NULL);
make_separator(menu);
make_item_with_label(menu, "Edit Map Info...", menu_command,
make_item_with_label(menu, _("Edit Map Info..."), menu_command,
&_menu.cmd_edit_map_info);
}
static void
make_goodies_menu(GtkWidget *menu_bar)
{
GtkWidget *goodies_menu = make_menu_bar_item(menu_bar, "Goodies");
_menu.grid = make_check_item(goodies_menu, "Grid", menu_grid, NULL);
make_item_with_label(goodies_menu, "Grid Settings...", menu_command,
GtkWidget *goodies_menu = make_menu_bar_item(menu_bar, _("Goodies"));
_menu.grid = make_check_item(goodies_menu, _("Grid"), menu_grid, NULL);
make_item_with_label(goodies_menu, _("Grid Settings..."), menu_command,
&_menu.cmd_grid_settings);
make_item_with_label(goodies_menu, "Create Guides...", menu_command,
make_item_with_label(goodies_menu, _("Create Guides..."), menu_command,
&_menu.cmd_create_guides);
}
static void
make_help_menu(GtkWidget *menu_bar)
{
GtkWidget *help_menu = make_menu_bar_item(menu_bar, "Help");
GtkWidget *help_menu = make_menu_bar_item(menu_bar, _("Help"));
gtk_menu_item_right_justify(GTK_MENU_ITEM(gtk_menu_get_attach_widget(
GTK_MENU(help_menu))));
make_item_with_label(help_menu, "About ImageMap...", menu_command,
make_item_with_label(help_menu, _("About ImageMap..."), menu_command,
&_menu.cmd_about);
}
......@@ -435,12 +437,12 @@ void
menu_build_mru_items(MRU_t *mru)
{
GList *p;
gint position = 6; /* Position of 'Close' entry */
gint position = 7; /* Position of 'Close' entry */
int i;
if (_menu.nr_off_mru_items) {
GList *children = gtk_container_children(GTK_CONTAINER(_menu.file_menu));
p = g_list_nth(children, position);
for (i = 0; i < _menu.nr_off_mru_items; i++, p = p->next) {
gtk_widget_destroy((GtkWidget*) p->data);
......@@ -450,8 +452,13 @@ menu_build_mru_items(MRU_t *mru)
i = 0;
for (p = mru->list; p; p = p->next, i++) {
insert_item_with_label(_menu.file_menu, position++, (gchar*) p->data,
menu_mru, p->data);
GtkWidget *item = insert_item_with_label(_menu.file_menu, position++,
(gchar*) p->data,
menu_mru, p->data);
if (i < 9) {
guchar accelerator_key = '1' + i;
add_accelerator(item, accelerator_key, GDK_CONTROL_MASK);
}
}
insert_separator(_menu.file_menu, position);
_menu.nr_off_mru_items = i + 1;
......@@ -492,7 +499,7 @@ void
menu_set_zoom(gint factor)
{
_menu_callback_lock = 2;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu.zoom[factor - 1]),
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu.zoom[factor - 1]),
TRUE);
menu_set_zoom_sensitivity(factor);
}
......@@ -26,7 +26,7 @@
static GtkAccelGroup *accelerator_group;
void
void
init_accel_group(GtkWidget *window)
{
accelerator_group = gtk_accel_group_new();
......@@ -37,8 +37,8 @@ void
add_accelerator(GtkWidget *widget, guchar accelerator_key,
guint8 accelerator_mods)
{
gtk_widget_add_accelerator(widget, "activate", accelerator_group,
accelerator_key, accelerator_mods,
gtk_widget_add_accelerator(widget, "activate", accelerator_group,
accelerator_key, accelerator_mods,
GTK_ACCEL_VISIBLE);
}
......@@ -75,7 +75,7 @@ prepend_item_with_label(GtkWidget *parent, gchar *label,
{
GtkWidget *item = gtk_menu_item_new_with_label(label);
gtk_menu_prepend(GTK_MENU(parent), item);
gtk_signal_connect(GTK_OBJECT(item), "activate",
gtk_signal_connect(GTK_OBJECT(item), "activate",
GTK_SIGNAL_FUNC(activate), data);
gtk_widget_show(item);
......@@ -88,7 +88,7 @@ insert_item_with_label(GtkWidget *parent, gint position, gchar *label,
{
GtkWidget *item = gtk_menu_item_new_with_label(label);
gtk_menu_insert(GTK_MENU(parent), item, position);
gtk_signal_connect(GTK_OBJECT(item), "activate",
gtk_signal_connect(GTK_OBJECT(item), "activate",
GTK_SIGNAL_FUNC(activate), data);
gtk_widget_show(item);
......@@ -104,10 +104,10 @@ make_check_item(GtkWidget *parent, gchar *label, MenuCallback activate,
}
GtkWidget*
make_radio_item(GtkWidget *parent, GSList *group, gchar *label,
make_radio_item(GtkWidget *parent, GSList *group, gchar *label,
MenuCallback activate, gpointer data)
{
return append_active_item(parent,
return append_active_item(parent,
gtk_radio_menu_item_new_with_label(group, label),
activate, data);
}
......@@ -144,6 +144,10 @@ make_menu_bar_item(GtkWidget *menu_bar, gchar *label)
{
GtkWidget *menu = gtk_menu_new();
GtkWidget *item = gtk_menu_item_new_with_label(label);
GtkWidget *tearoff = gtk_tearoff_menu_item_new();
gtk_menu_insert(GTK_MENU(menu), tearoff, 0);
gtk_widget_show(tearoff);
gtk_widget_show(item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
......
......@@ -21,6 +21,8 @@
*
*/
#include "libgimp/stdplugins-intl.h"
#include "imap_edit_area_info.h"
#include "imap_grid.h"
#include "imap_main.h"
......@@ -119,34 +121,35 @@ create_main_popup_menu(void)
GSList *group;
_popup.main = popup_menu = gtk_menu_new();
make_item_with_label(popup_menu, "Map Info...", menu_command,
make_item_with_label(popup_menu, _("Map Info..."), menu_command,
&_popup.cmd_edit_map_info);
sub_menu = make_sub_menu(popup_menu, "Tools");
_popup.arrow = make_radio_item(sub_menu, NULL, "Arrow", popup_arrow, NULL);
sub_menu = make_sub_menu(popup_menu, _("Tools"));
_popup.arrow = make_radio_item(sub_menu, NULL, _("Arrow"), popup_arrow,
NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_popup.arrow));
_popup.rectangle = make_radio_item(sub_menu, group, "Rectangle",
_popup.rectangle = make_radio_item(sub_menu, group, _("Rectangle"),
popup_rectangle, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_popup.rectangle));
_popup.circle = make_radio_item(sub_menu, group, "Circle",
_popup.circle = make_radio_item(sub_menu, group, _("Circle"),
popup_circle, NULL);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(_popup.circle));
_popup.polygon = make_radio_item(sub_menu, group, "Polygon",
_popup.polygon = make_radio_item(sub_menu, group, _("Polygon"),
popup_polygon, NULL);
sub_menu = make_sub_menu(popup_menu, "Zoom");
_popup.zoom_in = make_item_with_label(sub_menu, "In", menu_command,
sub_menu = make_sub_menu(popup_menu, _("Zoom"));
_popup.zoom_in = make_item_with_label(sub_menu, _("In"), menu_command,
&_popup.cmd_zoom_in);
_popup.zoom_out = make_item_with_label(sub_menu, "Out", menu_command,
_popup.zoom_out = make_item_with_label(sub_menu, _("Out"), menu_command,
&_popup.cmd_zoom_out);
gtk_widget_set_sensitive(_popup.zoom_out, FALSE);
_popup.grid = make_check_item(popup_menu, "Grid", popup_grid, NULL);
make_item_with_label(popup_menu, "Grid Settings...", menu_command,
_popup.grid = make_check_item(popup_menu, _("Grid"), popup_grid, NULL);
make_item_with_label(popup_menu, _("Grid Settings..."), menu_command,
&_popup.cmd_grid_settings);
make_item_with_label(popup_menu, "Guides...", menu_command,
make_item_with_label(popup_menu, _("Guides..."), menu_command,
&_popup.cmd_create_guides);
paste = make_item_with_label(popup_menu, "Paste", menu_command,
paste = make_item_with_label(popup_menu, _("Paste"), menu_command,
&_popup.cmd_paste);
gtk_widget_set_sensitive(paste, FALSE);
paste_buffer_add_add_cb(paste_buffer_added, (gpointer) paste);
......
......@@ -26,6 +26,7 @@
#include "imap_cmd_edit_object.h"
#include "imap_grid.h"
#include "imap_main.h"
#include "imap_popup.h"
#include "imap_preview.h"
#define PREVIEW_MASK GDK_EXPOSURE_MASK | \
......@@ -58,13 +59,13 @@ preview_user_data(GtkWidget *preview)
return (Preview_t*) gtk_object_get_user_data(GTK_OBJECT(preview));
}
gint
gint
preview_get_width(GtkWidget *preview)
{
return preview_user_data(preview)->width;
}
gint
gint
preview_get_height(GtkWidget *preview)
{
return preview_user_data(preview)->height;
......@@ -92,12 +93,12 @@ render_gray_image(GtkWidget *preview, GPixelRgn *srcrgn)
src_row = g_new(guchar, dwidth * bpp);
dest_row = g_new(guchar, pwidth * 3);
src_col = g_new(gint, pwidth);
for (col = 0; col < pwidth; col++)
src_col[col] = (col * dwidth / pwidth) * bpp;
for (row = 0; row < pheight; row++) {
gimp_pixel_rgn_get_row(srcrgn, src_row, 0, row * dheight / pheight,
gimp_pixel_rgn_get_row(srcrgn, src_row, 0, row * dheight / pheight,
dwidth);
dest = dest_row;
......@@ -141,21 +142,21 @@ render_indexed_image(GtkWidget *preview, GPixelRgn *srcrgn)
bpp = srcrgn->bpp;
alpha = bpp;
has_alpha = gimp_drawable_has_alpha(srcrgn->drawable->id);
if (has_alpha)
if (has_alpha)
alpha--;
cmap = gimp_image_get_cmap(gimp_drawable_image_id(srcrgn->drawable->id),
&ncols);
src_row = g_new(guchar, dwidth * bpp);
dest_row = g_new(guchar, pwidth * 3);
src_col = g_new(gint, pwidth);
for (col = 0; col < pwidth; col++)
src_col[col] = (col * dwidth / pwidth) * bpp;
for (row = 0; row < pheight; row++) {
gimp_pixel_rgn_get_row(srcrgn, src_row, 0, row * dheight / pheight,
gimp_pixel_rgn_get_row(srcrgn, src_row, 0, row * dheight / pheight,
dwidth);
dest = dest_row;
for (col = 0; col < pwidth; col++) {
......@@ -163,7 +164,7 @@ render_indexed_image(GtkWidget *preview, GPixelRgn *srcrgn)
colour = cmap + 3 * (int)(*src);
if (gray) {
guchar avg = (299 * *colour++ + 587 * *colour++ +
guchar avg = (299 * *colour++ + 587 * *colour++ +
114 * *colour++) / 1000;
*dest++ = avg;
*dest++ = avg;
......@@ -204,18 +205,18 @@ render_rgb_image(GtkWidget *preview, GPixelRgn *srcrgn)
bpp = srcrgn->bpp;
alpha = bpp;
has_alpha = gimp_drawable_has_alpha(srcrgn->drawable->id);
if (has_alpha)
if (has_alpha)
alpha--;
src_row = g_new(guchar, dwidth * bpp);
dest_row = g_new(guchar, pwidth * bpp);
src_col = g_new(gint, pwidth);
for (col = 0; col < pwidth; col++)
src_col[col] = (col * dwidth / pwidth) * bpp;
for (row = 0; row < pheight; row++) {
gimp_pixel_rgn_get_row(srcrgn, src_row, 0, row * dheight / pheight,
gimp_pixel_rgn_get_row(srcrgn, src_row, 0, row * dheight / pheight,
dwidth);
dest = dest_row;
for (col = 0; col < pwidth; col++) {
......@@ -231,7 +232,7 @@ render_rgb_image(GtkWidget *preview, GPixelRgn *srcrgn)
check = LIGHTCHECK;
else
check = DARKCHECK;
if (src[alpha] == 0) {
/* full transparent -- check */
for (b = 0; b < alpha; b++)
......@@ -239,7 +240,7 @@ render_rgb_image(GtkWidget *preview, GPixelRgn *srcrgn)
} else {
/* middlemost transparent -- mix check and src */
for (b = 0; b < alpha; b++)
dest[b] = (src[b] * src[alpha] +
dest[b] = (src[b] * src[alpha] +
check * (OPAQUE - src[alpha])) / OPAQUE;
}
}
......@@ -277,6 +278,15 @@ render_preview(GtkWidget *preview, GPixelRgn *srcrgn)
}
}
static gint
arrow_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
if (event->button == 1)
do_main_popup_menu(event);
gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "button_press_event");
return FALSE;
}
static gint