# HG changeset patch
# Node ID 8f40c6a02654
# Parent  6ceeda5ef4aa
diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -377,9 +377,9 @@ request_fields_cb(GntWidget *button, Pur
 
 	purple_notify_close_with_handle(button);
 
-	if (!g_object_get_data(G_OBJECT(button), "cancellation-function") &&
-			(!purple_request_page_all_required_filled(page) ||
-			!purple_request_page_is_valid(page))) {
+	if(!g_object_get_data(G_OBJECT(button), "cancellation-function") &&
+	   !purple_request_page_is_valid(page))
+	{
 		purple_notify_error(button, _("Error"),
 			_("You must properly fill all the required fields."),
 			_("The required fields are underlined."), NULL);
diff --git a/libpurple/protocols/demo/purpledemoprotocolactions.c b/libpurple/protocols/demo/purpledemoprotocolactions.c
--- a/libpurple/protocols/demo/purpledemoprotocolactions.c
+++ b/libpurple/protocols/demo/purpledemoprotocolactions.c
@@ -486,6 +486,7 @@ purple_demo_protocol_request_fields_acti
 
 	field = purple_request_field_string_new("string", _("A string"),
 	                                        _("default"), FALSE);
+	purple_request_field_set_required(field, TRUE);
 	purple_request_group_add_field(group, field);
 	field = purple_request_field_string_new("multiline-string",
 	                                        _("A multiline string"),
diff --git a/libpurple/purpleprivate.h b/libpurple/purpleprivate.h
--- a/libpurple/purpleprivate.h
+++ b/libpurple/purpleprivate.h
@@ -339,9 +339,7 @@ void purple_whiteboard_manager_shutdown(
 G_GNUC_INTERNAL void purple_account_set_enabled_plain(PurpleAccount *account, gboolean enabled);
 
 G_GNUC_INTERNAL void _purple_request_page_add_field(PurpleRequestPage *fields, PurpleRequestField *field);
-G_GNUC_INTERNAL void _purple_request_page_set_field_required(PurpleRequestPage *fields, PurpleRequestField *field, gboolean required);
 G_GNUC_INTERNAL void _purple_request_group_set_page(PurpleRequestGroup *group, PurpleRequestPage *fields);
-G_GNUC_INTERNAL void _purple_request_group_set_field_required(PurpleRequestGroup *group, PurpleRequestField *field, gboolean required);
 G_GNUC_INTERNAL void _purple_request_field_set_group(PurpleRequestField *field, PurpleRequestGroup *group);
 
 G_END_DECLS
diff --git a/libpurple/purplerequestfield.c b/libpurple/purplerequestfield.c
--- a/libpurple/purplerequestfield.c
+++ b/libpurple/purplerequestfield.c
@@ -403,11 +403,6 @@ purple_request_field_set_required(Purple
 
 	priv->required = required;
 
-	if(PURPLE_IS_REQUEST_GROUP(priv->group)) {
-		_purple_request_group_set_field_required(priv->group, field,
-		                                         required);
-	}
-
 	g_object_freeze_notify(G_OBJECT(field));
 	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_REQUIRED]);
 	g_object_notify_by_pspec(G_OBJECT(field), properties[PROP_VALID]);
diff --git a/libpurple/purplerequestgroup.c b/libpurple/purplerequestgroup.c
--- a/libpurple/purplerequestgroup.c
+++ b/libpurple/purplerequestgroup.c
@@ -230,16 +230,6 @@ void
 }
 
 void
-_purple_request_group_set_field_required(PurpleRequestGroup *group,
-                                         PurpleRequestField *field,
-                                         gboolean required)
-{
-	g_return_if_fail(PURPLE_IS_REQUEST_GROUP(group));
-
-	_purple_request_page_set_field_required(group->page, field, required);
-}
-
-void
 purple_request_group_add_field(PurpleRequestGroup *group,
                                PurpleRequestField *field)
 {
diff --git a/libpurple/purplerequestpage.h b/libpurple/purplerequestpage.h
--- a/libpurple/purplerequestpage.h
+++ b/libpurple/purplerequestpage.h
@@ -110,18 +110,6 @@ gboolean purple_request_page_exists(Purp
 gboolean purple_request_page_is_field_required(PurpleRequestPage *page, const char *id);
 
 /**
- * purple_request_page_all_required_filled:
- * @page: The fields page.
- *
- * Returns whether or not all required fields have values.
- *
- * Returns: TRUE if all required fields have values, or FALSE.
- *
- * Since: 3.0.0
- */
-gboolean purple_request_page_all_required_filled(PurpleRequestPage *page);
-
-/**
  * purple_request_page_is_valid:
  * @page: The fields page.
  *
diff --git a/libpurple/purplerequestpage.c b/libpurple/purplerequestpage.c
--- a/libpurple/purplerequestpage.c
+++ b/libpurple/purplerequestpage.c
@@ -37,8 +37,6 @@ struct _PurpleRequestPage {
 	GHashTable *invalid_groups;
 
 	GHashTable *fields;
-
-	GList *required_fields;
 };
 
 enum {
@@ -137,7 +135,6 @@ purple_request_page_finalize(GObject *ob
 
 	g_list_free_full(page->groups, g_object_unref);
 	g_clear_pointer(&page->invalid_groups, g_hash_table_destroy);
-	g_list_free(page->required_fields);
 	g_hash_table_destroy(page->fields);
 
 	G_OBJECT_CLASS(purple_request_page_parent_class)->finalize(obj);
@@ -181,20 +178,6 @@ purple_request_page_new(void) {
 }
 
 void
-_purple_request_page_set_field_required(PurpleRequestPage *page,
-                                        PurpleRequestField *field,
-                                        gboolean required)
-{
-	g_return_if_fail(PURPLE_IS_REQUEST_PAGE(page));
-
-	if(required) {
-		page->required_fields = g_list_append(page->required_fields, field);
-	} else {
-		page->required_fields = g_list_remove(page->required_fields, field);
-	}
-}
-
-void
 _purple_request_page_add_field(PurpleRequestPage *page,
                                PurpleRequestField *field)
 {
@@ -202,10 +185,6 @@ void
 
 	g_hash_table_insert(page->fields,
 	                    g_strdup(purple_request_field_get_id(field)), field);
-
-	if(purple_request_field_is_required(field)) {
-		page->required_fields = g_list_append(page->required_fields, field);
-	}
 }
 
 void
@@ -237,11 +216,6 @@ purple_request_page_add_group(PurpleRequ
 		g_hash_table_insert(page->fields,
 		                    g_strdup(purple_request_field_get_id(field)),
 		                    field);
-
-		if (purple_request_field_is_required(field)) {
-			page->required_fields = g_list_append(page->required_fields,
-			                                      field);
-		}
 	}
 
 	g_list_model_items_changed(G_LIST_MODEL(page), position, 0, 1);
@@ -278,22 +252,6 @@ purple_request_page_is_field_required(Pu
 }
 
 gboolean
-purple_request_page_all_required_filled(PurpleRequestPage *page) {
-	GList *l;
-
-	g_return_val_if_fail(PURPLE_IS_REQUEST_PAGE(page), FALSE);
-
-	for(l = page->required_fields; l != NULL; l = l->next) {
-		PurpleRequestField *field = PURPLE_REQUEST_FIELD(l->data);
-
-		if (!purple_request_field_is_filled(field))
-			return FALSE;
-	}
-
-	return TRUE;
-}
-
-gboolean
 purple_request_page_is_valid(PurpleRequestPage *page) {
 	g_return_val_if_fail(PURPLE_IS_REQUEST_PAGE(page), FALSE);
 
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -222,29 +222,10 @@ field_string_focus_out_cb(GtkEventContro
 }
 
 static void
-req_field_changed_common(G_GNUC_UNUSED GtkWidget *widget,
-                         PurpleRequestField *field)
-{
-	PurpleRequestGroup *group;
-	PurpleRequestPage *page;
-	PidginRequestData *req_data;
-
-	group = purple_request_field_get_group(field);
-	page = purple_request_group_get_page(group);
-	req_data = g_object_get_data(G_OBJECT(page), "pidgin-ui-data");
-
-	gtk_widget_set_sensitive(req_data->ok_button,
-		purple_request_page_all_required_filled(page) &&
-		purple_request_page_is_valid(page));
-}
-
-static void
 field_bool_cb(GtkCheckButton *button, PurpleRequestField *field)
 {
 	purple_request_field_bool_set_value(PURPLE_REQUEST_FIELD_BOOL(field),
 			gtk_check_button_get_active(button));
-
-	req_field_changed_common(GTK_WIDGET(button), field);
 }
 
 static void
@@ -271,8 +252,6 @@ field_account_cb(GObject *obj, G_GNUC_UN
 	purple_request_field_account_set_value(
 	        PURPLE_REQUEST_FIELD_ACCOUNT(field),
 	        pidgin_account_chooser_get_selected(chooser));
-
-	req_field_changed_common(GTK_WIDGET(obj), field);
 }
 
 static void
@@ -1066,8 +1045,6 @@ req_entry_field_changed_cb(GtkWidget *en
 			                                      purple_strempty(text) ? NULL : text);
 		}
 	}
-
-	req_field_changed_common(entry, field);
 }
 
 static void
@@ -2204,13 +2181,7 @@ pidgin_request_fields(const char *title,
 	g_object_unref(sg);
 	g_object_unref(datasheet_buttons_sg);
 
-	if(!purple_request_page_all_required_filled(page)) {
-		gtk_widget_set_sensitive(data->ok_button, FALSE);
-	}
-
-	if(!purple_request_page_is_valid(page)) {
-		gtk_widget_set_sensitive(data->ok_button, FALSE);
-	}
+	g_object_bind_property(page, "valid", data->ok_button, "sensitive", 0);
 
 	pidgin_auto_parent_window(win);
 
