/* * Select the given range and make the it visible. */ static gboolean wb_control_jump (WorkbookControl *wbc, Sheet *sheet, const GnmRangeRef *r) { SheetView *sv; GnmCellPos tmp; if (r->a.sheet) sheet = r->a.sheet; if (!sheet_is_visible (sheet)) { go_cmd_context_error_invalid (GO_CMD_CONTEXT (wbc), _("Cannot jump to an invisible sheet"), sheet->name_unquoted); return FALSE; } sv = sheet_get_view (sheet, wb_control_view (wbc)); tmp.col = r->a.col; tmp.row = r->a.row; sv_selection_set (sv, &tmp, r->a.col, r->a.row, r->b.col, r->b.row); sv_make_cell_visible (sv, r->b.col, r->b.row, FALSE); sv_make_cell_visible (sv, r->a.col, r->a.row, FALSE); sv_update (sv); if (wb_control_cur_sheet (wbc) != sheet) wb_view_sheet_focus (wbc->wb_view, sheet); return TRUE; }
static void cursor_change (GtkTreeView *tree_view, DialogState *dd) { int matchno; int lastmatch = dd->matches->len - 1; GtkTreePath *path; gtk_tree_view_get_cursor (tree_view, &path, NULL); if (path) { matchno = gtk_tree_path_get_indices (path)[0]; gtk_tree_path_free (path); } else { matchno = -1; } gtk_widget_set_sensitive (dd->prev_button, matchno > 0); gtk_widget_set_sensitive (dd->next_button, matchno >= 0 && matchno < lastmatch); if (matchno >= 0 && matchno <= lastmatch) { GnmSearchFilterResult *item = g_ptr_array_index (dd->matches, matchno); int col = item->ep.eval.col; int row = item->ep.eval.row; WorkbookControl *wbc = WORKBOOK_CONTROL (dd->wbcg); WorkbookView *wbv = wb_control_view (wbc); SheetView *sv; if (!sheet_is_visible (item->ep.sheet)) return; if (wb_control_cur_sheet (wbc) != item->ep.sheet) wb_view_sheet_focus (wbv, item->ep.sheet); sv = wb_view_cur_sheet_view (wbv); sv_set_edit_pos (sv, &item->ep.eval); sv_selection_set (sv, &item->ep.eval, col, row, col, row); sv_make_cell_visible (sv, col, row, FALSE); sv_update (sv); } }