diff options
author | Damon Chaplin <damon@ximian.com> | 2001-10-23 06:33:20 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-10-23 06:33:20 +0800 |
commit | b89da79e8c9a5db367cdff556ce024962b2cca82 (patch) | |
tree | 19823590a819dca96a2ab6591f403e3dea2a4075 /widgets/table/e-cell-text.c | |
parent | 798623d52b0bdf8a77fa7c6a0d1d12c180f3cbe5 (diff) | |
download | gsoc2013-evolution-b89da79e8c9a5db367cdff556ce024962b2cca82.tar.gz gsoc2013-evolution-b89da79e8c9a5db367cdff556ce024962b2cca82.tar.zst gsoc2013-evolution-b89da79e8c9a5db367cdff556ce024962b2cca82.zip |
added set_value() class method, which sets the model value based on the
2001-10-22 Damon Chaplin <damon@ximian.com>
* e-cell-text.[hc]: added set_value() class method, which sets the
model value based on the text. In ECellText itself it assumes the model
value is a char* and passes the text directly. Subclasses may parse
the text into some other datatype.
Also made the calls the e_cell_text_get_text(), e_cell_text_free_text()
and e_cell_text_set_value() public, since we need them in ECellCombo.
* e-cell-combo.c (e_cell_combo_select_matching_item):
(e_cell_combo_update_cell): use e_cell_text_get_text()/free_text()/
set_value() so it can handle subclasses of ECellText as the child.
svn path=/trunk/; revision=13901
Diffstat (limited to 'widgets/table/e-cell-text.c')
-rw-r--r-- | widgets/table/e-cell-text.c | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 2894ff30d5..469b5fb261 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -211,8 +211,8 @@ static GdkColor* e_cell_text_get_color (ECellTextView *cell_view, gchar *color_s static ECellClass *parent_class; -static char * -ect_get_text (ECellText *cell, ETableModel *model, int col, int row) +char * +e_cell_text_get_text (ECellText *cell, ETableModel *model, int col, int row) { if (ECT_CLASS(cell)->get_text) return ECT_CLASS(cell)->get_text (cell, model, col, row); @@ -220,13 +220,21 @@ ect_get_text (ECellText *cell, ETableModel *model, int col, int row) return NULL; } -static void -ect_free_text (ECellText *cell, char *text) +void +e_cell_text_free_text (ECellText *cell, char *text) { if (ECT_CLASS(cell)->free_text) ECT_CLASS(cell)->free_text (cell, text); } +void +e_cell_text_set_value (ECellText *cell, ETableModel *model, int col, int row, + const char *text) +{ + if (ECT_CLASS(cell)->set_value) + ECT_CLASS(cell)->set_value (cell, model, col, row, text); +} + static char * ect_real_get_text (ECellText *cell, ETableModel *model, int col, int row) { @@ -238,6 +246,17 @@ ect_real_free_text (ECellText *cell, char *text) { } +/* This is the default method for setting the ETableModel value based on + the text in the ECellText. This simply uses the text as it is - it assumes + the value in the model is a char*. Subclasses may parse the text into + data structures to pass to the model. */ +static void +ect_real_set_value (ECellText *cell, ETableModel *model, int col, int row, + const char *text) +{ + e_table_model_set_value_at (model, col, row, text); +} + static void ect_queue_redraw (ECellTextView *text_view, int view_col, int view_row) { @@ -253,10 +272,12 @@ static void ect_accept_edits (ECellTextView *text_view) { CurrentCell *cell = (CurrentCell *) text_view->edit; + ECellView *ecell_view = (ECellView *) text_view; + ECellText *ect = (ECellText *) ecell_view->ecell; if (strcmp (text_view->edit->old_text, cell->text)) { - e_table_model_set_value_at (text_view->cell_view.e_table_model, - cell->model_col, cell->row, cell->text); + e_cell_text_set_value (ect, ecell_view->e_table_model, + cell->model_col, cell->row, cell->text); } } @@ -951,9 +972,9 @@ ect_height (ECellView *ecell_view, int model_col, int view_col, int row) if (row == -1) { value = e_font_height (font) + TEXT_PAD; } else { - string = ect_get_text(ect, ecell_view->e_table_model, model_col, row); + string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row); value = e_font_height (font) * number_of_lines(string) + TEXT_PAD; - ect_free_text(ect, string); + e_cell_text_free_text(ect, string); } return value; @@ -1010,9 +1031,9 @@ ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row) edit->pointer_in = FALSE; edit->default_cursor_shown = TRUE; - temp = ect_get_text(ect, ecell_view->e_table_model, model_col, row); + temp = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row); edit->old_text = g_strdup (temp); - ect_free_text(ect, temp); + e_cell_text_free_text(ect, temp); edit->cell.text = g_strdup (edit->old_text); #if 0 @@ -1059,7 +1080,7 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, GnomeFont *font = gnome_font_new ("Helvetica", 12); char *string; ECellText *ect = E_CELL_TEXT(ecell_view->ecell); - string = ect_get_text(ect, ecell_view->e_table_model, model_col, row); + string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row); gnome_print_gsave(context); if (gnome_print_moveto(context, 2, 2) == -1) /* FIXME */; @@ -1077,7 +1098,7 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, gnome_print_setfont(context, font); gnome_print_show(context, string); gnome_print_grestore(context); - ect_free_text(ect, string); + e_cell_text_free_text(ect, string); } static gdouble @@ -1421,6 +1442,7 @@ e_cell_text_class_init (GtkObjectClass *object_class) ectc->get_text = ect_real_get_text; ectc->free_text = ect_real_free_text; + ectc->set_value = ect_real_set_value; object_class->get_arg = ect_get_arg; object_class->set_arg = ect_set_arg; @@ -2415,9 +2437,9 @@ build_current_cell (CurrentCell *cell, ECellTextView *text_view, int model_col, cell->row = row; cell->breaks = NULL; - temp = ect_get_text(ect, ecell_view->e_table_model, model_col, row); + temp = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row); cell->text = g_strdup(temp); - ect_free_text(ect, temp); + e_cell_text_free_text(ect, temp); cell->width = e_table_header_get_column ( ((ETableItem *)ecell_view->e_table_item_view)->header, |