diff --git a/ChangeLog b/ChangeLog index f36bb1ed..0df696a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ * src/navqueue.c: Fix possible segfault when a file is closed and using go forward. Fix 2 possible memory leaks when files have been closed. + * src/interface.c, src/keybindings.c, src/keybindings.h, + src/callbacks.c, src/callbacks.h, geany.glade: + Make pressing escape focus the editor when using incremental search + or the Goto Line entries. + Add keybindings_cmd() to mimic a keybinding action. 2007-07-17 Nick Treleaven diff --git a/geany.glade b/geany.glade index 05b172c0..0701d1ee 100644 --- a/geany.glade +++ b/geany.glade @@ -1823,6 +1823,7 @@ False + @@ -1882,6 +1883,7 @@ False 8 + diff --git a/src/callbacks.c b/src/callbacks.c index 2b1cd660..80ac6c2d 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -622,6 +622,20 @@ on_entry1_changed (GtkEditable *editable, } +gboolean +on_entry1_key_press_event (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data) +{ + if (event->keyval == GDK_Escape) + { + keybindings_cmd(GEANY_KEYS_SWITCH_EDITOR); + return TRUE; + } + return FALSE; +} + + // search text void on_toolbutton18_clicked (GtkToolButton *toolbutton, @@ -1248,6 +1262,15 @@ on_entry_goto_line_activate (GtkEntry *entry, } +gboolean +on_entry_goto_line_key_press_event (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data) +{ + return on_entry1_key_press_event(widget, event, user_data); +} + + void on_toolbutton_goto_clicked (GtkToolButton *toolbutton, gpointer user_data) @@ -2110,4 +2133,3 @@ gboolean on_motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer user return FALSE; } - diff --git a/src/callbacks.h b/src/callbacks.h index 68890dc1..173e9a66 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -583,3 +583,13 @@ on_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); + +gboolean +on_entry1_key_press_event (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data); + +gboolean +on_entry_goto_line_key_press_event (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data); diff --git a/src/interface.c b/src/interface.c index c2e53c7b..7865e635 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1576,12 +1576,18 @@ create_window1 (void) g_signal_connect ((gpointer) entry1, "changed", G_CALLBACK (on_entry1_changed), NULL); + g_signal_connect ((gpointer) entry1, "key_press_event", + G_CALLBACK (on_entry1_key_press_event), + NULL); g_signal_connect ((gpointer) toolbutton18, "clicked", G_CALLBACK (on_toolbutton18_clicked), NULL); g_signal_connect ((gpointer) entry_goto_line, "activate", G_CALLBACK (on_entry_goto_line_activate), NULL); + g_signal_connect ((gpointer) entry_goto_line, "key_press_event", + G_CALLBACK (on_entry_goto_line_key_press_event), + NULL); g_signal_connect ((gpointer) toolbutton25, "clicked", G_CALLBACK (on_toolbutton_goto_clicked), NULL); diff --git a/src/keybindings.c b/src/keybindings.c index 5f2de24f..fc6cea09 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -697,6 +697,13 @@ static binding *fill(KBCallback func, guint key, GdkModifierType mod, const gcha } +/* Mimic a keybinding action */ +void keybindings_cmd(GeanyKeyCommand cmd_id) +{ + keys[cmd_id]->cb_func(cmd_id); +} + + /* These are the callback functions, either each group or each shortcut has it's * own function. */ @@ -1211,3 +1218,4 @@ static void cb_func_nav_forward(G_GNUC_UNUSED guint key_id) { navqueue_go_forward(); } + diff --git a/src/keybindings.h b/src/keybindings.h index 8a42998d..6edce7ff 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -45,7 +45,7 @@ typedef struct binding } binding; -enum +typedef enum { GEANY_KEYS_MENU_NEW = 0, GEANY_KEYS_MENU_OPEN, @@ -149,16 +149,18 @@ enum GEANY_KEYS_EDIT_COMPLETECONSTRUCT, GEANY_KEYS_EDIT_SUPPRESSCOMPLETION, GEANY_MAX_KEYS -}; +} +GeanyKeyCommand; binding *keys[GEANY_MAX_KEYS]; - void keybindings_init(void); void keybindings_free(void); +void keybindings_cmd(GeanyKeyCommand cmd_id); + /* just write the content of the keys array to the config file */ void keybindings_write_to_file(void);