Added a "changed" signal.

2001-02-05  Christopher James Lahey  <clahey@helixcode.com>

	* e-table-config.c, e-table-config.h (dialog_apply): Added a
	"changed" signal.

	* e-table-sort-info.c, e-table-sort-info.h
	(e_table_sort_info_duplicate): Added this function.

	* e-table.c (e_table_set_state_object): Duplicate the state's
	sort_info object here.

svn path=/trunk/; revision=7985
This commit is contained in:
Christopher James Lahey
2001-02-05 21:16:13 +00:00
committed by Chris Lahey
parent f5ab714264
commit 707cce7733
5 changed files with 79 additions and 11 deletions

View File

@ -26,6 +26,13 @@
static GtkObjectClass *config_parent_class;
enum {
CHANGED,
LAST_SIGNAL
};
static guint e_table_config_signals [LAST_SIGNAL] = { 0, };
static void
config_destroy (GtkObject *object)
{
@ -42,11 +49,36 @@ config_destroy (GtkObject *object)
}
static void
config_class_init (GtkObjectClass *klass)
e_table_config_changed (ETableConfig *config, ETableState *state)
{
config_parent_class = gtk_type_class (PARENT_TYPE);
g_return_if_fail (config != NULL);
g_return_if_fail (E_IS_TABLE_CONFIG (config));
gtk_signal_emit(GTK_OBJECT(config),
e_table_config_signals [CHANGED],
state);
}
static void
config_class_init (GtkObjectClass *object_class)
{
ETableConfigClass *klass = E_TABLE_CONFIG_CLASS(object_class);
config_parent_class = gtk_type_class (PARENT_TYPE);
klass->destroy = config_destroy;
klass->changed = NULL;
object_class->destroy = config_destroy;
e_table_config_signals [CHANGED] =
gtk_signal_new ("changed",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (ETableConfigClass, changed),
gtk_marshal_NONE__OBJECT,
GTK_TYPE_NONE, 1, E_TABLE_STATE_TYPE);
gtk_object_class_add_signals (object_class, e_table_config_signals, LAST_SIGNAL);
}
static ETableColumnSpecification *
@ -351,6 +383,15 @@ dialog_destroyed (GtkObject *dialog, ETableConfig *config)
gtk_object_destroy (GTK_OBJECT (config));
}
static void
dialog_apply (GnomePropertyBox *pbox, gint page_num, ETableConfig *config)
{
if (page_num != -1)
return;
e_table_config_changed (config, config->state);
}
/*
* Invoked by the Glade auto-connect code
*/
@ -361,6 +402,7 @@ e_table_proxy_gtk_combo_text_new (void)
return gtk_combo_text_new (TRUE);
}
#if 0
static GtkWidget *
configure_dialog (GladeXML *gui, const char *widget_name, ETableConfig *config)
{
@ -370,6 +412,7 @@ configure_dialog (GladeXML *gui, const char *widget_name, ETableConfig *config)
return w;
}
#endif
static void
connect_button (ETableConfig *config, GladeXML *gui, const char *widget_name, void *cback)
@ -633,6 +676,10 @@ setup_gui (ETableConfig *config)
gtk_signal_connect (
GTK_OBJECT (config->dialog_toplevel), "destroy",
GTK_SIGNAL_FUNC (dialog_destroyed), config);
gtk_signal_connect (
GTK_OBJECT (config->dialog_toplevel), "apply",
GTK_SIGNAL_FUNC (dialog_apply), config);
gtk_object_unref (GTK_OBJECT (gui));
}

View File

@ -56,6 +56,9 @@ typedef struct {
typedef struct {
GtkObjectClass parent_class;
/* Signals */
void (*changed) (ETableConfig *config);
} ETableConfigClass;
GtkType e_table_config_get_type (void);

View File

@ -428,3 +428,20 @@ e_table_sort_info_save_to_node (ETableSortInfo *info,
return grouping;
}
ETableSortInfo *
e_table_sort_info_duplicate (ETableSortInfo *info)
{
ETableSortInfo *new_info;
new_info = e_table_sort_info_new();
new_info->group_count = info->group_count;
new_info->groupings = g_new(ETableSortColumn, new_info->group_count);
memmove(new_info->groupings, info->groupings, sizeof (ETableSortColumn) * new_info->group_count);
new_info->sort_count = info->sort_count;
new_info->sortings = g_new(ETableSortColumn, new_info->sort_count);
memmove(new_info->sortings, info->sortings, sizeof (ETableSortColumn) * new_info->sort_count);
return new_info;
}

View File

@ -70,5 +70,6 @@ void e_table_sort_info_load_from_node (ETableSortInfo *info,
gdouble state_version);
xmlNode *e_table_sort_info_save_to_node (ETableSortInfo *info,
xmlNode *parent);
ETableSortInfo *e_table_sort_info_duplicate (ETableSortInfo *info);
#endif /* _E_TABLE_SORT_INFO_H_ */

View File

@ -831,16 +831,16 @@ e_table_set_state_object(ETable *e_table, ETableState *state)
e_table->group_info_change_id);
gtk_object_unref(GTK_OBJECT(e_table->sort_info));
}
e_table->sort_info = state->sort_info;
if (e_table->sort_info) {
gtk_object_ref(GTK_OBJECT(e_table->sort_info));
if (state->sort_info) {
e_table->sort_info = e_table_sort_info_duplicate(state->sort_info);
e_table->group_info_change_id =
gtk_signal_connect (
GTK_OBJECT (e_table->sort_info),
"group_info_changed",
GTK_SIGNAL_FUNC (sort_info_changed),
e_table);
gtk_signal_connect (GTK_OBJECT (e_table->sort_info),
"group_info_changed",
GTK_SIGNAL_FUNC (sort_info_changed),
e_table);
}
else
e_table->sort_info = NULL;
if (e_table->sorter)
gtk_object_set(GTK_OBJECT(e_table->sorter),