From: David Woodhouse Date: Wed, 25 Apr 2018 14:36:34 +0000 (+0100) Subject: Close Joinable Meetings dialog when there are none left X-Git-Tag: v0.9~12 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=542a5b5dad8c4879bd608368e200a97a285c63ed;p=pidgin-chime.git Close Joinable Meetings dialog when there are none left In fact, we should probably do this when we *join* the only meeting too. --- diff --git a/prpl/meeting.c b/prpl/meeting.c index a04d03a..ad19a93 100644 --- a/prpl/meeting.c +++ b/prpl/meeting.c @@ -372,13 +372,30 @@ static gboolean update_joinable(gpointer _conn) return FALSE; } +static void count_mtg(ChimeConnection *cxn, ChimeMeeting *mtg, gpointer _count) +{ + int *count = _count; + + (*count)++; +} static void on_joinable_changed(ChimeMeeting *mtg, GParamSpec *ignored, PurpleConnection *conn) { struct purple_chime *pc = purple_connection_get_protocol_data(conn); - if (pc->joinable_handle && !pc->joinable_refresh_id) - pc->joinable_refresh_id = g_idle_add(update_joinable, conn); + if (pc->joinable_handle) { + int count = 0; + + chime_connection_foreach_meeting(PURPLE_CHIME_CXN(conn), count_mtg, &count); + if (!count) { + if (pc->joinable_refresh_id) + g_source_remove(pc->joinable_refresh_id); + pc->joinable_refresh_id = 0; + purple_notify_close(PURPLE_NOTIFY_SEARCHRESULTS, pc->joinable_handle); + pc->joinable_handle = NULL; + } else if (!pc->joinable_refresh_id) + pc->joinable_refresh_id = g_idle_add(update_joinable, conn); + } } static void unsub_mtg(ChimeConnection *cxn, ChimeMeeting *mtg, gpointer _conn)