Windows like GtkTreeView key bindings question.
- From: "Alex Nekorkin" <anekorkin gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Windows like GtkTreeView key bindings question.
- Date: Sat, 12 May 2007 16:24:03 +0400
Hello All,
I'm trying to make my application tree view to be more intuitive for Windows
users. This includes key bindings for KP_RIGHT and KP_LEFT to expand and
collapse current accordingly.
I have implemented it by registering the callback (see the code below). The
only problem is: this construction stops working correctly if my tree store
emits any signals like "row-inserted" or "row-child-toggled" and etc. In
this case GtkTreeView stops refreshing after KP_RIGHT key press, so row
expansion is not displayed immediately after key press.
I have already spent about three days investigating this issue but didn't
find any solution. So, will appreciate any advise.
Thanks,
- Alex.
gboolean on_treeview1_key_press_event(GtkWidget * pTreeView,
GdkEventKey * pEvent,
gpointer pData)
{
GtkTreeSelection *pSelection;
GtkTreeModel *pModel;
GtkTreePath *pPath;
GList *pList;
gboolean b;
assert(pTreeView!=NULL);
assert(pEvent!=NULL);
g_mutex_lock(pMutex);
if(pEvent->hardware_keycode==39)
{
pSelection = gtk_tree_view_get_selection((GtkTreeView*)pTreeView);
assert(pSelection!=NULL);
if(gtk_tree_selection_count_selected_rows(pSelection)==1)
{
pList = gtk_tree_selection_get_selected_rows(pSelection,
&pModel);
assert(pList);
pPath = (GtkTreePath*)pList->data;
assert(pPath!=NULL);
b = gtk_tree_view_expand_row((GtkTreeView*)pTreeView, pPath,
FALSE);
g_list_foreach(pList, (GFunc)gtk_tree_path_free, NULL);
g_list_free(pList);
}
g_mutex_unlock(pMutex);
return TRUE;
}
if(pEvent->hardware_keycode==37)
{
pSelection = gtk_tree_view_get_selection((GtkTreeView*)pTreeView);
assert(pSelection!=NULL);
if(gtk_tree_selection_count_selected_rows(pSelection))
{
pList = gtk_tree_selection_get_selected_rows(pSelection,
&pModel);
assert(pList);
pPath = (GtkTreePath*)pList->data;
assert(pPath!=NULL);
if(gtk_tree_view_row_expanded((GtkTreeView*)pTreeView, pPath))
gtk_tree_view_collapse_row((GtkTreeView*)pTreeView, pPath);
else
{
gtk_tree_selection_unselect_all(pSelection);
gtk_tree_path_up(pPath);
gtk_tree_view_set_cursor((GtkTreeView*)pTreeView, pPath,
NULL, FALSE);
}
g_list_foreach(pList, (GFunc)gtk_tree_path_free, NULL);
g_list_free(pList);
}
g_mutex_unlock(pMutex);
return TRUE;
}
g_mutex_unlock(pMutex);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]