From 3de981ec78d529eb1bd9b2f98f154eae91dffc6d Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sun, 5 Mar 2000 23:15:14 +0000 Subject: Added support for the sorting info. The Etable creates a sort_info object, 2000-03-05 Christopher James Lahey * e-table.c, e-table.h: Added support for the sorting info. The Etable creates a sort_info object, and then connects to the signals to rearrange the rows when the sort_info changes. It also passes the info object to the ETableHeaderItem. * e-table-model.c: Fixed a typo where ETableModel was written as ETableModle. * e-table-header.c, e-table-header.h: Added some code for sorting here, but it's not used. I don't think we want this code, but I wanted to check it in at least once so that it's not lost. * e-table-header-item.c, e-table-header-item.h: Added a "sort_info" argument to ETableHeaderItem. Added display of current sort settings. Added support for clicking to change the sort settings. * e-table-col.h: E_TABLE_COL_ARROW_NONE is marked as being = 0 since this is required in other places. (I think C defines this as being the case, but it's good to have the = 0 there so that it's obvious that it has to be first.) * TODO: Mark sorting as done. * e-table-sort-info.c, e-table-sort-info.h: New files for containing the xml grouping/sorting information and for sending signals on that information. * Makefile.am: Added e-table-sort-info.c and e-table-sort-info.h. svn path=/trunk/; revision=2060 --- widgets/table/e-table-sort-info.c | 124 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 widgets/table/e-table-sort-info.c (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 new file mode 100644 index 0000000000..1f465be99b --- /dev/null +++ b/widgets/table/e-table-sort-info.c @@ -0,0 +1,124 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * e-table-sort-info.c: a Table Model + * + * Author: + * Miguel de Icaza (miguel@gnu.org) + * + * (C) 1999 Helix Code, Inc. + */ +#include +#include +#include +#include "e-table-sort-info.h" + +#define ETM_CLASS(e) ((ETableSortInfoClass *)((GtkObject *)e)->klass) + +#define PARENT_TYPE gtk_object_get_type(); + + +static GtkObjectClass *e_table_sort_info_parent_class; + +enum { + SORT_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) +{ + ETableSortInfo *etsi; + + etsi = E_TABLE_SORT_INFO (o); + + switch (arg_id){ + case ARG_GROUPING: + etsi->grouping = GTK_VALUE_POINTER (*arg); + break; + } +} + +static void +etsi_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableSortInfo *etsi; + + etsi = E_TABLE_SORT_INFO (o); + + switch (arg_id){ + case ARG_GROUPING: + GTK_VALUE_POINTER (*arg) = etsi->grouping; + break; + } +} + +static void +e_table_sort_info_class_init (GtkObjectClass *object_class) +{ + e_table_sort_info_parent_class = gtk_type_class (gtk_object_get_type ()); + + object_class->set_arg = etsi_set_arg; + object_class->get_arg = etsi_get_arg; + + e_table_sort_info_signals [SORT_INFO_CHANGED] = + gtk_signal_new ("sort_info_changed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableSortInfoClass, sort_info_changed), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (object_class, e_table_sort_info_signals, LAST_SIGNAL); + + gtk_object_add_arg_type ("ETableSortInfo::grouping", GTK_TYPE_POINTER, + GTK_ARG_READWRITE, ARG_GROUPING); +} + + +guint +e_table_sort_info_get_type (void) +{ + static guint type = 0; + + if (!type) + { + GtkTypeInfo info = + { + "ETableSortInfo", + sizeof (ETableSortInfo), + sizeof (ETableSortInfoClass), + (GtkClassInitFunc) e_table_sort_info_class_init, + NULL, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + type = gtk_type_unique (gtk_object_get_type(), &info); + } + + return type; +} + +void +e_table_sort_info_changed (ETableSortInfo *e_table_sort_info) +{ + g_return_if_fail (e_table_sort_info != NULL); + g_return_if_fail (E_IS_TABLE_SORT_INFO (e_table_sort_info)); + + gtk_signal_emit (GTK_OBJECT (e_table_sort_info), + e_table_sort_info_signals [SORT_INFO_CHANGED]); +} + +ETableSortInfo * +e_table_sort_info_new (void) +{ + return gtk_type_new (e_table_sort_info_get_type ()); +} -- cgit v1.2.3