[Geany-devel] [Patch] - Modify <Space> behaviour on Symbols tabs
Can Koy
cankoy at xxxxx
Thu Feb 25 15:58:48 UTC 2010
<Space> and <Enter> keys do the same thing on Symbols tab. The following patch modifies that of <Space> key, so it only scrolls to corresponding symbol on editor but retains focus on Symbols tab. (Feature request #2919444)
Index: src/sidebar.c
===================================================================
--- src/sidebar.c (revision 4704)
+++ src/sidebar.c (working copy)
@@ -59,6 +59,12 @@
}
doc_items = {NULL, NULL, NULL, NULL};
+static struct sel_chg
+{
+ GtkTreeSelection *selection;
+ guint keyval;
+} sel_chgdata;
+
enum
{
TREEVIEW_SYMBOL = 0,
@@ -90,7 +96,7 @@
/* callback prototypes */
static gboolean on_openfiles_tree_selection_changed(GtkTreeSelection *selection);
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(struct sel_chg *p_sel_chgdata);
static gboolean sidebar_button_press_cb(GtkWidget *widget, GdkEventButton *event,
gpointer user_data);
static gboolean sidebar_key_press_cb(GtkWidget *widget, GdkEventKey *event,
@@ -735,13 +741,13 @@
}
-static gboolean on_taglist_tree_selection_changed(GtkTreeSelection *selection)
+static gboolean on_taglist_tree_selection_changed(struct sel_chg *p_sel_chgdata)
{
GtkTreeIter iter;
GtkTreeModel *model;
gint line = 0;
- if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ if (gtk_tree_selection_get_selected(p_sel_chgdata->selection, &model, &iter))
{
const TMTag *tag;
@@ -757,7 +763,8 @@
if (doc != NULL)
{
navqueue_goto_line(doc, doc, line);
- change_focus_to_editor(doc);
+ if (p_sel_chgdata->keyval != GDK_space)
+ change_focus_to_editor(doc);
}
}
}
@@ -780,8 +787,11 @@
* changes the selection (g_signal_connect_after would be better but it doesn't work) */
if (widget == tv.tree_openfiles) /* tag and doc list have separate handlers */
g_idle_add((GSourceFunc) on_openfiles_tree_selection_changed, selection);
- else
- g_idle_add((GSourceFunc) on_taglist_tree_selection_changed, selection);
+ else {
+ sel_chgdata.selection = selection;
+ sel_chgdata.keyval = event->keyval;
+ g_idle_add((GSourceFunc) on_taglist_tree_selection_changed, &sel_chgdata);
+ }
}
return FALSE;
}
@@ -822,8 +832,11 @@
* changes the selection (g_signal_connect_after would be better but it doesn't work) */
if (widget == tv.tree_openfiles)
g_idle_add((GSourceFunc) on_openfiles_tree_selection_changed, selection);
- else
- g_idle_add((GSourceFunc) on_taglist_tree_selection_changed, selection);
+ else {
+ sel_chgdata.selection = selection;
+ sel_chgdata.keyval = GDK_VoidSymbol;
+ g_idle_add((GSourceFunc) on_taglist_tree_selection_changed, &sel_chgdata);
+ }
}
else if (event->button == 3)
{
More information about the Devel
mailing list