From 707cce7733ad5bd9fda46ed3b48259df4e2d73f0 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 5 Feb 2001 21:16:13 +0000 Subject: Added a "changed" signal. 2001-02-05 Christopher James Lahey * 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 --- widgets/table/e-table-config.c | 53 ++++++++++++++++++++++++++++++++++++--- widgets/table/e-table-config.h | 3 +++ widgets/table/e-table-sort-info.c | 17 +++++++++++++ widgets/table/e-table-sort-info.h | 1 + widgets/table/e-table.c | 16 ++++++------ 5 files changed, 79 insertions(+), 11 deletions(-) (limited to 'widgets') diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c index accef6f174..f25e77245d 100644 --- a/widgets/table/e-table-config.c +++ b/widgets/table/e-table-config.c @@ -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)); } diff --git a/widgets/table/e-table-config.h b/widgets/table/e-table-config.h index df224c4a2a..e33aab33bf 100644 --- a/widgets/table/e-table-config.h +++ b/widgets/table/e-table-config.h @@ -56,6 +56,9 @@ typedef struct { typedef struct { GtkObjectClass parent_class; + + /* Signals */ + void (*changed) (ETableConfig *config); } ETableConfigClass; GtkType e_table_config_get_type (void); diff --git a/widgets/table/e-table-sort-info.c b/widgets/table/e-table-sort-info.c index 47f22ee5ff..c723ded8d8 100644 --- a/widgets/table/e-table-sort-info.c +++ b/widgets/table/e-table-sort-info.c @@ -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; +} diff --git a/widgets/table/e-table-sort-info.h b/widgets/table/e-table-sort-info.h index 71822337b7..c79eb019b3 100644 --- a/widgets/table/e-table-sort-info.h +++ b/widgets/table/e-table-sort-info.h @@ -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_ */ diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 238183ec8d..19db9e807e 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -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), -- cgit