# HG changeset patch
# Node ID 673b8b0858c9
# Parent  9898678c8cbd
diff --git a/pidgin/pidginaddchatdialog.c b/pidgin/pidginaddchatdialog.c
--- a/pidgin/pidginaddchatdialog.c
+++ b/pidgin/pidginaddchatdialog.c
@@ -37,14 +37,13 @@ struct _PidginAddChatDialog {
 	const gchar *default_name;
 
 	GtkWidget *account;
-	GtkWidget *dynamic_box;
+	GtkWidget *dynamic_group;
 	GtkWidget *alias;
 	GtkWidget *group;
 	GtkWidget *autojoin;
 	GtkWidget *persistent;
-	GtkSizeGroup *sg;
 
-	GList *inputs;
+	GList *rows;
 };
 
 G_DEFINE_TYPE(PidginAddChatDialog, pidgin_add_chat_dialog, GTK_TYPE_DIALOG)
@@ -58,18 +57,23 @@ static void pidgin_add_chat_dialog_input
 static void
 pidgin_add_chat_dialog_validate_input(gpointer data, gpointer user_data) {
 	gboolean *valid = user_data;
+	gboolean required = FALSE;
 
-	if(!g_object_get_data(data, "integer")) {
-		gboolean required = FALSE;
+	required = GPOINTER_TO_INT(g_object_get_data(data, "required"));
+	if(required) {
+		const gchar *value = gtk_editable_get_text(GTK_EDITABLE(data));
 
-		required = GPOINTER_TO_INT(g_object_get_data(data, "required"));
-		if(required) {
-			const gchar *value = NULL;
+		if(value == NULL || *value == '\0') {
+			*valid = FALSE;
+		} else if(g_object_get_data(data, "integer")) {
+			gint int_value = atoi(value);
+			char *str_value = g_strdup_printf("%d", int_value);
 
-			value = gtk_editable_get_text(GTK_EDITABLE(data));
-			if(value == NULL || *value == '\0') {
+			if(!purple_strequal(value, str_value)) {
 				*valid = FALSE;
 			}
+
+			g_free(str_value);
 		}
 	}
 }
@@ -81,7 +85,7 @@ pidgin_add_chat_dialog_validate(PidginAd
 	/* The callback should only set valid to FALSE if a field is invalid and
 	 * not set valid if the field is valid.
 	 */
-	g_list_foreach(dialog->inputs,
+	g_list_foreach(dialog->rows,
 	               pidgin_add_chat_dialog_validate_input,
 	               &valid);
 
@@ -94,16 +98,16 @@ pidgin_add_chat_dialog_update_components
 	PurpleAccount *account = NULL;
 	PurpleConnection *connection = NULL;
 	PurpleProtocol *protocol = NULL;
-	GtkWidget *child = NULL;
 	GList *info = NULL;
 	GHashTable *defaults = NULL;
 	gboolean focus_set = FALSE;
 
-	/* Clean up the dynamic box and our list of entires. */
-	while((child = gtk_widget_get_first_child(dialog->dynamic_box)) != NULL) {
-		gtk_box_remove(GTK_BOX(dialog->dynamic_box), child);
+	/* Clean up the dynamic group and our list of rows. */
+	while(dialog->rows != NULL) {
+		adw_preferences_group_remove(ADW_PREFERENCES_GROUP(dialog->dynamic_group),
+		                             dialog->rows->data);
+		dialog->rows = g_list_delete_link(dialog->rows, dialog->rows);
 	}
-	g_clear_pointer(&dialog->inputs, g_list_free);
 
 	account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(dialog->account));
 	if(!PURPLE_IS_ACCOUNT(account)) {
@@ -119,57 +123,48 @@ pidgin_add_chat_dialog_update_components
 	                                              dialog->default_name);
 
 	while(info != NULL) {
-		GtkWidget *box = NULL, *label = NULL, *input = NULL;
+		GtkWidget *row = NULL;
 		PurpleProtocolChatEntry *pce = info->data;
+		char *value = NULL;
 
 		if(pce->is_int) {
-			GtkAdjustment *adjustment = gtk_adjustment_new(pce->min, pce->min,
-			                                               pce->max, 1, 10, 10);
-			input = gtk_spin_button_new(adjustment, 1, 0);
+			row = adw_entry_row_new();
+			adw_entry_row_set_input_purpose(ADW_ENTRY_ROW(row),
+			                                GTK_INPUT_PURPOSE_NUMBER);
+		} else if(pce->secret) {
+			row = adw_password_entry_row_new();
 		} else {
-			gchar *value = NULL;
-
-			input = gtk_entry_new();
-			g_signal_connect(input, "changed",
-			                 G_CALLBACK(pidgin_add_chat_dialog_input_changed_cb),
-			                 dialog);
-
-			value = g_hash_table_lookup(defaults, pce->identifier);
-			if(value != NULL) {
-				gtk_editable_set_text(GTK_EDITABLE(input), value);
-			}
-
-			if(pce->secret) {
-				gtk_entry_set_visibility(GTK_ENTRY(input), FALSE);
-				gtk_entry_set_input_purpose(GTK_ENTRY(input),
-				                            GTK_INPUT_PURPOSE_PASSWORD);
-			}
+			row = adw_entry_row_new();
 		}
 
-		box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
-		gtk_box_append(GTK_BOX(dialog->dynamic_box), box);
+		value = g_hash_table_lookup(defaults, pce->identifier);
+		if(value != NULL) {
+			gtk_editable_set_text(GTK_EDITABLE(row), value);
+		}
+
+		g_signal_connect(row, "changed",
+		                 G_CALLBACK(pidgin_add_chat_dialog_input_changed_cb),
+		                 dialog);
 
-		label = gtk_label_new_with_mnemonic(pce->label);
-		gtk_label_set_xalign(GTK_LABEL(label), 0.0f);
-		gtk_label_set_yalign(GTK_LABEL(label), 0.0f);
-		gtk_box_append(GTK_BOX(box), label);
-		gtk_size_group_add_widget(dialog->sg, label);
+		adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), pce->label);
+		adw_preferences_row_set_use_underline(ADW_PREFERENCES_ROW(row), TRUE);
 
-		gtk_widget_set_hexpand(input, TRUE);
-		gtk_box_append(GTK_BOX(box), input);
+		adw_preferences_group_add(ADW_PREFERENCES_GROUP(dialog->dynamic_group),
+		                          row);
+
 		if(!focus_set) {
-			gtk_widget_grab_focus(input);
+			gtk_widget_grab_focus(row);
 			focus_set = TRUE;
 		}
 
-		g_object_set_data(G_OBJECT(input), "identifier",
+		g_object_set_data(G_OBJECT(row), "identifier",
 		                  (gpointer)pce->identifier);
-		g_object_set_data(G_OBJECT(input), "integer",
+		g_object_set_data(G_OBJECT(row), "integer",
 		                  GINT_TO_POINTER(pce->is_int));
-		g_object_set_data(G_OBJECT(input), "required",
+		g_object_set_data(G_OBJECT(row), "required",
 		                  GINT_TO_POINTER(pce->required));
 
-		dialog->inputs = g_list_append(dialog->inputs, input);
+		dialog->rows = g_list_append(dialog->rows, row);
 
 		g_free(pce);
 
@@ -210,7 +205,8 @@ pidgin_add_chat_dialog_add_input_to_comp
 	identifier = g_strdup(g_object_get_data(data, "identifier"));
 
 	if(g_object_get_data(data, "integer")) {
-		gint int_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data));
+		const char *str_value = gtk_editable_get_text(GTK_EDITABLE(data));
+		gint int_value = atoi(str_value);
 
 		value = g_strdup_printf("%d", int_value);
 	} else {
@@ -263,7 +259,7 @@ pidgin_add_chat_dialog_response_cb(GtkDi
 
 		components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
 		                                   g_free);
-		g_list_foreach(acdialog->inputs,
+		g_list_foreach(acdialog->rows,
 		               pidgin_add_chat_dialog_add_input_to_components,
 		               components);
 
@@ -287,11 +283,11 @@ pidgin_add_chat_dialog_response_cb(GtkDi
 
 			purple_blist_add_chat(chat, group, NULL);
 
-			if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(acdialog->autojoin))) {
+			if(gtk_switch_get_active(GTK_SWITCH(acdialog->autojoin))) {
 				purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
 				                           "gtk-autojoin", TRUE);
 			}
-			if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(acdialog->persistent))) {
+			if(gtk_switch_get_active(GTK_SWITCH(acdialog->persistent))) {
 				purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
 				                           "gtk-persistent", TRUE);
 			}
@@ -357,7 +353,7 @@ static void
 pidgin_add_chat_dialog_finalize(GObject *obj) {
 	PidginAddChatDialog *dialog = PIDGIN_ADD_CHAT_DIALOG(obj);
 
-	g_list_free(dialog->inputs);
+	g_list_free(dialog->rows);
 
 	G_OBJECT_CLASS(pidgin_add_chat_dialog_parent_class)->finalize(obj);
 }
@@ -394,7 +390,7 @@ pidgin_add_chat_dialog_class_init(Pidgin
 	gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
 	                                     account);
 	gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
-	                                     dynamic_box);
+	                                     dynamic_group);
 	gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
 	                                     alias);
 	gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
@@ -403,8 +399,6 @@ pidgin_add_chat_dialog_class_init(Pidgin
 	                                     autojoin);
 	gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
 	                                     persistent);
-	gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
-	                                     sg);
 
 	gtk_widget_class_bind_template_callback(widget_class,
 	                                        pidgin_add_chat_dialog_response_cb);
diff --git a/pidgin/resources/Dialogs/addbuddy.ui b/pidgin/resources/Dialogs/addbuddy.ui
--- a/pidgin/resources/Dialogs/addbuddy.ui
+++ b/pidgin/resources/Dialogs/addbuddy.ui
@@ -31,28 +31,27 @@ along with this program; if not, see <ht
     <signal name="response" handler="pidgin_add_buddy_dialog_response_cb" swapped="no"/>
     <child internal-child="content_area">
       <object class="GtkBox">
+        <property name="margin-bottom">24</property>
+        <property name="margin-end">24</property>
+        <property name="margin-start">24</property>
+        <property name="margin-top">24</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
+        <property name="spacing">24</property>
         <child>
           <object class="GtkLabel">
-            <property name="label" translatable="1">Add a buddy.</property>
-            <property name="xalign">0</property>
-            <property name="yalign">0</property>
+            <property name="css-classes">title-1</property>
+            <property name="label" translatable="1">Add a buddy</property>
           </object>
         </child>
         <child>
-          <object class="GtkLabel" id="spacer"/>
-        </child>
-        <child>
           <object class="GtkBox">
-            <property name="spacing">5</property>
+            <property name="spacing">6</property>
             <child>
               <object class="GtkLabel" id="label1">
                 <property name="label" translatable="1">A_ccount:</property>
                 <property name="use-underline">1</property>
                 <property name="mnemonic-widget">account</property>
                 <property name="xalign">0</property>
-                <property name="yalign">0</property>
               </object>
             </child>
             <child>
@@ -77,95 +76,42 @@ along with this program; if not, see <ht
           </object>
         </child>
         <child>
-          <object class="GtkBox">
-            <property name="spacing">5</property>
+          <object class="AdwPreferencesGroup">
+            <property name="title" translatable="1">Buddy information</property>
             <child>
-              <object class="GtkLabel" id="label2">
-                <property name="label" translatable="1">Buddy&apos;s _username:</property>
+              <object class="AdwEntryRow" id="username">
+                <property name="title" translatable="1">Buddy&apos;s _username</property>
                 <property name="use-underline">1</property>
-                <property name="mnemonic-widget">username</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
+                <property name="activates-default">1</property>
+                <signal name="changed" handler="pidgin_add_buddy_dialog_username_changed_cb" object="PidginAddBuddyDialog" swapped="no"/>
               </object>
             </child>
             <child>
-              <object class="GtkEntry" id="username">
-                <property name="hexpand">1</property>
-                <property name="focusable">1</property>
-                <property name="activates-default">1</property>
-                <signal name="changed" handler="pidgin_add_buddy_dialog_username_changed_cb" object="PidginAddBuddyDialog" swapped="no"/>
-                <accessibility>
-                  <relation name="labelled-by">label2</relation>
-                </accessibility>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="spacing">5</property>
-            <child>
-              <object class="GtkLabel" id="label3">
-                <property name="label" translatable="1">(Optional) A_lias:</property>
+              <object class="AdwEntryRow" id="alias">
+                <property name="title" translatable="1">(Optional) A_lias</property>
                 <property name="use-underline">1</property>
-                <property name="mnemonic-widget">alias</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
               </object>
             </child>
             <child>
-              <object class="GtkEntry" id="alias">
-                <property name="hexpand">1</property>
-                <property name="focusable">1</property>
-                <accessibility>
-                  <relation name="labelled-by">label3</relation>
-                </accessibility>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="spacing">5</property>
-            <child>
-              <object class="GtkLabel" id="label4">
-                <property name="label" translatable="1">(Optional) _Invite message:</property>
+              <object class="AdwEntryRow" id="message">
+                <property name="title" translatable="1">(Optional) _Invite message</property>
                 <property name="use-underline">1</property>
-                <property name="mnemonic-widget">message</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
+                <property name="sensitive">0</property>
               </object>
             </child>
             <child>
-              <object class="GtkEntry" id="message">
-                <property name="hexpand">1</property>
-                <property name="sensitive">0</property>
-                <property name="focusable">1</property>
-                <accessibility>
-                  <relation name="labelled-by">label4</relation>
-                </accessibility>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="spacing">5</property>
-            <child>
-              <object class="GtkLabel" id="label5">
-                <property name="label" translatable="1">Add buddy to _group:</property>
+              <object class="AdwActionRow">
+                <property name="activatable-widget">group</property>
+                <property name="focusable">0</property>
+                <property name="title" translatable="1">Add buddy to _group</property>
                 <property name="use-underline">1</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkComboBoxText" id="group">
-                <property name="hexpand">1</property>
-                <property name="has-entry">1</property>
-                <accessibility>
-                  <relation name="labelled-by">label5</relation>
-                </accessibility>
+                <child>
+                  <object class="GtkComboBoxText" id="group">
+                    <property name="hexpand">1</property>
+                    <property name="has-entry">1</property>
+                    <property name="valign">center</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
@@ -186,21 +132,13 @@ along with this program; if not, see <ht
     </child>
     <child type="action">
       <object class="GtkButton" id="button2">
+        <property name="css-classes">suggested-action</property>
+        <property name="focusable">1</property>
         <property name="label" translatable="1">_Add</property>
+        <property name="receives-default">1</property>
         <property name="sensitive">0</property>
-        <property name="focusable">1</property>
-        <property name="receives-default">1</property>
         <property name="use-underline">1</property>
       </object>
     </child>
   </template>
-  <object class="GtkSizeGroup">
-    <widgets>
-      <widget name="label1"/>
-      <widget name="label2"/>
-      <widget name="label3"/>
-      <widget name="label4"/>
-      <widget name="label5"/>
-    </widgets>
-  </object>
 </interface>
diff --git a/pidgin/resources/Dialogs/addchat.ui b/pidgin/resources/Dialogs/addchat.ui
--- a/pidgin/resources/Dialogs/addchat.ui
+++ b/pidgin/resources/Dialogs/addchat.ui
@@ -31,20 +31,19 @@ along with this program; if not, see <ht
     <signal name="response" handler="pidgin_add_chat_dialog_response_cb" swapped="no"/>
     <child internal-child="content_area">
       <object class="GtkBox">
+        <property name="margin-bottom">24</property>
+        <property name="margin-end">24</property>
+        <property name="margin-start">24</property>
+        <property name="margin-top">24</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
+        <property name="spacing">24</property>
         <child>
           <object class="GtkLabel">
-            <property name="label" translatable="1">Please enter an alias, and the appropriate information about the chat you would like to add to your buddy list.</property>
-            <property name="wrap">1</property>
-            <property name="xalign">0</property>
-            <property name="yalign">0</property>
+            <property name="css-classes">title-1</property>
+            <property name="label" translatable="1">Add a chat</property>
           </object>
         </child>
         <child>
-          <object class="GtkLabel" id="spacer"/>
-        </child>
-        <child>
           <object class="GtkBox">
             <property name="spacing">5</property>
             <child>
@@ -53,7 +52,6 @@ along with this program; if not, see <ht
                 <property name="use-underline">1</property>
                 <property name="mnemonic-widget">account</property>
                 <property name="xalign">0</property>
-                <property name="yalign">0</property>
               </object>
             </child>
             <child>
@@ -70,73 +68,69 @@ along with this program; if not, see <ht
                   </object>
                 </property>
                 <signal name="notify::account" handler="pidgin_add_chat_dialog_account_changed_cb" swapped="no"/>
+                <accessibility>
+                  <relation name="labelled-by">label1</relation>
+                </accessibility>
               </object>
             </child>
           </object>
         </child>
         <child>
-          <object class="GtkBox" id="dynamic_box">
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
-            <property name="hexpand">1</property>
-            <child>
-              <placeholder/>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="spacing">5</property>
-            <child>
-              <object class="GtkLabel" id="label4">
-                <property name="label" translatable="1">A_lias:</property>
-                <property name="use-underline">1</property>
-                <property name="mnemonic-widget">alias</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkEntry" id="alias">
-                <property name="hexpand">1</property>
-                <property name="focusable">1</property>
-              </object>
-            </child>
+          <object class="AdwPreferencesGroup" id="dynamic_group">
+            <property name="title" translatable="1">Chat information</property>
+            <property name="description" translatable="1">Please enter the appropriate information about the chat you would like to add to your buddy list.</property>
           </object>
         </child>
         <child>
-          <object class="GtkBox">
-            <property name="spacing">5</property>
+          <object class="AdwPreferencesGroup">
+            <property name="title" translatable="1">Local information</property>
+            <child>
+              <object class="AdwEntryRow" id="alias">
+                <property name="title" translatable="1">A_lias</property>
+                <property name="use-underline">1</property>
+              </object>
+            </child>
             <child>
-              <object class="GtkLabel" id="label5">
-                <property name="label" translatable="1">_Group:</property>
+              <object class="AdwActionRow">
+                <property name="activatable-widget">group</property>
+                <property name="focusable">0</property>
+                <property name="title" translatable="1">_Group</property>
                 <property name="use-underline">1</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
+                <child>
+                  <object class="GtkComboBoxText" id="group">
+                    <property name="hexpand">1</property>
+                    <property name="has-entry">1</property>
+                    <property name="valign">center</property>
+                  </object>
+                </child>
               </object>
             </child>
             <child>
-              <object class="GtkComboBoxText" id="group">
-                <property name="hexpand">1</property>
-                <property name="has-entry">1</property>
+              <object class="AdwActionRow">
+                <property name="activatable-widget">autojoin</property>
+                <property name="focusable">0</property>
+                <property name="title" translatable="1">Automatically _join when account connects</property>
+                <property name="use-underline">1</property>
+                <child>
+                  <object class="GtkSwitch" id="autojoin">
+                    <property name="valign">center</property>
+                  </object>
+                </child>
               </object>
             </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="autojoin">
-            <property name="label" translatable="1">Automatically _join when account connects</property>
-            <property name="focusable">1</property>
-            <property name="halign">start</property>
-            <property name="use-underline">1</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="persistent">
-            <property name="label" translatable="1">_Remain in chat after window is closed</property>
-            <property name="focusable">1</property>
-            <property name="halign">start</property>
-            <property name="use-underline">1</property>
+            <child>
+              <object class="AdwActionRow">
+                <property name="activatable-widget">persistent</property>
+                <property name="focusable">0</property>
+                <property name="title" translatable="1">_Remain in chat after window is closed</property>
+                <property name="use-underline">1</property>
+                <child>
+                  <object class="GtkSwitch" id="persistent">
+                    <property name="valign">center</property>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
         </child>
       </object>
@@ -171,11 +165,4 @@ along with this program; if not, see <ht
       <action-widget response="ok">button2</action-widget>
     </action-widgets>
   </template>
-  <object class="GtkSizeGroup" id="sg">
-    <widgets>
-      <widget name="label1"/>
-      <widget name="label4"/>
-      <widget name="label5"/>
-    </widgets>
-  </object>
 </interface>
