GdkPixbuf *
empathy_notify_manager_get_pixbuf_for_notification (EmpathyNotifyManager *self,
    EmpathyContact *contact,
    const char *icon_name)
{
  GdkPixbuf *pixbuf = NULL;

  if (contact != NULL)
    pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 48, 48);

  if (pixbuf == NULL)
    pixbuf = empathy_pixbuf_from_icon_name_sized (icon_name, 48);

  return pixbuf;
}
Пример #2
0
GdkPixbuf *
empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact,
					  const char *icon_name)
{
	GdkPixbuf *pixbuf = NULL;

	if (contact != NULL) {
		pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact,
								    48, 48);
	}

	if (!pixbuf) {
		pixbuf = empathy_pixbuf_from_icon_name_sized
					(icon_name, 48);
	}

	return pixbuf;
}
static void
empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
					 EmpathyContact   *contact)
{
	static guint block_signal = 0;
	EmpathyContactManager *manager;
	gboolean blocked, abusive;

	if (block_signal > 0)
		return;

	blocked = gtk_check_menu_item_get_active (item);

	if (blocked) {
		/* confirm the user really wishes to block the contact */
		GtkWidget *parent;
		GdkPixbuf *avatar;

		/* gtk_menu_get_attach_widget () doesn't behave properly here
		 * for some reason */
		parent = g_object_get_data (
			G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (item))),
			"window");

		avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 48, 48);

		if (!empathy_block_contact_dialog_show (GTK_WINDOW (parent),
					contact, avatar, &abusive))
			return;
	}

	manager = empathy_contact_manager_dup_singleton ();
	empathy_contact_list_set_blocked (EMPATHY_CONTACT_LIST (manager),
					  contact, blocked, abusive);
	g_object_unref (manager);

	/* update the toggle with the blocked status */
	block_signal++;
	gtk_check_menu_item_set_active (item, blocked);
	block_signal--;
}
Пример #4
0
static GdkPixbuf *
theme_boxes_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
{
	AvatarData        *data;
	EmpathyAvatar     *avatar;
	GdkPixbuf         *tmp_pixbuf;
	GdkPixbuf         *pixbuf = NULL;

	/* Check if avatar is in cache and if it's up to date */
	avatar = empathy_contact_get_avatar (contact);
	data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache");
	if (data) {
		if (avatar && !tp_strdiff (avatar->filename, data->filename)) {
			/* We have the avatar in cache */
			return data->pixbuf;
		}
	}

	/* Avatar not in cache, create pixbuf */
	tmp_pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
	if (tmp_pixbuf) {
		pixbuf = theme_boxes_pad_to_size (tmp_pixbuf, 32, 32, 6);
		g_object_unref (tmp_pixbuf);
	}
	if (!pixbuf) {
		return NULL;
	}

	/* Insert new pixbuf in cache. We store the filename as it's unique
	 * for each version of an avatar, so we can use it to perform change
	 * detection (as above). */
	data = g_slice_new0 (AvatarData);
	data->filename = g_strdup (avatar->filename);
	data->pixbuf = pixbuf;

	g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache",
				data, theme_boxes_avatar_cache_data_free);

	return data->pixbuf;
}
Пример #5
0
GdkPixbuf *
empathy_misc_get_pixbuf_for_indicator (EmpathyContact *contact)
{
	GdkPixbuf *pixbuf = NULL;
	GtkIconTheme *icon_theme;

	if (contact != NULL) {
		pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact,
								    16, 16);
	}

	if (!pixbuf) {
		icon_theme = gtk_icon_theme_get_default ();
		/* TODO: connect to icon theme changes */
		if (icon_theme) {
		pixbuf = gtk_icon_theme_load_icon (icon_theme, "stock_person",
				16, 0, NULL);
		}
	}

	return pixbuf;
}
Пример #6
0
static GdkPixbuf *
theme_boxes_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
{
	AvatarData        *data;
	EmpathyAvatar     *avatar;
	GdkPixbuf         *tmp_pixbuf;
	GdkPixbuf         *pixbuf = NULL;

	/* Check if avatar is in cache and if it's up to date */
	avatar = empathy_contact_get_avatar (contact);
	data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache");
	if (data) {
		if (avatar && !tp_strdiff (avatar->token, data->token)) {
			/* We have the avatar in cache */
			return data->pixbuf;
		}
	}

	/* Avatar not in cache, create pixbuf */
	tmp_pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
	if (tmp_pixbuf) {
		pixbuf = theme_boxes_pad_to_size (tmp_pixbuf, 32, 32, 6);
		g_object_unref (tmp_pixbuf);
	}
	if (!pixbuf) {
		return NULL;
	}

	/* Insert new pixbuf in cache */
	data = g_slice_new0 (AvatarData);
	data->token = g_strdup (avatar->token);
	data->pixbuf = pixbuf;

	g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache",
				data, theme_boxes_avatar_cache_data_free);

	return data->pixbuf;
}
static void
update_persona (EmpathyPersonaStore *self,
    FolksPersona *persona)
{
  EmpathyPersonaStorePriv *priv = GET_PRIV (self);
  GtkTreePath *path;
  gboolean do_set_active = FALSE;
  gboolean do_set_refresh = FALSE;
  const gchar *alias;

  path = find_persona (self, persona);
  alias = folks_aliasable_get_alias (FOLKS_ALIASABLE (persona));

  if (path == NULL)
    {
      DEBUG ("Contact:'%s' in list:NO, should be:YES", alias);

      add_persona (self, persona);

      if (priv->show_active)
        {
          do_set_active = TRUE;
          DEBUG ("Set active (contact added)");
        }
    }
  else
    {
      FolksPersonaStore *store;
      EmpathyContact *contact;
      GtkTreeIter iter;
      GdkPixbuf *pixbuf_avatar;
      GdkPixbuf *pixbuf_status;
      gboolean now_online = FALSE;
      gboolean was_online = TRUE;

      DEBUG ("Contact:'%s' in list:YES, should be:YES", alias);

      gtk_tree_model_get_iter (GTK_TREE_MODEL (self), &iter, path);
      gtk_tree_path_free (path);

      /* Get online state now. */
      now_online = folks_presence_is_online (FOLKS_PRESENCE (persona));

      /* Get online state before. */
      gtk_tree_model_get (GTK_TREE_MODEL (self), &iter,
          EMPATHY_PERSONA_STORE_COL_IS_ONLINE, &was_online,
          -1);

      /* Is this really an update or an online/offline. */
      if (priv->show_active)
        {
          if (was_online != now_online)
            {
              do_set_active = TRUE;
              do_set_refresh = TRUE;

              DEBUG ("Set active (contact updated %s)",
                  was_online ? "online  -> offline" : "offline -> online");
            }
          else
            {
              /* Was TRUE for presence updates. */
              /* do_set_active = FALSE;  */
              do_set_refresh = TRUE;
              DEBUG ("Set active (contact updated)");
            }
        }

      /* We still need to use EmpathyContact for the capabilities stuff */
      contact = empathy_contact_dup_from_tp_contact (tpf_persona_get_contact (
          TPF_PERSONA (persona)));
      store = folks_persona_get_store (persona);

      pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
          32, 32);
      pixbuf_status = get_persona_status_icon (self, persona);

      gtk_list_store_set (GTK_LIST_STORE (self), &iter,
          EMPATHY_PERSONA_STORE_COL_ICON_STATUS, pixbuf_status,
          EMPATHY_PERSONA_STORE_COL_PIXBUF_AVATAR, pixbuf_avatar,
          EMPATHY_PERSONA_STORE_COL_PIXBUF_AVATAR_VISIBLE, priv->show_avatars,
          EMPATHY_PERSONA_STORE_COL_NAME, alias,
          EMPATHY_PERSONA_STORE_COL_ACCOUNT_NAME,
              folks_persona_store_get_display_name (store),
          EMPATHY_PERSONA_STORE_COL_DISPLAY_ID,
              folks_persona_get_display_id (persona),
          EMPATHY_PERSONA_STORE_COL_PRESENCE_TYPE,
              folks_presence_get_presence_type (FOLKS_PRESENCE (persona)),
          EMPATHY_PERSONA_STORE_COL_STATUS,
              folks_presence_get_presence_message (FOLKS_PRESENCE (persona)),
          EMPATHY_PERSONA_STORE_COL_IS_ONLINE, now_online,
          EMPATHY_PERSONA_STORE_COL_CAN_AUDIO_CALL,
              empathy_contact_get_capabilities (contact) &
                EMPATHY_CAPABILITIES_AUDIO,
          EMPATHY_PERSONA_STORE_COL_CAN_VIDEO_CALL,
              empathy_contact_get_capabilities (contact) &
                EMPATHY_CAPABILITIES_VIDEO,
          -1);

      g_object_unref (contact);

      if (pixbuf_avatar)
        g_object_unref (pixbuf_avatar);
    }

  if (priv->show_active && do_set_active)
    {
      persona_set_active (self, persona, do_set_active, do_set_refresh);

      if (do_set_active)
        {
          ShowActiveData *data;

          data = persona_active_new (self, persona, FALSE);
          data->timeout = g_timeout_add_seconds (ACTIVE_USER_SHOW_TIME,
              (GSourceFunc) persona_active_cb,
              data);
        }
    }

  /* FIXME: when someone goes online then offline quickly, the
   * first timeout sets the user to be inactive and the second
   * timeout removes the user from the contact list, really we
   * should remove the first timeout.
   */
}
Пример #8
0
static void
contact_list_store_contact_update (EmpathyContactListStore *store,
				   EmpathyContact          *contact)
{
	EmpathyContactListStorePriv *priv;
	ShowActiveData             *data;
	GtkTreeModel               *model;
	GList                      *iters, *l;
	gboolean                    in_list;
	gboolean                    should_be_in_list;
	gboolean                    was_online = TRUE;
	gboolean                    now_online = FALSE;
	gboolean                    set_model = FALSE;
	gboolean                    do_remove = FALSE;
	gboolean                    do_set_active = FALSE;
	gboolean                    do_set_refresh = FALSE;
	gboolean                    show_avatar = FALSE;
	GdkPixbuf                  *pixbuf_avatar;

	priv = GET_PRIV (store);

	model = GTK_TREE_MODEL (store);

	iters = contact_list_store_find_contact (store, contact);
	if (!iters) {
		in_list = FALSE;
	} else {
		in_list = TRUE;
	}

	/* Get online state now. */
	now_online = empathy_contact_is_online (contact);

	if (priv->show_offline || now_online) {
		should_be_in_list = TRUE;
	} else {
		should_be_in_list = FALSE;
	}

	if (!in_list && !should_be_in_list) {
		/* Nothing to do. */
		DEBUG ("Contact:'%s' in list:NO, should be:NO",
			empathy_contact_get_name (contact));

		g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
		g_list_free (iters);
		return;
	}
	else if (in_list && !should_be_in_list) {
		DEBUG ("Contact:'%s' in list:YES, should be:NO",
			empathy_contact_get_name (contact));

		if (priv->show_active) {
			do_remove = TRUE;
			do_set_active = TRUE;
			do_set_refresh = TRUE;

			set_model = TRUE;
			DEBUG ("Remove item (after timeout)");
		} else {
			DEBUG ("Remove item (now)!");
			contact_list_store_remove_contact (store, contact);
		}
	}
	else if (!in_list && should_be_in_list) {
		DEBUG ("Contact:'%s' in list:NO, should be:YES",
			empathy_contact_get_name (contact));

		contact_list_store_add_contact (store, contact);

		if (priv->show_active) {
			do_set_active = TRUE;

			DEBUG ("Set active (contact added)");
		}
	} else {
		DEBUG ("Contact:'%s' in list:YES, should be:YES",
			empathy_contact_get_name (contact));

		/* Get online state before. */
		if (iters && g_list_length (iters) > 0) {
			gtk_tree_model_get (model, iters->data,
					    EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, &was_online,
					    -1);
		}

		/* Is this really an update or an online/offline. */
		if (priv->show_active) {
			if (was_online != now_online) {
				do_set_active = TRUE;
				do_set_refresh = TRUE;

				DEBUG ("Set active (contact updated %s)",
					was_online ? "online  -> offline" :
					"offline -> online");
			} else {
				/* Was TRUE for presence updates. */
				/* do_set_active = FALSE;  */
				do_set_refresh = TRUE;

				DEBUG ("Set active (contact updated)");
			}
		}

		set_model = TRUE;
	}

	if (priv->show_avatars && !priv->is_compact) {
		show_avatar = TRUE;
	}
	pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
	for (l = iters; l && set_model; l = l->next) {
		gtk_tree_store_set (GTK_TREE_STORE (store), l->data,
				    EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, empathy_icon_name_for_contact (contact),
				    EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, pixbuf_avatar,
				    EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
				    EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact),
				    EMPATHY_CONTACT_LIST_STORE_COL_STATUS, empathy_contact_get_status (contact),
				    EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, !priv->is_compact,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, now_online,
				    EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE,
				    EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL,
				      empathy_contact_get_capabilities (contact) &
				        EMPATHY_CAPABILITIES_AUDIO,
				    EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL,
				      empathy_contact_get_capabilities (contact) &
				        EMPATHY_CAPABILITIES_VIDEO,
				    -1);
	}

	if (pixbuf_avatar) {
		g_object_unref (pixbuf_avatar);
	}

	if (priv->show_active && do_set_active) {
		contact_list_store_contact_set_active (store, contact, do_set_active, do_set_refresh);

		if (do_set_active) {
			data = contact_list_store_contact_active_new (store, contact, do_remove);
			g_timeout_add_seconds (ACTIVE_USER_SHOW_TIME,
					       (GSourceFunc) contact_list_store_contact_active_cb,
					       data);
		}
	}

	/* FIXME: when someone goes online then offline quickly, the
	 * first timeout sets the user to be inactive and the second
	 * timeout removes the user from the contact list, really we
	 * should remove the first timeout.
	 */
	g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
	g_list_free (iters);
}