diff --git a/plug-ins/imagemap/Makefile.am b/plug-ins/imagemap/Makefile.am index 5bfedc2bac..9d6e58fc2d 100644 --- a/plug-ins/imagemap/Makefile.am +++ b/plug-ins/imagemap/Makefile.am @@ -136,10 +136,9 @@ imagemap_SOURCES = \ images/imagemap-icon-images.h AM_CPPFLAGS = \ - -DGIMP_DEPRECATED_REPLACE_NEW_API \ -I$(top_srcdir) \ $(GTK_CFLAGS) \ - $(GEGL_CFLAGS) \ + $(GEGL_CFLAGS) \ -I$(includedir) LDADD = \ diff --git a/plug-ins/imagemap/imap_cmd_gimp_guides.c b/plug-ins/imagemap/imap_cmd_gimp_guides.c index a7a2ef6f60..fbc6e17a15 100644 --- a/plug-ins/imagemap/imap_cmd_gimp_guides.c +++ b/plug-ins/imagemap/imap_cmd_gimp_guides.c @@ -38,18 +38,18 @@ #include "libgimp/stdplugins-intl.h" typedef struct { - DefaultDialog_t *dialog; + DefaultDialog_t *dialog; - ObjectList_t *list; - gint32 drawable_id; + ObjectList_t *list; + GimpDrawable *drawable; - GtkWidget *alternate; - GtkWidget *all; - GtkWidget *left_border; - GtkWidget *right_border; - GtkWidget *upper_border; - GtkWidget *lower_border; - GtkWidget *url; + GtkWidget *alternate; + GtkWidget *all; + GtkWidget *left_border; + GtkWidget *right_border; + GtkWidget *upper_border; + GtkWidget *lower_border; + GtkWidget *url; } GimpGuidesDialog_t; static gint @@ -67,7 +67,7 @@ gimp_guides_ok_cb(gpointer data) GSList *vguides, *vg; gboolean all; const gchar *url; - gint32 image_ID = gimp_item_get_image (param->drawable_id); + GimpImage *image = gimp_item_get_image (GIMP_ITEM (param->drawable)); /* First get some dialog values */ @@ -80,7 +80,7 @@ gimp_guides_ok_cb(gpointer data) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->right_border))) vguides = g_slist_append(vguides, - GINT_TO_POINTER(gimp_image_width(image_ID))); + GINT_TO_POINTER(gimp_image_width(image))); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->upper_border))) hguides = g_slist_append(NULL, GINT_TO_POINTER(0)); @@ -89,18 +89,18 @@ gimp_guides_ok_cb(gpointer data) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->lower_border))) hguides = g_slist_append(hguides, - GINT_TO_POINTER(gimp_image_height(image_ID))); + GINT_TO_POINTER(gimp_image_height(image))); url = gtk_entry_get_text(GTK_ENTRY(param->url)); /* Next get all the GIMP guides */ - guide_num = gimp_image_find_next_guide(image_ID, 0); + guide_num = gimp_image_find_next_guide(image, 0); while (guide_num > 0) { - gint position = gimp_image_get_guide_position(image_ID, guide_num); + gint position = gimp_image_get_guide_position(image, guide_num); - if (gimp_image_get_guide_orientation(image_ID, guide_num) + if (gimp_image_get_guide_orientation(image, guide_num) == GIMP_ORIENTATION_HORIZONTAL) { hguides = g_slist_insert_sorted(hguides, GINT_TO_POINTER(position), guide_sort_func); @@ -108,7 +108,7 @@ gimp_guides_ok_cb(gpointer data) vguides = g_slist_insert_sorted(vguides, GINT_TO_POINTER(position), guide_sort_func); } - guide_num = gimp_image_find_next_guide(image_ID, guide_num); + guide_num = gimp_image_find_next_guide(image, guide_num); } /* Create the areas */ @@ -207,22 +207,24 @@ make_gimp_guides_dialog(void) } static void -init_gimp_guides_dialog(GimpGuidesDialog_t *dialog, ObjectList_t *list, - gint32 drawable_id) +init_gimp_guides_dialog (GimpGuidesDialog_t *dialog, + ObjectList_t *list, + GimpDrawable *drawable) { dialog->list = list; - dialog->drawable_id = drawable_id; + dialog->drawable = drawable; } static void -do_create_gimp_guides_dialog(ObjectList_t *list, gint32 drawable_id) +do_create_gimp_guides_dialog (ObjectList_t *list, + GimpDrawable *drawable) { static GimpGuidesDialog_t *dialog; if (!dialog) dialog = make_gimp_guides_dialog(); - init_gimp_guides_dialog(dialog, list, drawable_id); + init_gimp_guides_dialog(dialog, list, drawable); default_dialog_show(dialog->dialog); } @@ -238,15 +240,16 @@ static CommandClass_t gimp_guides_command_class = { typedef struct { Command_t parent; ObjectList_t *list; - gint32 drawable_id; + GimpDrawable *drawable; } GimpGuidesCommand_t; Command_t* -gimp_guides_command_new(ObjectList_t *list, gint32 drawable_id) +gimp_guides_command_new (ObjectList_t *list, + GimpDrawable *drawable) { GimpGuidesCommand_t *command = g_new(GimpGuidesCommand_t, 1); command->list = list; - command->drawable_id = drawable_id; + command->drawable = drawable; return command_init(&command->parent, _("Use Gimp Guides"), &gimp_guides_command_class); } @@ -255,6 +258,6 @@ static CmdExecuteValue_t gimp_guides_command_execute(Command_t *parent) { GimpGuidesCommand_t *command = (GimpGuidesCommand_t*) parent; - do_create_gimp_guides_dialog(command->list, command->drawable_id); + do_create_gimp_guides_dialog(command->list, command->drawable); return CMD_DESTRUCT; } diff --git a/plug-ins/imagemap/imap_commands.h b/plug-ins/imagemap/imap_commands.h index af8637bc9e..c7b9ddfa57 100644 --- a/plug-ins/imagemap/imap_commands.h +++ b/plug-ins/imagemap/imap_commands.h @@ -37,7 +37,7 @@ 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 *gimp_guides_command_new(ObjectList_t *list, - gint32 _drawable_id); + GimpDrawable *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); diff --git a/plug-ins/imagemap/imap_main.c b/plug-ins/imagemap/imap_main.c index 6c21f87641..1f80168e01 100644 --- a/plug-ins/imagemap/imap_main.c +++ b/plug-ins/imagemap/imap_main.c @@ -60,8 +60,45 @@ #define ZOOMED(x) (_zoom_factor * (x)) #define GET_REAL_COORD(x) ((x) / _zoom_factor) -static gint zoom_in (void); -static gint zoom_out (void); + +typedef struct _Imap Imap; +typedef struct _ImapClass ImapClass; + +struct _Imap +{ + GimpPlugIn parent_instance; +}; + +struct _ImapClass +{ + GimpPlugInClass parent_class; +}; + + +#define IMAP_TYPE (imap_get_type ()) +#define IMAP (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IMAP_TYPE, Imap)) + +GType imap_get_type (void) G_GNUC_CONST; + +static GList * imap_query_procedures (GimpPlugIn *plug_in); +static GimpProcedure * imap_create_procedure (GimpPlugIn *plug_in, + const gchar *name); + +static GimpValueArray * imap_run (GimpProcedure *procedure, + GimpRunMode run_mode, + GimpImage *image, + GimpDrawable *drawable, + const GimpValueArray *args, + gpointer run_data); + +static gint dialog (GimpDrawable *drawable); +static gint zoom_in (void); +static gint zoom_out (void); + + +G_DEFINE_TYPE (Imap, imap, GIMP_TYPE_PLUG_IN) + +GIMP_MAIN (IMAP_TYPE) /* Global variables */ @@ -70,7 +107,7 @@ static PreferencesData_t _preferences = {CSIM, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, DEFAULT_UNDO_LEVELS, DEFAULT_MRU_SIZE}; static MRU_t *_mru; -static gint32 _drawable_id; +static GimpDrawable *_drawable; static GdkCursorType _cursor = GDK_TOP_LEFT_ARROW; static gboolean _show_url = TRUE; static gchar *_filename = NULL; @@ -86,89 +123,90 @@ static gint _zoom_factor = 1; static gboolean (*_button_press_func)(GtkWidget*, GdkEventButton*, gpointer); static gpointer _button_press_param; -/* Declare local functions. */ -static void query (void); -static void run (const gchar *name, - gint nparams, - const GimpParam *param, - gint *nreturn_vals, - GimpParam **return_vals); -static gint dialog (gint32 drawable_id); - -const GimpPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ -}; - -static int run_flag = 0; +static int run_flag = 0; -MAIN () - -static void query(void) +static void +imap_class_init (ImapClass *klass) { - static const GimpParamDef args[] = { - {GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0) }"}, - {GIMP_PDB_IMAGE, "image", "Input image (unused)"}, - {GIMP_PDB_DRAWABLE, "drawable", "Input drawable"}, - }; - static const GimpParamDef *return_vals = NULL; - static int nreturn_vals = 0; + GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass); - gimp_install_procedure(PLUG_IN_PROC, - N_("Create a clickable imagemap"), - "", - "Maurits Rijk", - "Maurits Rijk", - "1998-2005", - N_("_Image Map..."), - "RGB*, GRAY*, INDEXED*", - GIMP_PLUGIN, - G_N_ELEMENTS (args), nreturn_vals, - args, return_vals); - - gimp_plugin_menu_register (PLUG_IN_PROC, "/Filters/Web"); + plug_in_class->query_procedures = imap_query_procedures; + plug_in_class->create_procedure = imap_create_procedure; } static void -run (const gchar *name, - gint n_params, - const GimpParam *param, - gint *nreturn_vals, - GimpParam **return_vals) +imap_init (Imap *imap) { - static GimpParam values[1]; - GimpRunMode run_mode; - gint32 drawable_id; - GimpPDBStatusType status = GIMP_PDB_SUCCESS; +} - INIT_I18N (); - gegl_init (NULL, NULL); +static GList * +imap_query_procedures (GimpPlugIn *plug_in) +{ + return g_list_append (NULL, g_strdup (PLUG_IN_PROC)); +} - *nreturn_vals = 1; - *return_vals = values; +static GimpProcedure * +imap_create_procedure (GimpPlugIn *plug_in, + const gchar *name) +{ + GimpProcedure *procedure = NULL; - run_mode = param[0].data.d_int32; - drawable_id = param[2].data.d_drawable; + if (! strcmp (name, PLUG_IN_PROC)) + { + procedure = gimp_image_procedure_new (plug_in, name, GIMP_PLUGIN, + imap_run, NULL, NULL); - _drawable_id = drawable_id; - _image_name = gimp_image_get_name(param[1].data.d_image); - _image_width = gimp_image_width(param[1].data.d_image); - _image_height = gimp_image_height(param[1].data.d_image); + gimp_procedure_set_image_types (procedure, "*"); - _map_info.color = gimp_drawable_is_rgb(drawable_id); + gimp_procedure_set_menu_label (procedure, N_("_Image Map...")); + gimp_procedure_add_menu_path (procedure, "/Filters/Web"); - if (run_mode == GIMP_RUN_INTERACTIVE) { - if (!dialog(drawable_id)) { - /* The dialog was closed, or something similarly evil happened. */ - status = GIMP_PDB_EXECUTION_ERROR; - } - } + gimp_procedure_set_documentation (procedure, + N_("Create a clickable imagemap"), + NULL, + name); + gimp_procedure_set_attribution (procedure, + "Maurits Rijk", + "Maurits Rijk", + "1998-2005"); + } - values[0].type = GIMP_PDB_STATUS; - values[0].data.d_status = status; + return procedure; +} + +static GimpValueArray * +imap_run (GimpProcedure *procedure, + GimpRunMode run_mode, + GimpImage *image, + GimpDrawable *drawable, + const GimpValueArray *args, + gpointer run_data) +{ + INIT_I18N (); + gegl_init (NULL, NULL); + + _drawable = drawable; + + _image_name = gimp_image_get_name (image); + _image_width = gimp_image_width (image); + _image_height = gimp_image_height (image); + + _map_info.color = gimp_drawable_is_rgb (drawable); + + if (run_mode != GIMP_RUN_INTERACTIVE) + return gimp_procedure_new_return_values (procedure, + GIMP_PDB_CALLING_ERROR, + NULL); + + if (! dialog (drawable)) + return gimp_procedure_new_return_values (procedure, + GIMP_PDB_EXECUTION_ERROR, + NULL); + + return gimp_procedure_new_return_values (procedure, + GIMP_PDB_SUCCESS, + NULL); } GtkWidget* @@ -1185,7 +1223,7 @@ do_send_to_back(void) void do_use_gimp_guides_dialog(void) { - command_execute (gimp_guides_command_new (_shapes, _drawable_id)); + command_execute (gimp_guides_command_new (_shapes, _drawable)); } void @@ -1207,7 +1245,7 @@ factory_move_down(void) } static gint -dialog(gint32 drawable_id) +dialog (GimpDrawable *drawable) { GtkWidget *dlg; GtkWidget *hbox; @@ -1262,7 +1300,7 @@ dialog(gint32 drawable_id) /* selection_set_edit_command(tools, factory_edit); */ gtk_box_pack_start(GTK_BOX(hbox), tools, FALSE, FALSE, 0); - _preview = make_preview(drawable_id); + _preview = make_preview (drawable); g_signal_connect(_preview->preview, "motion-notify-event", G_CALLBACK(preview_move), NULL); diff --git a/plug-ins/imagemap/imap_preview.c b/plug-ins/imagemap/imap_preview.c index 256a297129..d82654033e 100644 --- a/plug-ins/imagemap/imap_preview.c +++ b/plug-ins/imagemap/imap_preview.c @@ -86,21 +86,21 @@ render_background(Preview_t *preview_base) static void render_rgb_image (Preview_t *preview_base, - gint32 drawable_id) + GimpDrawable *drawable) { GeglBuffer *buffer; guchar *dest_buffer; gint dwidth, dheight, pwidth, pheight; GtkWidget *preview = preview_base->preview; - dwidth = gimp_drawable_width (drawable_id); - dheight = gimp_drawable_height (drawable_id); + dwidth = gimp_drawable_width (drawable); + dheight = gimp_drawable_height (drawable); pwidth = preview_base->widget_width; pheight = preview_base->widget_height; dest_buffer = g_new (guchar, pwidth * pheight * 4); - buffer = gimp_drawable_get_buffer (drawable_id); + buffer = gimp_drawable_get_buffer (drawable); gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, pwidth, pheight), MIN ((gdouble) pwidth / (gdouble) dwidth, @@ -121,10 +121,10 @@ render_rgb_image (Preview_t *preview_base, static void render_preview (Preview_t *preview_base, - gint32 drawable_id) + GimpDrawable *drawable) { render_background (preview_base); - render_rgb_image (preview_base, drawable_id); + render_rgb_image (preview_base, drawable); } static gboolean @@ -180,7 +180,7 @@ preview_zoom(Preview_t *preview, gint 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_id); + render_preview(preview, preview->drawable); preview_redraw(); } @@ -239,7 +239,7 @@ preview_size_allocate (GtkWidget *widget, { Preview_t *preview = preview_void; - render_preview (preview, preview->drawable_id); + render_preview (preview, preview->drawable); } static void @@ -254,7 +254,7 @@ scroll_adj_changed (GtkAdjustment *adj, } Preview_t * -make_preview (gint32 drawable_id) +make_preview (GimpDrawable *drawable) { Preview_t *data = g_new(Preview_t, 1); GtkAdjustment *hadj; @@ -268,7 +268,7 @@ make_preview (gint32 drawable_id) GtkWidget *scrollbar; gint width, height; - data->drawable_id = drawable_id; + data->drawable = drawable; data->preview = preview = gimp_preview_area_new (); g_object_set_data (G_OBJECT (preview), "preview", data); @@ -289,8 +289,8 @@ make_preview (gint32 drawable_id) G_CALLBACK (handle_drop), NULL); - data->widget_width = data->width = gimp_drawable_width (drawable_id); - data->widget_height = data->height = gimp_drawable_height (drawable_id); + data->widget_width = data->width = gimp_drawable_width (drawable); + data->widget_height = data->height = gimp_drawable_height (drawable); gtk_widget_set_size_request (preview, data->widget_width, data->widget_height); @@ -381,7 +381,7 @@ make_preview (gint32 drawable_id) gtk_widget_show (preview); - render_preview (data, drawable_id); + render_preview (data, drawable); gtk_widget_show (grid); diff --git a/plug-ins/imagemap/imap_preview.h b/plug-ins/imagemap/imap_preview.h index 3fe01c4818..99750acdb7 100644 --- a/plug-ins/imagemap/imap_preview.h +++ b/plug-ins/imagemap/imap_preview.h @@ -26,20 +26,20 @@ #include typedef struct { - gint32 drawable_id; - GtkWidget *window; - GtkWidget *preview; - GtkWidget *hruler; - GtkWidget *vruler; - gint width; - gint height; - gint widget_width; - gint widget_height; + GimpDrawable *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(gint32 drawable_id); +Preview_t *make_preview(GimpDrawable *drawable); void preview_redraw(void); void preview_unset_tmp_obj (Object_t *obj);