Esempio n. 1
0
static void
test_cb(GntWidget *button, gpointer null)
{
	PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events)));
	FinchSoundEvent * event = &sounds[id];
	char *enabled, *file, *tmpfile, *volpref;
	gboolean temp_value;
	int volume;

	enabled = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",
			finch_sound_get_active_profile(), event->pref);
	file = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",
			finch_sound_get_active_profile(), event->pref);
	volpref = g_strdup(make_pref("/volume"));

	temp_value = purple_prefs_get_bool(enabled);
	tmpfile = g_strdup(purple_prefs_get_path(file));
	volume = purple_prefs_get_int(volpref);

	purple_prefs_set_path(file, event->file);
	if (!temp_value) purple_prefs_set_bool(enabled, TRUE);
	purple_prefs_set_int(volpref, gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume)));

	purple_sound_play_event(id, NULL);

	if (!temp_value) purple_prefs_set_bool(enabled, FALSE);
	purple_prefs_set_path(file, tmpfile);
	purple_prefs_set_int(volpref, volume);

	g_free(enabled);
	g_free(file);
	g_free(tmpfile);
	g_free(volpref);
}
Esempio n. 2
0
static gboolean
check_timeout(gpointer data)
{
	gint count = check_mail();
	PurpleBuddyList *list = purple_get_blist();

	if (count == -1)
		return FALSE;

	if (!list || !PURPLE_IS_GTK_BLIST(list) || !(PIDGIN_BLIST(list)->vbox))
		return TRUE;

	if (!mail) {
		/* guess we better build it then :P */
		GtkWidget *vbox = PIDGIN_BLIST(list)->vbox;

		mail = gtk_label_new("No mail messages.");
		gtk_box_pack_start(GTK_BOX(vbox), mail, FALSE, FALSE, 0);
		gtk_box_reorder_child(GTK_BOX(vbox), mail, 1);
		g_signal_connect(G_OBJECT(mail), "destroy", G_CALLBACK(destroy_cb), NULL);
		gtk_widget_show(mail);
	}

	if (count & NEW_MAIL)
		purple_sound_play_event(PURPLE_SOUND_POUNCE_DEFAULT, NULL);

	if (count & UNREAD_MAIL)
		gtk_label_set_text(GTK_LABEL(mail), "You have new mail!");
	else if (count & ANY_MAIL)
		gtk_label_set_text(GTK_LABEL(mail), "You have mail.");
	else
		gtk_label_set_text(GTK_LABEL(mail), "No mail messages.");

	return TRUE;
}
Esempio n. 3
0
static void
im_msg_received_cb(PurpleAccount *account, char *sender,
				   char *message, PurpleConversation *conv,
				   PurpleMessageFlags flags, PurpleSoundEventID event)
{
	if (flags & PURPLE_MESSAGE_DELAYED || flags & PURPLE_MESSAGE_NOTIFY)
		return;

	if (conv==NULL)
		purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account);
	else
		play_conv_event(conv, event);
}
Esempio n. 4
0
static void
playsound(gchar **str, gint which)
{
    GMatchInfo *match_info;
    const gchar *list = NULL;
    gchar **candidates = NULL, **candidate = NULL;

    list = purple_prefs_get_string(which ? OPT_USERLIST_SENDER :
                                   OPT_USERLIST_RECIPIENT);
    g_return_if_fail(list != NULL);
    if(strstr(list, DEFAULT_LIST))
        return;

    candidates = g_strsplit_set(list, " ,:;", 0);
    g_return_if_fail(candidates != NULL);

    g_regex_match(regp[which], *str, 0, &match_info);
    while(g_match_info_matches(match_info)) {
        gchar *user = NULL;
        if(which == RECIPIENT)
            user = g_match_info_fetch(match_info, 2);
        else if(which == SENDER)
            user = g_match_info_fetch(match_info, 2);
        twitter_debug("user = %s\n", user);

        for(candidate = candidates; *candidate; candidate++) {
            if(!strcmp(*candidate, ""))
                continue;
            twitter_debug("candidate = %s\n", *candidate);
            if(!strcmp(user, *candidate)) {
                twitter_debug("match. play sound\n");
                purple_sound_play_event(purple_prefs_get_int
                                        (which ? OPT_SOUNDID_SENDER :
                                         OPT_SOUNDID_RECIPIENT), NULL);
                break;
            }
        }
        g_free(user);
        g_match_info_next(match_info, NULL);
    }
    g_strfreev(candidates);
    g_match_info_free(match_info);
}
Esempio n. 5
0
/*
 * play a sound event for a conversation, honoring make_sound flag
 * of conversation and checking for focus if conv_focus pref is set
 */
static void
play_conv_event(PurpleConversation *conv, PurpleSoundEventID event)
{
	/* If we should not play the sound for some reason, then exit early */
	if (conv != NULL && PIDGIN_IS_PIDGIN_CONVERSATION(conv))
	{
		PidginConversation *gtkconv;
		gboolean has_focus;

		gtkconv = PIDGIN_CONVERSATION(conv);
		has_focus = purple_conversation_has_focus(conv);

		if (!gtkconv->make_sound ||
			(has_focus && !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus")))
		{
			return;
		}
	}

	purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL);
}
Esempio n. 6
0
/*
 * play a sound event for a conversation, honoring make_sound flag
 * of conversation and checking for focus if conv_focus pref is set
 */
static void
play_conv_event(PurpleConversation *conv, PurpleSoundEventID event)
{
	/* If we should not play the sound for some reason, then exit early */
	if (conv != NULL)
	{
		FinchConv *gntconv;
		gboolean has_focus;

		gntconv = FINCH_CONV(conv);

		has_focus = purple_conversation_has_focus(conv);

		if ((gntconv->flags & FINCH_CONV_NO_SOUND) ||
			(has_focus && !purple_prefs_get_bool(make_pref("/conv_focus"))))
		{
			return;
		}
	}

	purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL);
}
Esempio n. 7
0
static void
buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event)
{
	purple_sound_play_event(event, purple_buddy_get_account(buddy));
}