aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-06-09 06:11:48 +0800
committerChris Toshok <toshok@src.gnome.org>2004-06-09 06:11:48 +0800
commit5ce3f210b969c3e0ab6020911a6bb4b887e46d0a (patch)
tree60df09eefbd51a752b1fceb2d955b9e598b3b3ed /addressbook/gui
parent8777dda60dc8b1d00195ec0451aa5f40edc5c2b2 (diff)
downloadgsoc2013-evolution-5ce3f210b969c3e0ab6020911a6bb4b887e46d0a.tar.gz
gsoc2013-evolution-5ce3f210b969c3e0ab6020911a6bb4b887e46d0a.tar.zst
gsoc2013-evolution-5ce3f210b969c3e0ab6020911a6bb4b887e46d0a.zip
new function. do the get_view in an idle handler.
2004-06-08 Chris Toshok <toshok@ximian.com> * gui/widgets/e-addressbook-model.c (get_view_idle): new function. do the get_view in an idle handler. (eab_model_set_property): don't call get_view directly from any setter block. instead just add the idle handler (if it's not already added.) This keeps us from duplicating queries when both "book" and "query" are set using the same g_object_set. svn path=/trunk/; revision=26264
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c41
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h2
2 files changed, 33 insertions, 10 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 9630c83ff8..244c37cb0c 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -522,6 +522,16 @@ get_view (EABModel *model)
}
}
+static gboolean
+get_view_idle (EABModel *model)
+{
+ model->book_view_idle_id = 0;
+ get_view (model);
+ g_object_unref (model);
+ return FALSE;
+}
+
+
EContact *
eab_model_get_contact(EABModel *model,
int row)
@@ -536,6 +546,7 @@ static void
eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
EABModel *model;
+ gboolean need_get_book_view = FALSE;
model = EAB_MODEL (object);
@@ -556,6 +567,15 @@ eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GPa
}
model->book = E_BOOK(g_value_get_object (value));
if (model->book) {
+ model->writable_status_id =
+ g_signal_connect (model->book,
+ "writable_status",
+ G_CALLBACK (writable_status), model);
+ model->backend_died_id =
+ g_signal_connect (model->book,
+ "backend_died",
+ G_CALLBACK (backend_died), model);
+
if (!model->editable_set) {
model->editable = e_book_is_writable (model->book);
@@ -563,24 +583,17 @@ eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GPa
eab_model_signals [WRITABLE_STATUS], 0,
model->editable);
}
+
model->first_get_view = TRUE;
g_object_ref (model->book);
- get_view (model);
- model->writable_status_id =
- g_signal_connect (model->book,
- "writable_status",
- G_CALLBACK (writable_status), model);
- model->backend_died_id =
- g_signal_connect (model->book,
- "backend_died",
- G_CALLBACK (backend_died), model);
+ need_get_book_view = TRUE;
}
break;
case PROP_QUERY:
if (model->query)
e_book_query_unref (model->query);
model->query = e_book_query_from_string (g_value_get_string (value));
- get_view (model);
+ need_get_book_view = TRUE;
break;
case PROP_EDITABLE:
model->editable = g_value_get_boolean (value);
@@ -590,6 +603,14 @@ eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GPa
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
+
+ if (need_get_book_view) {
+ if (!model->book_view_idle_id) {
+ g_object_ref (model);
+ model->book_view_idle_id = g_idle_add ((GSourceFunc)get_view_idle, model);
+ }
+ }
+
}
static void
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 64ce6c3845..e83477ff93 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -24,6 +24,8 @@ struct _EABModel {
EBookQuery *query;
EBookView *book_view;
+ int book_view_idle_id;
+
EContact **data;
int data_count;
int allocated_count;