diff options
author | Sivaiah Nallagatla <snallagatla@novell.com> | 2005-01-22 12:03:51 +0800 |
---|---|---|
committer | Sivaiah Nallagatla <siva@src.gnome.org> | 2005-01-22 12:03:51 +0800 |
commit | 59dd1b2a261be4b5ba8784ce3619f7e002c98f2f (patch) | |
tree | 9081439bd485ad7e3c294c9fdcf51e066db74a46 /addressbook/gui | |
parent | 2420ae32bd6f7e9672ef84ca3f826dfa8d11a7f4 (diff) | |
download | gsoc2013-evolution-59dd1b2a261be4b5ba8784ce3619f7e002c98f2f.tar.gz gsoc2013-evolution-59dd1b2a261be4b5ba8784ce3619f7e002c98f2f.tar.zst gsoc2013-evolution-59dd1b2a261be4b5ba8784ce3619f7e002c98f2f.zip |
renamed the signal CONTACT_REMOVED to CONTACTS_REMOVED and chaned the
2005-01-21 Sivaiah Nallagatla <snallagatla@novell.com>
* gui/widgets/e-addressbook-model.[ch]
(eab_model_class_init) : renamed the signal
CONTACT_REMOVED to CONTACTS_REMOVED and chaned
the param type POINTER from INT
(remove_contact) : delete all the contacts
from the model and emit CONATCTS_REMOVED
signal instead of emitting it many times
* gui/widgets/e-addressbook-reflow-adpater.c
(e_addressbook_reflow_adapter_construct)
(remove_contacts) : renamed remove_contact to remove_contacts
and when number of conacts is more than 1 use _model_changed
instead of _remove_item
* gui/widgets/e-addressbook-table-adapter.c
(eab_table_adapter_construct)
(remove_contacts) : ditto
* gui/widgets/e-addressbook-view.c
(eab_view_new) :
(contacts_removed) : renamed contact_removed
to contacts_removed and traverese over indices
to find displayed contact indiex
fixes #71448
svn path=/trunk/; revision=28503
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 27 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.h | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-reflow-adapter.c | 17 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-table-adapter.c | 17 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 28 |
5 files changed, 58 insertions, 33 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index e6f4ecb868..da029adb19 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -42,7 +42,7 @@ enum { SEARCH_RESULT, FOLDER_BAR_MESSAGE, CONTACT_ADDED, - CONTACT_REMOVED, + CONTACTS_REMOVED, CONTACT_CHANGED, MODEL_CHANGED, STOP_STATE_CHANGED, @@ -191,9 +191,11 @@ remove_contact(EBookView *book_view, EABModel *model) { /* XXX we should keep a hash around instead of this O(n*m) loop */ - int i = 0; + gint i = 0; GList *l; + GArray *indices; + indices = g_array_new (FALSE, FALSE, sizeof (gint)); for (l = ids; l; l = l->next) { char *id = l->data; for ( i = 0; i < model->data_count; i++) { @@ -201,16 +203,15 @@ remove_contact(EBookView *book_view, g_object_unref (model->data[i]); memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (EContact *)); model->data_count--; - - g_signal_emit (model, - eab_model_signals [CONTACT_REMOVED], 0, - i); - + g_array_append_val (indices, i); break; } } } - + g_signal_emit (model, + eab_model_signals [CONTACTS_REMOVED], 0, + indices); + g_array_free (indices, FALSE); update_folder_bar_message (model); } @@ -367,14 +368,14 @@ eab_model_class_init (GObjectClass *object_class) eab_marshal_NONE__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); - eab_model_signals [CONTACT_REMOVED] = - g_signal_new ("contact_removed", + eab_model_signals [CONTACTS_REMOVED] = + g_signal_new ("contacts_removed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, contact_removed), + G_STRUCT_OFFSET (EABModelClass, contacts_removed), NULL, NULL, - eab_marshal_NONE__INT, - G_TYPE_NONE, 1, G_TYPE_INT); + eab_marshal_NONE__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); eab_model_signals [CONTACT_CHANGED] = g_signal_new ("contact_changed", diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h index e5ebb83dab..8ccc4f0693 100644 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ b/addressbook/gui/widgets/e-addressbook-model.h @@ -53,7 +53,7 @@ struct _EABModelClass { void (*status_message) (EABModel *model, const gchar *message); void (*folder_bar_message) (EABModel *model, const gchar *message); void (*contact_added) (EABModel *model, gint index, gint count); - void (*contact_removed) (EABModel *model, gint index); + void (*contacts_removed) (EABModel *model, gpointer id_list); void (*contact_changed) (EABModel *model, gint index); void (*model_changed) (EABModel *model); void (*stop_state_changed) (EABModel *model); diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c index 4d935198d1..96a7ceaa91 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c @@ -259,11 +259,18 @@ create_contact (EABModel *model, } static void -remove_contact (EABModel *model, - gint index, +remove_contacts (EABModel *model, + gpointer data, EAddressbookReflowAdapter *adapter) { - e_reflow_model_item_removed (E_REFLOW_MODEL (adapter), index); + GArray *indices = (GArray *) data; + int count = indices->len; + + if (count == 1) + e_reflow_model_item_removed (E_REFLOW_MODEL (adapter), g_array_index (indices, gint, 0)); + else + e_reflow_model_changed (E_REFLOW_MODEL (adapter)); + } static void @@ -472,8 +479,8 @@ e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter, G_CALLBACK(create_contact), adapter); priv->remove_contact_id = g_signal_connect(priv->model, - "contact_removed", - G_CALLBACK(remove_contact), + "contacts_removed", + G_CALLBACK(remove_contacts), adapter); priv->modify_contact_id = g_signal_connect(priv->model, "contact_changed", diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index c3fadfdf23..a11f749523 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -258,12 +258,19 @@ create_contact (EABModel *model, } static void -remove_contact (EABModel *model, - gint index, +remove_contacts (EABModel *model, + gpointer data, EAddressbookTableAdapter *adapter) { + GArray *indices = (GArray *) data; + int count = indices->len; + + e_table_model_pre_change (E_TABLE_MODEL (adapter)); - e_table_model_rows_deleted (E_TABLE_MODEL (adapter), index, 1); + if (count == 1) + e_table_model_rows_deleted (E_TABLE_MODEL (adapter), g_array_index (indices, gint, 0), 1); + else + e_table_model_changed (E_TABLE_MODEL (adapter)); } static void @@ -321,8 +328,8 @@ eab_table_adapter_construct (EAddressbookTableAdapter *adapter, G_CALLBACK(create_contact), adapter); priv->remove_contact_id = g_signal_connect(priv->model, - "contact_removed", - G_CALLBACK(remove_contact), + "contacts_removed", + G_CALLBACK(remove_contacts), adapter); priv->modify_contact_id = g_signal_connect(priv->model, "contact_changed", diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index dd45de4ba0..5f8397161b 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -99,7 +99,7 @@ static void stop_state_changed (GtkObject *object, EABView *eav); static void writable_status (GtkObject *object, gboolean writable, EABView *eav); static void backend_died (GtkObject *object, EABView *eav); static void contact_changed (EABModel *model, gint index, EABView *eav); -static void contact_removed (EABModel *model, gint index, EABView *eav); +static void contacts_removed (EABModel *model, gpointer data, EABView *eav); static GList *get_selected_contacts (EABView *view); static void command_state_change (EABView *eav); @@ -436,8 +436,8 @@ eab_view_new (void) G_CALLBACK (backend_died), eav); g_signal_connect (eav->model, "contact_changed", G_CALLBACK (contact_changed), eav); - g_signal_connect (eav->model, "contact_removed", - G_CALLBACK (contact_removed), eav); + g_signal_connect (eav->model, "contacts_removed", + G_CALLBACK (contacts_removed), eav); eav->editable = FALSE; eav->query = g_strdup (SHOW_ALL_SEARCH); @@ -1189,13 +1189,23 @@ contact_changed (EABModel *model, gint index, EABView *eav) } static void -contact_removed (EABModel *model, gint index, EABView *eav) +contacts_removed (EABModel *model, gpointer data, EABView *eav) { - if (eav->displayed_contact == index) { - /* if the contact that's presently displayed is changed, clear the display */ - eab_contact_display_render (EAB_CONTACT_DISPLAY (eav->contact_display), NULL, - EAB_CONTACT_DISPLAY_RENDER_NORMAL); - eav->displayed_contact = -1; + GArray *indices = (GArray *) data; + int count = indices->len; + gint i; + + for (i = 0; i < count; i ++) { + + + if (eav->displayed_contact == g_array_index (indices, gint, i)) { + + /* if the contact that's presently displayed is changed, clear the display */ + eab_contact_display_render (EAB_CONTACT_DISPLAY (eav->contact_display), NULL, + EAB_CONTACT_DISPLAY_RENDER_NORMAL); + eav->displayed_contact = -1; + break; + } } } |