static void render_get_value (gint row, gint column, gpointer _rd, GValue *value) { RenderData_t *rd = (RenderData_t *)_rd; GnumericLazyList *ll = GNUMERIC_LAZY_LIST (gtk_tree_view_get_model (rd->tree_view)); GPtrArray *lines = rd->lines; GPtrArray *line = (row < (int)lines->len) ? g_ptr_array_index (lines, row) : NULL; const char *text = (line && column < (int)line->len) ? g_ptr_array_index (line, column) : NULL; g_value_init (value, ll->column_headers[column]); if (text) { char *copy = NULL; char *tab = strchr (text, '\t'); if (tab) { copy = g_strdup (text); tab = copy + (tab - text); do { *tab = ' '; tab = strchr (tab + 1, '\t'); } while (tab); text = copy; } g_value_set_string (value, text); g_free (copy); } }
static void search_get_value (gint row, gint column, gpointer _dd, GValue *value) { DialogState *dd = (DialogState *)_dd; GnumericLazyList *ll = GNUMERIC_LAZY_LIST (gtk_tree_view_get_model (dd->matches_table)); GnmSearchFilterResult *item = g_ptr_array_index (dd->matches, row); GnmCell *cell; GnmComment *comment; if (item->locus == GNM_SRL_COMMENT) { cell = NULL; comment = sheet_get_comment (item->ep.sheet, &item->ep.eval); } else { cell = sheet_cell_get (item->ep.sheet, item->ep.eval.col, item->ep.eval.row); comment = NULL; } g_value_init (value, ll->column_headers[column]); #if 0 g_print ("col=%d,row=%d\n", column, row); #endif switch (column) { case COL_SHEET: g_value_set_string (value, item->ep.sheet->name_unquoted); return; case COL_CELL: g_value_set_string (value, cellpos_as_string (&item->ep.eval)); return; case COL_TYPE: switch (item->locus) { case GNM_SRL_COMMENT: g_value_set_static_string (value, _("Comment")); return; case GNM_SRL_VALUE: g_value_set_static_string (value, _("Result")); return; case GNM_SRL_CONTENTS: { GnmValue *v = cell ? cell->value : NULL; char const *type; gboolean is_expr = cell && gnm_cell_has_expr (cell); gboolean is_value = !is_expr && !gnm_cell_is_empty (cell) && v; if (!cell) type = _("Deleted"); else if (is_expr) type = _("Expression"); else if (is_value && VALUE_IS_STRING (v)) type = _("String"); else if (is_value && VALUE_IS_FLOAT (v)) type = _("Number"); else type = _("Other value"); g_value_set_static_string (value, type); return; } #ifndef DEBUG_SWITCH_ENUM default: g_assert_not_reached (); #endif } case COL_CONTENTS: switch (item->locus) { case GNM_SRL_COMMENT: if (comment) g_value_set_string (value, cell_comment_text_get (comment)); else g_value_set_static_string (value, _("Deleted")); return; case GNM_SRL_VALUE: if (cell && cell->value) g_value_take_string (value, value_get_as_string (cell->value)); else g_value_set_static_string (value, _("Deleted")); return; case GNM_SRL_CONTENTS: if (cell) g_value_take_string (value, gnm_cell_get_entered_text (cell)); else g_value_set_static_string (value, _("Deleted")); return; #ifndef DEBUG_SWITCH_ENUM default: g_assert_not_reached (); #endif } #ifndef DEBUG_SWITCH_ENUM default: g_assert_not_reached (); #endif } }