Make Space on the symbol and document list not focus the editor widget while Enter does (closes #2919444, patch by Can Koy, thanks).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4711 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-02-28 14:30:27 +00:00
parent 573b8d6c10
commit 32797c0ebd
4 changed files with 40 additions and 14 deletions

View File

@ -10,6 +10,12 @@
* scintilla/LexR.cxx:
Backport R lexer from Scintilla CVS to fix case sensitive keywords
(Scintilla bug #2956543).
* src/sidebar.c, src/about.c, THANKS:
Make Space on the symbol and document list not focus the editor
widget while Enter does (closes #2919444, patch by Can Koy, thanks).
* src/document.c, src/document.h:
Fix document_try_focus() to make it work with the sidebar document
list as well.
2010-02-28 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>

1
THANKS
View File

@ -74,6 +74,7 @@ Alexey Antipov <1a_antipov(at)mail(dot)ru> - Apply file open encoding only to no
Jörn Reder <joern(at)zyn(dot)de> - --socket-file command line option patch
Kelvin Gardiner <kelvin(at)mbmn(dot)net> - VHDL symbol list patch, Verilog filetype
Jon Senior <jon(at)restlesslemon(dot)co(dot)uk> - R tagmanager parser patch
Can Koy <cankoy(at)ymail(dot)com> - Multiple changes/improvements
Translators:
------------

View File

@ -82,7 +82,7 @@ static const gint prev_translators_len = G_N_ELEMENTS(prev_translators);
static const gchar *contributors =
"Alexander Rodin, Alexey Antipov, Andrew Rowland, Anh Phạm, blackdog, Bo Lorentsen, Bob Doan, "
"Bronisław Białek, Catalin Marinas, "
"Bronisław Białek, Can Koy, Catalin Marinas, "
"Chris Macksey, Christoph Berg, Colomban Wendling, Conrad Steenberg, Daniel Richard G., Dave Moore, "
"Dirk Weber, Elias Pschernig, Eric Forgeot, Eugene Arshinov, Felipe Pena, François Cami, "
"Giuseppe Torelli, Guillaume de Rorthais, Guillaume Hoffmann, Herbert Voss, Jason Oster, "

View File

@ -46,6 +46,7 @@
#include <gdk/gdkkeysyms.h>
SidebarTreeviews tv = {NULL, NULL, NULL};
/* while typeahead searching, editor should not get focus */
static gboolean may_steal_focus = FALSE;
@ -59,6 +60,12 @@ static struct
}
doc_items = {NULL, NULL, NULL, NULL};
static struct
{
GtkTreeSelection *selection;
guint keyval;
} selection_change = {NULL, 0};
enum
{
TREEVIEW_SYMBOL = 0,
@ -88,9 +95,9 @@ static gboolean documents_show_paths;
static GtkWidget *tag_window; /* scrolled window that holds the symbol list GtkTreeView */
/* callback prototypes */
static gboolean on_openfiles_tree_selection_changed(GtkTreeSelection *selection);
static gboolean on_openfiles_tree_selection_changed(gpointer data);
static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_data);
static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection);
static gboolean on_taglist_tree_selection_changed(gpointer data);
static gboolean sidebar_button_press_cb(GtkWidget *widget, GdkEventButton *event,
gpointer user_data);
static gboolean sidebar_key_press_cb(GtkWidget *widget, GdkEventKey *event,
@ -667,7 +674,6 @@ static void document_action(GeanyDocument *doc, gint action)
break;
}
}
}
@ -712,14 +718,14 @@ static void change_focus_to_editor(GeanyDocument *doc)
}
static gboolean on_openfiles_tree_selection_changed(GtkTreeSelection *selection)
static gboolean on_openfiles_tree_selection_changed(gpointer data)
{
GtkTreeIter iter;
GtkTreeModel *model;
GeanyDocument *doc = NULL;
/* use switch_notebook_page to ignore changing the notebook page because it is already done */
if (gtk_tree_selection_get_selected(selection, &model, &iter) && ! ignore_callback)
if (gtk_tree_selection_get_selected(selection_change.selection, &model, &iter) && ! ignore_callback)
{
gtk_tree_model_get(model, &iter, DOCUMENTS_DOCUMENT, &doc, -1);
if (! doc)
@ -729,19 +735,20 @@ static gboolean on_openfiles_tree_selection_changed(GtkTreeSelection *selection)
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
(GtkWidget*) doc->editor->sci));
change_focus_to_editor(doc);
if (selection_change.keyval != GDK_space)
change_focus_to_editor(doc);
}
return FALSE;
}
static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
static gboolean on_taglist_tree_selection_changed(gpointer data)
{
GtkTreeIter iter;
GtkTreeModel *model;
gint line = 0;
if (gtk_tree_selection_get_selected(selection, &model, &iter))
if (gtk_tree_selection_get_selected(selection_change.selection, &model, &iter))
{
const TMTag *tag;
@ -757,7 +764,8 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
if (doc != NULL)
{
navqueue_goto_line(doc, doc, line);
change_focus_to_editor(doc);
if (selection_change.keyval != GDK_space)
change_focus_to_editor(doc);
}
}
}
@ -765,6 +773,13 @@ static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
}
static void update_selection_change(GtkTreeSelection *selection, guint keyval)
{
selection_change.selection = selection;
selection_change.keyval = keyval;
}
static gboolean sidebar_key_press_cb(GtkWidget *widget, GdkEventKey *event,
gpointer user_data)
{
@ -778,10 +793,12 @@ static gboolean sidebar_key_press_cb(GtkWidget *widget, GdkEventKey *event,
may_steal_focus = TRUE;
/* delay the query of selection state because this callback is executed before GTK
* changes the selection (g_signal_connect_after would be better but it doesn't work) */
update_selection_change(selection, event->keyval);
if (widget == tv.tree_openfiles) /* tag and doc list have separate handlers */
g_idle_add((GSourceFunc) on_openfiles_tree_selection_changed, selection);
g_idle_add(on_openfiles_tree_selection_changed, NULL);
else
g_idle_add((GSourceFunc) on_taglist_tree_selection_changed, selection);
g_idle_add(on_taglist_tree_selection_changed, NULL);
}
return FALSE;
}
@ -820,10 +837,12 @@ static gboolean sidebar_button_press_cb(GtkWidget *widget, GdkEventButton *event
{ /* allow reclicking of taglist treeview item */
/* delay the query of selection state because this callback is executed before GTK
* changes the selection (g_signal_connect_after would be better but it doesn't work) */
update_selection_change(selection, 0);
if (widget == tv.tree_openfiles)
g_idle_add((GSourceFunc) on_openfiles_tree_selection_changed, selection);
g_idle_add(on_openfiles_tree_selection_changed, NULL);
else
g_idle_add((GSourceFunc) on_taglist_tree_selection_changed, selection);
g_idle_add(on_taglist_tree_selection_changed, NULL);
}
else if (event->button == 3)
{