1999-09-07 08:03:20 +08:00
|
|
|
/*
|
|
|
|
* This is a plug-in for the GIMP.
|
|
|
|
*
|
|
|
|
* Generates clickable image maps.
|
|
|
|
*
|
2006-07-14 21:37:56 +08:00
|
|
|
* Copyright (C) 1998-2006 Maurits Rijk m.rijk@chello.nl
|
1999-09-07 08:03:20 +08:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-11-05 10:47:39 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
#include "imap_about.h"
|
1999-09-07 08:03:20 +08:00
|
|
|
#include "imap_circle.h"
|
|
|
|
#include "imap_file.h"
|
|
|
|
#include "imap_grid.h"
|
|
|
|
#include "imap_main.h"
|
|
|
|
#include "imap_menu.h"
|
|
|
|
#include "imap_menu_funcs.h"
|
|
|
|
#include "imap_polygon.h"
|
|
|
|
#include "imap_preferences.h"
|
|
|
|
#include "imap_rectangle.h"
|
|
|
|
#include "imap_settings.h"
|
2002-06-02 23:06:31 +08:00
|
|
|
#include "imap_stock.h"
|
1999-09-07 08:03:20 +08:00
|
|
|
#include "imap_source.h"
|
|
|
|
|
2001-11-05 10:47:39 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
2005-01-02 16:07:03 +08:00
|
|
|
#include "libgimpwidgets/gimpstock.h"
|
|
|
|
|
2005-06-07 03:53:44 +08:00
|
|
|
/* Fix me: move all of these prototypes to imap_menu.h */
|
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
void save();
|
|
|
|
void do_close();
|
|
|
|
void do_quit();
|
|
|
|
void do_cut();
|
|
|
|
void do_copy();
|
|
|
|
void do_paste();
|
|
|
|
void do_clear();
|
|
|
|
void do_select_all();
|
|
|
|
void do_deselect_all();
|
|
|
|
void do_grid_settings_dialog();
|
2005-01-23 19:21:01 +08:00
|
|
|
void do_zoom_in();
|
|
|
|
void do_zoom_out();
|
2005-06-07 03:53:44 +08:00
|
|
|
void do_move_to_front();
|
|
|
|
void do_send_to_back();
|
2005-01-23 19:21:01 +08:00
|
|
|
void do_edit_selected_shape();
|
2005-05-29 02:13:18 +08:00
|
|
|
void do_create_guides_dialog();
|
|
|
|
void do_use_gimp_guides_dialog();
|
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
void imap_help();
|
|
|
|
void set_func(int func);
|
2006-07-14 21:37:56 +08:00
|
|
|
void set_preview_color();
|
|
|
|
void set_zoom_factor();
|
|
|
|
void toggle_area_list();
|
2001-11-05 10:47:39 +08:00
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
static Menu_t _menu;
|
2005-06-07 03:53:44 +08:00
|
|
|
static GtkUIManager *ui_manager;
|
|
|
|
|
|
|
|
GtkWidget*
|
|
|
|
menu_get_widget(const gchar *path)
|
|
|
|
{
|
|
|
|
return gtk_ui_manager_get_widget (ui_manager, path);
|
|
|
|
}
|
1999-09-07 08:03:20 +08:00
|
|
|
|
2005-08-23 08:18:08 +08:00
|
|
|
static void
|
2005-01-02 16:07:03 +08:00
|
|
|
set_sensitive (const gchar *path, gboolean sensitive)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
GtkAction *action = gtk_ui_manager_get_action (ui_manager, path);
|
|
|
|
g_object_set (action, "sensitive", sensitive, NULL);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
menu_mru(GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
MRU_t *mru = get_mru();
|
|
|
|
char *filename = (char*) data;
|
|
|
|
|
2002-12-20 06:23:37 +08:00
|
|
|
if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
|
1999-09-07 08:03:20 +08:00
|
|
|
load(filename);
|
|
|
|
} else {
|
1999-12-19 03:45:00 +08:00
|
|
|
do_file_error_dialog(_("Error opening file"), filename);
|
1999-09-07 08:03:20 +08:00
|
|
|
mru_remove(mru, filename);
|
|
|
|
menu_build_mru_items(mru);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menu_set_zoom_sensitivity(gint factor)
|
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
set_sensitive ("/MainMenu/ViewMenu/ZoomIn", factor < 8);
|
|
|
|
set_sensitive ("/MainMenu/ViewMenu/ZoomOut", factor > 1);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
2006-07-14 21:37:56 +08:00
|
|
|
void
|
|
|
|
menu_set_zoom(gint factor)
|
|
|
|
{
|
|
|
|
menu_set_zoom_sensitivity (factor);
|
|
|
|
}
|
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
void
|
|
|
|
menu_shapes_selected(gint count)
|
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
gboolean sensitive = (count > 0);
|
|
|
|
set_sensitive ("/MainMenu/EditMenu/Cut", sensitive);
|
|
|
|
set_sensitive ("/MainMenu/EditMenu/Copy", sensitive);
|
|
|
|
set_sensitive ("/MainMenu/EditMenu/Clear", sensitive);
|
|
|
|
set_sensitive ("/MainMenu/EditMenu/EditAreaInfo", sensitive);
|
|
|
|
set_sensitive ("/MainMenu/EditMenu/DeselectAll", sensitive);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:51:22 +08:00
|
|
|
#ifdef _NOT_READY_YET_
|
1999-09-07 08:03:20 +08:00
|
|
|
static void
|
|
|
|
command_list_changed(Command_t *command, gpointer data)
|
|
|
|
{
|
1999-12-31 02:54:17 +08:00
|
|
|
gchar *scratch;
|
2002-06-02 23:06:31 +08:00
|
|
|
GtkWidget *icon;
|
1999-09-07 08:03:20 +08:00
|
|
|
|
|
|
|
/* Set undo entry */
|
|
|
|
if (_menu.undo)
|
|
|
|
gtk_widget_destroy(_menu.undo);
|
2004-10-26 00:11:40 +08:00
|
|
|
scratch = g_strdup_printf (_("_Undo %s"),
|
2001-11-05 10:47:39 +08:00
|
|
|
command && command->name ? command->name : "");
|
1999-12-19 03:45:00 +08:00
|
|
|
_menu.undo = insert_item_with_label(_menu.edit_menu, 1, scratch,
|
1999-09-07 08:03:20 +08:00
|
|
|
menu_command, &_menu.cmd_undo);
|
1999-12-31 02:54:17 +08:00
|
|
|
g_free (scratch);
|
1999-09-07 08:03:20 +08:00
|
|
|
add_accelerator(_menu.undo, 'Z', GDK_CONTROL_MASK);
|
|
|
|
gtk_widget_set_sensitive(_menu.undo, (command != NULL));
|
|
|
|
|
2002-06-02 23:06:31 +08:00
|
|
|
icon = gtk_image_new_from_stock(GTK_STOCK_UNDO, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(_menu.undo), icon);
|
|
|
|
gtk_widget_show(icon);
|
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
/* Set redo entry */
|
|
|
|
command = command_list_get_redo_command();
|
|
|
|
if (_menu.redo)
|
|
|
|
gtk_widget_destroy(_menu.redo);
|
2004-10-26 00:11:40 +08:00
|
|
|
scratch = g_strdup_printf (_("_Redo %s"),
|
2001-11-05 10:47:39 +08:00
|
|
|
command && command->name ? command->name : "");
|
1999-12-19 03:45:00 +08:00
|
|
|
_menu.redo = insert_item_with_label(_menu.edit_menu, 2, scratch,
|
1999-09-07 08:03:20 +08:00
|
|
|
menu_command, &_menu.cmd_redo);
|
1999-12-31 02:54:17 +08:00
|
|
|
g_free (scratch);
|
2002-09-07 00:59:51 +08:00
|
|
|
add_accelerator(_menu.redo, 'Z', GDK_SHIFT_MASK|GDK_CONTROL_MASK);
|
1999-09-07 08:03:20 +08:00
|
|
|
gtk_widget_set_sensitive(_menu.redo, (command != NULL));
|
2002-06-02 23:06:31 +08:00
|
|
|
|
|
|
|
icon = gtk_image_new_from_stock(GTK_STOCK_REDO, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(_menu.redo), icon);
|
|
|
|
gtk_widget_show(icon);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
2005-07-19 19:51:22 +08:00
|
|
|
#endif
|
1999-09-07 08:03:20 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
paste_buffer_added(Object_t *obj, gpointer data)
|
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
set_sensitive("/MainMenu/EditMenu/Paste", TRUE);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paste_buffer_removed(Object_t *obj, gpointer data)
|
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
set_sensitive("/MainMenu/EditMenu/Paste", FALSE);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
/* Normal items */
|
2006-06-28 00:13:22 +08:00
|
|
|
static const GtkActionEntry entries[] = {
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "FileMenu", NULL, "_File" },
|
|
|
|
{ "Open", GTK_STOCK_OPEN, "_Open...", NULL, "Open", do_file_open_dialog},
|
|
|
|
{ "OpenRecentMenu", NULL, "Open Recent" },
|
|
|
|
{ "Save", GTK_STOCK_SAVE, "_Save...", NULL, "Save", save},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "SaveAs", GTK_STOCK_SAVE_AS, "Save _As...", "<shift><control>S", NULL,
|
2005-01-02 16:07:03 +08:00
|
|
|
do_file_save_as_dialog},
|
|
|
|
{ "Close", GTK_STOCK_CLOSE, NULL, NULL, NULL, do_close},
|
|
|
|
{ "Quit", GTK_STOCK_QUIT, NULL, NULL, NULL, do_quit},
|
|
|
|
|
|
|
|
{ "EditMenu", NULL, "_Edit" },
|
|
|
|
{ "Undo", GTK_STOCK_UNDO, NULL, NULL, "Undo", NULL},
|
|
|
|
{ "Redo", GTK_STOCK_REDO, NULL, NULL, "Redo", NULL},
|
|
|
|
{ "Cut", GTK_STOCK_CUT, NULL, NULL, "Cut", do_cut},
|
|
|
|
{ "Copy", GTK_STOCK_COPY, NULL, NULL, "Copy", do_copy},
|
|
|
|
{ "Paste", GTK_STOCK_PASTE, NULL, NULL, "Paste", do_paste},
|
2005-01-23 04:25:00 +08:00
|
|
|
{ "Clear", GTK_STOCK_DELETE, NULL, "Delete", NULL, do_clear},
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "SelectAll", NULL, "Select _All", "<control>A", NULL, do_select_all},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "DeselectAll", NULL, "Deselect _All", "<shift><control>A", NULL,
|
2005-01-02 16:07:03 +08:00
|
|
|
do_deselect_all},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "EditAreaInfo", GTK_STOCK_EDIT, "Edit Area Info...", NULL,
|
2005-01-23 19:21:01 +08:00
|
|
|
"Edit selected area info", do_edit_selected_shape},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, "Preferences",
|
2005-01-23 19:21:01 +08:00
|
|
|
do_preferences_dialog},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "MoveToFront", IMAP_STOCK_TO_FRONT, "", NULL, "Move to Front",
|
2005-06-07 03:53:44 +08:00
|
|
|
do_move_to_front},
|
|
|
|
{ "SendToBack", IMAP_STOCK_TO_BACK, "", NULL, "Send to Back",
|
|
|
|
do_send_to_back},
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "DeleteArea", NULL, "Delete Area", NULL, NULL, NULL},
|
2005-01-23 19:21:01 +08:00
|
|
|
{ "MoveUp", GTK_STOCK_GO_UP, "Move Up", NULL, NULL, NULL},
|
|
|
|
{ "MoveDown", GTK_STOCK_GO_DOWN, "Move Down", NULL, NULL, NULL},
|
2005-01-02 16:07:03 +08:00
|
|
|
|
2005-06-07 03:53:44 +08:00
|
|
|
{ "InsertPoint", NULL, "Insert Point", NULL, NULL, polygon_insert_point},
|
|
|
|
{ "DeletePoint", NULL, "Delete Point", NULL, NULL, polygon_delete_point},
|
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "ViewMenu", NULL, "_View" },
|
2005-01-23 19:21:01 +08:00
|
|
|
{ "Source", NULL, "Source...", NULL, NULL, do_source_dialog},
|
|
|
|
{ "ZoomIn", GTK_STOCK_ZOOM_IN, NULL, "plus", "Zoom in", do_zoom_in},
|
|
|
|
{ "ZoomOut", GTK_STOCK_ZOOM_OUT, NULL, "minus", "Zoom out", do_zoom_out},
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "ZoomToMenu", NULL, "_Zoom To" },
|
|
|
|
|
|
|
|
{ "MappingMenu", NULL, "_Mapping" },
|
2007-01-03 18:15:59 +08:00
|
|
|
{ "EditMapInfo", GTK_STOCK_INFO, "Edit Map Info...", NULL, NULL,
|
2005-06-07 03:53:44 +08:00
|
|
|
do_settings_dialog},
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "ToolsMenu", NULL, "_Tools" },
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "GridSettings", NULL, "Grid Settings...", NULL, NULL,
|
2005-01-02 16:07:03 +08:00
|
|
|
do_grid_settings_dialog},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "UseGimpGuides", NULL, "Use GIMP Guides...", NULL, NULL,
|
2005-05-29 02:13:18 +08:00
|
|
|
do_use_gimp_guides_dialog},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "CreateGuides", NULL, "Create Guides...", NULL, NULL,
|
2005-05-29 02:13:18 +08:00
|
|
|
do_create_guides_dialog},
|
2005-01-02 16:07:03 +08:00
|
|
|
|
|
|
|
{ "HelpMenu", NULL, "_Help" },
|
2005-05-29 02:13:18 +08:00
|
|
|
{ "Contents", GTK_STOCK_HELP, "_Contents", NULL, NULL, imap_help},
|
2006-06-23 20:05:13 +08:00
|
|
|
{ "About", GTK_STOCK_ABOUT, NULL, NULL, NULL,
|
2005-05-29 02:13:18 +08:00
|
|
|
do_about_dialog},
|
2005-01-02 16:07:03 +08:00
|
|
|
|
|
|
|
{ "ZoomMenu", NULL, "_Zoom" },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Toggle items */
|
2006-06-28 00:13:22 +08:00
|
|
|
static const GtkToggleActionEntry toggle_entries[] = {
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "AreaList", NULL, "Area List", NULL, NULL, NULL, TRUE },
|
2005-06-07 03:53:44 +08:00
|
|
|
{ "Grid", GIMP_STOCK_GRID, "_Grid", NULL, "Grid", toggle_grid, FALSE }
|
2005-01-02 16:07:03 +08:00
|
|
|
};
|
|
|
|
|
2006-06-28 00:13:22 +08:00
|
|
|
static const GtkRadioActionEntry color_entries[] = {
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "Color", NULL, "Color", NULL, NULL, 0},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "Gray", NULL, "Gray", NULL, NULL, 1},
|
2005-01-02 16:07:03 +08:00
|
|
|
};
|
|
|
|
|
2006-06-28 00:13:22 +08:00
|
|
|
static const GtkRadioActionEntry mapping_entries[] = {
|
2005-04-05 02:41:35 +08:00
|
|
|
{ "Arrow", GIMP_STOCK_CURSOR, "Arrow", NULL, "Select existing area", 0},
|
2005-08-23 08:18:08 +08:00
|
|
|
{ "Rectangle", IMAP_STOCK_RECTANGLE, "Rectangle", NULL,
|
2005-01-02 16:07:03 +08:00
|
|
|
"Define Rectangle area", 1},
|
|
|
|
{ "Circle", IMAP_STOCK_CIRCLE, "Circle", NULL, "Define Circle/Oval area", 2},
|
|
|
|
{ "Polygon", IMAP_STOCK_POLYGON, "Polygon", NULL, "Define Polygon area", 3},
|
|
|
|
};
|
|
|
|
|
2006-06-28 00:13:22 +08:00
|
|
|
static const GtkRadioActionEntry zoom_entries[] = {
|
2005-01-02 16:07:03 +08:00
|
|
|
{ "Zoom1:1", NULL, "1:1", NULL, NULL, 0},
|
|
|
|
{ "Zoom1:2", NULL, "1:2", NULL, NULL, 1},
|
|
|
|
{ "Zoom1:3", NULL, "1:3", NULL, NULL, 2},
|
|
|
|
{ "Zoom1:4", NULL, "1:4", NULL, NULL, 3},
|
|
|
|
{ "Zoom1:5", NULL, "1:5", NULL, NULL, 4},
|
|
|
|
{ "Zoom1:6", NULL, "1:6", NULL, NULL, 5},
|
|
|
|
{ "Zoom1:7", NULL, "1:7", NULL, NULL, 6},
|
|
|
|
{ "Zoom1:8", NULL, "1:8", NULL, NULL, 7},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *ui_description =
|
|
|
|
"<ui>"
|
|
|
|
" <menubar name='MainMenu'>"
|
|
|
|
" <menu action='FileMenu'>"
|
|
|
|
" <menuitem action='Open'/>"
|
|
|
|
" <menuitem action='Save'/>"
|
|
|
|
" <menuitem action='SaveAs'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='Close'/>"
|
|
|
|
" <menuitem action='Quit'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='EditMenu'>"
|
|
|
|
" <menuitem action='Cut'/>"
|
|
|
|
" <menuitem action='Copy'/>"
|
|
|
|
" <menuitem action='Paste'/>"
|
|
|
|
" <menuitem action='Clear'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='SelectAll'/>"
|
|
|
|
" <menuitem action='DeselectAll'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='EditAreaInfo'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='Preferences'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='ViewMenu'>"
|
|
|
|
" <menuitem action='AreaList'/>"
|
|
|
|
" <menuitem action='Source'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='Color'/>"
|
|
|
|
" <menuitem action='Gray'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='ZoomIn'/>"
|
|
|
|
" <menuitem action='ZoomOut'/>"
|
|
|
|
" <menu action='ZoomToMenu'>"
|
|
|
|
" <menuitem action='Zoom1:1'/>"
|
|
|
|
" <menuitem action='Zoom1:2'/>"
|
|
|
|
" <menuitem action='Zoom1:3'/>"
|
|
|
|
" <menuitem action='Zoom1:4'/>"
|
|
|
|
" <menuitem action='Zoom1:5'/>"
|
|
|
|
" <menuitem action='Zoom1:6'/>"
|
|
|
|
" <menuitem action='Zoom1:7'/>"
|
|
|
|
" <menuitem action='Zoom1:8'/>"
|
|
|
|
" </menu>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='MappingMenu'>"
|
|
|
|
" <menuitem action='Arrow'/>"
|
|
|
|
" <menuitem action='Rectangle'/>"
|
|
|
|
" <menuitem action='Circle'/>"
|
|
|
|
" <menuitem action='Polygon'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='EditMapInfo'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='ToolsMenu'>"
|
|
|
|
" <menuitem action='Grid'/>"
|
|
|
|
" <menuitem action='GridSettings'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <menuitem action='UseGimpGuides'/>"
|
|
|
|
" <menuitem action='CreateGuides'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='HelpMenu'>"
|
|
|
|
" <menuitem action='Contents'/>"
|
|
|
|
" <menuitem action='About'/>"
|
|
|
|
" </menu>"
|
|
|
|
" </menubar>"
|
|
|
|
""
|
|
|
|
" <popup name='PopupMenu'>"
|
|
|
|
" <menuitem action='EditMapInfo'/>"
|
|
|
|
" <menu action='ToolsMenu'>"
|
|
|
|
" <menuitem action='Arrow'/>"
|
|
|
|
" <menuitem action='Rectangle'/>"
|
|
|
|
" <menuitem action='Circle'/>"
|
|
|
|
" <menuitem action='Polygon'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menu action='ZoomMenu'>"
|
|
|
|
" <menuitem action='ZoomIn'/>"
|
|
|
|
" <menuitem action='ZoomOut'/>"
|
|
|
|
" </menu>"
|
|
|
|
" <menuitem action='Grid'/>"
|
|
|
|
" <menuitem action='GridSettings'/>"
|
|
|
|
" <menuitem action='CreateGuides'/>"
|
|
|
|
" <menuitem action='Paste'/>"
|
|
|
|
" </popup>"
|
|
|
|
""
|
|
|
|
" <popup name='ObjectPopupMenu'>"
|
|
|
|
" <menuitem action='EditAreaInfo'/>"
|
|
|
|
" <menuitem action='DeleteArea'/>"
|
|
|
|
" <menuitem action='MoveUp'/>"
|
|
|
|
" <menuitem action='MoveDown'/>"
|
|
|
|
" <menuitem action='Cut'/>"
|
|
|
|
" <menuitem action='Copy'/>"
|
|
|
|
" </popup>"
|
|
|
|
""
|
2005-06-07 03:53:44 +08:00
|
|
|
" <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>"
|
|
|
|
""
|
2005-01-02 16:07:03 +08:00
|
|
|
" <toolbar name='Toolbar'>"
|
|
|
|
" <toolitem action='Open'/>"
|
|
|
|
" <toolitem action='Save'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <toolitem action='Preferences'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <toolitem action='Undo'/>"
|
|
|
|
" <toolitem action='Redo'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <toolitem action='Cut'/>"
|
|
|
|
" <toolitem action='Copy'/>"
|
|
|
|
" <toolitem action='Paste'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <toolitem action='ZoomIn'/>"
|
|
|
|
" <toolitem action='ZoomOut'/>"
|
|
|
|
" <separator/>"
|
|
|
|
" <toolitem action='EditMapInfo'/>"
|
|
|
|
" <separator/>"
|
2005-06-07 03:53:44 +08:00
|
|
|
" <toolitem action='MoveToFront'/>"
|
|
|
|
" <toolitem action='SendToBack'/>"
|
|
|
|
" <separator/>"
|
2005-01-02 16:07:03 +08:00
|
|
|
" <toolitem action='Grid'/>"
|
|
|
|
" </toolbar>"
|
|
|
|
""
|
|
|
|
" <toolbar name='Tools'>"
|
|
|
|
" <toolitem action='Arrow'/>"
|
|
|
|
" <toolitem action='Rectangle'/>"
|
|
|
|
" <toolitem action='Circle'/>"
|
|
|
|
" <toolitem action='Polygon'/>"
|
2005-01-23 19:21:01 +08:00
|
|
|
" <separator/>"
|
|
|
|
" <toolitem action='EditAreaInfo'/>"
|
|
|
|
" </toolbar>"
|
|
|
|
""
|
|
|
|
" <toolbar name='Selection'>"
|
|
|
|
" <toolitem action='MoveUp'/>"
|
|
|
|
" <toolitem action='MoveDown'/>"
|
|
|
|
" <toolitem action='EditAreaInfo'/>"
|
|
|
|
" <toolitem action='Clear'/>"
|
2005-01-02 16:07:03 +08:00
|
|
|
" </toolbar>"
|
|
|
|
"</ui>";
|
1999-09-07 08:03:20 +08:00
|
|
|
|
|
|
|
Menu_t*
|
|
|
|
make_menu(GtkWidget *main_vbox, GtkWidget *window)
|
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
GtkWidget *menubar;
|
|
|
|
GtkActionGroup *action_group;
|
|
|
|
GtkAccelGroup *accel_group;
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
action_group = gtk_action_group_new ("MenuActions");
|
2005-08-23 08:18:08 +08:00
|
|
|
gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries),
|
2005-01-02 16:07:03 +08:00
|
|
|
window);
|
2005-08-23 08:18:08 +08:00
|
|
|
gtk_action_group_add_toggle_actions (action_group, toggle_entries,
|
2005-01-02 16:07:03 +08:00
|
|
|
G_N_ELEMENTS (toggle_entries), window);
|
2006-07-14 21:37:56 +08:00
|
|
|
|
2007-01-03 18:15:59 +08:00
|
|
|
gtk_action_group_add_radio_actions (action_group, color_entries,
|
|
|
|
G_N_ELEMENTS (color_entries), 0,
|
2006-07-14 21:37:56 +08:00
|
|
|
G_CALLBACK (set_preview_color), NULL);
|
2007-01-03 18:15:59 +08:00
|
|
|
gtk_action_group_add_radio_actions (action_group, zoom_entries,
|
|
|
|
G_N_ELEMENTS (zoom_entries), 0,
|
2006-07-14 21:37:56 +08:00
|
|
|
G_CALLBACK (set_zoom_factor), NULL);
|
2005-08-23 08:18:08 +08:00
|
|
|
gtk_action_group_add_radio_actions (action_group, mapping_entries,
|
|
|
|
G_N_ELEMENTS (mapping_entries), 0,
|
2005-01-02 16:07:03 +08:00
|
|
|
G_CALLBACK (set_func), window);
|
|
|
|
|
|
|
|
ui_manager = gtk_ui_manager_new ();
|
|
|
|
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
error = NULL;
|
2005-08-23 08:18:08 +08:00
|
|
|
if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1,
|
2005-01-02 16:07:03 +08:00
|
|
|
&error))
|
|
|
|
{
|
|
|
|
g_message ("building menus failed: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
/* exit (EXIT_FAILURE); */
|
|
|
|
}
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
menubar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu");
|
|
|
|
gtk_widget_show (menubar);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
paste_buffer_add_add_cb(paste_buffer_added, NULL);
|
|
|
|
paste_buffer_add_remove_cb(paste_buffer_removed, NULL);
|
|
|
|
|
|
|
|
set_sensitive ("/MainMenu/EditMenu/Paste", FALSE);
|
|
|
|
menu_shapes_selected (0);
|
|
|
|
|
2006-07-14 21:37:56 +08:00
|
|
|
menu_set_zoom_sensitivity (1);
|
|
|
|
|
2005-01-02 16:07:03 +08:00
|
|
|
return &_menu;
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menu_build_mru_items(MRU_t *mru)
|
|
|
|
{
|
|
|
|
GList *p;
|
2003-01-01 21:23:47 +08:00
|
|
|
gint position = 0;
|
1999-09-07 08:03:20 +08:00
|
|
|
int i;
|
|
|
|
|
2005-02-28 04:39:36 +08:00
|
|
|
return;
|
|
|
|
|
1999-09-07 08:03:20 +08:00
|
|
|
if (_menu.nr_off_mru_items) {
|
2003-01-01 21:23:47 +08:00
|
|
|
GList *children;
|
|
|
|
|
|
|
|
children = gtk_container_get_children(GTK_CONTAINER(_menu.open_recent));
|
1999-09-07 08:03:20 +08:00
|
|
|
p = g_list_nth(children, position);
|
|
|
|
for (i = 0; i < _menu.nr_off_mru_items; i++, p = p->next) {
|
|
|
|
gtk_widget_destroy((GtkWidget*) p->data);
|
|
|
|
}
|
|
|
|
g_list_free(children);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
1999-10-25 04:57:17 +08:00
|
|
|
for (p = mru->list; p; p = p->next, i++) {
|
2003-01-01 21:23:47 +08:00
|
|
|
GtkWidget *item = insert_item_with_label(_menu.open_recent, position++,
|
1999-12-19 03:45:00 +08:00
|
|
|
(gchar*) p->data,
|
|
|
|
menu_mru, p->data);
|
|
|
|
if (i < 9) {
|
|
|
|
guchar accelerator_key = '1' + i;
|
|
|
|
add_accelerator(item, accelerator_key, GDK_CONTROL_MASK);
|
|
|
|
}
|
1999-10-25 04:57:17 +08:00
|
|
|
}
|
2003-05-26 04:10:24 +08:00
|
|
|
_menu.nr_off_mru_items = i;
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-02 16:07:03 +08:00
|
|
|
do_main_popup_menu(GdkEventButton *event)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2005-01-02 16:07:03 +08:00
|
|
|
GtkWidget *popup = gtk_ui_manager_get_widget (ui_manager, "/PopupMenu");
|
|
|
|
gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
|
|
|
|
event->button, event->time);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-02 16:07:03 +08:00
|
|
|
menu_check_grid(gboolean check)
|
1999-09-07 08:03:20 +08:00
|
|
|
{
|
2005-08-23 08:18:08 +08:00
|
|
|
GtkAction *action = gtk_ui_manager_get_action (ui_manager,
|
2005-01-02 16:07:03 +08:00
|
|
|
"/MainMenu/ToolsMenu/Grid");
|
|
|
|
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), check);
|
1999-09-07 08:03:20 +08:00
|
|
|
}
|
|
|
|
|
2005-01-23 19:21:01 +08:00
|
|
|
GtkWidget*
|
|
|
|
make_toolbar(GtkWidget *main_vbox, GtkWidget *window)
|
|
|
|
{
|
|
|
|
GtkWidget *handlebox, *toolbar;
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-01-23 19:21:01 +08:00
|
|
|
handlebox = gtk_handle_box_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), handlebox, FALSE, FALSE, 0);
|
|
|
|
toolbar = gtk_ui_manager_get_widget (ui_manager, "/Toolbar");
|
|
|
|
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (toolbar), 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
gtk_widget_show (handlebox);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-01-23 19:21:01 +08:00
|
|
|
return handlebox;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
|
|
|
make_tools(GtkWidget *window)
|
|
|
|
{
|
|
|
|
GtkWidget *handlebox, *toolbar;
|
|
|
|
|
|
|
|
handlebox = gtk_handle_box_new ();
|
|
|
|
toolbar = gtk_ui_manager_get_widget (ui_manager, "/Tools");
|
2005-08-23 08:18:08 +08:00
|
|
|
gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar),
|
2005-01-23 19:21:01 +08:00
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (toolbar), 0);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
gtk_widget_show (handlebox);
|
|
|
|
|
|
|
|
return handlebox;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
|
|
|
make_selection_toolbar(void)
|
|
|
|
{
|
|
|
|
GtkWidget *toolbar;
|
|
|
|
|
|
|
|
toolbar = gtk_ui_manager_get_widget (ui_manager, "/Selection");
|
|
|
|
|
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
|
|
|
|
gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);
|
|
|
|
|
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
return toolbar;
|
|
|
|
}
|