diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-03-25 16:17:15 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-03-25 16:17:15 +0800 |
commit | 1190e292f4e32be10c45ffd92e36eb62e8592a53 (patch) | |
tree | 51b03058290b93f1a416764c36b6159cc778723f /widgets/table | |
parent | 2ed07fe856571d969c17c944e1fdb16740252b95 (diff) | |
download | gsoc2013-evolution-1190e292f4e32be10c45ffd92e36eb62e8592a53.tar.gz gsoc2013-evolution-1190e292f4e32be10c45ffd92e36eb62e8592a53.tar.zst gsoc2013-evolution-1190e292f4e32be10c45ffd92e36eb62e8592a53.zip |
Added e-selection-model-array.lo.
2001-03-25 Christopher James Lahey <clahey@ximian.com>
* gal/Makefile.am (libgal_la_LIBADD): Added
e-selection-model-array.lo.
* gal/widgets/Makefile.am: Added e-selection-model-array.c and
e-selection-model-array.h.
* gal/widgets/e-selection-model-array.c,
gal/widgets/e-selection-model-array.h: New class that implements
the details of ESelectionModel. ESelectionModel has been
refactored to just be a this virtual class. ESelectionModelArray
is the original implementation of ESelectionModel. This is what
most people will want to use or derive from.
* gal/widgets/e-selection-model-simple.c,
gal/widgets/e-selection-model-simple.h: Made the parent class of
this be ESelectionModelArray instead of ESelectionModel. Changed
some function names to match this change.
* gal/widgets/e-selection-model.c,
gal/widgets/e-selection-model.h: Refactored most of the
implementation of this class into ESelectionModelArray. Now just
a thin virtual class.
From gal/e-table/ChangeLog:
2001-03-25 Christopher James Lahey <clahey@ximian.com>
* e-table-selection-model.c, e-table-selection-model.h: Made the
parent object of this be ESelectionModelArray instead of
ESelectionModel due to their refactoring. Changed the commented
out code for saving the selection a bit.
svn path=/trunk/; revision=8924
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-table-selection-model.c | 74 | ||||
-rw-r--r-- | widgets/table/e-table-selection-model.h | 8 |
2 files changed, 51 insertions, 31 deletions
diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c index faeb1fad31..f570a28176 100644 --- a/widgets/table/e-table-selection-model.c +++ b/widgets/table/e-table-selection-model.c @@ -15,11 +15,11 @@ #define ETSM_CLASS(e) ((ETableSelectionModelClass *)((GtkObject *)e)->klass) -#define PARENT_TYPE e_selection_model_get_type () +#define PARENT_TYPE e_selection_model_array_get_type () -static ESelectionModel *parent_class; +static ESelectionModelArray *parent_class; -static gint etsm_get_row_count (ESelectionModel *esm); +static gint etsm_get_row_count (ESelectionModelArray *esm); enum { ARG_0, @@ -61,7 +61,7 @@ model_pre_change (ETableModel *etm, ETableSelectionModel *etsm) free_hash(etsm); #if 0 - if (etsm->model && e_table_model_has_save_id(etsm->model)) { + if (etsm->model && (!etsm->hash) && e_table_model_has_save_id(etsm->model)) { gint cursor_row; etsm->hash = g_hash_table_new(g_str_hash, g_str_equal); e_selection_model_foreach(E_SELECTION_MODEL(etsm), save_to_hash, etsm); @@ -75,33 +75,45 @@ model_pre_change (ETableModel *etm, ETableSelectionModel *etsm) #endif } -static void -model_changed(ETableModel *etm, ETableSelectionModel *etsm) +#if 0 +static gint +model_changed_idle(ETableSelectionModel *etsm) { + ETableModel *etm = etsm->model; + e_selection_model_clear(E_SELECTION_MODEL(etsm)); -#if 0 - if (etm && e_table_model_has_save_id(etm)) { + if (etsm->hash && etm && e_table_model_has_save_id(etm)) { int row_count = e_table_model_row_count(etm); int i; - if (e_selection_model_confirm_row_count(E_SELECTION_MODEL(etsm))) { - for (i = 0; i < row_count; i++) { - char *save_id = e_table_model_get_save_id(etm, i); - if (g_hash_table_lookup(etsm->hash, save_id)) - e_selection_model_change_one_row(E_SELECTION_MODEL(etsm), i, TRUE); - if (etsm->cursor_id && !strcmp(etsm->cursor_id, save_id)) { - e_selection_model_change_cursor(E_SELECTION_MODEL(etsm), i); - g_free(etsm->cursor_id); - etsm->cursor_id = NULL; - } - g_free(save_id); + e_selection_model_array_confirm_row_count(E_SELECTION_MODEL_ARRAY(etsm)); + for (i = 0; i < row_count; i++) { + char *save_id = e_table_model_get_save_id(etm, i); + if (g_hash_table_lookup(etsm->hash, save_id)) + e_selection_model_change_one_row(E_SELECTION_MODEL(etsm), i, TRUE); + if (etsm->cursor_id && !strcmp(etsm->cursor_id, save_id)) { + e_selection_model_change_cursor(E_SELECTION_MODEL(etsm), i, e_selection_model_cursor_row(E_SELECTION_MODEL(etsm))); + g_free(etsm->cursor_id); + etsm->cursor_id = NULL; } + g_free(save_id); } + free_hash(etsm); } + etsm->model_changed_idle_id = 0; + return FALSE; +} #endif - if (etsm->hash) - free_hash(etsm); +static void +model_changed(ETableModel *etm, ETableSelectionModel *etsm) +{ + e_selection_model_clear(E_SELECTION_MODEL(etsm)); +#if 0 + if (!etsm->model_changed_idle_id && etm && e_table_model_has_save_id(etm)) { + etsm->model_changed_idle_id = g_idle_add_full(G_PRIORITY_HIGH, (GSourceFunc) model_changed_idle, etsm, NULL); + } +#endif } static void @@ -122,7 +134,7 @@ model_cell_changed(ETableModel *etm, int col, int row, ETableSelectionModel *ets static void model_rows_inserted(ETableModel *etm, int row, int count, ETableSelectionModel *etsm) { - e_selection_model_insert_rows(E_SELECTION_MODEL(etsm), row, count); + e_selection_model_array_insert_rows(E_SELECTION_MODEL_ARRAY(etsm), row, count); if (etsm->hash) free_hash(etsm); } @@ -130,7 +142,7 @@ model_rows_inserted(ETableModel *etm, int row, int count, ETableSelectionModel * static void model_rows_deleted(ETableModel *etm, int row, int count, ETableSelectionModel *etsm) { - e_selection_model_delete_rows(E_SELECTION_MODEL(etsm), row, count); + e_selection_model_array_delete_rows(E_SELECTION_MODEL_ARRAY(etsm), row, count); if (etsm->hash) free_hash(etsm); } @@ -187,6 +199,7 @@ drop_model(ETableSelectionModel *etsm) etsm->model_rows_inserted_id); gtk_signal_disconnect(GTK_OBJECT(etsm->model), etsm->model_rows_deleted_id); + gtk_object_unref(GTK_OBJECT(etsm->model)); } etsm->model = NULL; @@ -199,6 +212,9 @@ etsm_destroy (GtkObject *object) etsm = E_TABLE_SELECTION_MODEL (object); + if (etsm->model_changed_idle_id) { + g_source_remove(etsm->model_changed_idle_id); + } drop_model(etsm); free_hash(etsm); @@ -237,24 +253,26 @@ e_table_selection_model_init (ETableSelectionModel *selection) selection->model = NULL; selection->hash = NULL; selection->cursor_id = NULL; + + selection->model_changed_idle_id = 0; } static void e_table_selection_model_class_init (ETableSelectionModelClass *klass) { GtkObjectClass *object_class; - ESelectionModelClass *esm_class; + ESelectionModelArrayClass *esma_class; parent_class = gtk_type_class (PARENT_TYPE); object_class = GTK_OBJECT_CLASS(klass); - esm_class = E_SELECTION_MODEL_CLASS(klass); + esma_class = E_SELECTION_MODEL_ARRAY_CLASS(klass); object_class->destroy = etsm_destroy; object_class->get_arg = etsm_get_arg; object_class->set_arg = etsm_set_arg; - esm_class->get_row_count = etsm_get_row_count; + esma_class->get_row_count = etsm_get_row_count; gtk_object_add_arg_type ("ETableSelectionModel::model", GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_MODEL); @@ -277,9 +295,9 @@ e_table_selection_model_new (void) } static gint -etsm_get_row_count (ESelectionModel *esm) +etsm_get_row_count (ESelectionModelArray *esma) { - ETableSelectionModel *etsm = E_TABLE_SELECTION_MODEL(esm); + ETableSelectionModel *etsm = E_TABLE_SELECTION_MODEL(esma); return e_table_model_row_count (etsm->model); } diff --git a/widgets/table/e-table-selection-model.h b/widgets/table/e-table-selection-model.h index 02b1949257..94eaf2bb94 100644 --- a/widgets/table/e-table-selection-model.h +++ b/widgets/table/e-table-selection-model.h @@ -3,7 +3,7 @@ #define _E_TABLE_SELECTION_MODEL_H_ #include <gtk/gtkobject.h> -#include <gal/widgets/e-selection-model.h> +#include <gal/widgets/e-selection-model-array.h> #include <gal/e-table/e-table-model.h> #include <gal/e-table/e-table-defines.h> #include <gal/e-table/e-table-sorter.h> @@ -19,7 +19,7 @@ extern "C" { #define E_IS_TABLE_SELECTION_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SELECTION_MODEL_TYPE)) typedef struct { - ESelectionModel base; + ESelectionModelArray base; ETableModel *model; @@ -30,6 +30,8 @@ typedef struct { guint model_rows_inserted_id; guint model_rows_deleted_id; + guint model_changed_idle_id; + guint frozen : 1; guint selection_model_changed : 1; guint group_info_changed : 1; @@ -39,7 +41,7 @@ typedef struct { } ETableSelectionModel; typedef struct { - ESelectionModelClass parent_class; + ESelectionModelArrayClass parent_class; } ETableSelectionModelClass; GtkType e_table_selection_model_get_type (void); |