diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-06-02 08:45:24 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-06-02 08:45:24 +0800 |
commit | f5916a12a69fddd8d68c777850d2f4b217d41ae6 (patch) | |
tree | 564742692079896a60cd3d5a22b6eaab56a4cc67 /widgets/e-table | |
parent | 9f325587d4b11c0959d5d6aa415236250da073d9 (diff) | |
download | gsoc2013-evolution-f5916a12a69fddd8d68c777850d2f4b217d41ae6.tar.gz gsoc2013-evolution-f5916a12a69fddd8d68c777850d2f4b217d41ae6.tar.zst gsoc2013-evolution-f5916a12a69fddd8d68c777850d2f4b217d41ae6.zip |
Added "text_filter" argument that takes a const void * and returns an
2000-06-01 Christopher James Lahey <clahey@helixcode.com>
* e-cell-text.c, e-cell-text.h: Added "text_filter" argument that
takes a const void * and returns an allocated char *.
svn path=/trunk/; revision=3356
Diffstat (limited to 'widgets/e-table')
-rw-r--r-- | widgets/e-table/ChangeLog | 7 | ||||
-rw-r--r-- | widgets/e-table/e-cell-text.c | 65 | ||||
-rw-r--r-- | widgets/e-table/e-cell-text.h | 2 |
3 files changed, 49 insertions, 25 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index 972775ee52..895d2b7ce9 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,6 +1,11 @@ 2000-06-01 Christopher James Lahey <clahey@helixcode.com> - * e-table-item.c: Copy and paste error. + * e-cell-text.c, e-cell-text.h: Added "text_filter" argument that + takes a const void * and returns an allocated char *. + +2000-06-01 Christopher James Lahey <clahey@helixcode.com> + + * e-table-item.c: Copy and paste error. 2000-06-01 Christopher James Lahey <clahey@helixcode.com> diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c index d2de76f04f..a3a7acf35b 100644 --- a/widgets/e-table/e-cell-text.c +++ b/widgets/e-table/e-cell-text.c @@ -203,6 +203,7 @@ static void _get_xy_from_position (CurrentCell *cell, gint position, gint *xp, g static gboolean _blink_scroll_timeout (gpointer data); static void build_current_cell (CurrentCell *cell, ECellTextView *text_view, int model_col, int view_col, int row); +static void unbuild_current_cell (CurrentCell *cell); static void calc_ellipsis (ECellTextView *text_view); static ECellClass *parent_class; @@ -689,6 +690,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, lines++; } unref_lines (&cell); + unbuild_current_cell (&cell); } gdk_gc_set_clip_rectangle (text_view->gc, NULL); @@ -870,7 +872,8 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, case GDK_KEY_RELEASE: if (event->key.keyval == GDK_Escape){ ect_cancel_edit (text_view); - return TRUE; + return_val = TRUE; + break; } if ((!edit_display) && e_table_model_is_cell_editable (ecell_view->e_table_model, view_col, row)) { @@ -891,8 +894,9 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, e_tep_event.key.length = key.length; e_tep_event.key.string = key.string; _get_tep (edit); - return e_text_event_processor_handle_event (edit->tep, - &e_tep_event); + return_val = e_text_event_processor_handle_event (edit->tep, + &e_tep_event); + break; } } @@ -995,6 +999,8 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, default: break; } + + unbuild_current_cell (&cell); if (return_val) return return_val; #if 0 @@ -1044,16 +1050,15 @@ ect_height (ECellView *ecell_view, int model_col, int view_col, int row) { ECellTextView *text_view = (ECellTextView *) ecell_view; GdkFont *font; + ECellText *ect = E_CELL_TEXT(ecell_view->ecell); font = text_view->font; -#if 0 - if (text_view->filter) { - char *string = text_view->filter(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); + if (ect->filter) { + char *string = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); int value = (font->ascent + font->descent) * number_of_lines(string) + TEXT_PAD; g_free(string); return value; } else -#endif return (font->ascent + font->descent) * number_of_lines(e_table_model_value_at (ecell_view->e_table_model, model_col, row)) + TEXT_PAD; } @@ -1066,6 +1071,7 @@ ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row) ECellTextView *text_view = (ECellTextView *) ecell_view; char *str; CellEdit *edit; + ECellText *ect = E_CELL_TEXT(ecell_view->ecell); edit = g_new (CellEdit, 1); text_view->edit = edit; @@ -1105,16 +1111,13 @@ ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row) edit->pointer_in = FALSE; edit->default_cursor_shown = TRUE; -#if 0 if (ect->filter) { - str = ect->filter(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); + str = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); edit->old_text = str; - } else -#endif - { - str = e_table_model_value_at (ecell_view->e_table_model, model_col, row); - edit->old_text = g_strdup (str); - } + } else { + str = e_table_model_value_at (ecell_view->e_table_model, model_col, row); + edit->old_text = g_strdup (str); + } edit->cell.text = g_strdup (str); #if 0 @@ -1143,6 +1146,7 @@ ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, voi if (edit){ ect_accept_edits (text_view); ect_stop_editing (text_view); + unbuild_current_cell (CURRENT_CELL(edit)); } else { /* * We did invoke this leave edit internally @@ -1172,17 +1176,15 @@ ect_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) switch (arg_id) { case ARG_STRIKEOUT_COLUMN: - if (text->strikeout_column != GTK_VALUE_INT (*arg)) { - text->strikeout_column = GTK_VALUE_INT (*arg); - } + text->strikeout_column = GTK_VALUE_INT (*arg); break; case ARG_BOLD_COLUMN: - if (text->bold_column != GTK_VALUE_INT (*arg)) { - text->bold_column = GTK_VALUE_INT (*arg); - } + text->bold_column = GTK_VALUE_INT (*arg); + break; + case ARG_TEXT_FILTER: + text->filter = GTK_VALUE_POINTER (*arg); break; - default: return; } @@ -1205,6 +1207,10 @@ ect_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) GTK_VALUE_INT (*arg) = text->bold_column; break; + case ARG_TEXT_FILTER: + GTK_VALUE_POINTER (*arg) = text->filter; + break; + default: arg->type = GTK_TYPE_INVALID; break; @@ -1237,6 +1243,8 @@ e_cell_text_class_init (GtkObjectClass *object_class) GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_STRIKEOUT_COLUMN); gtk_object_add_arg_type ("ECellText::bold_column", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_BOLD_COLUMN); + gtk_object_add_arg_type ("ECellText::text_filter", + GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_TEXT_FILTER); if (!clipboard_atom) clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); @@ -2082,14 +2090,25 @@ static void build_current_cell (CurrentCell *cell, ECellTextView *text_view, int model_col, int view_col, int row) { ECellView *ecell_view = (ECellView *) text_view; + ECellText *ect = E_CELL_TEXT (ecell_view->ecell); cell->text_view = text_view; cell->model_col = model_col; cell->view_col = view_col; cell->row = row; cell->breaks = NULL; - cell->text = e_table_model_value_at (ecell_view->e_table_model, model_col, row); + if (ect->filter) + cell->text = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); + else + cell->text = g_strdup(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); cell->width = e_table_header_get_column ( ((ETableItem *)ecell_view->e_table_item_view)->header, view_col)->width - 8; } + +static void +unbuild_current_cell (CurrentCell *cell) +{ + g_free(cell->text); +} + diff --git a/widgets/e-table/e-cell-text.h b/widgets/e-table/e-cell-text.h index 59b6558157..13e7d2e486 100644 --- a/widgets/e-table/e-cell-text.h +++ b/widgets/e-table/e-cell-text.h @@ -28,7 +28,7 @@ #include "e-cell.h" /* Should return a malloced object. */ -typedef char *(*ECellTextFilter) (void *); +typedef char *(*ECellTextFilter) (const void *); #define E_CELL_TEXT_TYPE (e_cell_text_get_type ()) #define E_CELL_TEXT(o) (GTK_CHECK_CAST ((o), E_CELL_TEXT_TYPE, ECellText)) |