Code clean-up, removing use of deprecated GtkCList widget

This commit is contained in:
Maurits Rijk 2003-01-01 13:23:47 +00:00
parent 0f2f38e20e
commit 9897f388ae
20 changed files with 394 additions and 323 deletions

View File

@ -1,3 +1,18 @@
2003-01-01 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/imagemap/imap_about.c
* plug-ins/imagemap/imap_file.c
* plug-ins/imagemap/imap_grid.c
* plug-ins/imagemap/imap_main.c
* plug-ins/imagemap/imap_menu.[ch]
* plug-ins/imagemap/imap_polygon.[ch]
* plug-ins/imagemap/imap_preview.c
* plug-ins/imagemap/imap_stock.[ch]
* plug-ins/imagemap/imap_edit_area_info.[ch]
* plug-ins/imagemap/imap_statusbar.[ch]
* plug-ins/imagemap/imap_cmd_copy.[ch]: removed use of deprecated GTK
widgets and routines plus some code clean-up.
2003-01-01 Tor Lillqvist <tml@iki.fi> 2003-01-01 Tor Lillqvist <tml@iki.fi>
* modules/Makefile.am: On Win32, use -no-undefined, and add * modules/Makefile.am: On Win32, use -no-undefined, and add

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -41,7 +41,7 @@ do_about_dialog(void)
default_dialog_hide_help_button(dialog); default_dialog_hide_help_button(dialog);
default_dialog_set_label(dialog, _("Imagemap plug-in 2.0")); default_dialog_set_label(dialog, _("Imagemap plug-in 2.0"));
default_dialog_set_label( default_dialog_set_label(
dialog, _("Copyright(c) 1999-2002 by Maurits Rijk")); dialog, _("Copyright(c) 1999-2003 by Maurits Rijk"));
default_dialog_set_label(dialog, _("lpeek.mrijk@consunet.nl")); default_dialog_set_label(dialog, _("lpeek.mrijk@consunet.nl"));
default_dialog_set_label( default_dialog_set_label(
dialog, _(" Released under the GNU General Public License ")); dialog, _(" Released under the GNU General Public License "));

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -23,11 +23,6 @@
#include "config.h" #include "config.h"
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "imap_cmd_copy.h" #include "imap_cmd_copy.h"

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * 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 * 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 * it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,10 +26,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -42,7 +38,7 @@
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
static gint callback_lock; static gboolean callback_lock;
static gchar* static gchar*
@ -105,8 +101,9 @@ set_url(GtkWidget *widget, AreaInfoDialog_t *param, const gchar *prefix)
p = url; p = url;
} }
} }
gtk_entry_set_text(GTK_ENTRY(param->url), prefix); p = g_strconcat(prefix, p, NULL);
gtk_entry_append_text(GTK_ENTRY(param->url), p); gtk_entry_set_text(GTK_ENTRY(param->url), p);
g_free(p);
g_free(url); g_free(url);
} }
} }

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,6 +29,7 @@
#include "imap_default_dialog.h" #include "imap_default_dialog.h"
#include "imap_file.h" #include "imap_file.h"
#include "imap_main.h" #include "imap_main.h"
#include "imap_misc.h"
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
@ -119,55 +120,6 @@ do_file_save_as_dialog(void)
gtk_widget_show(dialog); gtk_widget_show(dialog);
} }
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *label;
} Alert_t;
Alert_t*
create_alert(const gchar *stock_id)
{
Alert_t *alert = g_new(Alert_t, 1);
DefaultDialog_t *dialog;
GtkWidget *hbox;
GtkWidget *image;
alert->dialog = dialog = make_default_dialog("");
default_dialog_hide_apply_button(dialog);
default_dialog_hide_cancel_button(dialog);
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(stock_id, GTK_ICON_SIZE_DIALOG);
gtk_container_add(GTK_CONTAINER(hbox), image);
gtk_widget_show(image);
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);
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);
g_free(text);
}
void void
do_file_error_dialog(const char *error, const char *filename) do_file_error_dialog(const char *error, const char *filename)
{ {

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -364,6 +364,7 @@ draw_grid(GtkWidget *preview)
if (!grid_gc) { if (!grid_gc) {
grid_gc = gdk_gc_new(preview->window); grid_gc = gdk_gc_new(preview->window);
gdk_gc_set_line_attributes(grid_gc, 1, GDK_LINE_ON_OFF_DASH, gdk_gc_set_line_attributes(grid_gc, 1, GDK_LINE_ON_OFF_DASH,
GDK_CAP_BUTT, GDK_JOIN_BEVEL); GDK_CAP_BUTT, GDK_JOIN_BEVEL);
} }

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -64,6 +64,7 @@
#include "imap_grid.h" #include "imap_grid.h"
#include "imap_main.h" #include "imap_main.h"
#include "imap_menu.h" #include "imap_menu.h"
#include "imap_misc.h"
#include "imap_object.h" #include "imap_object.h"
#include "imap_polygon.h" #include "imap_polygon.h"
#include "imap_popup.h" #include "imap_popup.h"
@ -469,7 +470,7 @@ fuzzy_select_on_button_press(GtkWidget *widget, GdkEventButton *event,
add_shape(object); add_shape(object);
x0 = gimp_path_get_point_at_dist(image_ID, 0.0, &y0, &grad0); x0 = gimp_path_get_point_at_dist(image_ID, 0.0, &y0, &grad0);
polygon->points = g_list_append(NULL, new_point(x0, y0)); polygon_append_point(polygon, x0, y0);
for (distance = 1.0;; distance += 1.0) { for (distance = 1.0;; distance += 1.0) {
gint x1, y1 = -1; gint x1, y1 = -1;
@ -490,8 +491,7 @@ fuzzy_select_on_button_press(GtkWidget *widget, GdkEventButton *event,
diff = grad1; diff = grad1;
if (fabs(diff) > 0.1) { if (fabs(diff) > 0.1) {
polygon->points = g_list_append(polygon->points, polygon_append_point(polygon, x1, y1);
new_point(x1, y1));
grad0 = grad1; grad0 = grad1;
} }
x0 = x1; x0 = x1;
@ -748,18 +748,15 @@ clear_map_info(void)
static void static void
do_data_changed_dialog(void (*continue_cb)(gpointer), gpointer param) do_data_changed_dialog(void (*continue_cb)(gpointer), gpointer param)
{ {
static DefaultDialog_t *dialog; static Alert_t *alert;
if (!dialog) { if (!alert) {
dialog = make_default_dialog(_("Data changed")); alert = create_confirm_alert(GTK_STOCK_DIALOG_WARNING);
default_dialog_hide_apply_button(dialog); alert_set_text(alert, _("Some data has been changed!"),
default_dialog_set_label( _("Do you really want to discard your changes?"));
dialog,
_("Some data has been changed.\n"
"Do you really want to discard your changes?"));
} }
default_dialog_set_ok_cb(dialog, continue_cb, param); default_dialog_set_ok_cb(alert->dialog, continue_cb, param);
default_dialog_show(dialog); default_dialog_show(alert->dialog);
} }
static void static void
@ -990,21 +987,16 @@ resize_image_cancel_cb(gpointer data)
static void static void
do_image_size_changed_dialog(void) do_image_size_changed_dialog(void)
{ {
static DefaultDialog_t *dialog; static Alert_t *alert;
if (!dialog) { if (!alert) {
dialog = make_default_dialog( _("Image size changed")); alert = create_confirm_alert(GTK_STOCK_DIALOG_WARNING);
default_dialog_hide_apply_button(dialog); alert_set_text(alert, _("Image size has changed."),
default_dialog_set_label( _("Resize area's?"));
dialog,
_("Image size has changed.\n"
"Resize Area's?"));
default_dialog_set_ok_cb(dialog, resize_image_ok_cb, NULL);
default_dialog_set_cancel_cb(dialog, resize_image_cancel_cb, NULL);
} }
default_dialog_show(dialog); default_dialog_set_ok_cb(alert->dialog, resize_image_ok_cb, NULL);
default_dialog_set_cancel_cb(alert->dialog, resize_image_cancel_cb, NULL);
default_dialog_show(alert->dialog);
} }
static void static void
@ -1056,10 +1048,11 @@ toggle_area_list(void)
selection_toggle_visibility(_selection); selection_toggle_visibility(_selection);
} }
static void static gboolean
close_callback(GtkWidget *widget, gpointer data) close_callback(GtkWidget *widget, gpointer data)
{ {
gtk_main_quit(); do_quit();
return TRUE;
} }
static gboolean static gboolean
@ -1442,7 +1435,7 @@ dialog(GimpDrawable *drawable)
gimp_help_connect (dlg, gimp_standard_help_func, "filters/imagemap.html"); gimp_help_connect (dlg, gimp_standard_help_func, "filters/imagemap.html");
gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_MOUSE); gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_MOUSE);
g_signal_connect(G_OBJECT(dlg), "destroy", g_signal_connect(G_OBJECT(dlg), "delete_event",
G_CALLBACK(close_callback), NULL); G_CALLBACK(close_callback), NULL);
g_signal_connect(G_OBJECT(dlg), "key_press_event", g_signal_connect(G_OBJECT(dlg), "key_press_event",
G_CALLBACK(key_press_cb), NULL); G_CALLBACK(key_press_cb), NULL);

View File

@ -183,6 +183,7 @@ make_file_menu(GtkWidget *menu_bar)
_menu.file_menu = file_menu; _menu.file_menu = file_menu;
make_item_with_image(file_menu, GTK_STOCK_OPEN, menu_command, make_item_with_image(file_menu, GTK_STOCK_OPEN, menu_command,
&_menu.cmd_open); &_menu.cmd_open);
_menu.open_recent = make_sub_menu(file_menu, _("Open Recent"));
make_item_with_image(file_menu, GTK_STOCK_SAVE, menu_command, make_item_with_image(file_menu, GTK_STOCK_SAVE, menu_command,
&_menu.cmd_save); &_menu.cmd_save);
item = make_item_with_image(file_menu, GTK_STOCK_SAVE_AS, menu_command, item = make_item_with_image(file_menu, GTK_STOCK_SAVE_AS, menu_command,
@ -424,11 +425,13 @@ void
menu_build_mru_items(MRU_t *mru) menu_build_mru_items(MRU_t *mru)
{ {
GList *p; GList *p;
gint position = 7; /* Position of 'Close' entry */ gint position = 0;
int i; int i;
if (_menu.nr_off_mru_items) { if (_menu.nr_off_mru_items) {
GList *children = gtk_container_get_children(GTK_CONTAINER(_menu.file_menu)); GList *children;
children = gtk_container_get_children(GTK_CONTAINER(_menu.open_recent));
p = g_list_nth(children, position); p = g_list_nth(children, position);
for (i = 0; i < _menu.nr_off_mru_items; i++, p = p->next) { for (i = 0; i < _menu.nr_off_mru_items; i++, p = p->next) {
@ -439,7 +442,7 @@ menu_build_mru_items(MRU_t *mru)
i = 0; i = 0;
for (p = mru->list; p; p = p->next, i++) { for (p = mru->list; p; p = p->next, i++) {
GtkWidget *item = insert_item_with_label(_menu.file_menu, position++, GtkWidget *item = insert_item_with_label(_menu.open_recent, position++,
(gchar*) p->data, (gchar*) p->data,
menu_mru, p->data); menu_mru, p->data);
if (i < 9) { if (i < 9) {
@ -447,7 +450,6 @@ menu_build_mru_items(MRU_t *mru)
add_accelerator(item, accelerator_key, GDK_CONTROL_MASK); add_accelerator(item, accelerator_key, GDK_CONTROL_MASK);
} }
} }
insert_separator(_menu.file_menu, position);
_menu.nr_off_mru_items = i + 1; _menu.nr_off_mru_items = i + 1;
} }

View File

@ -28,60 +28,61 @@
#include "imap_mru.h" #include "imap_mru.h"
typedef struct { typedef struct {
GtkWidget *file_menu; GtkWidget *file_menu;
GtkWidget *edit_menu; GtkWidget *edit_menu;
GtkWidget *undo; GtkWidget *open_recent;
GtkWidget *redo; GtkWidget *undo;
GtkWidget *cut; GtkWidget *redo;
GtkWidget *copy; GtkWidget *cut;
GtkWidget *clear; GtkWidget *copy;
GtkWidget *edit; GtkWidget *clear;
GtkWidget *deselect_all; GtkWidget *edit;
GtkWidget *arrow; GtkWidget *deselect_all;
GtkWidget *fuzzy_select; GtkWidget *arrow;
GtkWidget *rectangle; GtkWidget *fuzzy_select;
GtkWidget *circle; GtkWidget *rectangle;
GtkWidget *polygon; GtkWidget *circle;
GtkWidget *grid; GtkWidget *polygon;
GtkWidget *gray; GtkWidget *grid;
GtkWidget *color; GtkWidget *gray;
GtkWidget *zoom[8]; GtkWidget *color;
GtkWidget *zoom_in; GtkWidget *zoom[8];
GtkWidget *zoom_out; GtkWidget *zoom_in;
GtkWidget *zoom_out;
gint nr_off_mru_items;
gint nr_off_mru_items; CommandFactory_t cmd_open;
CommandFactory_t cmd_save;
CommandFactory_t cmd_open; CommandFactory_t cmd_save_as;
CommandFactory_t cmd_save; CommandFactory_t cmd_preferences;
CommandFactory_t cmd_save_as; CommandFactory_t cmd_close;
CommandFactory_t cmd_preferences; CommandFactory_t cmd_quit;
CommandFactory_t cmd_close;
CommandFactory_t cmd_quit; CommandFactory_t cmd_undo;
CommandFactory_t cmd_redo;
CommandFactory_t cmd_undo; CommandFactory_t cmd_cut;
CommandFactory_t cmd_redo; CommandFactory_t cmd_copy;
CommandFactory_t cmd_cut; CommandFactory_t cmd_paste;
CommandFactory_t cmd_copy; CommandFactory_t cmd_select_all;
CommandFactory_t cmd_paste; CommandFactory_t cmd_deselect_all;
CommandFactory_t cmd_select_all; CommandFactory_t cmd_clear;
CommandFactory_t cmd_deselect_all; CommandFactory_t cmd_edit_area_info;
CommandFactory_t cmd_clear;
CommandFactory_t cmd_edit_area_info; CommandFactory_t cmd_area_list;
CommandFactory_t cmd_source;
CommandFactory_t cmd_area_list; CommandFactory_t cmd_color;
CommandFactory_t cmd_source; CommandFactory_t cmd_gray;
CommandFactory_t cmd_color; CommandFactory_t cmd_zoom_in;
CommandFactory_t cmd_gray; CommandFactory_t cmd_zoom_out;
CommandFactory_t cmd_zoom_in;
CommandFactory_t cmd_zoom_out; CommandFactory_t cmd_edit_map_info;
CommandFactory_t cmd_edit_map_info; CommandFactory_t cmd_grid_settings;
CommandFactory_t cmd_create_guides;
CommandFactory_t cmd_grid_settings; CommandFactory_t cmd_use_gimp_guides;
CommandFactory_t cmd_create_guides;
CommandFactory_t cmd_use_gimp_guides; CommandFactory_t cmd_about;
CommandFactory_t cmd_about;
} Menu_t; } Menu_t;
#define menu_set_open_command(menu, command) \ #define menu_set_open_command(menu, command) \

View File

@ -70,6 +70,64 @@ make_toolbar_toggle_icon(GtkWidget *toolbar, const gchar *stock_id,
GTK_SIGNAL_FUNC(callback), udata); GTK_SIGNAL_FUNC(callback), udata);
} }
static Alert_t*
create_base_alert(const gchar *stock_id)
{
Alert_t *alert = g_new(Alert_t, 1);
DefaultDialog_t *dialog;
GtkWidget *hbox;
GtkWidget *image;
alert->dialog = dialog = make_default_dialog("");
default_dialog_hide_apply_button(dialog);
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(stock_id, GTK_ICON_SIZE_DIALOG);
gtk_container_add(GTK_CONTAINER(hbox), image);
gtk_widget_show(image);
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);
return alert;
}
Alert_t*
create_alert(const gchar *stock_id)
{
Alert_t *alert = create_base_alert(stock_id);
default_dialog_hide_cancel_button(alert->dialog);
return alert;
}
Alert_t*
create_confirm_alert(const gchar *stock_id)
{
return create_base_alert(stock_id);
}
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);
g_free(text);
}
#define SASH_SIZE 8 #define SASH_SIZE 8
static gint _sash_size = SASH_SIZE; static gint _sash_size = SASH_SIZE;

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -44,5 +44,15 @@ void set_sash_size(gboolean double_size);
void draw_sash(GdkWindow *window, GdkGC *gc, gint x, gint y); void draw_sash(GdkWindow *window, GdkGC *gc, gint x, gint y);
gboolean near_sash(gint sash_x, gint sash_y, gint x, gint y); gboolean near_sash(gint sash_x, gint sash_y, gint x, gint y);
typedef struct {
DefaultDialog_t *dialog;
GtkWidget *label;
} Alert_t;
Alert_t *create_alert(const gchar *stock_id);
Alert_t *create_confirm_alert(const gchar *stock_id);
void alert_set_text(Alert_t *alert, const char *primary_text,
const char *secondary_text);
#endif /* _IMAP_MISC_H */ #endif /* _IMAP_MISC_H */

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,11 +26,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "imap_cmd_delete_point.h" #include "imap_cmd_delete_point.h"
@ -142,8 +137,7 @@ polygon_clone(Object_t *obj)
clone->points = NULL; clone->points = NULL;
for (p = polygon->points; p; p = p->next) { for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data; GdkPoint *point = (GdkPoint*) p->data;
clone->points = g_list_append(clone->points, polygon_append_point(clone, point->x, point->y);
new_point(point->x, point->y));
} }
return &clone->obj; return &clone->obj;
} }
@ -158,8 +152,7 @@ polygon_assign(Object_t *obj, Object_t *des)
polygon_free_list(des_polygon); polygon_free_list(des_polygon);
for (p = src_polygon->points; p; p = p->next) { for (p = src_polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data; GdkPoint *point = (GdkPoint*) p->data;
des_polygon->points = g_list_append(des_polygon->points, polygon_append_point(des_polygon, point->x, point->y);
new_point(point->x, point->y));
} }
} }
@ -298,7 +291,8 @@ polygon_move(Object_t *obj, gint dx, gint dy)
typedef struct { typedef struct {
Object_t *obj; Object_t *obj;
GtkWidget *list; GtkListStore *store;
GtkTreeSelection *selection;
GtkWidget *x; GtkWidget *x;
GtkWidget *y; GtkWidget *y;
GtkWidget *update; GtkWidget *update;
@ -310,64 +304,98 @@ typedef struct {
} PolygonProperties_t; } PolygonProperties_t;
static void static void
select_row_cb(GtkWidget *widget, gint row, gint column, GdkEventButton *event, select_row_cb(GtkTreeSelection *selection, PolygonProperties_t *data)
PolygonProperties_t *data)
{ {
gchar *text; GtkTreeIter iter;
data->selected_row = row; GtkTreeModel *model;
_sash_point = g_list_nth(ObjectToPolygon(data->obj)->points, row)->data; if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
GdkPoint *point;
gtk_clist_get_text(GTK_CLIST(data->list), row, 0, &text); gtk_tree_model_get (model, &iter, 0, &point, -1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->x), atoi(text));
gtk_clist_get_text(GTK_CLIST(data->list), row, 1, &text); _sash_point = point;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->y), atoi(text));
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 static void
update_button_clicked(GtkWidget *widget, PolygonProperties_t *data) update_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{ {
gtk_clist_set_text(GTK_CLIST(data->list), data->selected_row, 0, GtkTreeIter iter;
gtk_entry_get_text(GTK_ENTRY(data->x))); GtkTreeModel *model = GTK_TREE_MODEL(data->store);
gtk_clist_set_text(GTK_CLIST(data->list), data->selected_row, 1,
gtk_entry_get_text(GTK_ENTRY(data->y))); 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 static void
set_buttons_sensitivity(PolygonProperties_t *data) set_buttons_sensitivity(PolygonProperties_t *data)
{ {
gint rows = GTK_CLIST(data->list)->rows; gint rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(data->store),
gint sensitive = (rows != MAX_POLYGON_POINTS) && (rows > 2); NULL);
gtk_widget_set_sensitive(data->insert, sensitive); gtk_widget_set_sensitive(data->insert, rows != MAX_POLYGON_POINTS);
gtk_widget_set_sensitive(data->append, sensitive); gtk_widget_set_sensitive(data->append, rows != MAX_POLYGON_POINTS);
gtk_widget_set_sensitive(data->remove, rows > 2);
} }
static void static void
insert_button_clicked(GtkWidget *widget, PolygonProperties_t *data) insert_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{ {
const gchar *text[2]; GtkTreeIter iter;
text[0] = gtk_entry_get_text(GTK_ENTRY(data->x)); GtkTreeModel *model = GTK_TREE_MODEL(data->store);
text[1] = gtk_entry_get_text(GTK_ENTRY(data->y));
gtk_clist_insert(GTK_CLIST(data->list), data->selected_row, (gchar **) text); if (gtk_tree_selection_get_selected (data->selection, &model, &iter)) {
set_buttons_sensitivity(data); 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 static void
append_button_clicked(GtkWidget *widget, PolygonProperties_t *data) append_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{ {
const gchar *text[2]; gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->x));
text[0] = gtk_entry_get_text(GTK_ENTRY(data->x)); gint y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->y));
text[1] = gtk_entry_get_text(GTK_ENTRY(data->y));
gtk_clist_append(GTK_CLIST(data->list), (gchar **) text); polygon_append_point(ObjectToPolygon(data->obj), x, y);
set_buttons_sensitivity(data); polygon_fill_info_tab(data->obj, data);
} }
static void static void
remove_button_clicked(GtkWidget *widget, PolygonProperties_t *data) remove_button_clicked(GtkWidget *widget, PolygonProperties_t *data)
{ {
gtk_clist_remove(GTK_CLIST(data->list), data->selected_row); GtkTreeIter iter;
set_buttons_sensitivity(data); 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 static void
@ -388,47 +416,80 @@ y_changed_cb(GtkWidget *widget, gpointer data)
edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog); 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(G_OBJECT(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(G_OBJECT(cell), "text", scratch, "xalign", 1.0, NULL);
}
static gpointer static gpointer
polygon_create_info_widget(GtkWidget *frame) polygon_create_info_widget(GtkWidget *frame)
{ {
PolygonProperties_t *props = g_new(PolygonProperties_t, 1); PolygonProperties_t *props = g_new(PolygonProperties_t, 1);
GtkWidget *hbox, *swin, *table, *label; GtkWidget *hbox, *swin, *table, *label;
GtkWidget *list; GtkWidget *view;
gint max_width = get_image_width(); gint max_width = get_image_width();
gint max_height = get_image_height(); gint max_height = get_image_height();
gchar *titles[] = {N_("x (pixels)"), N_("y (pixels)")}; GtkCellRenderer *renderer;
gint i; GtkTreeViewColumn *column;
hbox = gtk_hbox_new(FALSE, 1); hbox = gtk_hbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(frame), hbox); gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox); gtk_widget_show(hbox);
for (i = 0; i < 2; i++)
titles[i] = gettext(titles[i]);
props->list = list = gtk_clist_new_with_titles(2, titles);
gtk_clist_column_titles_passive(GTK_CLIST(list));
swin = gtk_scrolled_window_new(NULL, NULL); swin = gtk_scrolled_window_new(NULL, NULL);
gtk_container_set_border_width(GTK_CONTAINER(swin), 10); gtk_container_set_border_width(GTK_CONTAINER(swin), 10);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); 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_box_pack_start(GTK_BOX(hbox), swin, FALSE, FALSE, FALSE);
gtk_widget_show(swin); gtk_widget_show(swin);
gtk_clist_set_shadow_type(GTK_CLIST(list), GTK_SHADOW_ETCHED_IN); props->store = gtk_list_store_new (1, G_TYPE_POINTER);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), list); view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (props->store));
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
g_object_unref (G_OBJECT (props->store));
gtk_widget_show (view);
gtk_clist_set_column_width(GTK_CLIST(list), 0, 48); renderer = gtk_cell_renderer_text_new ();
gtk_clist_set_column_width(GTK_CLIST(list), 1, 48); column = gtk_tree_view_column_new_with_attributes (_("x (pixels)"),
gtk_clist_set_column_justification(GTK_CLIST(list), 0, GTK_JUSTIFY_RIGHT); renderer,
gtk_clist_set_column_justification(GTK_CLIST(list), 1, GTK_JUSTIFY_RIGHT); 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);
gtk_signal_connect(GTK_OBJECT(list), "select_row", renderer = gtk_cell_renderer_text_new ();
GTK_SIGNAL_FUNC(select_row_cb), props); column = gtk_tree_view_column_new_with_attributes (_("y (pixels)"),
gtk_clist_set_selection_mode(GTK_CLIST(list), GTK_SELECTION_SINGLE); renderer,
gtk_widget_show(list); 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);
table = gtk_table_new(6, 3, FALSE); table = gtk_table_new(6, 3, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_container_set_border_width(GTK_CONTAINER(table), 10);
@ -440,49 +501,54 @@ polygon_create_info_widget(GtkWidget *frame)
label = create_label_in_table(table, 0, 0, "_x:"); label = create_label_in_table(table, 0, 0, "_x:");
props->x = create_spin_button_in_table(table, label, 0, 1, 1, 0, props->x = create_spin_button_in_table(table, label, 0, 1, 1, 0,
max_width - 1); max_width - 1);
gtk_signal_connect(GTK_OBJECT(props->x), "changed", g_signal_connect(G_OBJECT(props->x), "changed",
(GtkSignalFunc) x_changed_cb, (gpointer) props); G_CALLBACK(x_changed_cb), (gpointer) props);
gtk_widget_set_usize(props->x, 64, -1); gtk_widget_set_size_request(props->x, 64, -1);
create_label_in_table(table, 0, 2, _("pixels")); create_label_in_table(table, 0, 2, _("pixels"));
label = create_label_in_table(table, 1, 0, "_y:"); label = create_label_in_table(table, 1, 0, "_y:");
props->y = create_spin_button_in_table(table, label, 1, 1, 1, 0, props->y = create_spin_button_in_table(table, label, 1, 1, 1, 0,
max_height - 1); max_height - 1);
gtk_signal_connect(GTK_OBJECT(props->y), "changed", g_signal_connect(G_OBJECT(props->y), "changed",
(GtkSignalFunc) y_changed_cb, (gpointer) props); G_CALLBACK(y_changed_cb), (gpointer) props);
gtk_widget_set_usize(props->y, 64, -1); gtk_widget_set_size_request(props->y, 64, -1);
create_label_in_table(table, 1, 2, _("pixels")); create_label_in_table(table, 1, 2, _("pixels"));
props->update = gtk_button_new_with_mnemonic(_("_Update")); props->update = gtk_button_new_with_mnemonic(_("_Update"));
gtk_signal_connect(GTK_OBJECT(props->update), "clicked", g_signal_connect(G_OBJECT(props->update), "clicked",
GTK_SIGNAL_FUNC(update_button_clicked), props); G_CALLBACK(update_button_clicked), props);
gtk_table_attach_defaults(GTK_TABLE(table), props->update, 1, 2, 2, 3); gtk_table_attach_defaults(GTK_TABLE(table), props->update, 1, 2, 2, 3);
gtk_widget_show(props->update); gtk_widget_show(props->update);
props->insert = gtk_button_new_with_mnemonic(_("_Insert")); props->insert = gtk_button_new_with_mnemonic(_("_Insert"));
gtk_signal_connect(GTK_OBJECT(props->insert), "clicked", g_signal_connect(G_OBJECT(props->insert), "clicked",
GTK_SIGNAL_FUNC(insert_button_clicked), props); G_CALLBACK(insert_button_clicked), props);
gtk_table_attach_defaults(GTK_TABLE(table), props->insert, 1, 2, 3, 4); gtk_table_attach_defaults(GTK_TABLE(table), props->insert, 1, 2, 3, 4);
gtk_widget_show(props->insert); gtk_widget_show(props->insert);
props->append = gtk_button_new_with_mnemonic(_("A_ppend")); props->append = gtk_button_new_with_mnemonic(_("A_ppend"));
gtk_signal_connect(GTK_OBJECT(props->append), "clicked", g_signal_connect(G_OBJECT(props->append), "clicked",
GTK_SIGNAL_FUNC(append_button_clicked), props); G_CALLBACK(append_button_clicked), props);
gtk_table_attach_defaults(GTK_TABLE(table), props->append, 1, 2, 4, 5); gtk_table_attach_defaults(GTK_TABLE(table), props->append, 1, 2, 4, 5);
gtk_widget_show(props->append); gtk_widget_show(props->append);
props->remove = gtk_button_new_with_mnemonic(_("_Remove")); props->remove = gtk_button_new_with_mnemonic(_("_Remove"));
gtk_signal_connect(GTK_OBJECT(props->remove), "clicked", g_signal_connect(G_OBJECT(props->remove), "clicked",
GTK_SIGNAL_FUNC(remove_button_clicked), props); G_CALLBACK(remove_button_clicked), props);
gtk_table_attach_defaults(GTK_TABLE(table), props->remove, 1, 2, 5, 6); gtk_table_attach_defaults(GTK_TABLE(table), props->remove, 1, 2, 5, 6);
gtk_widget_show(props->remove); gtk_widget_show(props->remove);
props->timeout = 0; 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 (G_OBJECT (props->selection), "changed",
G_CALLBACK (select_row_cb), props);
return props; return props;
} }
static gint static gboolean
update_timeout(gpointer data) update_timeout(gpointer data)
{ {
PolygonProperties_t *props = (PolygonProperties_t*) data; PolygonProperties_t *props = (PolygonProperties_t*) data;
@ -494,14 +560,16 @@ static void
polygon_update_info_widget(Object_t *obj, gpointer data) polygon_update_info_widget(Object_t *obj, gpointer data)
{ {
PolygonProperties_t *props = (PolygonProperties_t*) 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->x), _sash_point->x);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), _sash_point->y); gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), _sash_point->y);
if (props->selected_row != _sash_index) { if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(props->store), &iter,
props->selected_row = _sash_index; NULL, _sash_index)) {
gtk_clist_select_row(GTK_CLIST(props->list), _sash_index, -1); gtk_tree_selection_select_iter(props->selection, &iter);
} }
if (props->timeout) if (props->timeout)
gtk_timeout_remove(props->timeout); gtk_timeout_remove(props->timeout);
props->timeout = gtk_timeout_add(1000, update_timeout, data); props->timeout = gtk_timeout_add(1000, update_timeout, data);
@ -512,25 +580,22 @@ polygon_fill_info_tab(Object_t *obj, gpointer data)
{ {
Polygon_t *polygon = ObjectToPolygon(obj); Polygon_t *polygon = ObjectToPolygon(obj);
PolygonProperties_t *props = (PolygonProperties_t*) data; PolygonProperties_t *props = (PolygonProperties_t*) data;
GtkTreeIter iter;
GList *p; GList *p;
props->obj = obj; props->obj = obj;
gtk_clist_freeze(GTK_CLIST(props->list));
gtk_clist_clear(GTK_CLIST(props->list));
for (p = polygon->points; p; p = p->next) {
GdkPoint *point = (GdkPoint*) p->data;
char x[16], y[16];
char *text[2];
text[0] = x; gtk_list_store_clear(props->store);
text[1] = y;
sprintf(x, "%d", point->x); for (p = polygon->points; p; p = p->next) {
sprintf(y, "%d", point->y); gtk_list_store_append(props->store, &iter);
gtk_clist_append(GTK_CLIST(props->list), text); gtk_list_store_set(props->store, &iter, 0, p->data, -1);
} }
gtk_clist_select_row(GTK_CLIST(props->list), _sash_index, -1);
gtk_clist_thaw(GTK_CLIST(props->list));
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); set_buttons_sensitivity(props);
} }
@ -544,25 +609,7 @@ polygon_set_initial_focus(Object_t *obj, gpointer data)
static void static void
polygon_update(Object_t* obj, gpointer data) polygon_update(Object_t* obj, gpointer data)
{ {
Polygon_t *polygon = ObjectToPolygon(obj); /* Nothing to be done! */
PolygonProperties_t *props = (PolygonProperties_t*) data;
gint rows = GTK_CLIST(props->list)->rows;
int i;
g_list_free(polygon->points);
polygon->points = NULL;
for (i = 0; i < rows; i++) {
gchar *text;
GdkPoint *point = g_new(GdkPoint, 1);
gtk_clist_get_text(GTK_CLIST(props->list), i, 0, &text);
point->x = atoi(text);
gtk_clist_get_text(GTK_CLIST(props->list), i, 1, &text);
point->y = atoi(text);
polygon->points = g_list_append(polygon->points, point);
}
} }
static void static void
@ -609,7 +656,7 @@ polygon_write_ncsa(Object_t *obj, gpointer param, OutputFunc_t output)
output(param, " %d,%d", first->x, first->y); output(param, " %d,%d", first->x, first->y);
} }
static gint _insert_edge; static gboolean _insert_edge;
static gint _insert_x; static gint _insert_x;
static gint _insert_y; static gint _insert_y;
@ -645,7 +692,7 @@ point_near_edge(GdkPoint *first, GdkPoint *second, gint x, gint y)
gint sy = first->y + (gint) (u * (second->y - first->y)) - y; gint sy = first->y + (gint) (u * (second->y - first->y)) - y;
return sx * sx + sy * sy <= 25; /* Fix me! */ return sx * sx + sy * sy <= 25; /* Fix me! */
} }
return 0; return FALSE;
} }
static gint static gint
@ -718,7 +765,7 @@ polygon_factory_finish(Object_t *obj, gint x, gint y)
polygon_remove_last_point(polygon); polygon_remove_last_point(polygon);
return TRUE; return TRUE;
} else { } else {
g_list_append(polygon->points, new_point(x, y)); polygon_append_point(polygon, x, y);
_prev_link = _prev_link->next; _prev_link = _prev_link->next;
} }
return FALSE; return FALSE;
@ -795,3 +842,9 @@ new_point(gint x, gint y)
point->y = y; point->y = y;
return point; 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

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -35,7 +35,9 @@ typedef struct {
Object_t *create_polygon(GList *points); Object_t *create_polygon(GList *points);
ObjectFactory_t *get_polygon_factory(guint state); ObjectFactory_t *get_polygon_factory(guint state);
void polygon_remove_last_point(Polygon_t *polygon); 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); GdkPoint *new_point(gint x, gint y);
#endif /* _IMAP_POLYGON_H */ #endif /* _IMAP_POLYGON_H */

View File

@ -300,9 +300,9 @@ preview_expose(GtkWidget *widget, GdkEventExpose *event)
{ {
Preview_t *data = preview_user_data(widget); Preview_t *data = preview_user_data(widget);
gtk_signal_handler_block(GTK_OBJECT(widget), data->exp_id); g_signal_handler_block(G_OBJECT(widget), data->exp_id);
gtk_widget_draw(widget, (event) ? &event->area : NULL); gtk_widget_draw(widget, (event) ? &event->area : NULL);
gtk_signal_handler_unblock(GTK_OBJECT(widget), data->exp_id ); g_signal_handler_unblock(G_OBJECT(widget), data->exp_id );
draw_grid(widget); draw_grid(widget);
draw_shapes(widget); draw_shapes(widget);
@ -349,7 +349,6 @@ preview_zoom(Preview_t *preview, gint zoom_factor)
{ {
gint pwidth = preview->width * zoom_factor; gint pwidth = preview->width * zoom_factor;
gint pheight = preview->height * zoom_factor; gint pheight = preview->height * zoom_factor;
gtk_preview_size(GTK_PREVIEW(preview->preview), pwidth, pheight); gtk_preview_size(GTK_PREVIEW(preview->preview), pwidth, pheight);
gtk_widget_queue_resize(preview->window); gtk_widget_queue_resize(preview->window);
render_preview(preview->preview, &preview->src_rgn); render_preview(preview->preview, &preview->src_rgn);

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,26 +26,16 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "imap_statusbar.h" #include "imap_statusbar.h"
#include "imap_stock.h"
#include "coord.xpm"
#include "dimension.xpm"
StatusBar_t* StatusBar_t*
make_statusbar(GtkWidget *main_vbox, GtkWidget *window) make_statusbar(GtkWidget *main_vbox, GtkWidget *window)
{ {
StatusBar_t *statusbar = g_new(StatusBar_t, 1); StatusBar_t *statusbar = g_new(StatusBar_t, 1);
GtkWidget *hbox, *iconw; GtkWidget *hbox, *iconw;
GdkPixmap *icon;
GdkBitmap *mask;
GtkStyle *style;
hbox = gtk_hbox_new(FALSE, 1); hbox = gtk_hbox_new(FALSE, 1);
gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0);
@ -58,38 +48,35 @@ make_statusbar(GtkWidget *main_vbox, GtkWidget *window)
gtk_widget_show(statusbar->status); gtk_widget_show(statusbar->status);
/* (x, y) coordinate */ /* (x, y) coordinate */
style = gtk_widget_get_style(window); iconw = gtk_image_new_from_stock(IMAP_STOCK_COORD,
icon = gdk_pixmap_create_from_xpm_d(window->window, &mask, GTK_ICON_SIZE_SMALL_TOOLBAR);
&style->bg[GTK_STATE_NORMAL],
coord_xpm);
iconw = gtk_pixmap_new(icon, mask);
gtk_box_pack_start(GTK_BOX(hbox), iconw, FALSE, FALSE, 10); gtk_box_pack_start(GTK_BOX(hbox), iconw, FALSE, FALSE, 10);
gtk_widget_show(iconw); gtk_widget_show(iconw);
statusbar->xy = gtk_entry_new(); statusbar->xy = gtk_entry_new();
gtk_widget_set_usize(statusbar->xy, 64, -1); gtk_widget_set_size_request(statusbar->xy, 96, -1);
gtk_entry_set_editable(GTK_ENTRY(statusbar->xy), FALSE); gtk_editable_set_editable(GTK_EDITABLE(statusbar->xy), FALSE);
GTK_WIDGET_UNSET_FLAGS(statusbar->xy, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS(statusbar->xy, GTK_CAN_FOCUS);
gtk_box_pack_start(GTK_BOX(hbox), statusbar->xy, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), statusbar->xy, FALSE, FALSE, 0);
gtk_widget_show(statusbar->xy); gtk_widget_show(statusbar->xy);
/* Dimension info */ /* Dimension info */
icon = gdk_pixmap_create_from_xpm_d(window->window, &mask, iconw = gtk_image_new_from_stock(IMAP_STOCK_DIMENSION,
&style->bg[GTK_STATE_NORMAL], GTK_ICON_SIZE_SMALL_TOOLBAR);
dimension_xpm);
iconw = gtk_pixmap_new(icon, mask);
gtk_box_pack_start(GTK_BOX(hbox), iconw, FALSE, FALSE, 10); gtk_box_pack_start(GTK_BOX(hbox), iconw, FALSE, FALSE, 10);
gtk_widget_show(iconw); gtk_widget_show(iconw);
statusbar->dimension = gtk_entry_new(); statusbar->dimension = gtk_entry_new();
gtk_widget_set_usize(statusbar->dimension, 64, -1); gtk_widget_set_size_request(statusbar->dimension, 96, -1);
gtk_entry_set_editable(GTK_ENTRY(statusbar->dimension), FALSE); gtk_editable_set_editable(GTK_EDITABLE(statusbar->dimension), FALSE);
GTK_WIDGET_UNSET_FLAGS(statusbar->dimension, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS(statusbar->dimension, GTK_CAN_FOCUS);
gtk_box_pack_start(GTK_BOX(hbox), statusbar->dimension, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), statusbar->dimension, FALSE, FALSE, 0);
gtk_widget_show(statusbar->dimension); gtk_widget_show(statusbar->dimension);
/* Zoom info */ /* Zoom info */
statusbar->zoom = gtk_statusbar_new(); statusbar->zoom = gtk_statusbar_new();
gtk_widget_set_size_request(statusbar->zoom, 48, -1);
statusbar->zoom_id = gtk_statusbar_get_context_id( statusbar->zoom_id = gtk_statusbar_get_context_id(
GTK_STATUSBAR(statusbar->zoom), "zoom_status"); GTK_STATUSBAR(statusbar->zoom), "zoom_status");
gtk_box_pack_start(GTK_BOX(hbox), statusbar->zoom, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), statusbar->zoom, FALSE, FALSE, 5);

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,18 +27,20 @@
#include "imap_stock.h" #include "imap_stock.h"
#include "arrow.xpm"
#include "circle.xpm"
#include "coord.xpm"
#include "dimension.xpm"
#include "grid.xpm" #include "grid.xpm"
#include "map_info.xpm"
#include "polygon.xpm"
#include "rectangle.xpm"
#include "to_back.xpm" #include "to_back.xpm"
#include "to_front.xpm" #include "to_front.xpm"
#include "map_info.xpm"
#include "arrow.xpm"
#include "rectangle.xpm"
#include "circle.xpm"
#include "polygon.xpm"
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
static GtkStockItem imap_stock_items[] = { static GtkStockItem imap_stock_items[] = {
{IMAP_STOCK_MAP_INFO, N_("Edit Map Info..."), 0, 0, "imap"}, {IMAP_STOCK_MAP_INFO, N_("Edit Map Info..."), 0, 0, "imap"},
{IMAP_STOCK_GRID, N_("Grid"), 0, 0, "imap"}, {IMAP_STOCK_GRID, N_("Grid"), 0, 0, "imap"},
}; };
@ -47,8 +49,8 @@ static void
add_stock_icon(GtkIconFactory *factory, const gchar *stock_id, add_stock_icon(GtkIconFactory *factory, const gchar *stock_id,
const char **xpm_data) const char **xpm_data)
{ {
GtkIconSet *icon_set; GtkIconSet *icon_set;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_xpm_data(xpm_data); pixbuf = gdk_pixbuf_new_from_xpm_data(xpm_data);
icon_set = gtk_icon_set_new_from_pixbuf(pixbuf); icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
@ -60,17 +62,19 @@ add_stock_icon(GtkIconFactory *factory, const gchar *stock_id,
void void
init_stock_icons(void) init_stock_icons(void)
{ {
GtkIconFactory *factory = gtk_icon_factory_new(); GtkIconFactory *factory = gtk_icon_factory_new();
add_stock_icon(factory, IMAP_STOCK_ARROW, (const char**) arrow_xpm);
add_stock_icon(factory, IMAP_STOCK_CIRCLE, (const char**) circle_xpm);
add_stock_icon(factory, IMAP_STOCK_COORD, (const char**) coord_xpm);
add_stock_icon(factory, IMAP_STOCK_DIMENSION, (const char**) dimension_xpm);
add_stock_icon(factory, IMAP_STOCK_GRID, (const char**) grid_xpm);
add_stock_icon(factory, IMAP_STOCK_MAP_INFO, (const char**) map_info_xpm);
add_stock_icon(factory, IMAP_STOCK_POLYGON, (const char**) polygon_xpm);
add_stock_icon(factory, IMAP_STOCK_RECTANGLE, (const char**) rectangle_xpm);
add_stock_icon(factory, IMAP_STOCK_TO_BACK, (const char**) to_back_xpm); add_stock_icon(factory, IMAP_STOCK_TO_BACK, (const char**) to_back_xpm);
add_stock_icon(factory, IMAP_STOCK_TO_FRONT, (const char**) to_front_xpm); add_stock_icon(factory, IMAP_STOCK_TO_FRONT, (const char**) to_front_xpm);
add_stock_icon(factory, IMAP_STOCK_MAP_INFO, (const char**) map_info_xpm);
add_stock_icon(factory, IMAP_STOCK_ARROW, (const char**) arrow_xpm);
add_stock_icon(factory, IMAP_STOCK_RECTANGLE, (const char**) rectangle_xpm);
add_stock_icon(factory, IMAP_STOCK_CIRCLE, (const char**) circle_xpm);
add_stock_icon(factory, IMAP_STOCK_POLYGON, (const char**) polygon_xpm);
add_stock_icon(factory, IMAP_STOCK_GRID, (const char**) grid_xpm);
gtk_icon_factory_add_default(factory); gtk_icon_factory_add_default(factory);
gtk_stock_add_static(imap_stock_items, G_N_ELEMENTS(imap_stock_items)); gtk_stock_add_static(imap_stock_items, G_N_ELEMENTS(imap_stock_items));

View File

@ -3,7 +3,7 @@
* *
* Generates clickable image maps. * Generates clickable image maps.
* *
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl * Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,14 +24,16 @@
#ifndef _IMAP_STOCK_H #ifndef _IMAP_STOCK_H
#define _IMAP_STOCK_H #define _IMAP_STOCK_H
#define IMAP_STOCK_MAP_INFO "imap-map-info"
#define IMAP_STOCK_TO_FRONT "imap-to-front"
#define IMAP_STOCK_TO_BACK "imap-to-back"
#define IMAP_STOCK_ARROW "imap_arrow" #define IMAP_STOCK_ARROW "imap_arrow"
#define IMAP_STOCK_RECTANGLE "imap_rectangle"
#define IMAP_STOCK_CIRCLE "imap_circle" #define IMAP_STOCK_CIRCLE "imap_circle"
#define IMAP_STOCK_POLYGON "imap_polygon" #define IMAP_STOCK_COORD "imap_coord"
#define IMAP_STOCK_DIMENSION "imap_dimension"
#define IMAP_STOCK_GRID "imap_grid" #define IMAP_STOCK_GRID "imap_grid"
#define IMAP_STOCK_MAP_INFO "imap-map-info"
#define IMAP_STOCK_POLYGON "imap_polygon"
#define IMAP_STOCK_RECTANGLE "imap_rectangle"
#define IMAP_STOCK_TO_BACK "imap-to-back"
#define IMAP_STOCK_TO_FRONT "imap-to-front"
void init_stock_icons(void); void init_stock_icons(void);