# HG changeset patch
# Node ID d377b39ae4bb8cd5185f1fc2ba6379800345988c
# Parent  5b5a883528e0bc7c56c602f1d497325f97c31893
diff --git a/libpurple/purpleaccountmanager.c b/libpurple/purpleaccountmanager.c
--- a/libpurple/purpleaccountmanager.c
+++ b/libpurple/purpleaccountmanager.c
@@ -500,6 +500,7 @@
 
 	g_signal_emit(manager, signals[SIG_ADDED], 0, account);
 	g_list_model_items_changed(G_LIST_MODEL(manager), 0, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	if(manager->online && purple_account_get_enabled(account)) {
 		purple_account_connect(account);
@@ -518,6 +519,7 @@
 	if(g_ptr_array_find(manager->accounts, account, &index)) {
 		g_ptr_array_steal_index(manager->accounts, index);
 		g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 	}
 
 	/* Disconnect all the signals we added for the account. */
@@ -618,6 +620,7 @@
 	if(g_ptr_array_find(manager->accounts, account, &index)) {
 		g_ptr_array_steal_index(manager->accounts, index);
 		g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 		/* If new_index is greater than the current index, we need to
 		 * decrement new_index by 1 to account for the move as we'll be
@@ -636,6 +639,7 @@
 	/* Insert the account into its new position. */
 	g_ptr_array_insert(manager->accounts, new_index, account);
 	g_list_model_items_changed(G_LIST_MODEL(manager), new_index, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	purple_accounts_schedule_save();
 }
diff --git a/libpurple/purplebadges.c b/libpurple/purplebadges.c
--- a/libpurple/purplebadges.c
+++ b/libpurple/purplebadges.c
@@ -201,6 +201,7 @@
 	g_ptr_array_sort_values(badges->badges, purple_badges_compare);
 
 	g_list_model_items_changed(G_LIST_MODEL(badges), 0, len, len + 1);
+	g_object_notify_by_pspec(G_OBJECT(badges), properties[PROP_N_ITEMS]);
 
 	return TRUE;
 }
@@ -228,6 +229,7 @@
 	g_ptr_array_remove_index(badges->badges, index);
 
 	g_list_model_items_changed(G_LIST_MODEL(badges), index, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(badges), properties[PROP_N_ITEMS]);
 
 	return TRUE;
 }
diff --git a/libpurple/purplecontactmanager.c b/libpurple/purplecontactmanager.c
--- a/libpurple/purplecontactmanager.c
+++ b/libpurple/purplecontactmanager.c
@@ -693,6 +693,7 @@
 	g_ptr_array_add(manager->people, g_object_ref(person));
 	g_list_model_items_changed(G_LIST_MODEL(manager), manager->people->len - 1,
 	                           0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 	g_signal_emit(manager, signals[SIG_PERSON_ADDED], 0, person);
 }
 
@@ -733,6 +734,7 @@
 	g_ptr_array_remove_index(manager->people, index);
 
 	g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	/* Emit the removed signal and clear our temporary reference. */
 	g_signal_emit(manager, signals[SIG_PERSON_REMOVED], 0, person);
diff --git a/libpurple/purpleconversationmanager.c b/libpurple/purpleconversationmanager.c
--- a/libpurple/purpleconversationmanager.c
+++ b/libpurple/purpleconversationmanager.c
@@ -441,6 +441,7 @@
 	/* Tell everyone about the new conversation. */
 	g_signal_emit(manager, signals[SIG_ADDED], 0, conversation);
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	return TRUE;
 }
@@ -568,6 +569,7 @@
 	/* Tell everyone about the removed conversation. */
 	g_signal_emit(manager, signals[SIG_REMOVED], 0, conversation);
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	g_object_unref(conversation);
 
diff --git a/libpurple/purpleconversationmembers.c b/libpurple/purpleconversationmembers.c
--- a/libpurple/purpleconversationmembers.c
+++ b/libpurple/purpleconversationmembers.c
@@ -325,6 +325,7 @@
 	              message);
 	g_list_model_items_changed(G_LIST_MODEL(members),
 	                           members->members->len - 1, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(members), properties[PROP_N_ITEMS]);
 
 	return member;
 }
@@ -400,6 +401,7 @@
 	g_signal_emit(members, signals[SIG_MEMBER_REMOVED], 0, member,
 	              announce, message);
 	g_list_model_items_changed(G_LIST_MODEL(members), position, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(members), properties[PROP_N_ITEMS]);
 
 	g_clear_object(&member);
 
diff --git a/libpurple/purplecredentialmanager.c b/libpurple/purplecredentialmanager.c
--- a/libpurple/purplecredentialmanager.c
+++ b/libpurple/purplecredentialmanager.c
@@ -488,6 +488,7 @@
 
 	g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, provider);
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	/* If we don't currently have an active provider, check if the newly
 	 * registered provider has the id of the stored provider in preferences.
@@ -747,6 +748,7 @@
 
 		g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, provider);
 		g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 		g_object_unref(provider);
 
diff --git a/libpurple/purplefiletransfermanager.c b/libpurple/purplefiletransfermanager.c
--- a/libpurple/purplefiletransfermanager.c
+++ b/libpurple/purplefiletransfermanager.c
@@ -301,6 +301,7 @@
 	                        manager, 0);
 
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	g_signal_emit(manager, signals[SIG_ADDED], 0, transfer);
 }
@@ -328,6 +329,7 @@
 	g_ptr_array_remove_index(manager->transfers, position);
 
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 	g_signal_emit(manager, signals[SIG_REMOVED], 0, transfer);
 
 	g_object_unref(transfer);
diff --git a/libpurple/purplehistorymanager.c b/libpurple/purplehistorymanager.c
--- a/libpurple/purplehistorymanager.c
+++ b/libpurple/purplehistorymanager.c
@@ -305,6 +305,7 @@
 
 	g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, adapter);
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	return TRUE;
 }
@@ -335,8 +336,10 @@
 	existing = purple_history_manager_find_with_id(manager, id, &position);
 	if(PURPLE_IS_HISTORY_ADAPTER(existing)) {
 		g_ptr_array_remove_index(manager->adapters, position);
+
 		g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, adapter);
 		g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 		ret = TRUE;
 	} else {
diff --git a/libpurple/purplemessages.c b/libpurple/purplemessages.c
--- a/libpurple/purplemessages.c
+++ b/libpurple/purplemessages.c
@@ -68,11 +68,14 @@
  * Callbacks
  *****************************************************************************/
 static void
-purple_messages_items_changed_cb(G_GNUC_UNUSED GListModel *model,
-                                 guint position, guint removed, guint added,
-                                 gpointer data)
+purple_messages_items_changed_cb(GListModel *model, guint position,
+                                 guint removed, guint added, gpointer data)
 {
 	g_list_model_items_changed(data, position, removed, added);
+
+	if(removed > 0 || added > 0) {
+		g_object_notify_by_pspec(G_OBJECT(model), properties[PROP_N_ITEMS]);
+	}
 }
 
 /******************************************************************************
diff --git a/libpurple/purplenotificationmanager.c b/libpurple/purplenotificationmanager.c
--- a/libpurple/purplenotificationmanager.c
+++ b/libpurple/purplenotificationmanager.c
@@ -412,6 +412,7 @@
 
 	g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, notification);
 	g_list_model_items_changed(G_LIST_MODEL(manager), 0, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 }
 
 void
@@ -447,6 +448,7 @@
 
 		g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, notification);
 		g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 		g_object_unref(notification);
 	}
@@ -535,6 +537,8 @@
 				/* Remove the run of items from the list. */
 				g_ptr_array_remove_range(manager->notifications, start, count);
 				g_list_model_items_changed(model, start, count, 0);
+				g_object_notify_by_pspec(G_OBJECT(manager),
+				                         properties[PROP_N_ITEMS]);
 
 				/* Adjust pos and len for the items that we removed. */
 				pos = pos - count;
@@ -549,6 +553,7 @@
 	if(have_same) {
 		g_ptr_array_remove_range(manager->notifications, start, count);
 		g_list_model_items_changed(model, start, count, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 	}
 }
 
@@ -578,4 +583,5 @@
 	g_ptr_array_remove_range(manager->notifications, 0, count);
 
 	g_list_model_items_changed(G_LIST_MODEL(manager), 0, count, 0);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 }
diff --git a/libpurple/purpleperson.c b/libpurple/purpleperson.c
--- a/libpurple/purpleperson.c
+++ b/libpurple/purpleperson.c
@@ -104,6 +104,7 @@
 
 	/* Tell the list we update our stuff. */
 	g_list_model_items_changed(G_LIST_MODEL(person), 0, n_items, n_items);
+	g_object_notify_by_pspec(G_OBJECT(person), properties[PROP_N_ITEMS]);
 
 	/* See if the priority contact changed. */
 	new_priority = g_ptr_array_index(person->contacts, 0);
diff --git a/libpurple/purplepresencemanager.c b/libpurple/purplepresencemanager.c
--- a/libpurple/purplepresencemanager.c
+++ b/libpurple/purplepresencemanager.c
@@ -162,6 +162,7 @@
 	g_signal_emit(manager, signals[SIG_ADDED], 0, presence);
 	g_list_model_items_changed(G_LIST_MODEL(manager),
 	                           manager->presences->len - 1, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	return presence;
 }
@@ -661,6 +662,7 @@
 
 	g_signal_emit(manager, signals[SIG_REMOVED], 0, presence);
 	g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	/* Unref the presence as we are now done with it. */
 	g_object_unref(presence);
diff --git a/libpurple/purpleprotocolmanager.c b/libpurple/purpleprotocolmanager.c
--- a/libpurple/purpleprotocolmanager.c
+++ b/libpurple/purpleprotocolmanager.c
@@ -279,6 +279,7 @@
 
 	g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, protocol);
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	return TRUE;
 }
@@ -322,6 +323,7 @@
 
 		g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, protocol);
 		g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0);
+		g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 		ret = TRUE;
 	} else {
diff --git a/libpurple/purplewhiteboardmanager.c b/libpurple/purplewhiteboardmanager.c
--- a/libpurple/purplewhiteboardmanager.c
+++ b/libpurple/purplewhiteboardmanager.c
@@ -267,6 +267,7 @@
 
 	g_signal_emit(manager, signals[SIG_ADDED], 0, whiteboard);
 	g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	return TRUE;
 }
@@ -302,6 +303,7 @@
 
 	g_signal_emit(manager, signals[SIG_REMOVED], 0, whiteboard);
 	g_list_model_items_changed(G_LIST_MODEL(manager), index, 1, 0);
+	g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]);
 
 	g_object_unref(whiteboard);
 
diff --git a/libpurple/request/purplerequestgroup.c b/libpurple/request/purplerequestgroup.c
--- a/libpurple/request/purplerequestgroup.c
+++ b/libpurple/request/purplerequestgroup.c
@@ -268,6 +268,7 @@
 	                 G_CALLBACK(purple_request_group_notify_field_cb), group);
 
 	g_list_model_items_changed(G_LIST_MODEL(group), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(group), properties[PROP_N_ITEMS]);
 }
 
 const char *
diff --git a/libpurple/request/purplerequestpage.c b/libpurple/request/purplerequestpage.c
--- a/libpurple/request/purplerequestpage.c
+++ b/libpurple/request/purplerequestpage.c
@@ -256,6 +256,7 @@
 	                 G_CALLBACK(purple_request_page_items_changed_cb), page);
 
 	g_list_model_items_changed(G_LIST_MODEL(page), position, 0, 1);
+	g_object_notify_by_pspec(G_OBJECT(page), properties[PROP_N_ITEMS]);
 }
 
 gboolean
