plug-ins: Port ImageMap to GAction/GMenuModel

Additionally, the ImageMap-specific icons weren't showing up due to the
filenames not matching the references strings ("imap-polygon" but
the filename was "imagemap-polygon.png"). This patch fixes that by
renaming the strings to match file name.
Partial code style fixes were made as well; a lot more are needed.
This commit is contained in:
Alx Sa 2023-02-15 04:29:39 +00:00
parent 8b204d50ff
commit 5102355ac9
27 changed files with 1526 additions and 973 deletions

View File

@ -30,7 +30,9 @@
#include "libgimp/stdplugins-intl.h"
void
do_about_dialog(void)
do_about_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GtkWidget *dialog;
if (!dialog)

View File

@ -23,6 +23,8 @@
#ifndef _IMAP_ABOUT_H
#define _IMAP_ABOUT_H
void do_about_dialog(void);
void do_about_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
#endif /* _IMAP_ABOUT_H */

View File

@ -49,7 +49,7 @@ open_cb (GtkWidget *dialog,
return;
}
load (filename);
load (filename, data);
g_free (filename);
}
@ -57,7 +57,9 @@ open_cb (GtkWidget *dialog,
}
void
do_file_open_dialog (void)
do_file_open_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GtkWidget *dialog;
@ -84,7 +86,7 @@ do_file_open_dialog (void)
&dialog);
g_signal_connect (dialog, "response",
G_CALLBACK (open_cb),
dialog);
user_data);
}
gtk_window_present (GTK_WINDOW (dialog));
@ -109,7 +111,9 @@ save_cb (GtkWidget *dialog,
}
void
do_file_save_as_dialog (void)
do_file_save_as_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GtkWidget *dialog;

View File

@ -23,9 +23,14 @@
#ifndef _IMAP_FILE_H
#define _IMAP_FILE_H
void do_file_open_dialog(void);
void do_file_save_as_dialog(void);
void do_file_error_dialog(const char *error, const char *filename);
void do_file_open_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_file_save_as_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_file_error_dialog (const char *error,
const char *filename);
gboolean load_csim (const char* filename);
gboolean load_cern (const char* filename);

View File

@ -68,12 +68,13 @@ static gint grid_top = 0;
static GridType_t grid_type = GRID_LINES;
static void
grid_settings_ok_cb(gpointer data)
grid_settings_ok_cb (gpointer data)
{
GridDialog_t *param = (GridDialog_t*) data;
gboolean new_snap;
GimpImap *imap = GIMP_IMAP (data);
GridDialog_t *param = (GridDialog_t*) imap->grid_data;
gboolean new_snap;
new_snap = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(param->snap));
new_snap = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (param->snap));
grid_width = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->width));
grid_height = gtk_spin_button_get_value_as_int(
@ -83,18 +84,24 @@ grid_settings_ok_cb(gpointer data)
grid_top = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(param->top));
if (grid_snap != new_snap) {
grid_snap = new_snap;
menu_check_grid(grid_snap);
}
if (grid_snap != new_snap)
{
GAction *action;
grid_snap = new_snap;
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "grid");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), grid_snap);
}
preview_redraw();
}
static void
snap_toggled_cb(GtkWidget *widget, gpointer data)
snap_toggled_cb (GtkWidget *widget,
gpointer data)
{
GridDialog_t *param = (GridDialog_t*) data;
gint sensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
gint sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
gtk_widget_set_sensitive(param->type_frame, sensitive);
gtk_widget_set_sensitive(param->granularity_frame, sensitive);
@ -170,7 +177,7 @@ left_changed_cb(GtkWidget *widget, gpointer data)
}
static void
top_changed_cb(GtkWidget *widget, gpointer data)
top_changed_cb (GtkWidget *widget, gpointer data)
{
GridDialog_t *dialog = (GridDialog_t*) data;
@ -183,18 +190,21 @@ top_changed_cb(GtkWidget *widget, gpointer data)
}
static GridDialog_t*
create_grid_settings_dialog(void)
create_grid_settings_dialog (gpointer user_data)
{
GridDialog_t *data = g_new(GridDialog_t, 1);
GimpImap *imap = GIMP_IMAP (user_data);
GridDialog_t *data = g_new (GridDialog_t, 1);
DefaultDialog_t *dialog;
GtkWidget *main_grid, *grid, *label;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *chain_button;
GtkWidget *main_grid, *grid, *label;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *chain_button;
data->dialog = dialog = make_default_dialog(_("Grid Settings"));
default_dialog_set_ok_cb(dialog, grid_settings_ok_cb, (gpointer) data);
imap->grid_data = data;
default_dialog_set_ok_cb (dialog, grid_settings_ok_cb, (gpointer) imap);
main_grid = default_dialog_add_grid (dialog);
data->snap = gtk_check_button_new_with_mnemonic(_("_Snap-to grid enabled"));
@ -290,7 +300,7 @@ create_grid_settings_dialog(void)
G_CALLBACK (toggle_preview_cb), (gpointer) data);
gtk_widget_show(data->preview);
snap_toggled_cb(data->snap, data);
snap_toggled_cb (data->snap, data);
gtk_widget_show(grid);
gtk_widget_show(frame);
@ -299,19 +309,21 @@ create_grid_settings_dialog(void)
}
void
do_grid_settings_dialog(void)
do_grid_settings_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static GridDialog_t* dialog;
GtkWidget *type;
if (!dialog)
dialog = create_grid_settings_dialog();
dialog = create_grid_settings_dialog (user_data);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->snap), grid_snap);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->width), grid_width);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->height), grid_height);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->left), grid_left);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->top), grid_top);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->snap), grid_snap);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->width), grid_width);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->height), grid_height);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->left), grid_left);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->top), grid_top);
if (grid_type == GRID_HIDDEN)
type = dialog->hidden;
@ -319,9 +331,9 @@ do_grid_settings_dialog(void)
type = dialog->lines;
else
type = dialog->crosses;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(type), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(type), TRUE);
default_dialog_show(dialog->dialog);
default_dialog_show (dialog->dialog);
}
static void
@ -352,7 +364,9 @@ draw_crosses(cairo_t *cr, gint width, gint height)
}
void
draw_grid(cairo_t *cr, gint width, gint height)
draw_grid (cairo_t *cr,
gint width,
gint height)
{
if (grid_snap && grid_type != GRID_HIDDEN)
{
@ -370,28 +384,38 @@ draw_grid(cairo_t *cr, gint width, gint height)
}
void
toggle_grid(void)
toggle_grid (GSimpleAction *action,
GVariant *new_state,
gpointer user_data)
{
grid_snap = !grid_snap;
preview_redraw();
GtkToggleToolButton *grid_toggle;
grid_snap = ! grid_snap;
preview_redraw();
g_simple_action_set_state (action, new_state);
grid_toggle = GTK_TOGGLE_TOOL_BUTTON (GIMP_IMAP (user_data)->grid_toggle);
gtk_toggle_tool_button_set_active (grid_toggle, grid_snap);
}
static gint
grid_nearest_x(gint x)
grid_nearest_x (gint x)
{
return grid_left + (x - grid_left + grid_width / 2) / grid_width
* grid_width;
}
static gint
grid_nearest_y(gint y)
grid_nearest_y (gint y)
{
return grid_top + (y - grid_top + grid_height / 2) / grid_height
* grid_height;
}
void
round_to_grid(gint *x, gint *y)
round_to_grid (gint *x,
gint *y)
{
if (grid_snap) {
*x = grid_nearest_x(*x);

View File

@ -23,12 +23,19 @@
#ifndef _IMAP_GRID_H
#define _IMAP_GRID_H
void do_grid_settings_dialog (void);
void draw_grid (cairo_t *cr, gint width, gint height);
void toggle_grid (void);
void round_to_grid (gint *x, gint *y);
void do_grid_settings_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void draw_grid (cairo_t *cr,
gint width,
gint height);
void toggle_grid (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void round_to_grid (gint *x,
gint *y);
gboolean grid_near_x (gint x);
gboolean grid_near_y (gint y);
gboolean grid_near_x (gint x);
gboolean grid_near_y (gint y);
#endif /* _IMAP_GRID_H */

View File

@ -23,16 +23,16 @@
#ifndef _IMAP_ICONS_H
#define _IMAP_ICONS_H
#define IMAP_ARROW "imap-arrow"
#define IMAP_CIRCLE "imap-circle"
#define IMAP_COORD "imap-coord"
#define IMAP_DIMENSION "imap-dimension"
#define IMAP_JAVA "imap-java"
#define IMAP_LINK "imap-link"
#define IMAP_POLYGON "imap-polygon"
#define IMAP_RECTANGLE "imap-rectangle"
#define IMAP_TO_BACK "imap-to-back"
#define IMAP_TO_FRONT "imap-to-front"
#define IMAP_ARROW "imagemap-arrow"
#define IMAP_CIRCLE "imagemap-circle"
#define IMAP_COORD "imagemap-coord"
#define IMAP_DIMENSION "imagemap-dimension"
#define IMAP_JAVA "imagemap-java"
#define IMAP_LINK "imagemap-link"
#define IMAP_POLYGON "imagemap-polygon"
#define IMAP_RECTANGLE "imagemap-rectangle"
#define IMAP_TO_BACK "imagemap-to-back"
#define IMAP_TO_FRONT "imagemap-to-front"
void init_icons (void);

File diff suppressed because it is too large Load Diff

View File

@ -24,49 +24,70 @@
#define _IMAP_MAIN_H
#include "imap_mru.h"
#include "imap_grid.h"
#include "imap_object.h"
#include "imap_preferences.h"
#include "imap_preview.h"
struct _GimpImap
{
GimpPlugIn parent_instance;
GtkApplication *app;
GtkWidget *dlg;
GtkWidget *grid_toggle;
gpointer grid_data;
gchar *tmp_filename;
GimpDrawable *drawable;
gboolean success;
GtkBuilder *builder;
};
#define PLUG_IN_PROC "plug-in-imagemap"
#define PLUG_IN_BINARY "imagemap"
#define PLUG_IN_ROLE "gimp-imagemap"
#define GIMP_TYPE_IMAP (gimp_imap_get_type ())
G_DECLARE_FINAL_TYPE (GimpImap, gimp_imap, GIMP, IMAP, GimpPlugIn)
typedef enum {NCSA, CERN, CSIM} MapFormat_t;
typedef struct {
MapFormat_t map_format;
gchar *image_name;
gchar *title;
gchar *author;
gchar *default_url;
gchar *description;
gint old_image_width;
gint old_image_height;
gchar *image_name;
gchar *title;
gchar *author;
gchar *default_url;
gchar *description;
gint old_image_width;
gint old_image_height;
gboolean color; /* Color (TRUE) or Gray (FALSE) */
gboolean show_gray;
} MapInfo_t;
void main_set_dimension(gint width, gint height);
void main_clear_dimension(void);
void load(const gchar *filename);
void save_as(const gchar *filename);
void dump_output(gpointer param, OutputFunc_t output);
GtkWidget *get_dialog(void);
MRU_t *get_mru(void);
MapInfo_t *get_map_info(void);
PreferencesData_t *get_preferences(void);
void main_set_dimension (gint width, gint height);
void main_clear_dimension (void);
void load (const gchar *filename,
gpointer data);
void save_as (const gchar *filename);
void dump_output (gpointer param, OutputFunc_t output);
GtkWidget *get_dialog (void);
MRU_t *get_mru (void);
MapInfo_t *get_map_info (void);
PreferencesData_t *get_preferences (void);
gint get_image_width(void);
gint get_image_height(void);
gint get_image_width (void);
gint get_image_height (void);
void set_busy_cursor(void);
void remove_busy_cursor(void);
void set_busy_cursor (void);
void remove_busy_cursor (void);
void main_toolbar_set_grid(gboolean active);
void main_toolbar_set_grid (gboolean active);
void set_zoom(gint zoom_factor);
gint get_real_coord(gint coord);
void set_zoom (gint zoom_factor);
gint get_real_coord (gint coord);
void draw_line(cairo_t *cr, gint x1, gint y1, gint x2,
gint y2);
void draw_rectangle(cairo_t *cr, gboolean filled, gint x, gint y,
@ -83,43 +104,101 @@ void update_shape(Object_t *obj);
void select_shape(GtkWidget *widget, GdkEventButton *event);
void edit_shape(gint x, gint y);
void do_popup_menu(GdkEventButton *event);
void do_popup_menu (GdkEventButton *event,
gpointer data);
void draw_shapes(cairo_t *cr);
void show_url(void);
void hide_url(void);
void set_preview_color (GtkRadioAction *action,
GtkRadioAction *current,
void set_preview_color (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void set_zoom_factor (GtkRadioAction *action,
GtkRadioAction *current,
void set_zoom_factor (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void set_func (GtkRadioAction *action,
GtkRadioAction *current,
void set_func (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void do_edit_selected_shape (void);
void do_zoom_in (void);
void do_zoom_out (void);
void do_close (void);
void do_quit (void);
void do_undo (void);
void do_redo (void);
void do_cut (void);
void do_copy (void);
void do_paste (void);
void do_select_all (void);
void do_deselect_all (void);
void do_clear (void);
void do_move_up (void);
void do_move_down (void);
void do_move_to_front (void);
void do_send_to_back (void);
void do_use_gimp_guides_dialog (void);
void do_create_guides_dialog (void);
void save (void);
void imap_help (void);
void toggle_area_list (void);
void do_edit_selected_shape (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_zoom_in (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_zoom_out (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_close (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_quit (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_undo (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_redo (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_cut (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_copy (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_paste (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_select_all (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_deselect_all (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_clear (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_move_up (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_move_down (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_move_to_front (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_send_to_back (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_use_gimp_guides_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void do_create_guides_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void save (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void imap_help (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
void toggle_area_list (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
const gchar * get_image_name (void);
GtkWidget * add_tool_button (GtkWidget *toolbar,
const char *action,
const char *icon,
const char *label,
const char *tooltip);
GtkWidget * add_toggle_button (GtkWidget *toolbar,
const char *action,
const char *icon,
const char *label,
const char *tooltip);
void add_tool_separator (GtkWidget *toolbar,
gboolean expand);
#endif /* _IMAP_MAIN_H */

View File

@ -41,505 +41,145 @@
#include "libgimp/stdplugins-intl.h"
static Menu_t _menu;
static GtkUIManager *ui_manager;
GtkWidget*
menu_get_widget(const gchar *path)
void
menu_set_zoom_sensitivity (gpointer data,
gint factor)
{
return gtk_ui_manager_get_widget (ui_manager, path);
}
GAction *action;
GimpImap *imap = GIMP_IMAP (data);
static void
set_sensitive (const gchar *path, gboolean sensitive)
{
GtkAction *action = gtk_ui_manager_get_action (ui_manager, path);
g_object_set (action, "sensitive", sensitive, NULL);
}
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "zoom-in");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), factor < 8);
static void
menu_mru(GtkWidget *widget, gpointer data)
{
MRU_t *mru = get_mru();
char *filename = (char*) data;
if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
load(filename);
} else {
do_file_error_dialog(_("Error opening file"), filename);
mru_remove(mru, filename);
menu_build_mru_items(mru);
}
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "zoom-out");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), factor > 1);
}
void
menu_set_zoom_sensitivity(gint factor)
menu_set_zoom (gpointer data,
gint factor)
{
set_sensitive ("/MainMenu/ViewMenu/ZoomIn", factor < 8);
set_sensitive ("/MainMenu/ViewMenu/ZoomOut", factor > 1);
menu_set_zoom_sensitivity (data, factor);
}
void
menu_set_zoom(gint factor)
{
menu_set_zoom_sensitivity (factor);
}
void
menu_shapes_selected(gint count)
menu_shapes_selected (gint count,
gpointer data)
{
GimpImap *imap = GIMP_IMAP (data);
gboolean sensitive = (count > 0);
GAction *action;
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);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "cut");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "copy");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "clear");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "edit-area-info");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "deselect-all");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), sensitive);
}
static void
command_list_changed(Command_t *command, gpointer data)
command_list_changed (Command_t *command,
gpointer data)
{
GtkAction *action;
gchar *label;
GAction *action;
GimpImap *imap;
gchar *label;
action = gtk_ui_manager_get_action (ui_manager, "/MainMenu/EditMenu/Undo");
imap = GIMP_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "undo");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), command != NULL);
label = g_strdup_printf (_("_Undo %s"),
command && command->name ? command->name : "");
g_object_set (action,
"label", label,
"sensitive", command != NULL,
NULL);
/* TODO: Find a way to change GAction label in menu for undo */
g_free (label);
command = command_list_get_redo_command();
command = command_list_get_redo_command ();
action = gtk_ui_manager_get_action (ui_manager, "/MainMenu/EditMenu/Redo");
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "redo");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), command != NULL);
label = g_strdup_printf (_("_Redo %s"),
command && command->name ? command->name : "");
g_object_set (action,
"label", label,
"sensitive", command != NULL,
NULL);
/* TODO: Find a way to change GAction label in menu for redo */
g_free (label);
}
static void
paste_buffer_added(Object_t *obj, gpointer data)
paste_buffer_added (Object_t *obj, gpointer data)
{
set_sensitive("/MainMenu/EditMenu/Paste", TRUE);
GAction *action;
GimpImap *imap = GIMP_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
}
static void
paste_buffer_removed(Object_t *obj, gpointer data)
paste_buffer_removed (Object_t *obj, gpointer data)
{
set_sensitive("/MainMenu/EditMenu/Paste", FALSE);
GAction *action;
GimpImap *imap = GIMP_IMAP (data);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
/* Normal items */
static const GtkActionEntry entries[] =
{
{ "FileMenu", NULL,
N_("_File") },
{ "Open", GIMP_ICON_DOCUMENT_OPEN,
N_("_Open..."), NULL, N_("Open"),
do_file_open_dialog},
{ "Save", GIMP_ICON_DOCUMENT_SAVE,
N_("_Save..."), NULL, N_("Save"),
save},
{ "SaveAs", GIMP_ICON_DOCUMENT_SAVE_AS,
N_("Save _As..."), "<shift><control>S", NULL,
do_file_save_as_dialog},
{ "Close", GIMP_ICON_CLOSE, N_("_Close"), "<primary>w", NULL, do_close},
{ "Quit", GIMP_ICON_APPLICATION_EXIT,
N_("_Quit"), "<primary>q", NULL, do_quit},
{ "EditMenu", NULL, N_("_Edit") },
{ "Undo", GIMP_ICON_EDIT_UNDO,
N_("_Undo"), NULL, N_("Undo"), do_undo},
{ "Redo", GIMP_ICON_EDIT_REDO,
N_("_Redo"), NULL, N_("Redo"), do_redo},
{ "Cut", GIMP_ICON_EDIT_CUT,
N_("Cu_t"), "<primary>x", N_("Cut"), do_cut},
{ "Copy", GIMP_ICON_EDIT_COPY,
N_("_Copy"), "<primary>c", N_("Copy"), do_copy},
{ "Paste", GIMP_ICON_EDIT_PASTE,
N_("_Paste"), "<primary>v", N_("Paste"), do_paste},
{ "Clear", GIMP_ICON_EDIT_DELETE,
N_("_Delete"), NULL, N_("Delete"), do_clear},
{ "SelectAll", NULL,
N_("Select _All"), "<primary>A", NULL, do_select_all},
{ "DeselectAll", NULL,
N_("D_eselect All"), "<shift><primary>A", NULL,
do_deselect_all},
{ "EditAreaInfo", GIMP_ICON_EDIT
, N_("Edit Area _Info..."), NULL,
N_("Edit selected area info"), do_edit_selected_shape},
{ "Preferences", GIMP_ICON_PREFERENCES_SYSTEM,
N_("_Preferences"), NULL, N_("Preferences"),
do_preferences_dialog},
{ "MoveToFront", IMAP_TO_FRONT, "", NULL, N_("Move Area to Front"),
do_move_to_front},
{ "SendToBack", IMAP_TO_BACK, "", NULL, N_("Move Area to Bottom"),
do_send_to_back},
{ "DeleteArea", NULL, N_("Delete Area"), NULL, NULL, NULL},
{ "MoveUp", GIMP_ICON_GO_UP, N_("Move Up"), NULL, NULL, NULL},
{ "MoveDown", GIMP_ICON_GO_DOWN, N_("Move Down"), NULL, NULL, NULL},
{ "InsertPoint", NULL, N_("Insert Point"), NULL, NULL, polygon_insert_point},
{ "DeletePoint", NULL, N_("Delete Point"), NULL, NULL, polygon_delete_point},
{ "ViewMenu", NULL, N_("_View") },
{ "Source", NULL, N_("Source..."), NULL, NULL, do_source_dialog},
{ "ZoomIn", GIMP_ICON_ZOOM_IN, N_("Zoom _In"), "plus", N_("Zoom in"), do_zoom_in},
{ "ZoomOut", GIMP_ICON_ZOOM_OUT, N_("Zoom _Out"), "minus", N_("Zoom out"), do_zoom_out},
{ "ZoomToMenu", NULL, N_("_Zoom To") },
{ "MappingMenu", NULL, N_("_Mapping") },
{ "EditMapInfo", GIMP_ICON_DIALOG_INFORMATION, N_("Edit Map Info..."), NULL,
N_("Edit Map Info"), do_settings_dialog},
{ "ToolsMenu", NULL, N_("_Tools") },
{ "GridSettings", NULL, N_("Grid Settings..."), NULL, NULL,
do_grid_settings_dialog},
{ "UseGimpGuides", NULL, N_("Use GIMP Guides..."), NULL, NULL,
do_use_gimp_guides_dialog},
{ "CreateGuides", NULL, N_("Create Guides..."), NULL, NULL,
do_create_guides_dialog},
{ "HelpMenu", NULL, N_("_Help") },
{ "Contents", GIMP_ICON_HELP, N_("_Contents"), NULL, NULL, imap_help},
{ "About", GIMP_ICON_HELP_ABOUT, N_("_About"), NULL, NULL, do_about_dialog},
{ "ZoomMenu", NULL, N_("_Zoom") },
};
/* Toggle items */
static const GtkToggleActionEntry toggle_entries[] = {
{ "AreaList", NULL, N_("Area List"), NULL, NULL, NULL, TRUE },
{ "Grid", GIMP_ICON_GRID, N_("_Grid"), NULL, N_("Grid"), toggle_grid, FALSE }
};
static const GtkRadioActionEntry color_entries[] = {
{ "Color", NULL, N_("Color"), NULL, NULL, 0},
{ "Gray", NULL, N_("Gray"), NULL, NULL, 1},
};
static const GtkRadioActionEntry mapping_entries[] = {
{ "Arrow", GIMP_ICON_CURSOR, N_("Arrow"), NULL,
N_("Select existing area"), 0},
{ "Rectangle", IMAP_RECTANGLE, N_("Rectangle"), NULL,
N_("Define Rectangle area"), 1},
{ "Circle", IMAP_CIRCLE, N_("Circle"), NULL,
N_("Define Circle/Oval area"), 2},
{ "Polygon", IMAP_POLYGON, N_("Polygon"), NULL,
N_("Define Polygon area"), 3},
};
static const GtkRadioActionEntry zoom_entries[] = {
{ "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 gchar 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='Undo'/>"
" <menuitem action='Redo'/>"
" <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>"
""
" <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'/>"
" <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/>"
" <toolitem action='MoveToFront'/>"
" <toolitem action='SendToBack'/>"
" <separator/>"
" <toolitem action='Grid'/>"
" </toolbar>"
""
" <toolbar name='Tools'>"
" <toolitem action='Arrow'/>"
" <toolitem action='Rectangle'/>"
" <toolitem action='Circle'/>"
" <toolitem action='Polygon'/>"
" <separator/>"
" <toolitem action='EditAreaInfo'/>"
" </toolbar>"
""
" <toolbar name='Selection'>"
" <toolitem action='MoveUp'/>"
" <toolitem action='MoveDown'/>"
" <toolitem action='EditAreaInfo'/>"
" <toolitem action='Clear'/>"
" </toolbar>"
"</ui>";
Menu_t*
make_menu(GtkWidget *main_vbox, GtkWidget *window)
make_menu (GimpImap *imap)
{
GtkWidget *menubar;
GtkActionGroup *action_group;
GtkAccelGroup *accel_group;
GError *error;
GAction *action;
action_group = gtk_action_group_new ("MenuActions");
gtk_action_group_set_translation_domain (action_group, NULL);
paste_buffer_add_add_cb (paste_buffer_added, imap);
paste_buffer_add_remove_cb (paste_buffer_removed, imap);
gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries),
window);
gtk_action_group_add_toggle_actions (action_group, toggle_entries,
G_N_ELEMENTS (toggle_entries), window);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "paste");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
gtk_action_group_add_radio_actions (action_group, color_entries,
G_N_ELEMENTS (color_entries), 0,
G_CALLBACK (set_preview_color), NULL);
gtk_action_group_add_radio_actions (action_group, zoom_entries,
G_N_ELEMENTS (zoom_entries), 0,
G_CALLBACK (set_zoom_factor), NULL);
gtk_action_group_add_radio_actions (action_group, mapping_entries,
G_N_ELEMENTS (mapping_entries), 0,
G_CALLBACK (set_func), window);
menu_shapes_selected (0, imap);
ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
menu_set_zoom_sensitivity (imap, 1);
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
command_list_add_update_cb (command_list_changed, imap);
error = NULL;
if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1,
&error))
{
g_warning ("building menus failed: %s", error->message);
g_error_free (error);
/* exit (EXIT_FAILURE); */
}
command_list_changed (NULL, imap);
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);
menu_set_zoom_sensitivity (1);
command_list_add_update_cb (command_list_changed, NULL);
command_list_changed (NULL, NULL);
return &_menu;
return NULL;
}
void
menu_build_mru_items(MRU_t *mru)
do_main_popup_menu (GdkEventButton *event,
gpointer data)
{
GList *p;
gint position = 0;
int i;
GtkWidget *menu;
GMenuModel *model;
GimpImap *imap = GIMP_IMAP (data);
return;
model = G_MENU_MODEL (gtk_builder_get_object (imap->builder, "imap-main-popup"));
menu = gtk_menu_new_from_model (model);
if (_menu.nr_off_mru_items) {
GList *children;
children = gtk_container_get_children(GTK_CONTAINER(_menu.open_recent));
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;
for (p = mru->list; p; p = p->next, i++) {
GtkWidget *item = insert_item_with_label(_menu.open_recent, position++,
(gchar*) p->data,
menu_mru, p->data);
if (i < 9) {
guchar accelerator_key = '1' + i;
add_accelerator(item, accelerator_key, GDK_CONTROL_MASK);
}
}
_menu.nr_off_mru_items = i;
}
void
do_main_popup_menu(GdkEventButton *event)
{
GtkWidget *popup = gtk_ui_manager_get_widget (ui_manager, "/PopupMenu");
gtk_menu_popup_at_pointer (GTK_MENU (popup), (GdkEvent *) event);
}
void
menu_check_grid(gboolean check)
{
GtkAction *action = gtk_ui_manager_get_action (ui_manager,
"/MainMenu/ToolsMenu/Grid");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), check);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (imap->dlg), NULL);
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
}
GtkWidget*
make_toolbar(GtkWidget *main_vbox, GtkWidget *window)
make_selection_toolbar (GimpImap *imap)
{
GtkWidget *toolbar;
GtkWidget *toolbar = gtk_toolbar_new ();
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_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_widget_show (toolbar);
return toolbar;
}
GtkWidget*
make_tools(GtkWidget *window)
{
GtkWidget *toolbar;
toolbar = gtk_ui_manager_get_widget (ui_manager, "/Tools");
gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
GTK_ORIENTATION_VERTICAL);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
gtk_container_set_border_width (GTK_CONTAINER (toolbar), 0);
gtk_widget_show (toolbar);
return toolbar;
}
GtkWidget*
make_selection_toolbar(void)
{
GtkWidget *toolbar;
toolbar = gtk_ui_manager_get_widget (ui_manager, "/Selection");
add_tool_button (toolbar, "app.move-up", GIMP_ICON_GO_UP,
_("Move Up"), _("Move Up"));
add_tool_button (toolbar, "app.move-down", GIMP_ICON_GO_DOWN,
_("Move Down"), _("Move Down"));
add_tool_button (toolbar, "app.edit-area-info", GIMP_ICON_EDIT,
_("Edit Area Info..."), _("Edit selected area info"));
add_tool_button (toolbar, "app.clear", GIMP_ICON_EDIT_DELETE,
_("Delete"), _("Delete"));
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),

View File

@ -47,19 +47,19 @@ 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);
Menu_t *make_menu (GimpImap *imap);
void menu_build_mru_items (MRU_t *mru);
void menu_set_zoom_sensitivity (gpointer data,
gint factor);
void menu_set_zoom(gint factor);
void menu_check_grid(gboolean check);
void menu_shapes_selected(gint count);
void menu_set_zoom (gpointer data,
gint factor);
void menu_shapes_selected (gint count,
gpointer imap);
void do_main_popup_menu(GdkEventButton *event);
void do_main_popup_menu (GdkEventButton *event,
gpointer data);
GtkWidget *make_toolbar(GtkWidget *main_vbox, GtkWidget *window);
GtkWidget *make_tools(GtkWidget *window);
GtkWidget *make_selection_toolbar(void);
GtkWidget *make_selection_toolbar (GimpImap *imap);
#endif /* _IMAP_MENU_H */

View File

@ -46,13 +46,16 @@ add_accelerator(GtkWidget *widget, guint accelerator_key,
}
GtkWidget*
insert_item_with_label(GtkWidget *parent, gint position, gchar *label,
MenuCallback activate, gpointer data)
insert_item_with_label (GtkWidget *parent,
gint position,
gchar *label,
MenuCallback activate,
gpointer data)
{
GtkWidget *item = gtk_image_menu_item_new_with_mnemonic(label);
gtk_menu_shell_insert(GTK_MENU_SHELL(parent), item, position);
g_signal_connect(item, "activate", G_CALLBACK(activate), data);
gtk_widget_show(item);
GtkWidget *item = gtk_menu_item_new_with_mnemonic (label);
gtk_menu_shell_insert (GTK_MENU_SHELL (parent), item, position);
g_signal_connect (item, "activate", G_CALLBACK (activate), data);
gtk_widget_show (item);
return item;
}

View File

@ -75,7 +75,9 @@ struct ObjectClass_t {
void (*write_csim)(Object_t *obj, gpointer param, OutputFunc_t output);
void (*write_cern)(Object_t *obj, gpointer param, OutputFunc_t output);
void (*write_ncsa)(Object_t *obj, gpointer param, OutputFunc_t output);
void (*do_popup)(Object_t *obj, GdkEventButton *event);
void (*do_popup)(Object_t *obj,
GdkEventButton *event,
gpointer data);
const gchar* (*get_icon_name)(void);
};

View File

@ -32,7 +32,10 @@
#include "libgimp/stdplugins-intl.h"
void
object_handle_popup(ObjectPopup_t *popup, Object_t *obj, GdkEventButton *event)
object_handle_popup (ObjectPopup_t *popup,
Object_t *obj,
GdkEventButton *event,
GimpImap *imap)
{
/* int position = object_get_position_in_list(obj) + 1; */
@ -42,18 +45,25 @@ object_handle_popup(ObjectPopup_t *popup, Object_t *obj, GdkEventButton *event)
(position < g_list_length(obj->list->list))
? TRUE : FALSE);
#endif
gtk_menu_attach_to_widget (GTK_MENU (popup->menu), GTK_WIDGET (imap->dlg), NULL);
gtk_menu_popup_at_pointer (GTK_MENU (popup->menu), (GdkEvent *) event);
}
void
object_do_popup(Object_t *obj, GdkEventButton *event)
object_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data)
{
static ObjectPopup_t *popup;
static ObjectPopup_t *popup;
GMenuModel *model;
GimpImap *imap = GIMP_IMAP (data);
if (!popup)
if (! popup)
{
popup = g_new (ObjectPopup_t, 1);
popup->menu = menu_get_widget ("/ObjectPopupMenu");
popup = g_new (ObjectPopup_t, 1);
model = G_MENU_MODEL (gtk_builder_get_object
(imap->builder, "imap-object-popup"));
popup->menu = gtk_menu_new_from_model (model);
}
object_handle_popup (popup, obj, event);
object_handle_popup (popup, obj, event, imap);
}

View File

@ -32,8 +32,12 @@ typedef struct {
Object_t *obj;
} ObjectPopup_t;
void object_handle_popup(ObjectPopup_t *popup, Object_t *obj,
GdkEventButton *event);
void object_do_popup(Object_t *obj, GdkEventButton *event);
void object_handle_popup (ObjectPopup_t *popup,
Object_t *obj,
GdkEventButton *event,
GimpImap *imap);
void object_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data);
#endif /* _IMAP_OBJECT_POPUP_H */

View File

@ -65,7 +65,9 @@ static void polygon_write_cern(Object_t* obj, gpointer param,
OutputFunc_t output);
static void polygon_write_ncsa(Object_t* obj, gpointer param,
OutputFunc_t output);
static void polygon_do_popup(Object_t *obj, GdkEventButton *event);
static void polygon_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data);
static const gchar* polygon_get_icon_name(void);
static ObjectClass_t polygon_class = {
@ -656,7 +658,9 @@ static gint _insert_x;
static gint _insert_y;
void
polygon_insert_point(void)
polygon_insert_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data)
{
Command_t *command = insert_point_command_new (_current_obj, _insert_x,
_insert_y, _insert_edge);
@ -664,7 +668,9 @@ polygon_insert_point(void)
}
void
polygon_delete_point(void)
polygon_delete_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data)
{
Command_t *command = delete_point_command_new(_current_obj, _sash_point);
command_execute (command);
@ -708,30 +714,41 @@ polygon_near_edge(Object_t *obj, gint x, gint y)
}
static void
polygon_handle_popup (GdkEventButton *event, gboolean near_sash,
gboolean near_edge)
polygon_handle_popup (GdkEventButton *event,
GimpImap *imap,
gboolean near_sash,
gboolean near_edge)
{
GtkWidget *popup = menu_get_widget ("/PolygonPopupMenu");
GtkWidget *delete = menu_get_widget ("/PolygonPopupMenu/DeletePoint");
GtkWidget *insert = menu_get_widget ("/PolygonPopupMenu/InsertPoint");
GtkWidget *menu;
GMenuModel *model;
GAction *action;
gtk_widget_set_sensitive (delete, near_sash);
gtk_widget_set_sensitive (insert, near_edge);
model = G_MENU_MODEL (gtk_builder_get_object (imap->builder, "imap-polygon-popup"));
menu = gtk_menu_new_from_model (model);
gtk_menu_popup_at_pointer (GTK_MENU (popup), (GdkEvent *) event);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "insert-point");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), near_edge);
action = g_action_map_lookup_action (G_ACTION_MAP (imap->app), "delete-point");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), near_sash);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (imap->dlg), NULL);
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
}
static void
polygon_do_popup(Object_t *obj, GdkEventButton *event)
polygon_do_popup (Object_t *obj,
GdkEventButton *event,
gpointer data)
{
gint x = get_real_coord ((gint) event->x);
gint y = get_real_coord ((gint) event->y);
gint x = get_real_coord ((gint) event->x);
gint y = get_real_coord ((gint) event->y);
GimpImap *imap = GIMP_IMAP (data);
_current_obj = obj;
if (polygon_near_sash (obj, x, y))
{
polygon_handle_popup (event, TRUE, FALSE);
polygon_handle_popup (event, imap, TRUE, FALSE);
}
else
{
@ -739,13 +756,14 @@ polygon_do_popup(Object_t *obj, GdkEventButton *event)
if (_insert_edge)
{
_insert_x = x;
_insert_y = y;
_insert_y = y;
polygon_handle_popup (event, FALSE, TRUE);
polygon_handle_popup (event,imap, FALSE, TRUE);
}
else
{
object_do_popup (obj, event, imap);
}
else {
object_do_popup (obj, event);
}
}
}

View File

@ -25,21 +25,29 @@
#include "imap_object.h"
typedef struct {
Object_t obj;
GList *points;
typedef struct
{
Object_t obj;
GList *points;
} Polygon_t;
#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_insert_point (void);
void polygon_delete_point (void);
void polygon_insert_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
void polygon_delete_point (GSimpleAction *action,
GVariant *new_state,
gpointer user_data);
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_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 */

View File

@ -271,7 +271,7 @@ preferences_save(PreferencesData_t *data)
}
static void
preferences_ok_cb(gpointer data)
preferences_ok_cb (gpointer data)
{
PreferencesDialog_t *param = (PreferencesDialog_t*) data;
PreferencesData_t *old_data = param->old_data;
@ -299,12 +299,11 @@ preferences_ok_cb(gpointer data)
GTK_TOGGLE_BUTTON(param->use_doublesized));
old_data->mru_size =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->mru_size));
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(param->mru_size));
old_data->undo_levels =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(param->undo_levels));
mru_set_size(mru, old_data->mru_size);
menu_build_mru_items(mru);
command_list_set_undo_level(old_data->undo_levels);
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(param->undo_levels));
mru_set_size (mru, old_data->mru_size);
command_list_set_undo_level (old_data->undo_levels);
get_button_colors (param, colors);
@ -504,7 +503,9 @@ create_preferences_dialog(void)
}
void
do_preferences_dialog(void)
do_preferences_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static PreferencesDialog_t *dialog;
PreferencesData_t *old_data;

View File

@ -49,8 +49,10 @@ typedef struct {
ColorSelData_t colors;
} PreferencesData_t;
void do_preferences_dialog(void);
gboolean preferences_load(PreferencesData_t *data);
void preferences_save(PreferencesData_t *data);
void do_preferences_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
gboolean preferences_load (PreferencesData_t *data);
void preferences_save (PreferencesData_t *data);
#endif /* _IMAP_PREFERENCES_H */

View File

@ -128,10 +128,12 @@ render_preview (Preview_t *preview_base,
}
static gboolean
arrow_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
arrow_cb (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
{
if (event->button == 1)
do_main_popup_menu(event);
do_main_popup_menu (event, data);
return TRUE;
}
@ -254,9 +256,10 @@ scroll_adj_changed (GtkAdjustment *adj,
}
Preview_t *
make_preview (GimpDrawable *drawable)
make_preview (GimpDrawable *drawable,
gpointer imap)
{
Preview_t *data = g_new(Preview_t, 1);
Preview_t *data = g_new (Preview_t, 1);
GtkAdjustment *hadj;
GtkAdjustment *vadj;
GtkWidget *preview;
@ -310,7 +313,7 @@ make_preview (GimpDrawable *drawable)
g_signal_connect (button, "button-press-event",
G_CALLBACK (arrow_cb),
NULL);
imap);
arrow = gtk_image_new_from_icon_name (GIMP_ICON_GO_NEXT,
GTK_ICON_SIZE_BUTTON);

View File

@ -39,8 +39,9 @@ typedef struct {
GdkCursorType cursor;
} Preview_t;
Preview_t *make_preview(GimpDrawable *drawable);
void preview_redraw(void);
Preview_t *make_preview (GimpDrawable *drawable,
gpointer imap);
void preview_redraw (void);
void preview_unset_tmp_obj (Object_t *obj);
void preview_set_tmp_obj (Object_t *obj);

View File

@ -307,7 +307,8 @@ render_comment (GtkTreeViewColumn *column, GtkCellRenderer *cell,
}
Selection_t*
make_selection(ObjectList_t *object_list)
make_selection (ObjectList_t *object_list,
GimpImap *imap)
{
Selection_t *data = g_new(Selection_t, 1);
GtkWidget *swin, *frame, *hbox;
@ -331,7 +332,7 @@ make_selection(ObjectList_t *object_list)
gtk_container_add(GTK_CONTAINER(frame), hbox);
gtk_widget_show(hbox);
toolbar = make_selection_toolbar ();
toolbar = make_selection_toolbar (imap);
gtk_box_pack_start (GTK_BOX (hbox), toolbar, TRUE, TRUE, 0);
/* Create selection */
@ -418,7 +419,7 @@ make_selection(ObjectList_t *object_list)
/* Callbacks we are interested in */
data->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
gtk_tree_selection_set_mode (data->selection, GTK_SELECTION_MULTIPLE);
g_signal_connect (data->selection, "changed", G_CALLBACK(changed_cb), data);
g_signal_connect (data->selection, "changed", G_CALLBACK (changed_cb), data);
/* Set object list callbacks we're interested in */
object_list_add_add_cb (object_list, object_added_cb, data);

View File

@ -46,7 +46,8 @@ typedef struct {
CommandFactory_t cmd_edit;
} Selection_t;
Selection_t *make_selection(ObjectList_t *list);
Selection_t *make_selection (ObjectList_t *list,
GimpImap *imap);
void selection_toggle_visibility(Selection_t *selection);
void selection_freeze(Selection_t *selection);
void selection_thaw(Selection_t *selection);

View File

@ -35,21 +35,21 @@
typedef struct {
DefaultDialog_t *dialog;
BrowseWidget_t *imagename;
GtkWidget *filename;
GtkWidget *title;
GtkWidget *author;
GtkWidget *default_url;
GtkWidget *ncsa;
GtkWidget *cern;
GtkWidget *csim;
GtkTextBuffer *description;
BrowseWidget_t *imagename;
GtkWidget *filename;
GtkWidget *title;
GtkWidget *author;
GtkWidget *default_url;
GtkWidget *ncsa;
GtkWidget *cern;
GtkWidget *csim;
GtkTextBuffer *description;
} SettingsDialog_t;
static MapFormat_t _map_format = CSIM;
static void
settings_ok_cb(gpointer data)
settings_ok_cb (gpointer data)
{
SettingsDialog_t *param = (SettingsDialog_t*) data;
MapInfo_t *info = get_map_info();
@ -72,14 +72,14 @@ settings_ok_cb(gpointer data)
}
static void
type_toggled_cb(GtkWidget *widget, gpointer data)
type_toggled_cb (GtkWidget *widget, gpointer data)
{
if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED)
_map_format = (MapFormat_t) data;
}
static SettingsDialog_t*
create_settings_dialog(void)
create_settings_dialog (void)
{
SettingsDialog_t *data = g_new(SettingsDialog_t, 1);
GtkWidget *grid, *view, *frame, *hbox, *label, *swin;
@ -155,7 +155,9 @@ create_settings_dialog(void)
}
void
do_settings_dialog(void)
do_settings_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static SettingsDialog_t *dialog;
const char *filename = get_filename();

View File

@ -23,6 +23,8 @@
#ifndef _IMAP_SETTINGS_H
#define _IMAP_SETTINGS_H
void do_settings_dialog(void);
void do_settings_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
#endif /* _IMAP_SETTINGS_H */

View File

@ -38,7 +38,7 @@ static void save_to_view (GtkTextBuffer *buffer,
...) G_GNUC_PRINTF(2,3);
static void
save_to_view(GtkTextBuffer *buffer, const char* format, ...)
save_to_view (GtkTextBuffer *buffer, const char* format, ...)
{
va_list ap;
char scratch[1024];
@ -53,7 +53,9 @@ save_to_view(GtkTextBuffer *buffer, const char* format, ...)
}
void
do_source_dialog(void)
do_source_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
static DefaultDialog_t *dialog;
static GtkWidget *text;

View File

@ -23,6 +23,8 @@
#ifndef _IMAP_SOURCE_H
#define _IMAP_SOURCE_H
void do_source_dialog(void);
void do_source_dialog (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
#endif /* _IMAP_SOURCE_H */