Ubuntu 11.10 上删除Empathy的聊天记录(5)

if (!tpl_log_manager_get_entities_finish (TPL_LOG_MANAGER (manager),
      result, &entities, &error))
    {
      DEBUG ("%s. Aborting", error->message);
      g_error_free (error);
      goto out;
    }

view = GTK_TREE_VIEW (ctx->self->priv->treeview_who);
  model = gtk_tree_view_get_model (view);
  selection = gtk_tree_view_get_selection (view);
  store = GTK_LIST_STORE (model);

/* Block signals to stop the logs being retrieved prematurely  */
  g_signal_handlers_block_by_func (selection,
      log_window_who_changed_cb, ctx->self);

for (l = entities; l; l = l->next)
    {
      TplEntity *entity = TPL_ENTITY (l->data);
      TplEntityType type = tpl_entity_get_entity_type (entity);
      EmpathyContact *contact;
      const gchar *name;
      gchar *sort_key;
      gboolean room = type == TPL_ENTITY_ROOM;

contact = empathy_contact_from_tpl_contact (ctx->account, entity);

name = empathy_contact_get_alias (contact);
      sort_key = g_utf8_collate_key (name, -1);

gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter,
          COL_WHO_TYPE, COL_TYPE_NORMAL,
          COL_WHO_ICON, room ? EMPATHY_IMAGE_GROUP_MESSAGE
                             : EMPATHY_IMAGE_AVATAR_DEFAULT,
          COL_WHO_NAME, name,
          COL_WHO_NAME_SORT_KEY, sort_key,
          COL_WHO_ID, tpl_entity_get_identifier (entity),
          COL_WHO_ACCOUNT, ctx->account,
          COL_WHO_TARGET, entity,
          -1);

g_free (sort_key);
      g_object_unref (contact);

if (ctx->self->priv->selected_account != NULL &&
          !tp_strdiff (tp_proxy_get_object_path (ctx->account),
          tp_proxy_get_object_path (ctx->self->priv->selected_account)))
        select_account = TRUE;
    }
  g_list_free_full (entities, g_object_unref);

if (gtk_tree_model_get_iter_first (model, &iter))
    {
      gint type;

gtk_tree_model_get (model, &iter,
          COL_WHO_TYPE, &type,
          -1);

if (type != COL_TYPE_ANY)
        {
          gtk_list_store_prepend (store, &iter);
          gtk_list_store_set (store, &iter,
              COL_WHO_TYPE, COL_TYPE_SEPARATOR,
              COL_WHO_NAME, "separator",
              -1);

gtk_list_store_prepend (store, &iter);
          gtk_list_store_set (store, &iter,
              COL_WHO_TYPE, COL_TYPE_ANY,
              COL_WHO_NAME, _("Anyone"),
              -1);
        }
    }

/* Unblock signals */
  g_signal_handlers_unblock_by_func (selection,
      log_window_who_changed_cb,
      ctx->self);

/* We display the selected account if we populate the model with chats from
   * this account. */
  if (select_account)
    log_window_chats_set_selected (ctx->self);

out:
  _tpl_action_chain_continue (log_window->priv->chain);
  ctx_free (ctx);
}

static void
get_entities_for_account (TplActionChain *chain, gpointer user_data)
{
  Ctx *ctx = user_data;

tpl_log_manager_get_entities_async (ctx->self->priv->log_manager, ctx->account,
      log_manager_got_entities_cb, ctx);
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/23243.html