static gboolean book_view_gtk_find_iter_for_contact (BookViewGtk *view, Ekiga::ContactPtr contact, GtkTreeIter *iter) { GtkTreeModel *model = NULL; gboolean found = FALSE; model = gtk_tree_view_get_model (view->priv->tree_view); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), iter)) { do { Ekiga::Contact *iter_contact = NULL; gtk_tree_model_get (model, iter, COLUMN_CONTACT_POINTER, &iter_contact, -1); if (iter_contact == contact.get ()) found = TRUE; } while (!found && gtk_tree_model_iter_next (model, iter)); } return found; }
/* react to a new call being inserted in history */ static void on_contact_added (Ekiga::ContactPtr contact, GtkListStore *store) { time_t t; struct tm *timeinfo = NULL; char buffer [80]; std::stringstream info; std::string id; boost::shared_ptr<History::Contact> hcontact = boost::dynamic_pointer_cast<History::Contact> (contact); GtkTreeIter iter; if (hcontact) { switch (hcontact->get_type ()) { case History::RECEIVED: id = "go-previous-symbolic"; break; case History::PLACED: id = "go-next-symbolic"; break; case History::MISSED: id = "call-missed-symbolic"; break; default: break; } } gtk_list_store_prepend (store, &iter); t = hcontact->get_call_start (); timeinfo = localtime (&t); if (timeinfo != NULL) { strftime (buffer, 80, "%x %X", timeinfo); info << buffer; if (!hcontact->get_call_duration ().empty ()) info << " (" << hcontact->get_call_duration () << ")"; else gtk_list_store_set (store, &iter, COLUMN_ERROR_PIXBUF, "error", -1); } else info << hcontact->get_call_duration (); gtk_list_store_set (store, &iter, COLUMN_CONTACT, contact.get (), COLUMN_PIXBUF, id.c_str (), COLUMN_NAME, contact->get_name ().c_str (), COLUMN_INFO, info.str ().c_str (), -1); }
/* Implementation of the static functions */ static void book_view_gtk_add_contact (BookViewGtk *self, Ekiga::ContactPtr contact) { GtkTreeModel *model = NULL; GtkListStore *store = NULL; GtkTreeIter iter; model = gtk_tree_view_get_model (self->priv->tree_view); store = GTK_LIST_STORE (model); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_CONTACT_POINTER, contact.get (), -1); book_view_gtk_update_contact (self, contact, &iter); }