diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-cell-text.c | 3 | ||||
-rw-r--r-- | widgets/table/e-table-header.c | 46 | ||||
-rw-r--r-- | widgets/table/e-table-header.h | 1 | ||||
-rw-r--r-- | widgets/table/e-table.c | 101 | ||||
-rw-r--r-- | widgets/table/e-table.h | 7 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 118 | ||||
-rw-r--r-- | widgets/table/e-tree.h | 1 |
7 files changed, 239 insertions, 38 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 1fc6b1ef50..4d7f4a3dff 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -2152,6 +2152,9 @@ e_cell_text_view_command (ETextEventProcessor *tep, ETextEventProcessorCommand * case E_TEP_UNGRAB: edit->actions = E_CELL_UNGRAB; break; + case E_TEP_CAPS: + /* FIXME */ + break; case E_TEP_NOP: break; } diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c index aa12c54722..ad585bdc2b 100644 --- a/widgets/table/e-table-header.c +++ b/widgets/table/e-table-header.c @@ -41,6 +41,7 @@ enum { enum { STRUCTURE_CHANGE, DIMENSION_CHANGE, + EXPANSION_CHANGE, REQUEST_WIDTH, LAST_SIGNAL }; @@ -235,11 +236,12 @@ eth_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) static void e_table_header_class_init (GtkObjectClass *object_class) { + ETableHeaderClass *klass = E_TABLE_HEADER_CLASS (object_class); + object_class->destroy = eth_destroy; object_class->set_arg = eth_set_arg; object_class->get_arg = eth_get_arg; - e_table_header_parent_class = (gtk_type_class (gtk_object_get_type ())); gtk_object_add_arg_type ("ETableHeader::width", GTK_TYPE_DOUBLE, @@ -263,6 +265,13 @@ e_table_header_class_init (GtkObjectClass *object_class) GTK_SIGNAL_OFFSET (ETableHeaderClass, dimension_change), gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); + eth_signals [EXPANSION_CHANGE] = + gtk_signal_new ("expansion_change", + GTK_RUN_LAST, + E_OBJECT_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (ETableHeaderClass, expansion_change), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); eth_signals [REQUEST_WIDTH] = gtk_signal_new ("request_width", GTK_RUN_LAST, @@ -272,6 +281,11 @@ e_table_header_class_init (GtkObjectClass *object_class) GTK_TYPE_INT, 1, GTK_TYPE_INT); E_OBJECT_CLASS_ADD_SIGNALS (object_class, eth_signals, LAST_SIGNAL); + + klass->structure_change = NULL; + klass->dimension_change = NULL; + klass->expansion_change = NULL; + klass->request_width = NULL; } static void @@ -677,6 +691,8 @@ eth_set_size (ETableHeader *eth, int idx, int size) for (i = idx + 1; i < eth->col_count; i++) { eth->columns[i]->expansion = 0; } + + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [EXPANSION_CHANGE]); return; } @@ -686,6 +702,7 @@ eth_set_size (ETableHeader *eth, int idx, int size) for (i = idx; i < eth->col_count; i++) { eth->columns[i]->expansion = 0; } + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [EXPANSION_CHANGE]); return; } @@ -702,6 +719,7 @@ eth_set_size (ETableHeader *eth, int idx, int size) for (i = idx + 1; i < eth->col_count; i++) { eth->columns[i]->expansion = 0; } + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [EXPANSION_CHANGE]); return; } @@ -726,6 +744,7 @@ eth_set_size (ETableHeader *eth, int idx, int size) eth->columns[i]->expansion = expansion / expandable_count; } } + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [EXPANSION_CHANGE]); return; } @@ -737,6 +756,7 @@ eth_set_size (ETableHeader *eth, int idx, int size) eth->columns[i]->expansion *= expansion / old_expansion; } } + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [EXPANSION_CHANGE]); } /** @@ -782,6 +802,11 @@ eth_calc_widths (ETableHeader *eth) int last_position = 0; double next_position = 0; int last_resizable = -1; + int *widths; + gboolean changed; + + widths = g_new (int, eth->col_count); + /* - 1 to account for the last pixel border. */ extra = eth->width - 1; expansion = 0; @@ -790,21 +815,31 @@ eth_calc_widths (ETableHeader *eth) if (eth->columns[i]->resizable && eth->columns[i]->expansion > 0) last_resizable = i; expansion += eth->columns[i]->resizable ? eth->columns[i]->expansion : 0; - eth->columns[i]->width = eth->columns[i]->min_width + eth->width_extras; + widths[i] = eth->columns[i]->min_width + eth->width_extras; } if (eth->sort_info) extra -= e_table_sort_info_grouping_get_count(eth->sort_info) * GROUP_INDENT; if (expansion != 0 && extra > 0) { for (i = 0; i < last_resizable; i++) { next_position += extra * (eth->columns[i]->resizable ? eth->columns[i]->expansion : 0)/expansion; - eth->columns[i]->width += next_position - last_position; + widths[i] += next_position - last_position; last_position = next_position; } - eth->columns[i]->width += extra - last_position; + widths[i] += extra - last_position; } + changed = FALSE; + + for (i = 0; i < eth->col_count; i++) { + if (eth->columns[i]->width != widths[i]) { + changed = TRUE; + eth->columns[i]->width = widths[i]; + } + } + g_free (widths); + if (changed) + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]); eth_update_offsets (eth); - gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]); } void @@ -825,6 +860,7 @@ e_table_header_update_horizontal (ETableHeader *eth) eth->columns[i]->expansion = 1; } enqueue(eth, -1, eth->nominal_width); + gtk_signal_emit (GTK_OBJECT (eth), eth_signals [EXPANSION_CHANGE]); } GtkType diff --git a/widgets/table/e-table-header.h b/widgets/table/e-table-header.h index cfd6ebb6c6..6bde250b91 100644 --- a/widgets/table/e-table-header.h +++ b/widgets/table/e-table-header.h @@ -67,6 +67,7 @@ typedef struct { void (*structure_change) (ETableHeader *eth); void (*dimension_change) (ETableHeader *eth, int col); + void (*expansion_change) (ETableHeader *eth); int (*request_width) (ETableHeader *eth, int col); } ETableHeaderClass; diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 2d37fa45ef..065e821b4f 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -74,6 +74,7 @@ enum { CLICK, KEY_PRESS, START_DRAG, + STATE_CHANGE, TABLE_DRAG_BEGIN, TABLE_DRAG_END, @@ -185,6 +186,58 @@ et_disconnect_model (ETable *et) } static void +e_table_state_change (ETable *et) +{ + gtk_signal_emit (GTK_OBJECT (et), + et_signals [STATE_CHANGE]); +} + +static void +structure_changed (ETableHeader *header, ETable *et) +{ + e_table_state_change (et); +} + +static void +expansion_changed (ETableHeader *header, ETable *et) +{ + e_table_state_change (et); +} + +static void +disconnect_header (ETable *e_table) +{ + if (e_table->header == NULL) + return; + + if (e_table->structure_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_table->header), + e_table->structure_change_id); + if (e_table->expansion_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_table->header), + e_table->expansion_change_id); + + gtk_object_unref(GTK_OBJECT(e_table->header)); + e_table->header = NULL; +} + +static void +connect_header (ETable *e_table, ETableState *state) +{ + if (e_table->header != NULL) + disconnect_header (e_table); + + e_table->header = e_table_state_to_header (GTK_WIDGET(e_table), e_table->full_header, state); + + e_table->structure_change_id = + gtk_signal_connect (GTK_OBJECT (e_table->header), "structure_change", + structure_changed, e_table); + e_table->expansion_change_id = + gtk_signal_connect (GTK_OBJECT (e_table->header), "expansion_change", + expansion_changed, e_table); +} + +static void et_destroy (GtkObject *object) { ETable *et = E_TABLE (object); @@ -194,16 +247,20 @@ et_destroy (GtkObject *object) if (et->group_info_change_id) gtk_signal_disconnect (GTK_OBJECT (et->sort_info), et->group_info_change_id); - + if (et->sort_info_change_id) + gtk_signal_disconnect (GTK_OBJECT (et->sort_info), + et->sort_info_change_id); + if (et->reflow_idle_id) g_source_remove(et->reflow_idle_id); et->reflow_idle_id = 0; scroll_off (et); + disconnect_header (et); + gtk_object_unref (GTK_OBJECT (et->model)); gtk_object_unref (GTK_OBJECT (et->full_header)); - gtk_object_unref (GTK_OBJECT (et->header)); gtk_object_unref (GTK_OBJECT (et->sort_info)); gtk_object_unref (GTK_OBJECT (et->sorter)); gtk_object_unref (GTK_OBJECT (et->selection)); @@ -240,6 +297,9 @@ e_table_init (GtkObject *object) e_table->sort_info = NULL; e_table->group_info_change_id = 0; + e_table->sort_info_change_id = 0; + e_table->structure_change_id = 0; + e_table->expansion_change_id = 0; e_table->reflow_idle_id = 0; e_table->scroll_idle_id = 0; @@ -337,7 +397,7 @@ header_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_ } static void -sort_info_changed (ETableSortInfo *info, ETable *et) +group_info_changed (ETableSortInfo *info, ETable *et) { gboolean will_be_grouped = e_table_sort_info_grouping_get_count(info) > 0; if (et->is_grouped || will_be_grouped) { @@ -348,6 +408,13 @@ sort_info_changed (ETableSortInfo *info, ETable *et) et->rebuild_idle_id = g_idle_add_full (20, changed_idle, et, NULL); } } + e_table_state_change (et); +} + +static void +sort_info_changed (ETableSortInfo *info, ETable *et) +{ + e_table_state_change (et); } static void @@ -927,10 +994,7 @@ e_table_fill_table (ETable *e_table, ETableModel *model) void e_table_set_state_object(ETable *e_table, ETableState *state) { - if (e_table->header) - gtk_object_unref(GTK_OBJECT(e_table->header)); - e_table->header = e_table_state_to_header (GTK_WIDGET(e_table), e_table->full_header, state); - + connect_header (e_table, state); gtk_object_set (GTK_OBJECT (e_table->header), "width", (double) (GTK_WIDGET(e_table->table_canvas)->allocation.width), NULL); @@ -939,6 +1003,9 @@ e_table_set_state_object(ETable *e_table, ETableState *state) if (e_table->group_info_change_id) gtk_signal_disconnect (GTK_OBJECT (e_table->sort_info), e_table->group_info_change_id); + if (e_table->sort_info_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_table->sort_info), + e_table->sort_info_change_id); gtk_object_unref(GTK_OBJECT(e_table->sort_info)); } if (state->sort_info) { @@ -947,6 +1014,11 @@ e_table_set_state_object(ETable *e_table, ETableState *state) e_table->group_info_change_id = gtk_signal_connect (GTK_OBJECT (e_table->sort_info), "group_info_changed", + GTK_SIGNAL_FUNC (group_info_changed), + e_table); + e_table->sort_info_change_id = + gtk_signal_connect (GTK_OBJECT (e_table->sort_info), + "sort_info_changed", GTK_SIGNAL_FUNC (sort_info_changed), e_table); } @@ -1154,7 +1226,7 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete, gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - e_table->header = e_table_state_to_header (GTK_WIDGET(e_table), e_table->full_header, state); + connect_header (e_table, state); e_table->horizontal_scrolling = specification->horizontal_scrolling; e_table->allow_grouping = specification->allow_grouping; @@ -1164,6 +1236,10 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete, e_table->group_info_change_id = gtk_signal_connect (GTK_OBJECT (e_table->sort_info), "group_info_changed", + GTK_SIGNAL_FUNC (group_info_changed), e_table); + + e_table->sort_info_change_id = + gtk_signal_connect (GTK_OBJECT (e_table->sort_info), "sort_info_changed", GTK_SIGNAL_FUNC (sort_info_changed), e_table); @@ -2678,6 +2754,7 @@ e_table_class_init (ETableClass *class) class->click = NULL; class->key_press = NULL; class->start_drag = et_real_start_drag; + class->state_change = NULL; class->table_drag_begin = NULL; class->table_drag_end = NULL; @@ -2753,6 +2830,14 @@ e_table_class_init (ETableClass *class) e_marshal_INT__INT_INT_POINTER, GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_GDK_EVENT); + et_signals [STATE_CHANGE] = + gtk_signal_new ("state_change", + GTK_RUN_LAST, + E_OBJECT_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (ETableClass, state_change), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + et_signals[TABLE_DRAG_BEGIN] = gtk_signal_new ("table_drag_begin", GTK_RUN_LAST, diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index 0e4a25f156..11e86e1903 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -81,6 +81,10 @@ typedef struct { int table_rows_deleted_id; int group_info_change_id; + int sort_info_change_id; + + int structure_change_id; + int expansion_change_id; int reflow_idle_id; int scroll_idle_id; @@ -150,6 +154,7 @@ typedef struct { gint (*click) (ETable *et, int row, int col, GdkEvent *event); gint (*key_press) (ETable *et, int row, int col, GdkEvent *event); gint (*start_drag) (ETable *et, int row, int col, GdkEvent *event); + void (*state_change) (ETable *et); void (*set_scroll_adjustments) (ETable *table, GtkAdjustment *hadjustment, @@ -244,7 +249,7 @@ void e_table_load_state (ETable *e_tabl void e_table_set_cursor_row (ETable *e_table, int row); -/* -1 means we don't have the cursor. */ +/* -1 means we don't have the cursor. This is in model rows. */ int e_table_get_cursor_row (ETable *e_table); void e_table_selected_row_foreach (ETable *e_table, EForeachFunc callback, diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index 0796e1bb25..5e301aabf0 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -75,6 +75,7 @@ enum { CLICK, KEY_PRESS, START_DRAG, + STATE_CHANGE, TREE_DRAG_BEGIN, TREE_DRAG_END, @@ -113,9 +114,13 @@ struct ETreePriv { ETableHeader *full_header, *header; + guint structure_change_id, expansion_change_id; + ETableSortInfo *sort_info; ESorter *sorter; + guint sort_info_change_id, group_info_change_id; + ESelectionModel *selection; ETableSpecification *spec; @@ -257,6 +262,78 @@ et_disconnect_from_etta (ETree *et) } static void +e_tree_state_change (ETree *et) +{ + gtk_signal_emit (GTK_OBJECT (et), + et_signals [STATE_CHANGE]); +} + +static void +change_trigger (GtkObject *object, ETree *et) +{ + e_tree_state_change (et); +} + +static void +disconnect_header (ETree *e_tree) +{ + if (e_tree->priv->header == NULL) + return; + + if (e_tree->priv->structure_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_tree->priv->header), + e_tree->priv->structure_change_id); + if (e_tree->priv->expansion_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_tree->priv->header), + e_tree->priv->expansion_change_id); + if (e_tree->priv->sort_info) { + if (e_tree->priv->sort_info_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_tree->priv->sort_info), + e_tree->priv->sort_info_change_id); + if (e_tree->priv->group_info_change_id) + gtk_signal_disconnect (GTK_OBJECT (e_tree->priv->sort_info), + e_tree->priv->group_info_change_id); + + gtk_object_unref(GTK_OBJECT(e_tree->priv->sort_info)); + } + gtk_object_unref(GTK_OBJECT(e_tree->priv->header)); + e_tree->priv->header = NULL; + e_tree->priv->sort_info = NULL; +} + +static void +connect_header (ETree *e_tree, ETableState *state) +{ + if (e_tree->priv->header != NULL) + disconnect_header (e_tree); + + e_tree->priv->header = e_table_state_to_header (GTK_WIDGET(e_tree), e_tree->priv->full_header, state); + + e_tree->priv->structure_change_id = + gtk_signal_connect (GTK_OBJECT (e_tree->priv->header), "structure_change", + change_trigger, e_tree); + e_tree->priv->expansion_change_id = + gtk_signal_connect (GTK_OBJECT (e_tree->priv->header), "expansion_change", + change_trigger, e_tree); + + if (state->sort_info) { + e_tree->priv->sort_info = e_table_sort_info_duplicate(state->sort_info); + e_table_sort_info_set_can_group (e_tree->priv->sort_info, FALSE); + e_tree->priv->sort_info_change_id = + gtk_signal_connect (GTK_OBJECT (e_tree->priv->sort_info), "sort_info_changed", + change_trigger, e_tree); + e_tree->priv->group_info_change_id = + gtk_signal_connect (GTK_OBJECT (e_tree->priv->sort_info), "group_info_changed", + change_trigger, e_tree); + } else + e_tree->priv->sort_info = NULL; + + gtk_object_set(GTK_OBJECT(e_tree->priv->header), + "sort_info", e_tree->priv->sort_info, + NULL); +} + +static void et_destroy (GtkObject *object) { ETree *et = E_TREE (object); @@ -275,8 +352,7 @@ et_destroy (GtkObject *object) gtk_object_unref (GTK_OBJECT (et->priv->model)); gtk_object_unref (GTK_OBJECT (et->priv->sorted)); gtk_object_unref (GTK_OBJECT (et->priv->full_header)); - gtk_object_unref (GTK_OBJECT (et->priv->header)); - gtk_object_unref (GTK_OBJECT (et->priv->sort_info)); + disconnect_header (et); gtk_object_unref (GTK_OBJECT (et->priv->selection)); if (et->priv->spec) gtk_object_unref (GTK_OBJECT (et->priv->spec)); @@ -317,6 +393,11 @@ e_tree_init (GtkObject *object) e_tree->priv->full_header = NULL; e_tree->priv->header = NULL; + e_tree->priv->structure_change_id = 0; + e_tree->priv->expansion_change_id = 0; + e_tree->priv->sort_info_change_id = 0; + e_tree->priv->group_info_change_id = 0; + e_tree->priv->sort_info = NULL; e_tree->priv->sorter = NULL; e_tree->priv->reflow_idle_id = 0; @@ -853,23 +934,12 @@ e_tree_setup_table (ETree *e_tree) void e_tree_set_state_object(ETree *e_tree, ETableState *state) { - if (e_tree->priv->header) - gtk_object_unref(GTK_OBJECT(e_tree->priv->header)); - e_tree->priv->header = e_table_state_to_header (GTK_WIDGET(e_tree), e_tree->priv->full_header, state); + connect_header (e_tree, state); gtk_object_set (GTK_OBJECT (e_tree->priv->header), "width", (double) (GTK_WIDGET(e_tree->priv->table_canvas)->allocation.width), NULL); - if (e_tree->priv->sort_info) - gtk_object_unref(GTK_OBJECT(e_tree->priv->sort_info)); - - if (state->sort_info) { - e_tree->priv->sort_info = e_table_sort_info_duplicate(state->sort_info); - e_table_sort_info_set_can_group (e_tree->priv->sort_info, FALSE); - } else - e_tree->priv->sort_info = NULL; - if (e_tree->priv->header_item) gtk_object_set(GTK_OBJECT(e_tree->priv->header_item), "ETableHeader", e_tree->priv->header, @@ -1106,18 +1176,9 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, e_tree->priv->cursor_mode = specification->cursor_mode; e_tree->priv->full_header = e_table_spec_to_full_header(specification, ete); - e_tree->priv->header = e_table_state_to_header (GTK_WIDGET(e_tree), e_tree->priv->full_header, state); + connect_header (e_tree, state); e_tree->priv->horizontal_scrolling = specification->horizontal_scrolling; - e_tree->priv->sort_info = state->sort_info; - gtk_object_ref (GTK_OBJECT (e_tree->priv->sort_info)); - - e_table_sort_info_set_can_group (e_tree->priv->sort_info, FALSE); - - gtk_object_set(GTK_OBJECT(e_tree->priv->header), - "sort_info", e_tree->priv->sort_info, - NULL); - e_tree->priv->model = etm; gtk_object_ref (GTK_OBJECT (etm)); @@ -2724,6 +2785,7 @@ e_tree_class_init (ETreeClass *class) class->click = NULL; class->key_press = NULL; class->start_drag = et_real_start_drag; + class->state_change = NULL; class->tree_drag_begin = NULL; class->tree_drag_end = NULL; @@ -2799,6 +2861,14 @@ e_tree_class_init (ETreeClass *class) e_marshal_NONE__INT_POINTER_INT_POINTER, GTK_TYPE_NONE, 4, GTK_TYPE_INT, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_GDK_EVENT); + et_signals [STATE_CHANGE] = + gtk_signal_new ("state_change", + GTK_RUN_LAST, + E_OBJECT_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (ETreeClass, state_change), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + et_signals[TREE_DRAG_BEGIN] = gtk_signal_new ("tree_drag_begin", GTK_RUN_LAST, diff --git a/widgets/table/e-tree.h b/widgets/table/e-tree.h index fea53eb184..68b60f8c25 100644 --- a/widgets/table/e-tree.h +++ b/widgets/table/e-tree.h @@ -70,6 +70,7 @@ typedef struct { gint (*click) (ETree *et, int row, ETreePath path, int col, GdkEvent *event); gint (*key_press) (ETree *et, int row, ETreePath path, int col, GdkEvent *event); gint (*start_drag) (ETree *et, int row, ETreePath path, int col, GdkEvent *event); + gint (*state_change) (ETree *et); void (*set_scroll_adjustments) (ETree *tree, GtkAdjustment *hadjustment, |