static void
mex_telepathy_channel_on_contact_fetched (TpConnection     *connection,
                                          guint             n_contacts,
                                          TpContact *const *contacts,
                                          guint             n_failed,
                                          const TpHandle   *failed,
                                          const GError     *fetched_error,
                                          gpointer          user_data,
                                          GObject          *weak_object)
{
  MexTelepathyChannel *self = MEX_TELEPATHY_CHANNEL (user_data);

  int i = 0;

  if (self->priv->channel)
    {
      for (i = 0; i < n_contacts; ++i)
        {
          gchar *text;
          const gchar *alias;
          TpContact *current;
          GFile *file;

          // Get the contacts.
          current = contacts[i];

          // Connect to alias change signal.
          // Add the alias to the label.
          alias = tp_contact_get_alias (current);
          mx_label_set_text (MX_LABEL (self->priv->title_label),
                             alias);

          if (tp_channel_get_requested(self->priv->channel))
            text = g_strdup_printf ("Calling %s", alias);
          else
            text = g_strdup_printf ("Setting up call with %s", alias);
          mx_label_set_text (MX_LABEL (self->priv->busy_label), text);
          g_free (text);

          file = tp_contact_get_avatar_file (current);
          if (file)
            {
              gchar *filename = g_file_get_path (file);
              GError *error = NULL;
              MEX_DEBUG ("setting new avatar filename to %s", filename);
              mx_image_set_from_file (MX_IMAGE(self->priv->avatar_image),
                                      filename,
                                      &error);
              if (error)
                {
                  MEX_ERROR ("ERROR %s loading avatar from file %s\n",
                             error->message, filename);
                  g_clear_error (&error);
                }
              if (filename)
                g_free (filename);
            }
        }
    }
}
示例#2
0
文件: approver.c 项目: CaoMomo/core
static void
show_dialog (
    TpSimpleApprover *self,
    TpChannelDispatchOperation *cdo,
    TpContact *target)
{
    GFile *avatar_file = tp_contact_get_avatar_file (target);
    GtkWidget *dialog = gtk_message_dialog_new_with_markup (NULL,
        0, /* flags */
        GTK_MESSAGE_QUESTION,
        GTK_BUTTONS_NONE,
        "<b>%s</b> (<i>%s</i>) would like to edit a spreadsheet in LibreOffice "
        "with you.",
        tp_contact_get_alias (target),
        tp_contact_get_identifier (target));

    if (avatar_file != NULL)
    {
        GtkWidget *avatar = gtk_image_new_from_file (g_file_get_path (avatar_file));

        gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), avatar);
    }

    gtk_dialog_add_buttons (GTK_DIALOG (dialog),
        "_Reject", GTK_RESPONSE_REJECT,
        "_Accept", GTK_RESPONSE_ACCEPT,
        NULL);

    g_object_set_data_full (G_OBJECT (dialog), "client", g_object_ref (self), g_object_unref);
    g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), g_object_ref (cdo));

    gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);

    gtk_widget_show_all (dialog);
}