gboolean vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) { ViewDir *vd = data; GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &tpath, NULL); if (tpath) { GtkTreeModel *store; NodeData *nd; store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); gtk_tree_model_get_iter(store, &iter, tpath); gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); gtk_tree_path_free(tpath); fd = (nd) ? nd->fd : NULL; } switch (event->keyval) { case GDK_KEY_Menu: vd->click_fd = fd; vd_color_set(vd, vd->click_fd, TRUE); vd->popup = vd_pop_menu(vd, vd->click_fd); gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME); return TRUE; break; case GDK_KEY_plus: case GDK_KEY_Right: case GDK_KEY_KP_Add: if (fd) { vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd); if (islink(fd->path)) { vdtree_icon_set_by_iter(vd, &iter, vd->pf->link); } else { vdtree_icon_set_by_iter(vd, &iter, vd->pf->open); } } break; } return FALSE; }
gboolean vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { ViewDir *vd = data; GtkTreePath *tpath; GtkTreeViewColumn *column; GtkTreeIter iter; NodeData *nd = NULL; if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, &tpath, &column, NULL, NULL)) { GtkTreeModel *store; gint left_of_expander; store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); gtk_tree_model_get_iter(store, &iter, tpath); gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); if (vdtree_clicked_on_expander(GTK_TREE_VIEW(widget), tpath, column, bevent->x, bevent->y, &left_of_expander)) { vd->click_fd = NULL; /* clicking this region should automatically reveal an expander, if necessary * treeview bug: the expander will not expand until a button_motion_event highlights it. */ if (bevent->button == MOUSE_BUTTON_LEFT && !left_of_expander && !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath)) { vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd); vdtree_icon_set_by_iter(vd, &iter, vd->pf->open); } gtk_tree_path_free(tpath); return FALSE; } gtk_tree_path_free(tpath); } vd->click_fd = (nd) ? nd->fd : NULL; vd_color_set(vd, vd->click_fd, TRUE); if (bevent->button == MOUSE_BUTTON_RIGHT) { vd->popup = vd_pop_menu(vd, vd->click_fd); gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); } return (bevent->button != MOUSE_BUTTON_LEFT); }