Commit dcd2c254 authored by Maurits Rijk's avatar Maurits Rijk

Make imagemap plug-in a bit more GNOME HIG compliant. Code clean-up for semiflatten plug-in.

parent 97cb7b6d
2002-09-06 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/common/semiflatten.c: minor code cleanup (matching
g_new/g_free pairs iso g_new/free, etc.)
2002-09-05 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/imagemap/imap_default_dialog.c (make_default_dialog): more
changes for GNOME HIG compliance
* plug-ins/imagemap/imap_main.c (dialog)
* plug-ins/imagemap/imap_menu.c: Moved a few menu items to make it
compliant to the GNOME Human Interface Guidelines.
2002-09-05 Manish Singh <yosh@gimp.org>
* acinclude.m4: emptied
......
......@@ -45,9 +45,8 @@ static void run (gchar *name,
GimpParam **return_vals);
static void semiflatten (GimpDrawable *drawable);
static void semiflatten_render_row (const guchar *src_row,
guchar *dest_row,
gint row,
static void semiflatten_render_row (const guchar *src,
guchar *dest,
gint row_width,
gint bytes);
......@@ -139,11 +138,9 @@ run (gchar *name,
gimp_drawable_detach (drawable);
}
static void
semiflatten_render_row (const guchar *src_row,
guchar *dest_row,
gint row,
semiflatten_render_row (const guchar *src,
guchar *dest,
gint row_width,
gint bytes)
{
......@@ -151,23 +148,16 @@ semiflatten_render_row (const guchar *src_row,
for (col = 0; col < row_width ; col++)
{
dest_row[col*bytes+0] =
(src_row[col*bytes+0]*src_row[col*bytes+3])/255 +
(bgred*(255-src_row[col*bytes+3]))/255;
dest_row[col*bytes+1] =
(src_row[col*bytes+1]*src_row[col*bytes+3])/255 +
(bggreen*(255-src_row[col*bytes+3]))/255;
dest_row[col*bytes+2] =
(src_row[col*bytes+2]*src_row[col*bytes+3])/255 +
(bgblue*(255-src_row[col*bytes+3]))/255;
dest[0] = (src[0] * src[3]) / 255 + (bgred * (255 - src[3])) / 255;
dest[1] = (src[1] * src[3]) / 255 + (bggreen * (255 - src[3])) / 255;
dest[2] = (src[2] * src[3]) / 255 + (bgblue * (255 - src[3])) / 255;
dest[3] = (src[3] == 0) ? 0 : 255;
dest_row[col*bytes+3] = (src_row[col*bytes+3] == 0) ? 0 : 255;
src += bytes;
dest += bytes;
}
}
static void
semiflatten (GimpDrawable *drawable)
{
......@@ -184,12 +174,6 @@ semiflatten (GimpDrawable *drawable)
gimp_palette_get_background (&background);
gimp_rgb_get_uchar (&background, &bgred, &bggreen, &bgblue);
/* Get the input area. This is the bounding box of the selection in
* the image (or the entire image if there is no selection). Only
* operating on the input area is simply an optimization. It doesn't
* need to be done for correct operation. (It simply makes it go
* faster, since fewer pixels need to be operated on).
*/
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
/* Get the size of the input image. (This will/must be the same
......@@ -209,16 +193,14 @@ semiflatten (GimpDrawable *drawable)
for (row = y1; row < y2; row++)
{
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, row, (x2 - x1));
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, row, x2 - x1);
semiflatten_render_row (src_row,
dest_row,
row,
(x2 - x1),
bytes);
/* store the dest */
gimp_pixel_rgn_set_row (&destPR, dest_row, x1, row, (x2 - x1));
gimp_pixel_rgn_set_row (&destPR, dest_row, x1, row, x2 - x1);
if ((row % 10) == 0)
gimp_progress_update ((double) row / (double) (y2 - y1));
......@@ -229,6 +211,6 @@ semiflatten (GimpDrawable *drawable)
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
free (src_row);
free (dest_row);
g_free (src_row);
g_free (dest_row);
}
......@@ -103,17 +103,19 @@ make_default_dialog(const gchar *title)
data->apply_cb = NULL;
data->cancel_cb = NULL;
data->dialog = dialog = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(dialog), title);
if (title)
gtk_window_set_title(GTK_WINDOW(dialog), title);
g_signal_connect(G_OBJECT(dialog), "delete_event",
G_CALLBACK(dialog_destroy), (gpointer) data);
/* Action area */
gtk_container_set_border_width(GTK_CONTAINER(
GTK_DIALOG(dialog)->action_area), 2);
GTK_DIALOG(dialog)->action_area), 12);
gtk_box_set_homogeneous(GTK_BOX(GTK_DIALOG(dialog)->action_area), FALSE);
hbbox = gtk_hbutton_box_new();
gtk_box_set_spacing(GTK_BOX(hbbox), 4);
gtk_box_set_spacing(GTK_BOX(hbbox), 6);
gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->action_area), hbbox, FALSE,
FALSE, 0);
gtk_widget_show (hbbox);
......
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
* 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
......@@ -131,53 +131,62 @@ do_file_save_as_dialog(void)
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *error;
GtkWidget *filename;
} FileErrorDialog_t;
GtkWidget *label;
} Alert_t;
static FileErrorDialog_t*
create_file_error_dialog()
Alert_t*
create_alert(const gchar *stock_id)
{
FileErrorDialog_t *file_dialog = g_new(FileErrorDialog_t, 1);
Alert_t *alert = g_new(Alert_t, 1);
DefaultDialog_t *dialog;
GtkWidget *table, *hbox;
GtkWidget *hbox;
GtkWidget *image;
file_dialog->dialog = dialog = make_default_dialog(_("Error"));
alert->dialog = dialog = make_default_dialog("");
default_dialog_hide_apply_button(dialog);
default_dialog_hide_cancel_button(dialog);
hbox = gtk_hbox_new(FALSE, 10);
hbox = gtk_hbox_new(FALSE, 12);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), hbox,
TRUE, TRUE, 10);
gtk_widget_show(hbox);
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_DIALOG);
gtk_container_add(GTK_CONTAINER(hbox), image);
gtk_widget_show(image);
table = gtk_table_new(2, 1, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_widget_show(table);
alert->label = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(alert->label), 0.0, 0.0);
gtk_container_add(GTK_CONTAINER(hbox), alert->label);
gtk_widget_show(alert->label);
file_dialog->error = create_label_in_table(table, 0, 0, "");
file_dialog->filename = create_label_in_table(table, 1, 0, "");
return alert;
}
void
alert_set_text(Alert_t *alert, const char *primary_text,
const char *secondary_text)
{
gchar *text;
text =
g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
primary_text, secondary_text);
gtk_label_set_markup(GTK_LABEL(alert->label), text);
return file_dialog;
g_free(text);
}
void
do_file_error_dialog(const char *error, const char *filename)
{
static FileErrorDialog_t *dialog;
if (!dialog)
dialog = create_file_error_dialog();
static Alert_t *alert;
if (!alert)
alert = create_alert(GTK_STOCK_DIALOG_ERROR);
gtk_label_set_text(GTK_LABEL(dialog->error), error);
gtk_label_set_text(GTK_LABEL(dialog->filename), filename);
alert_set_text(alert, error, filename);
default_dialog_show(dialog->dialog);
default_dialog_show(alert->dialog);
}
......@@ -1301,6 +1301,12 @@ factory_select_all(void)
return select_all_command_new(_shapes);
}
static Command_t*
factory_deselect_all(void)
{
return unselect_all_command_new(_shapes, NULL);
}
static Command_t*
factory_clear(void)
{
......@@ -1470,6 +1476,7 @@ dialog(GimpDrawable *drawable)
menu_set_copy_command(menu, factory_copy);
menu_set_paste_command(menu, factory_paste);
menu_set_select_all_command(menu, factory_select_all);
menu_set_deselect_all_command(menu, factory_deselect_all);
menu_set_clear_command(menu, factory_clear);
menu_set_edit_erea_info_command(menu, factory_edit);
menu_set_area_list_command(menu, factory_toggle_area_list);
......
......@@ -83,11 +83,12 @@ menu_set_zoom_sensitivity(gint factor)
void
menu_shapes_selected(gint count)
{
gint sensitive = (count > 0);
gboolean sensitive = (count > 0);
gtk_widget_set_sensitive(_menu.cut, sensitive);
gtk_widget_set_sensitive(_menu.copy, sensitive);
gtk_widget_set_sensitive(_menu.clear, sensitive);
gtk_widget_set_sensitive(_menu.edit, sensitive);
gtk_widget_set_sensitive(_menu.deselect_all, sensitive);
}
static void
......@@ -182,18 +183,17 @@ 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;
make_item_with_image(file_menu, GTK_STOCK_OPEN, menu_command,
&_menu.cmd_open);
make_item_with_image(file_menu, GTK_STOCK_SAVE, menu_command,
&_menu.cmd_save);
make_item_with_image(file_menu, GTK_STOCK_SAVE_AS, menu_command,
&_menu.cmd_save_as);
make_separator(file_menu);
make_item_with_image(file_menu, GTK_STOCK_PREFERENCES, menu_command,
&_menu.cmd_preferences);
item = make_item_with_image(file_menu, GTK_STOCK_SAVE_AS, menu_command,
&_menu.cmd_save_as);
add_accelerator(item, 'S', GDK_SHIFT_MASK|GDK_CONTROL_MASK);
make_separator(file_menu);
make_item_with_image(file_menu, GTK_STOCK_CLOSE, menu_command,
&_menu.cmd_close);
......@@ -231,7 +231,7 @@ command_list_changed(Command_t *command, gpointer data)
_menu.redo = insert_item_with_label(_menu.edit_menu, 2, scratch,
menu_command, &_menu.cmd_redo);
g_free (scratch);
add_accelerator(_menu.redo, 'R', GDK_CONTROL_MASK);
add_accelerator(_menu.redo, 'Z', GDK_SHIFT_MASK|GDK_CONTROL_MASK);
gtk_widget_set_sensitive(_menu.redo, (command != NULL));
icon = gtk_image_new_from_stock(GTK_STOCK_REDO, GTK_ICON_SIZE_MENU);
......@@ -267,17 +267,24 @@ make_edit_menu(GtkWidget *menu_bar)
&_menu.cmd_copy);
paste = make_item_with_image(edit_menu, GTK_STOCK_PASTE, menu_command,
&_menu.cmd_paste);
add_accelerator(paste, 'V', GDK_CONTROL_MASK);
gtk_widget_set_sensitive(paste, FALSE);
_menu.clear = make_item_with_image(edit_menu, GTK_STOCK_CLEAR, menu_command,
&_menu.cmd_clear);
add_accelerator(_menu.clear, 'K', GDK_CONTROL_MASK);
make_separator(edit_menu);
item = make_item_with_label(edit_menu, _("Select _All"), menu_command,
&_menu.cmd_select_all);
add_accelerator(item, 'A', GDK_CONTROL_MASK);
_menu.deselect_all = make_item_with_label(edit_menu, _("Deselect _All"),
menu_command,
&_menu.cmd_deselect_all);
add_accelerator(_menu.deselect_all, 'A', GDK_SHIFT_MASK|GDK_CONTROL_MASK);
make_separator(edit_menu);
_menu.clear = make_item_with_image(edit_menu, GTK_STOCK_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);
make_separator(edit_menu);
make_item_with_image(edit_menu, GTK_STOCK_PREFERENCES, menu_command,
&_menu.cmd_preferences);
paste_buffer_add_add_cb(paste_buffer_added, (gpointer) paste);
paste_buffer_add_remove_cb(paste_buffer_removed, (gpointer) paste);
......@@ -374,16 +381,16 @@ make_mapping_menu(GtkWidget *menu_bar)
}
static void
make_goodies_menu(GtkWidget *menu_bar)
make_tools_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 *tools_menu = make_menu_bar_item(menu_bar, _("_Tools"));
_menu.grid = make_check_item(tools_menu, _("Grid"), menu_grid, NULL);
make_item_with_label(tools_menu, _("Grid Settings..."), menu_command,
&_menu.cmd_grid_settings);
make_separator(goodies_menu);
make_item_with_label(goodies_menu, _("Use GIMP Guides..."), menu_command,
make_separator(tools_menu);
make_item_with_label(tools_menu, _("Use GIMP Guides..."), menu_command,
&_menu.cmd_use_gimp_guides);
make_item_with_label(goodies_menu, _("Create Guides..."), menu_command,
make_item_with_label(tools_menu, _("Create Guides..."), menu_command,
&_menu.cmd_create_guides);
}
......@@ -411,7 +418,7 @@ make_menu(GtkWidget *main_vbox, GtkWidget *window)
make_edit_menu(menu_bar);
make_view_menu(menu_bar);
make_mapping_menu(menu_bar);
make_goodies_menu(menu_bar);
make_tools_menu(menu_bar);
make_help_menu(menu_bar);
menu_shapes_selected(0);
......
......@@ -36,6 +36,7 @@ typedef struct {
GtkWidget *copy;
GtkWidget *clear;
GtkWidget *edit;
GtkWidget *deselect_all;
GtkWidget *arrow;
GtkWidget *fuzzy_select;
GtkWidget *rectangle;
......@@ -63,6 +64,7 @@ typedef struct {
CommandFactory_t cmd_copy;
CommandFactory_t cmd_paste;
CommandFactory_t cmd_select_all;
CommandFactory_t cmd_deselect_all;
CommandFactory_t cmd_clear;
CommandFactory_t cmd_edit_area_info;
......@@ -106,6 +108,8 @@ typedef struct {
((menu)->cmd_paste = (command))
#define menu_set_select_all_command(menu, command) \
((menu)->cmd_select_all = (command))
#define menu_set_deselect_all_command(menu, command) \
((menu)->cmd_deselect_all = (command))
#define menu_set_clear_command(menu, command) \
((menu)->cmd_clear = (command))
#define menu_set_edit_erea_info_command(menu, command) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment