Skip to content

Commit

Permalink
Make Space on the symbol and document list not focus the editor widge…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
eht16 committed Feb 28, 2010
1 parent 573b8d6 commit 32797c0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -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:
------------
Expand Down
2 changes: 1 addition & 1 deletion src/about.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
45 changes: 32 additions & 13 deletions src/sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -667,7 +674,6 @@ static void document_action(GeanyDocument *doc, gint action)
break;
}
}

}


Expand Down Expand Up @@ -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)
Expand All @@ -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;

Expand All @@ -757,14 +764,22 @@ 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);
}
}
}
return FALSE;
}


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)
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 32797c0

Please sign in to comment.