Commit 3d526e74 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/display/gimpdisplayshell-callbacks.[ch] override

2003-02-25  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-callbacks.[ch]
	* app/display/gimpdisplayshell.c: override GtkWidget::popup_menu()
	so we popup the Image menu on the default shortcut (Shift F10).

	* app/gui/image-menu.c (image_menu_entries): removed or replaced
	shortcuts that use the Alt key. Added access keys to all toplevel
	entries of the Image menu (see bug #106991).

	* app/gui/tools-commands.[ch]: removed "Swap Contexts" functionality.

	* app/widgets/gimpselectioneditor.[ch]: moved "Invert" button.
parent f6a95200
2003-02-25 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-callbacks.[ch]
* app/display/gimpdisplayshell.c: override GtkWidget::popup_menu()
so we popup the Image menu on the default shortcut (Shift F10).
* app/gui/image-menu.c (image_menu_entries): removed or replaced
shortcuts that use the Alt key. Added access keys to all toplevel
entries of the Image menu (see bug #106991).
* app/gui/tools-commands.[ch]: removed "Swap Contexts" functionality.
* app/widgets/gimpselectioneditor.[ch]: moved "Invert" button.
2003-02-25 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell.[ch]: replaced the "gboolean
......@@ -66,36 +66,6 @@ tools_swap_colors_cmd_callback (GtkWidget *widget,
gimp_context_swap_colors (gimp_get_user_context (gimp));
}
void
tools_swap_contexts_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
static GimpContext *swap_context = NULL;
static GimpContext *temp_context = NULL;
Gimp *gimp;
return_if_no_gimp (gimp, data);
if (! swap_context)
{
swap_context = gimp_context_new (gimp, "Swap Context",
gimp_get_user_context (gimp));
temp_context = gimp_context_new (gimp, "Temp Context",
NULL);
}
gimp_context_copy_properties (gimp_get_user_context (gimp),
temp_context,
GIMP_CONTEXT_ALL_PROPS_MASK);
gimp_context_copy_properties (swap_context,
gimp_get_user_context (gimp),
GIMP_CONTEXT_ALL_PROPS_MASK);
gimp_context_copy_properties (temp_context,
swap_context,
GIMP_CONTEXT_ALL_PROPS_MASK);
}
void
tools_select_cmd_callback (GtkWidget *widget,
gpointer data,
......
......@@ -26,9 +26,6 @@ void tools_default_colors_cmd_callback (GtkWidget *widget,
void tools_swap_colors_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void tools_swap_contexts_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void tools_select_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
......
......@@ -115,57 +115,19 @@ gimp_display_shell_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell)
{
Gimp *gimp = shell->gdisp->gimage->gimp;
gboolean set_display = FALSE;
gboolean popup_menu = FALSE;
Gimp *gimp = shell->gdisp->gimage->gimp;
gboolean set_display = FALSE;
GdkEventKey *kevent;
switch (event->type)
{
GdkEventKey *kevent;
case GDK_KEY_PRESS:
if (! GTK_WIDGET_VISIBLE (GTK_ITEM_FACTORY (shell->menubar_factory)->widget))
{
gchar *accel = NULL;
g_object_get (gtk_widget_get_settings (widget),
"gtk-menu-bar-accel", &accel,
NULL);
if (accel)
{
guint keyval = 0;
GdkModifierType mods = 0;
gtk_accelerator_parse (accel, &keyval, &mods);
if (keyval == 0)
g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
kevent = (GdkEventKey *) event;
/* FIXME this is wrong, needs to be in the global accel
* resolution thing, to properly consider i18n etc., but
* that probably requires AccelGroup changes etc.
*/
if (kevent->keyval == keyval &&
((kevent->state & gtk_accelerator_get_default_mod_mask ()) ==
(mods & gtk_accelerator_get_default_mod_mask ())))
{
popup_menu = TRUE;
}
g_free (accel);
}
}
/* fallthru */
case GDK_KEY_RELEASE:
kevent = (GdkEventKey *) event;
if (gimp->busy)
return TRUE;
kevent = (GdkEventKey *) event;
/* do not process any key events while BUTTON1 is down. We do this
* so tools keep the modifier state they were in when BUTTON1 was
* pressed and to prevent accelerators from being invoked.
......@@ -194,12 +156,12 @@ gimp_display_shell_events (GtkWidget *widget,
switch (kevent->keyval)
{
case GDK_Left: case GDK_Right:
case GDK_Up: case GDK_Down:
case GDK_Left: case GDK_Right:
case GDK_Up: case GDK_Down:
case GDK_space:
case GDK_Tab:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Alt_L: case GDK_Alt_R:
case GDK_Shift_L: case GDK_Shift_R:
case GDK_Control_L: case GDK_Control_R:
break;
......@@ -228,12 +190,6 @@ gimp_display_shell_events (GtkWidget *widget,
shell->gdisp);
}
if (popup_menu)
{
gimp_display_shell_origin_menu_popup (shell, 0, event->key.time);
return TRUE;
}
return FALSE;
}
......@@ -364,6 +320,14 @@ gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
shell->draw_cursor = ! current_device->has_cursor;
}
gboolean
gimp_display_shell_popup_menu (GtkWidget *widget)
{
gimp_display_shell_origin_menu_popup (GIMP_DISPLAY_SHELL (widget), 0, 0);
return TRUE;
}
gboolean
gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
GdkEvent *event,
......
......@@ -46,6 +46,7 @@ gboolean gimp_display_shell_canvas_configure (GtkWidget *widget,
gboolean gimp_display_shell_canvas_expose (GtkWidget *widget,
GdkEventExpose *eevent,
GimpDisplayShell *shell);
gboolean gimp_display_shell_popup_menu (GtkWidget *widget);
gboolean gimp_display_shell_canvas_tool_events (GtkWidget *widget,
GdkEvent *event,
GimpDisplayShell *shell);
......
......@@ -172,6 +172,7 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
object_class->destroy = gimp_display_shell_destroy;
widget_class->delete_event = gimp_display_shell_delete_event;
widget_class->popup_menu = gimp_display_shell_popup_menu;
klass->scaled = gimp_display_shell_real_scaled;
klass->scrolled = NULL;
......
......@@ -172,6 +172,7 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
object_class->destroy = gimp_display_shell_destroy;
widget_class->delete_event = gimp_display_shell_delete_event;
widget_class->popup_menu = gimp_display_shell_popup_menu;
klass->scaled = gimp_display_shell_real_scaled;
klass->scrolled = NULL;
......
......@@ -75,6 +75,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/File */
MENU_BRANCH (N_("/_File")),
{ { N_("/File/New..."), "<control>N",
file_new_cmd_callback, 1,
"<StockItem>", GTK_STOCK_NEW },
......@@ -130,6 +132,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Edit */
MENU_BRANCH (N_("/_Edit")),
{ { N_("/Edit/Undo"), "<control>Z",
edit_undo_cmd_callback, 0,
"<StockItem>", GTK_STOCK_UNDO },
......@@ -214,11 +218,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Select */
{ { N_("/Select/Invert"), "<control>I",
select_invert_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_INVERT },
NULL,
"select/invert.html", NULL },
MENU_BRANCH (N_("/_Select")),
{ { N_("/Select/All"), "<control>A",
select_all_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_SELECTION_ALL },
......@@ -229,6 +230,11 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GIMP_STOCK_SELECTION_NONE },
NULL,
"select/none.html", NULL },
{ { N_("/Select/Invert"), "<control>I",
select_invert_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_INVERT },
NULL,
"select/invert.html", NULL },
{ { N_("/Select/Float"), "<control><shift>L",
select_float_cmd_callback, 0 },
NULL,
......@@ -236,11 +242,11 @@ GimpItemFactoryEntry image_menu_entries[] =
MENU_SEPARATOR ("/Select/---"),
{ { N_("/Select/Feather..."), "<control><shift>F",
{ { N_("/Select/Feather..."), NULL,
select_feather_cmd_callback, 0 },
NULL,
"select/dialogs/feather_selection.html", NULL },
{ { N_("/Select/Sharpen"), "<control><shift>H",
{ { N_("/Select/Sharpen"), NULL,
select_sharpen_cmd_callback, 0 },
NULL,
"select/sharpen.html", NULL },
......@@ -274,6 +280,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/View */
MENU_BRANCH (N_("/_View")),
{ { N_("/View/Zoom In"), "equal",
view_zoom_in_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_IN },
......@@ -406,19 +414,23 @@ GimpItemFactoryEntry image_menu_entries[] =
NULL,
"view/new_view.html", NULL },
/* <Image>/Image */
MENU_BRANCH (N_("/_Image")),
/* <Image>/Image/Mode */
{ { N_("/Image/Mode/RGB"), "<alt>R",
{ { N_("/Image/Mode/RGB"), NULL,
image_convert_rgb_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_CONVERT_RGB },
NULL,
"image/mode/convert_to_rgb.html", NULL },
{ { N_("/Image/Mode/Grayscale"), "<alt>G",
{ { N_("/Image/Mode/Grayscale"), NULL,
image_convert_grayscale_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_CONVERT_GRAYSCALE },
NULL,
"image/mode/convert_to_grayscale.html", NULL },
{ { N_("/Image/Mode/Indexed..."), "<alt>I",
{ { N_("/Image/Mode/Indexed..."), NULL,
image_convert_indexed_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_CONVERT_INDEXED },
NULL,
......@@ -466,7 +478,9 @@ GimpItemFactoryEntry image_menu_entries[] =
NULL,
"layers/flatten_image.html", NULL },
/* <Image>/Layer */
/* <Image>/Layer */
MENU_BRANCH (N_("/_Layer")),
/* <Image>/Layer/Stack */
......@@ -626,6 +640,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Tools */
MENU_BRANCH (N_("/_Tools")),
{ { N_("/Tools/Toolbox"), NULL,
dialogs_show_toolbox_cmd_callback, 0 },
NULL,
......@@ -640,10 +656,6 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GIMP_STOCK_SWAP_COLORS },
NULL,
"toolbox/toolbox.html#swap_colors", NULL },
{ { N_("/Tools/Swap Contexts"), "<alt>X",
tools_swap_contexts_cmd_callback, 0 },
NULL,
"toolbox/toolbox.html#swap_colors", NULL },
MENU_SEPARATOR ("/Tools/---"),
......@@ -653,6 +665,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Dialogs */
MENU_BRANCH (N_("/_Dialogs")),
{ { N_("/Dialogs/Layers, Channels & Paths..."), NULL,
dialogs_create_lc_cmd_callback, 0 },
NULL,
......@@ -756,16 +770,18 @@ GimpItemFactoryEntry image_menu_entries[] =
"gimp-error-console",
"dialogs/error_console.html", NULL },
MENU_SEPARATOR ("/filters-separator"),
/* <Image>/Filters */
{ { N_("/Filters/Repeat Last"), "<alt>F",
MENU_SEPARATOR ("/filters-separator"),
MENU_BRANCH (N_("/Filte_rs")),
{ { N_("/Filters/Repeat Last"), "<control>F",
plug_in_repeat_cmd_callback, (guint) FALSE,
"<StockItem>", GTK_STOCK_EXECUTE },
NULL,
"filters/repeat_last.html", NULL },
{ { N_("/Filters/Re-Show Last"), "<alt><shift>F",
{ { N_("/Filters/Re-Show Last"), "<control><shift>F",
plug_in_repeat_cmd_callback, (guint) TRUE,
"<StockItem>", GIMP_STOCK_RESHOW_FILTER },
NULL,
......
......@@ -66,36 +66,6 @@ tools_swap_colors_cmd_callback (GtkWidget *widget,
gimp_context_swap_colors (gimp_get_user_context (gimp));
}
void
tools_swap_contexts_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
static GimpContext *swap_context = NULL;
static GimpContext *temp_context = NULL;
Gimp *gimp;
return_if_no_gimp (gimp, data);
if (! swap_context)
{
swap_context = gimp_context_new (gimp, "Swap Context",
gimp_get_user_context (gimp));
temp_context = gimp_context_new (gimp, "Temp Context",
NULL);
}
gimp_context_copy_properties (gimp_get_user_context (gimp),
temp_context,
GIMP_CONTEXT_ALL_PROPS_MASK);
gimp_context_copy_properties (swap_context,
gimp_get_user_context (gimp),
GIMP_CONTEXT_ALL_PROPS_MASK);
gimp_context_copy_properties (temp_context,
swap_context,
GIMP_CONTEXT_ALL_PROPS_MASK);
}
void
tools_select_cmd_callback (GtkWidget *widget,
gpointer data,
......
......@@ -26,9 +26,6 @@ void tools_default_colors_cmd_callback (GtkWidget *widget,
void tools_swap_colors_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void tools_swap_contexts_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void tools_select_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
......
......@@ -75,6 +75,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/File */
MENU_BRANCH (N_("/_File")),
{ { N_("/File/New..."), "<control>N",
file_new_cmd_callback, 1,
"<StockItem>", GTK_STOCK_NEW },
......@@ -130,6 +132,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Edit */
MENU_BRANCH (N_("/_Edit")),
{ { N_("/Edit/Undo"), "<control>Z",
edit_undo_cmd_callback, 0,
"<StockItem>", GTK_STOCK_UNDO },
......@@ -214,11 +218,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Select */
{ { N_("/Select/Invert"), "<control>I",
select_invert_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_INVERT },
NULL,
"select/invert.html", NULL },
MENU_BRANCH (N_("/_Select")),
{ { N_("/Select/All"), "<control>A",
select_all_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_SELECTION_ALL },
......@@ -229,6 +230,11 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GIMP_STOCK_SELECTION_NONE },
NULL,
"select/none.html", NULL },
{ { N_("/Select/Invert"), "<control>I",
select_invert_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_INVERT },
NULL,
"select/invert.html", NULL },
{ { N_("/Select/Float"), "<control><shift>L",
select_float_cmd_callback, 0 },
NULL,
......@@ -236,11 +242,11 @@ GimpItemFactoryEntry image_menu_entries[] =
MENU_SEPARATOR ("/Select/---"),
{ { N_("/Select/Feather..."), "<control><shift>F",
{ { N_("/Select/Feather..."), NULL,
select_feather_cmd_callback, 0 },
NULL,
"select/dialogs/feather_selection.html", NULL },
{ { N_("/Select/Sharpen"), "<control><shift>H",
{ { N_("/Select/Sharpen"), NULL,
select_sharpen_cmd_callback, 0 },
NULL,
"select/sharpen.html", NULL },
......@@ -274,6 +280,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/View */
MENU_BRANCH (N_("/_View")),
{ { N_("/View/Zoom In"), "equal",
view_zoom_in_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ZOOM_IN },
......@@ -406,19 +414,23 @@ GimpItemFactoryEntry image_menu_entries[] =
NULL,
"view/new_view.html", NULL },
/* <Image>/Image */
MENU_BRANCH (N_("/_Image")),
/* <Image>/Image/Mode */
{ { N_("/Image/Mode/RGB"), "<alt>R",
{ { N_("/Image/Mode/RGB"), NULL,
image_convert_rgb_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_CONVERT_RGB },
NULL,
"image/mode/convert_to_rgb.html", NULL },
{ { N_("/Image/Mode/Grayscale"), "<alt>G",
{ { N_("/Image/Mode/Grayscale"), NULL,
image_convert_grayscale_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_CONVERT_GRAYSCALE },
NULL,
"image/mode/convert_to_grayscale.html", NULL },
{ { N_("/Image/Mode/Indexed..."), "<alt>I",
{ { N_("/Image/Mode/Indexed..."), NULL,
image_convert_indexed_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_CONVERT_INDEXED },
NULL,
......@@ -466,7 +478,9 @@ GimpItemFactoryEntry image_menu_entries[] =
NULL,
"layers/flatten_image.html", NULL },
/* <Image>/Layer */
/* <Image>/Layer */
MENU_BRANCH (N_("/_Layer")),
/* <Image>/Layer/Stack */
......@@ -626,6 +640,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Tools */
MENU_BRANCH (N_("/_Tools")),
{ { N_("/Tools/Toolbox"), NULL,
dialogs_show_toolbox_cmd_callback, 0 },
NULL,
......@@ -640,10 +656,6 @@ GimpItemFactoryEntry image_menu_entries[] =
"<StockItem>", GIMP_STOCK_SWAP_COLORS },
NULL,
"toolbox/toolbox.html#swap_colors", NULL },
{ { N_("/Tools/Swap Contexts"), "<alt>X",
tools_swap_contexts_cmd_callback, 0 },
NULL,
"toolbox/toolbox.html#swap_colors", NULL },
MENU_SEPARATOR ("/Tools/---"),
......@@ -653,6 +665,8 @@ GimpItemFactoryEntry image_menu_entries[] =
/* <Image>/Dialogs */
MENU_BRANCH (N_("/_Dialogs")),
{ { N_("/Dialogs/Layers, Channels & Paths..."), NULL,
dialogs_create_lc_cmd_callback, 0 },
NULL,
......@@ -756,16 +770,18 @@ GimpItemFactoryEntry image_menu_entries[] =
"gimp-error-console",
"dialogs/error_console.html", NULL },
MENU_SEPARATOR ("/filters-separator"),
/* <Image>/Filters */
{ { N_("/Filters/Repeat Last"), "<alt>F",
MENU_SEPARATOR ("/filters-separator"),
MENU_BRANCH (N_("/Filte_rs")),
{ { N_("/Filters/Repeat Last"), "<control>F",
plug_in_repeat_cmd_callback, (guint) FALSE,
"<StockItem>", GTK_STOCK_EXECUTE },
NULL,
"filters/repeat_last.html", NULL },
{ { N_("/Filters/Re-Show Last"), "<alt><shift>F",
{ { N_("/Filters/Re-Show Last"), "<control><shift>F",
plug_in_repeat_cmd_callback, (guint) TRUE,
"<StockItem>", GIMP_STOCK_RESHOW_FILTER },
NULL,
......
......@@ -162,14 +162,6 @@ gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
gimp_selection_editor_drop_color,
selection_editor);
selection_editor->invert_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GIMP_STOCK_INVERT,
_("Invert Selection"), NULL,
G_CALLBACK (gimp_selection_editor_invert_clicked),
NULL,
selection_editor);
selection_editor->all_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GIMP_STOCK_SELECTION_ALL,
......@@ -186,6 +178,14 @@ gimp_selection_editor_init (GimpSelectionEditor *selection_editor)
NULL,
selection_editor);
selection_editor->invert_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GIMP_STOCK_INVERT,
_("Invert Selection"), NULL,
G_CALLBACK (gimp_selection_editor_invert_clicked),
NULL,
selection_editor);
selection_editor->save_button =
gimp_editor_add_button (GIMP_EDITOR (selection_editor),
GIMP_STOCK_SELECTION_TO_CHANNEL,
......
......@@ -39,9 +39,9 @@ struct _GimpSelectionEditor
GtkWidget *preview;
GtkWidget *invert_button;
GtkWidget *all_button;
GtkWidget *none_button;
GtkWidget *invert_button;
GtkWidget *save_button;
};
......
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