diff options
author | Jon Trowbridge <trow@ximian.com> | 2001-07-17 12:58:55 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-07-17 12:58:55 +0800 |
commit | 6bb3bbdfff7383749d19a57cfe3162cd67aabf9b (patch) | |
tree | 45ed719c87fd8e1fd8f3e304d0bf187bfba3a7d3 /addressbook/gui/component/select-names/e-select-names-model.c | |
parent | ca133393551eb77aeff1af61e04541b71be4a28a (diff) | |
download | gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.tar gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.tar.gz gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.tar.bz2 gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.tar.lz gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.tar.xz gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.tar.zst gsoc2013-evolution-6bb3bbdfff7383749d19a57cfe3162cd67aabf9b.zip |
Added addSectionWithLimit to the SelectNames interface.
2001-07-16 Jon Trowbridge <trow@ximian.com>
* gui/component/select-names/Evolution-Addressbook-SelectNames.idl:
Added addSectionWithLimit to the SelectNames interface.
* gui/component/select-names/e-select-names-bonobo.c
(impl_SelectNames_add_section_with_limit): Added. Implements
addSectionWithLimit.
(e_select_names_bonobo_construct): Set up as a BonoboEventSource.
(init): Listen for "changed" signals from our manager.
(manager_changed_cb): Notify our listeners if we get a changed
signal from our manager.
* gui/component/select-names/e-select-names-manager.c
(e_select_names_manager_class_init): Added a "changed" signal".
(section_copy): Propogate the signal connection.
(section_free): Disconnect the changed handler.
(e_select_names_manager_add_section_with_limit): Connect to the
new section's model, listening for changes.
(e_select_names_manager_activate_dialog): Connect to the "working
copy" model, listening for changes.
(e_select_names_manager_add_section_with_limit): Added.
(e_select_names_manager_add_section): Changed to just be a special
case of e_select_names_manager_add_section_with_limit.
* gui/component/select-names/e-select-names-model.c
(e_select_names_model_set_limit): Added. Allows a max number of
names allowed in the model.
(e_select_names_model_get_limit): Added. Returns the limit.
(e_select_names_model_at_limit): Added. Returns TRUE if the
model is "full".
(e_select_names_model_insert): Check that we aren't at the
limit before inserting. Silently return if we are.
(e_select_names_model_append): Check that we aren't at the
limit before appending. Silently return if we are.
svn path=/trunk/; revision=11150
Diffstat (limited to 'addressbook/gui/component/select-names/e-select-names-model.c')
-rw-r--r-- | addressbook/gui/component/select-names/e-select-names-model.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index 3fd5249a26..f102421f0e 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -56,6 +56,8 @@ struct _ESelectNamesModelPrivate { GList *data; /* of EDestination */ gchar *text; gchar *addr_text; + + gint limit; }; @@ -148,6 +150,8 @@ static void e_select_names_model_init (ESelectNamesModel *model) { model->priv = g_new0 (struct _ESelectNamesModelPrivate, 1); + + model->priv->limit = -1; } static void @@ -239,6 +243,8 @@ e_select_names_model_duplicate (ESelectNamesModel *old) model->priv->data = g_list_append (model->priv->data, dup); } + model->priv->limit = old->priv->limit; + return model; } @@ -318,6 +324,33 @@ e_select_names_model_count (ESelectNamesModel *model) return g_list_length (model->priv->data); } +gint +e_select_names_model_get_limit (ESelectNamesModel *model) +{ + g_return_val_if_fail (model != NULL, 0); + g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), 0); + + return model->priv->limit; +} + +void +e_select_names_model_set_limit (ESelectNamesModel *model, gint limit) +{ + g_return_if_fail (model != NULL); + g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); + + model->priv->limit = MAX (limit, -1); +} + +gboolean +e_select_names_model_at_limit (ESelectNamesModel *model) +{ + g_return_val_if_fail (model != NULL, TRUE); + g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), TRUE); + + return model->priv->limit >= 0 && g_list_length (model->priv->data) >= model->priv->limit; +} + const EDestination * e_select_names_model_get_destination (ESelectNamesModel *model, gint index) { @@ -419,6 +452,12 @@ e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination g_return_if_fail (0 <= index && index <= g_list_length (model->priv->data)); g_return_if_fail (dest && E_IS_DESTINATION (dest)); + if (e_select_names_model_at_limit (model)) { + /* FIXME: This is bad. */ + gtk_object_unref (GTK_OBJECT (dest)); + return; + } + model->priv->data = g_list_insert (model->priv->data, dest, index); gtk_object_ref (GTK_OBJECT (dest)); @@ -433,6 +472,12 @@ e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (dest && E_IS_DESTINATION (dest)); + if (e_select_names_model_at_limit (model)) { + /* FIXME: This is bad. */ + gtk_object_unref (GTK_OBJECT (dest)); + return; + } + model->priv->data = g_list_append (model->priv->data, dest); gtk_object_ref (GTK_OBJECT (dest)); |