Commit f9dc08a4 authored by Maurits Rijk's avatar Maurits Rijk Committed by Maurits Rijk

plug-ins/imagemap/imap_grid.[ch] plug-ins/imagemap/imap_main.c

2005-06-06  Maurits Rijk  <m.rijk@chello.nl>

	* plug-ins/imagemap/imap_grid.[ch]
	* plug-ins/imagemap/imap_main.c
	* plug-ins/imagemap/imap_menu.[ch]
	* plug-ins/imagemap/imap_menu_funcs.[ch]
	* plug-ins/imagemap/imap_object_popup.[ch]
	* plug-ins/imagemap/imap_polygon.[ch]: more conversion to action based
	menus. Almost done.
parent b29fc29b
2005-06-06 Maurits Rijk <m.rijk@chello.nl>
* plug-ins/imagemap/imap_grid.[ch]
* plug-ins/imagemap/imap_main.c
* plug-ins/imagemap/imap_menu.[ch]
* plug-ins/imagemap/imap_menu_funcs.[ch]
* plug-ins/imagemap/imap_object_popup.[ch]
* plug-ins/imagemap/imap_polygon.[ch]: more conversion to action based
menus. Almost done.
2005-06-06 Sven Neumann <sven@gimp.org>
* plug-ins/gfig/gfig.c (gfig_load_from_parasite): only create the
......
......@@ -370,12 +370,11 @@ draw_grid(GtkWidget *preview)
}
}
gboolean
void
toggle_grid(void)
{
grid_snap = !grid_snap;
redraw_preview();
return grid_snap;
}
static gint
......
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -26,7 +26,7 @@
void do_grid_settings_dialog();
void draw_grid(GtkWidget *preview);
gboolean toggle_grid();
void toggle_grid();
void round_to_grid(gint *x, gint *y);
gboolean grid_near_x(gint x);
......
......@@ -41,7 +41,6 @@
#include "imap_default_dialog.h"
#include "imap_edit_area_info.h"
#include "imap_file.h"
#include "imap_grid.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_misc.h"
......@@ -1270,6 +1269,18 @@ do_move_down(void)
*/
}
void
do_move_to_front(void)
{
command_execute(move_to_front_command_new(_shapes));
}
void
do_send_to_back(void)
{
command_execute(send_to_back_command_new(_shapes));
}
void
do_use_gimp_guides_dialog(void)
{
......@@ -1302,17 +1313,6 @@ factory_preview_gray(void)
return command_new(set_preview_gray);
}
static Command_t*
factory_move_to_front(void)
{
return move_to_front_command_new(_shapes);
}
static Command_t*
factory_send_to_back(void)
{
return send_to_back_command_new(_shapes);
}
#endif
......
......@@ -43,6 +43,8 @@
#include "libgimp/stdplugins-intl.h"
#include "libgimpwidgets/gimpstock.h"
/* Fix me: move all of these prototypes to imap_menu.h */
void save();
void do_close();
void do_quit();
......@@ -55,6 +57,8 @@ void do_deselect_all();
void do_grid_settings_dialog();
void do_zoom_in();
void do_zoom_out();
void do_move_to_front();
void do_send_to_back();
void do_edit_selected_shape();
void do_create_guides_dialog();
void do_use_gimp_guides_dialog();
......@@ -63,7 +67,13 @@ void imap_help();
void set_func(int func);
static Menu_t _menu;
GtkUIManager *ui_manager;
static GtkUIManager *ui_manager;
GtkWidget*
menu_get_widget(const gchar *path)
{
return gtk_ui_manager_get_widget (ui_manager, path);
}
static void
set_sensitive (const gchar *path, gboolean sensitive)
......@@ -178,16 +188,21 @@ static GtkActionEntry entries[] = {
{ "SelectAll", NULL, "Select _All", "<control>A", NULL, do_select_all},
{ "DeselectAll", NULL, "Deselect _All", "<shift><control>A", NULL,
do_deselect_all},
{ "EditAreaInfo", GTK_STOCK_PROPERTIES, "Edit Area Info...", NULL,
{ "EditAreaInfo", GTK_STOCK_EDIT, "Edit Area Info...", NULL,
"Edit selected area info", do_edit_selected_shape},
{ "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, "Preferences",
do_preferences_dialog},
{ "MoveToFront", IMAP_STOCK_TO_FRONT, NULL, NULL, "Move to Front", NULL},
{ "SendToBack", IMAP_STOCK_TO_BACK, NULL, NULL, "Send to Back", NULL},
{ "MoveToFront", IMAP_STOCK_TO_FRONT, "", NULL, "Move to Front",
do_move_to_front},
{ "SendToBack", IMAP_STOCK_TO_BACK, "", NULL, "Send to Back",
do_send_to_back},
{ "DeleteArea", NULL, "Delete Area", NULL, NULL, NULL},
{ "MoveUp", GTK_STOCK_GO_UP, "Move Up", NULL, NULL, NULL},
{ "MoveDown", GTK_STOCK_GO_DOWN, "Move Down", NULL, NULL, NULL},
{ "InsertPoint", NULL, "Insert Point", NULL, NULL, polygon_insert_point},
{ "DeletePoint", NULL, "Delete Point", NULL, NULL, polygon_delete_point},
{ "ViewMenu", NULL, "_View" },
{ "Source", NULL, "Source...", NULL, NULL, do_source_dialog},
{ "ZoomIn", GTK_STOCK_ZOOM_IN, NULL, "plus", "Zoom in", do_zoom_in},
......@@ -195,7 +210,8 @@ static GtkActionEntry entries[] = {
{ "ZoomToMenu", NULL, "_Zoom To" },
{ "MappingMenu", NULL, "_Mapping" },
{ "EditMapInfo", IMAP_STOCK_MAP_INFO, "Edit Map Info...", NULL, NULL, NULL},
{ "EditMapInfo", IMAP_STOCK_MAP_INFO, "Edit Map Info...", NULL, NULL,
do_settings_dialog},
{ "ToolsMenu", NULL, "_Tools" },
{ "GridSettings", NULL, "Grid Settings...", NULL, NULL,
......@@ -216,7 +232,7 @@ static GtkActionEntry entries[] = {
/* Toggle items */
static GtkToggleActionEntry toggle_entries[] = {
{ "AreaList", NULL, "Area List", NULL, NULL, NULL, TRUE },
{ "Grid", GIMP_STOCK_GRID, "_Grid", NULL, "Grid", NULL, FALSE }
{ "Grid", GIMP_STOCK_GRID, "_Grid", NULL, "Grid", toggle_grid, FALSE }
};
static GtkRadioActionEntry color_entries[] = {
......@@ -335,6 +351,17 @@ static const char *ui_description =
" <menuitem action='Copy'/>"
" </popup>"
""
" <popup name='PolygonPopupMenu'>"
" <menuitem action='InsertPoint'/>"
" <menuitem action='DeletePoint'/>"
" <menuitem action='EditAreaInfo'/>"
" <menuitem action='DeleteArea'/>"
" <menuitem action='MoveUp'/>"
" <menuitem action='MoveDown'/>"
" <menuitem action='Cut'/>"
" <menuitem action='Copy'/>"
" </popup>"
""
" <toolbar name='Toolbar'>"
" <toolitem action='Open'/>"
" <toolitem action='Save'/>"
......@@ -353,6 +380,9 @@ static const char *ui_description =
" <separator/>"
" <toolitem action='EditMapInfo'/>"
" <separator/>"
" <toolitem action='MoveToFront'/>"
" <toolitem action='SendToBack'/>"
" <separator/>"
" <toolitem action='Grid'/>"
" </toolbar>"
""
......
......@@ -48,7 +48,7 @@ typedef struct {
gint nr_off_mru_items;
} Menu_t;
GtkWidget *menu_get_widget(const gchar *path);
Menu_t *make_menu(GtkWidget *main_vbox, GtkWidget *window);
void menu_build_mru_items(MRU_t *mru);
void menu_set_zoom_sensitivity(gint factor);
......
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -46,18 +46,6 @@ add_accelerator(GtkWidget *widget, guint accelerator_key,
GTK_ACCEL_VISIBLE);
}
GtkWidget*
prepend_item_with_label(GtkWidget *parent, gchar *label,
MenuCallback activate, gpointer data)
{
GtkWidget *item = gtk_menu_item_new_with_mnemonic(label);
gtk_menu_shell_prepend(GTK_MENU_SHELL(parent), item);
g_signal_connect(item, "activate", G_CALLBACK(activate), data);
gtk_widget_show(item);
return item;
}
GtkWidget*
insert_item_with_label(GtkWidget *parent, gint position, gchar *label,
MenuCallback activate, gpointer data)
......@@ -69,11 +57,3 @@ insert_item_with_label(GtkWidget *parent, gint position, gchar *label,
return item;
}
void
menu_command(GtkWidget *widget, gpointer data)
{
CommandFactory_t *factory = (CommandFactory_t*) data;
Command_t *command = (*factory)();
command_execute(command);
}
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -27,12 +27,6 @@
typedef void (*MenuCallback)(GtkWidget *widget, gpointer data);
void init_accel_group(GtkWidget *window);
GtkWidget *make_item_with_label(GtkWidget *parent, gchar *label,
MenuCallback activate, gpointer data);
GtkWidget *make_item_with_image(GtkWidget *parent, const gchar *stock_id,
MenuCallback activate, gpointer data);
GtkWidget *prepend_item_with_label(GtkWidget *parent, gchar *label,
MenuCallback activate, gpointer data);
GtkWidget *insert_item_with_label(GtkWidget *parent, gint position,
gchar *label, MenuCallback activate,
gpointer data);
......
......@@ -27,43 +27,16 @@
#include "imap_commands.h"
#include "imap_main.h"
#include "imap_menu.h"
#include "imap_object_popup.h"
#include "libgimp/stdplugins-intl.h"
/* Current object with popup menu */
static Object_t *_current_obj;
Object_t*
get_popup_object(void)
{
return _current_obj;
}
extern GtkUIManager *ui_manager;
ObjectPopup_t*
make_object_popup(void)
{
ObjectPopup_t *popup = g_new (ObjectPopup_t, 1);
popup->menu = gtk_ui_manager_get_widget (ui_manager, "/ObjectPopupMenu");
return popup;
}
GtkWidget*
object_popup_prepend_menu(ObjectPopup_t *popup, gchar *label,
MenuCallback activate, gpointer data)
{
return prepend_item_with_label(popup->menu, label, activate, data);
}
void
object_handle_popup(ObjectPopup_t *popup, Object_t *obj, GdkEventButton *event)
{
/* int position = object_get_position_in_list(obj) + 1; */
_current_obj = popup->obj = obj;
#ifdef _TEMP_
gtk_widget_set_sensitive(popup->up, (position > 1) ? TRUE : FALSE);
gtk_widget_set_sensitive(popup->down,
......@@ -80,6 +53,9 @@ object_do_popup(Object_t *obj, GdkEventButton *event)
static ObjectPopup_t *popup;
if (!popup)
popup = make_object_popup();
object_handle_popup(popup, obj, event);
{
popup = g_new (ObjectPopup_t, 1);
popup->menu = menu_get_widget ("/ObjectPopupMenu");
}
object_handle_popup (popup, obj, event);
}
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -33,12 +33,8 @@ typedef struct {
Object_t *obj;
} ObjectPopup_t;
ObjectPopup_t *make_object_popup(void);
GtkWidget *object_popup_prepend_menu(ObjectPopup_t *popup, gchar *label,
MenuCallback activate, gpointer data);
void object_handle_popup(ObjectPopup_t *popup, Object_t *obj,
GdkEventButton *event);
void object_do_popup(Object_t *obj, GdkEventButton *event);
Object_t *get_popup_object(void);
#endif /* _IMAP_OBJECT_POPUP_H */
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2004 Maurits Rijk m.rijk@chello.nl
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -31,6 +31,7 @@
#include "imap_commands.h"
#include "imap_main.h"
#include "imap_misc.h"
#include "imap_menu.h"
#include "imap_object_popup.h"
#include "imap_polygon.h"
#include "imap_stock.h"
......@@ -653,24 +654,24 @@ polygon_write_ncsa(Object_t *obj, gpointer param, OutputFunc_t output)
output(param, " %d,%d", first->x, first->y);
}
static Object_t *_current_obj;
static gboolean _insert_edge;
static gint _insert_x;
static gint _insert_y;
static void
polygon_insert_point(GtkWidget *widget, gpointer data)
void
polygon_insert_point(void)
{
Command_t *command = insert_point_command_new(get_popup_object(), _insert_x,
_insert_y, _insert_edge);
command_execute(command);
Command_t *command = insert_point_command_new (_current_obj, _insert_x,
_insert_y, _insert_edge);
command_execute (command);
}
static void
polygon_delete_point(GtkWidget *widget, gpointer data)
void
polygon_delete_point(void)
{
Command_t *command = delete_point_command_new(get_popup_object(),
_sash_point);
command_execute(command);
Command_t *command = delete_point_command_new(_current_obj, _sash_point);
command_execute (command);
}
static gboolean
......@@ -711,37 +712,46 @@ polygon_near_edge(Object_t *obj, gint x, gint y)
}
static void
polygon_do_popup(Object_t *obj, GdkEventButton *event)
polygon_handle_popup (GdkEventButton *event, gboolean near_sash,
gboolean near_edge)
{
gint x = get_real_coord((gint) event->x);
gint y = get_real_coord((gint) event->y);
GtkWidget *popup = menu_get_widget ("/PolygonPopupMenu");
GtkWidget *delete = menu_get_widget ("/PolygonPopupMenu/DeletePoint");
GtkWidget *insert = menu_get_widget ("/PolygonPopupMenu/InsertPoint");
if (polygon_near_sash(obj, x, y)) {
static ObjectPopup_t *delete_popup;
if (!delete_popup) {
delete_popup = make_object_popup();
object_popup_prepend_menu(delete_popup, _("Delete Point"),
polygon_delete_point, delete_popup);
}
object_handle_popup(delete_popup, obj, event);
} else {
_insert_edge = polygon_near_edge(obj, x, y);
if (_insert_edge) {
static ObjectPopup_t *insert_popup;
_insert_x = x;
_insert_y = y;
if (!insert_popup) {
insert_popup = make_object_popup();
object_popup_prepend_menu(insert_popup, _("Insert Point"),
polygon_insert_point, insert_popup);
}
object_handle_popup(insert_popup, obj, event);
} else {
object_do_popup(obj, event);
gtk_widget_set_sensitive (delete, near_sash);
gtk_widget_set_sensitive (insert, near_edge);
gtk_menu_popup(GTK_MENU(popup), NULL, NULL, NULL, NULL,
event->button, event->time);
}
static void
polygon_do_popup(Object_t *obj, GdkEventButton *event)
{
gint x = get_real_coord ((gint) event->x);
gint y = get_real_coord ((gint) event->y);
_current_obj = obj;
if (polygon_near_sash (obj, x, y))
{
polygon_handle_popup (event, TRUE, FALSE);
}
else
{
_insert_edge = polygon_near_edge (obj, x, y);
if (_insert_edge)
{
_insert_x = x;
_insert_y = y;
polygon_handle_popup (event, FALSE, TRUE);
}
else {
object_do_popup (obj, event);
}
}
}
}
static const gchar*
......
......@@ -3,7 +3,7 @@
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -33,11 +33,14 @@ typedef struct {
#define ObjectToPolygon(obj) ((Polygon_t*) (obj))
Object_t *create_polygon(GList *points);
ObjectFactory_t *get_polygon_factory(guint state);
Object_t *create_polygon (GList *points);
ObjectFactory_t *get_polygon_factory (guint state);
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);
void polygon_insert_point (void);
void polygon_delete_point (void);
void polygon_remove_last_point (Polygon_t *polygon);
void polygon_append_point (Polygon_t *polygon, gint x, gint y);
GdkPoint *new_point (gint x, gint y);
#endif /* _IMAP_POLYGON_H */
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