Ejemplo n.º 1
0
static void
pidgin_notify_searchresults_new_rows(PurpleConnection *gc, PurpleNotifySearchResults *results,
									   void *data_)
{
	PidginNotifySearchResultsData *data = data_;
	GtkListStore *model = data->model;
	GtkTreeIter iter;
	GdkPixbuf *pixbuf;
	GList *row, *column;
	guint n;

	gtk_list_store_clear(data->model);

	pixbuf = pidgin_create_prpl_icon(purple_connection_get_account(gc), 0.5);

	for (row = results->rows; row != NULL; row = row->next) {

		gtk_list_store_append(model, &iter);
		gtk_list_store_set(model, &iter, 0, pixbuf, -1);

		n = 1;
		for (column = row->data; column != NULL; column = column->next) {
			GValue v;

			v.g_type = 0;
			g_value_init(&v, G_TYPE_STRING);
			g_value_set_string(&v, column->data);
			gtk_list_store_set_value(model, &iter, n, &v);
			n++;
		}
	}

	if (pixbuf != NULL)
		g_object_unref(pixbuf);
}
Ejemplo n.º 2
0
void
gevo_add_buddy_dialog_add_person(GevoAddBuddyDialog *dialog,
								 EContact *contact, const char *name,
								 PurpleAccount *account, const char *screenname)
{
	GdkPixbuf *pixbuf;
	GtkTreeIter iter;

	pixbuf = pidgin_create_prpl_icon(account, 0.5);

	gtk_list_store_append(dialog->model, &iter);

	gtk_list_store_set(dialog->model, &iter,
					   COLUMN_NAME, name,
					   COLUMN_PRPL_ICON, pixbuf,
					   COLUMN_DATA, contact,
					   COLUMN_USERNAME, screenname,
					   -1);

	if (contact != NULL)
		dialog->contacts = g_list_append(dialog->contacts, contact);

	if (pixbuf != NULL)
		g_object_unref(G_OBJECT(pixbuf));
}
Ejemplo n.º 3
0
static void
set_account(GtkListStore *store, GtkTreeIter *iter, PurpleAccount *account)
{
  GdkPixbuf *pixbuf;
  GdkPixbuf *scale;

  scale = NULL;

  pixbuf = pidgin_create_prpl_icon(account, 0.5);

  if (pixbuf != NULL)
  {
    scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);

    if (purple_account_is_disconnected(account))
      gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
  }

  gtk_list_store_set(store, iter,
    COLUMN_ICON, scale,
    COLUMN_SCREENNAME, purple_account_get_username(account),
    COLUMN_ENABLED, ap_account_has_profile_enabled(account),
    COLUMN_PROTOCOL, purple_account_get_protocol_name(account),
    COLUMN_DATA, account,
    -1);

  if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
  if (scale  != NULL) g_object_unref(G_OBJECT(scale));
}
Ejemplo n.º 4
0
void pidgin_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account) {
	struct log_viewer_hash_t *ht;
	PidginLogViewer *lv = NULL;
	const char *name = screenname;
	char *title;
	GdkPixbuf *prpl_icon;

	g_return_if_fail(account != NULL);
	g_return_if_fail(screenname != NULL);

	ht = g_new0(struct log_viewer_hash_t, 1);

	ht->type = type;
	ht->screenname = g_strdup(screenname);
	ht->account = account;

	if (log_viewers == NULL) {
		log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
	} else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
		gtk_window_present(GTK_WINDOW(lv->window));
		g_free(ht->screenname);
		g_free(ht);
		return;
	}

	if (type == PURPLE_LOG_CHAT) {
		PurpleChat *chat;

		chat = purple_blist_find_chat(account, screenname);
		if (chat != NULL)
			name = purple_chat_get_name(chat);

		title = g_strdup_printf(_("Conversations in %s"), name);
	} else {
		PurpleBuddy *buddy;

		buddy = purple_find_buddy(account, screenname);
		if (buddy != NULL)
			name = purple_buddy_get_contact_alias(buddy);

		title = g_strdup_printf(_("Conversations with %s"), name);
	}

	prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM);

	display_log_viewer(ht, purple_log_get_logs(type, screenname, account),
			title, gtk_image_new_from_pixbuf(prpl_icon),
			purple_log_get_total_size(type, screenname, account));

	if (prpl_icon)
		g_object_unref(prpl_icon);
	g_free(title);
}
static void
notify (const gchar *title,
		const gchar *body,
		PurpleBuddy *buddy,
		PurpleConversation *conv)
{
	NotifyNotification *notification = NULL;
	GdkPixbuf *icon;
	PurpleBuddyIcon *buddy_icon;
	gchar *tr_body;
	PurpleContact *contact;

	if (buddy)
		contact = purple_buddy_get_contact (buddy);
	else
		contact = NULL;

	if (body)
		tr_body = truncate_escape_string (body, 60);
	else
		tr_body = NULL;

	if (!conv && buddy)
		conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_ANY, buddy->name, buddy->account);

	if (conv && conv->ui_ops && conv->ui_ops->has_focus) {
	    if (conv->ui_ops->has_focus(conv) == TRUE) {
		/* do not notify if the conversation is currently in focus */
		return;
	    }
	}

	if (contact)
		notification = g_hash_table_lookup (buddy_hash, contact);
	else if (conv)
		notification = g_hash_table_lookup (buddy_hash, conv);
	else
		notification = NULL;

	if (notification != NULL) {
		notify_notification_update (notification, title, tr_body, NULL);
		notify_notification_set_timeout(notification, purple_prefs_get_int("/plugins/gtk/libnotify/timeout"));
		/* this shouldn't be necessary, file a bug */
		notify_notification_show (notification, NULL);

		purple_debug_info (PLUGIN_ID, "notify(), update: "
						 "title: '%s', body: '%s', buddy: '%s'\n",
						 title, tr_body, buddy ? best_name (buddy) : "");

		g_free (tr_body);
		return;
	}
#ifdef LIBNOTIFY_07
	notification = notify_notification_new (title, tr_body, NULL);
#else
	notification = notify_notification_new (title, tr_body, NULL, NULL);
#endif
	purple_debug_info (PLUGIN_ID, "notify(), new: "
					 "title: '%s', body: '%s', buddy: '%s'\n",
					 title, tr_body, buddy ? best_name (buddy) : "");

	g_free (tr_body);

	if (buddy)
		buddy_icon = purple_buddy_get_icon (buddy);
	else
		buddy_icon = NULL;

	if (buddy_icon) {
		icon = pixbuf_from_buddy_icon (buddy_icon);
		purple_debug_info (PLUGIN_ID, "notify(), has a buddy icon.\n");
	} else if (buddy) {
		icon = pidgin_create_prpl_icon (buddy->account, 1);
		purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n");
	} else if (conv) {
		icon = pidgin_create_prpl_icon (conv->account, 1);
		purple_debug_info (PLUGIN_ID, "notify(), has a prpl icon.\n");
	} else {
		icon = NULL;
		purple_debug_info (PLUGIN_ID, "notify(), has no icon.\n");
	}

	if (icon) {
		notify_notification_set_icon_from_pixbuf (notification, icon);
		g_object_unref (icon);
	} else {
		purple_debug_warning (PLUGIN_ID, "notify(), couldn't find any icon!\n");
	}

	if (contact)
		g_hash_table_insert (buddy_hash, contact, notification);
	else if (conv)
		g_hash_table_insert (buddy_hash, conv, notification);

	g_object_set_data (G_OBJECT(notification), "contact", contact);
	g_object_set_data (G_OBJECT(notification), "conv", conv);
	g_object_set_data (G_OBJECT(notification), "buddy", buddy);

	g_signal_connect (notification, "closed", G_CALLBACK(closed_cb), NULL);

	notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);

	notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);

	notify_notification_set_timeout(notification, purple_prefs_get_int("/plugins/gtk/libnotify/timeout"));
	if (!notify_notification_show (notification, NULL)) {
		purple_debug_error (PLUGIN_ID, "notify(), failed to send notification\n");
	}

}
Ejemplo n.º 6
0
void init_acct_features_dialog(struct acct_features_dialog *f_diag)
{
  GList *a = purple_accounts_get_all_active();
  /* TODO: should be freed ? */
  GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
                                          GTK_ICON_SIZE_MENU, NULL);
  GdkPixbuf *no  = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
                                          GTK_ICON_SIZE_MENU, NULL);

  /* last line summarize all available features */
  GtkTreeIter e_iter;
  GdkPixbuf *e_icon     = gtk_widget_render_icon(f_diag->window,
                                                 PIDGIN_STOCK_INFO,
                                                 GTK_ICON_SIZE_MENU,
                                                 NULL);
  GdkPixbuf *e_pm        = no;
  GdkPixbuf *e_buddyicon = no;
  GdkPixbuf *e_nickname  = no;
  GdkPixbuf *e_mood      = no;
  GdkPixbuf *e_moodmsg   = no;
  GdkPixbuf *e_game      = no;
  GdkPixbuf *e_app       = no;
  GdkPixbuf *e_tune      = no;

  for(; a ; a = a->next) {
    PurpleAccount *acct  = (PurpleAccount *)a->data;
    PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
    PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);

    GtkTreeIter iter;
    gchar *username = g_strdup_printf("%s (%s)",
                                           purple_account_get_username(acct),
                                           purple_account_get_protocol_name(acct));
    GdkPixbuf *a_icon = pidgin_create_prpl_icon(acct, PIDGIN_PRPL_ICON_MEDIUM);
    GHashTable *attrs  = get_account_attrs(acct);

    GdkPixbuf *nickname, *mood, *moodmsg, *game, *app, *tune, *pm, *buddyicon;

    if(g_hash_table_lookup(attrs, "mood"))
      e_mood = mood = yes;
    else
      mood = no;
    if(g_hash_table_lookup(attrs, "moodtext"))
      e_moodmsg = moodmsg = yes;
    else
      moodmsg = no;
    if(g_hash_table_lookup(attrs, "game"))
      e_game = game = yes;
    else
      game = no;
    if(g_hash_table_lookup(attrs, "office"))
      e_app = app = yes;
    else
      app = no;
    if((g_hash_table_lookup(attrs, "tune_title") &&
        g_hash_table_lookup(attrs, "tune_artist") &&
        g_hash_table_lookup(attrs, "tune_album")))
      e_tune = tune = yes;
    else
      tune = no;
    g_hash_table_destroy(attrs);

    if(protocol->set_status)
      e_pm = pm = yes;
    else
      pm = no;
    if(protocol->set_buddy_icon)
      e_buddyicon = buddyicon = yes;
    else
      buddyicon = no;
    /* exception for XMPP
       nickname supported
       manually
       FIXME: however some XMPP account don't support nickname extension */
    if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
      e_nickname = nickname = yes;
    else
      nickname = no;

    gtk_list_store_append(f_diag->list_store, &iter);
    gtk_list_store_set(f_diag->list_store, &iter,
                       ACCT_COLUMN, username,
                       ACCTICON_COLUMN, a_icon,
                       NICKNAME_COLUMN, nickname,
                       PM_COLUMN, pm,
                       ICON_COLUMN, buddyicon,
                       MOOD_COLUMN, mood,
                       MOODMSG_COLUMN, moodmsg,
                       TUNE_COLUMN, tune,
                       GAME_COLUMN, game,
                       APP_COLUMN, app,
                       -1);
    g_free(username);
  }

  /* last line summarize all available features */
  gtk_list_store_append(f_diag->list_store, &e_iter);
  gtk_list_store_set(f_diag->list_store, &e_iter,
                     ACCT_COLUMN, "Available features",
                     ACCTICON_COLUMN, e_icon,
                     NICKNAME_COLUMN, e_nickname,
                     PM_COLUMN, e_pm,
                     ICON_COLUMN, e_buddyicon,
                     MOOD_COLUMN, e_mood,
                     MOODMSG_COLUMN, e_moodmsg,
                     TUNE_COLUMN, e_tune,
                     GAME_COLUMN, e_game,
                     APP_COLUMN, e_app,
                     -1);
}
Ejemplo n.º 7
0
/* count == 0 means this is a detailed mail notification.
 * count > 0 mean non-detailed.
 */
static void *
pidgin_notify_add_mail(GtkTreeStore *treemodel, PurpleAccount *account, char *notification, const char *url, int count, gboolean clear, gboolean *new_data)
{
	PidginNotifyMailData *data = NULL;
	GtkTreeIter iter;
	GdkPixbuf *icon;
	gboolean new_n = TRUE;

	if (count > 0 || clear) {
		/* Allow only one non-detailed email notification for each account */
		if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(treemodel), &iter)) {
			gboolean advanced;
			do {
				advanced = FALSE;
				gtk_tree_model_get(GTK_TREE_MODEL(treemodel), &iter,
						PIDGIN_MAIL_DATA, &data, -1);
				if (data->account == account) {
					if (clear) {
#if GTK_CHECK_VERSION(2,2,0)
						advanced = gtk_tree_store_remove(treemodel, &iter);
#else
						gtk_tree_store_remove(treemodel, &iter);
						advanced = (iter.stamp == 0) ? FALSE : TRUE;
#endif
						purple_notify_close(PURPLE_NOTIFY_EMAILS, data);
						/* We're completely done if we've processed all entries */
						if (!advanced)
							return NULL;
					} else if (data->count > 0) {
						new_n = FALSE;
						g_free(data->url);
						data->url = NULL;
						mail_dialog->total_count -= data->count;
						break;
					}
				}
			} while (advanced || gtk_tree_model_iter_next(GTK_TREE_MODEL(treemodel), &iter));
		}
	}

	if (clear)
		return NULL;

	icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM);

	if (new_n) {
		data = g_new0(PidginNotifyMailData, 1);
		data->purple_has_handle = TRUE;
		gtk_tree_store_append(treemodel, &iter, NULL);
	}

	if (url != NULL)
		data->url = g_strdup(url);

	gtk_tree_store_set(treemodel, &iter,
								PIDGIN_MAIL_ICON, icon,
								PIDGIN_MAIL_TEXT, notification,
								PIDGIN_MAIL_DATA, data,
								-1);
	data->account = account;
	data->count = count;

	if (icon)
		g_object_unref(icon);

	if (new_data)
		*new_data = new_n;
	return data;
}
Ejemplo n.º 8
0
static void
add_ims(GevoAddBuddyDialog *dialog, EContact *contact, const char *name,
		GList *list, const char *id)
{
	PurpleAccount *account = NULL;
	GList *l;
	GtkTreeIter iter;
	GdkPixbuf *pixbuf;

	if (list == NULL)
		return;

	for (l = purple_connections_get_all(); l != NULL; l = l->next)
	{
		PurpleConnection *gc = (PurpleConnection *)l->data;

		account = purple_connection_get_account(gc);

		if (!strcmp(purple_account_get_protocol_id(account), id))
			break;

		account = NULL;
	}

	if (account == NULL)
		return;

	pixbuf = pidgin_create_prpl_icon(account, 0.5);

	for (l = list; l != NULL; l = l->next)
	{
		char *account_name = (char *)l->data;

		if (account_name == NULL)
			continue;

		if (purple_find_buddy(dialog->account, account_name) != NULL)
			continue;

		gtk_list_store_append(dialog->model, &iter);

		gtk_list_store_set(dialog->model, &iter,
						   COLUMN_NAME, name,
						   COLUMN_PRPL_ICON, pixbuf,
						   COLUMN_USERNAME, account_name,
						   COLUMN_DATA, contact,
						   -1);

		if (!strcmp(purple_account_get_protocol_id(account),
					purple_account_get_protocol_id(dialog->account)) &&
			dialog->username != NULL &&
			!strcmp(account_name, dialog->username))
		{
			GtkTreeSelection *selection;

			/* This is it. Select it. */
			selection = gtk_tree_view_get_selection(
				GTK_TREE_VIEW(dialog->treeview));

			gtk_tree_selection_select_iter(selection, &iter);
		}
	}

	if (pixbuf != NULL)
		g_object_unref(G_OBJECT(pixbuf));

	g_list_foreach(list, (GFunc)g_free, NULL);
	g_list_free(list);
}