From fe016cce581d311c97652e08fbd7bfcb4042bbe4 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 6 Apr 2000 08:00:35 +0000 Subject: Got rid of some warnings. 2000-04-06 Christopher James Lahey * test-cols.c, test-table.c: Got rid of some warnings. * e-table-group-container.c, e-table-group-container.h, e-table-group-leaf.c, e-table-group-leaf.h, e-table-group.c, e-table-group.h, e-table-header-item.c, e-table-header-item.h, e-table-sort-info.c, e-table-sort-info.h, e-table-sorted-variable.c, e-table-sorted-variable.h, e-table.c, e-table.h: Changed ETableSortInfo to not use xml internally. svn path=/trunk/; revision=2305 --- widgets/table/e-table-sort-info.c | 198 +++++++++++++++++++++++++++++++------- 1 file changed, 161 insertions(+), 37 deletions(-) (limited to 'widgets/table/e-table-sort-info.c') diff --git a/widgets/table/e-table-sort-info.c b/widgets/table/e-table-sort-info.c index bf90a13602..b33784c140 100644 --- a/widgets/table/e-table-sort-info.c +++ b/widgets/table/e-table-sort-info.c @@ -9,7 +9,6 @@ */ #include #include -#include #include "e-table-sort-info.h" #include "e-util/e-util.h" @@ -22,51 +21,47 @@ static GtkObjectClass *e_table_sort_info_parent_class; enum { SORT_INFO_CHANGED, + GROUP_INFO_CHANGED, LAST_SIGNAL }; static guint e_table_sort_info_signals [LAST_SIGNAL] = { 0, }; -enum { - ARG_0, - ARG_GROUPING -}; - static void -etsi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +etsi_destroy (GtkObject *object) { ETableSortInfo *etsi; - etsi = E_TABLE_SORT_INFO (o); - - switch (arg_id){ - case ARG_GROUPING: - etsi->grouping = GTK_VALUE_POINTER (*arg); - break; - } + etsi = E_TABLE_SORT_INFO (object); + + if (etsi->groupings) + g_free(etsi->groupings); + if (etsi->sortings) + g_free(etsi->sortings); } static void -etsi_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) +e_table_sort_info_init (ETableSortInfo *info) { - ETableSortInfo *etsi; - - etsi = E_TABLE_SORT_INFO (o); - - switch (arg_id){ - case ARG_GROUPING: - GTK_VALUE_POINTER (*arg) = etsi->grouping; - break; - } + info->group_count = 0; + info->groupings = NULL; + info->sort_count = 0; + info->sortings = NULL; + info->frozen = 0; + info->sort_info_changed = 0; + info->group_info_changed = 0; } static void -e_table_sort_info_class_init (GtkObjectClass *object_class) +e_table_sort_info_class_init (ETableSortInfoClass *klass) { + GtkObjectClass *object_class; + e_table_sort_info_parent_class = gtk_type_class (gtk_object_get_type ()); + + object_class = GTK_OBJECT_CLASS(klass); - object_class->set_arg = etsi_set_arg; - object_class->get_arg = etsi_get_arg; + object_class->destroy = etsi_destroy; e_table_sort_info_signals [SORT_INFO_CHANGED] = gtk_signal_new ("sort_info_changed", @@ -76,25 +71,154 @@ e_table_sort_info_class_init (GtkObjectClass *object_class) gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, e_table_sort_info_signals, LAST_SIGNAL); + e_table_sort_info_signals [GROUP_INFO_CHANGED] = + gtk_signal_new ("group_info_changed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableSortInfoClass, group_info_changed), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); - gtk_object_add_arg_type ("ETableSortInfo::grouping", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_GROUPING); + klass->sort_info_changed = NULL; + klass->group_info_changed = NULL; + + gtk_object_class_add_signals (object_class, e_table_sort_info_signals, LAST_SIGNAL); } E_MAKE_TYPE(e_table_sort_info, "ETableSortInfo", ETableSortInfo, - e_table_sort_info_class_init, NULL, PARENT_TYPE); + e_table_sort_info_class_init, e_table_sort_info_init, PARENT_TYPE); -void -e_table_sort_info_changed (ETableSortInfo *e_table_sort_info) +static void +e_table_sort_info_sort_info_changed (ETableSortInfo *info) +{ + g_return_if_fail (info != NULL); + g_return_if_fail (E_IS_TABLE_SORT_INFO (info)); + + if (info->frozen) { + info->sort_info_changed = 1; + } else { + gtk_signal_emit (GTK_OBJECT (info), + e_table_sort_info_signals [SORT_INFO_CHANGED]); + } +} + +static void +e_table_sort_info_group_info_changed (ETableSortInfo *info) { - g_return_if_fail (e_table_sort_info != NULL); - g_return_if_fail (E_IS_TABLE_SORT_INFO (e_table_sort_info)); + g_return_if_fail (info != NULL); + g_return_if_fail (E_IS_TABLE_SORT_INFO (info)); - gtk_signal_emit (GTK_OBJECT (e_table_sort_info), - e_table_sort_info_signals [SORT_INFO_CHANGED]); + if (info->frozen) { + info->group_info_changed = 1; + } else { + gtk_signal_emit (GTK_OBJECT (info), + e_table_sort_info_signals [GROUP_INFO_CHANGED]); + } +} + +void +e_table_sort_info_freeze (ETableSortInfo *info) +{ + info->frozen = 1; +} + +void +e_table_sort_info_thaw (ETableSortInfo *info) +{ + info->frozen = 0; + if (info->sort_info_changed) { + info->sort_info_changed = 0; + e_table_sort_info_sort_info_changed(info); + } + if (info->group_info_changed) { + info->group_info_changed = 0; + e_table_sort_info_group_info_changed(info); + } +} + + +guint +e_table_sort_info_grouping_get_count (ETableSortInfo *info) +{ + return info->group_count; +} + +void +e_table_sort_info_grouping_truncate (ETableSortInfo *info, int length) +{ + if (length < info->group_count) { + info->group_count = length; + } + if (length > info->group_count) { + info->groupings = g_realloc(info->groupings, length * sizeof(ETableSortColumn)); + info->group_count = length; + } + e_table_sort_info_group_info_changed(info); +} + +ETableSortColumn +e_table_sort_info_grouping_get_nth (ETableSortInfo *info, int n) +{ + if (n < info->group_count) { + return info->groupings[n]; + } else { + ETableSortColumn fake = {0, 0}; + return fake; + } +} + +void +e_table_sort_info_grouping_set_nth (ETableSortInfo *info, int n, ETableSortColumn column) +{ + if (n >= info->group_count) { + e_table_sort_info_grouping_truncate(info, n + 1); + } + info->groupings[n] = column; + e_table_sort_info_group_info_changed(info); +} + + +guint +e_table_sort_info_sorting_get_count (ETableSortInfo *info) +{ + return info->sort_count; +} + +void +e_table_sort_info_sorting_truncate (ETableSortInfo *info, int length) +{ + if (length < info->sort_count) { + info->sort_count = length; + } + if (length > info->sort_count) { + info->sortings = g_realloc(info->sortings, length * sizeof(ETableSortColumn)); + info->sort_count = length; + } + e_table_sort_info_sort_info_changed(info); } +ETableSortColumn +e_table_sort_info_sorting_get_nth (ETableSortInfo *info, int n) +{ + if (n < info->sort_count) { + return info->sortings[n]; + } else { + ETableSortColumn fake = {0, 0}; + return fake; + } +} + +void +e_table_sort_info_sorting_set_nth (ETableSortInfo *info, int n, ETableSortColumn column) +{ + if (n >= info->sort_count) { + e_table_sort_info_sorting_truncate(info, n + 1); + } + info->sortings[n] = column; + e_table_sort_info_sort_info_changed(info); +} + + ETableSortInfo * e_table_sort_info_new (void) { -- cgit v1.2.3