# HG changeset patch
# Node ID e5161ff2f9a9
# Parent  2c4d1b5de78f
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -302,7 +302,6 @@
 		PurpleMediaSessionType type =
 				purple_media_get_session_type(gtkmedia->priv->media, session_id);
 		gchar *key = create_key(session_id, participant);
-		GtkRequisition req;
 
 		if (type & PURPLE_MEDIA_AUDIO) {
 			g_hash_table_remove(gtkmedia->priv->recv_progressbars, key);
@@ -310,10 +309,10 @@
 			if (g_hash_table_size(gtkmedia->priv->recv_progressbars) == 0 &&
 				gtkmedia->priv->send_progress) {
 
-				gtk_widget_destroy(gtkmedia->priv->send_progress);
+				gtk_widget_unparent(gtkmedia->priv->send_progress);
 				gtkmedia->priv->send_progress = NULL;
 
-				gtk_widget_destroy(gtkmedia->priv->mute);
+				gtk_widget_unparent(gtkmedia->priv->mute);
 				gtkmedia->priv->mute = NULL;
 			}
 		} else if (type & PURPLE_MEDIA_VIDEO) {
@@ -322,20 +321,17 @@
 			if (g_hash_table_size(gtkmedia->priv->remote_videos) == 0 &&
 				gtkmedia->priv->local_video) {
 
-				gtk_widget_destroy(gtkmedia->priv->local_video);
+				gtk_widget_unparent(gtkmedia->priv->local_video);
 				gtkmedia->priv->local_video = NULL;
 
-				gtk_widget_destroy(gtkmedia->priv->pause);
+				gtk_widget_unparent(gtkmedia->priv->pause);
 				gtkmedia->priv->pause = NULL;
 			}
 		}
 
 		g_free(key);
 
-		gtk_widget_destroy(widget);
-
-		gtk_widget_get_preferred_size(GTK_WIDGET(gtkmedia), NULL, &req);
-		gtk_window_resize(GTK_WINDOW(gtkmedia), req.width, req.height);
+		gtk_window_destroy(GTK_WINDOW(widget));
 	}
 }
 
@@ -540,7 +536,7 @@
 {
 	g_return_if_fail(GTK_IS_WIDGET(parent));
 
-	gtk_widget_destroy(parent);
+	gtk_window_destroy(GTK_WINDOW(parent));
 }
 
 static GtkWidget *
@@ -570,19 +566,20 @@
 	/* Setup widget structure */
 	volume_widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
 	progress_parent = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-	gtk_box_pack_start(GTK_BOX(volume_widget),
-			progress_parent, TRUE, TRUE, 0);
+	gtk_widget_set_vexpand(volume_widget, TRUE);
+	gtk_widget_set_valign(volume_widget, GTK_ALIGN_FILL);
+	gtk_box_append(GTK_BOX(volume_widget), progress_parent);
 
 	/* Volume button */
 	volume = gtk_volume_button_new();
 	gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume), value/100.0);
-	gtk_box_pack_end(GTK_BOX(volume_widget),
-			volume, FALSE, FALSE, 0);
+	gtk_box_append(GTK_BOX(volume_widget), volume);
 
 	/* Volume level indicator */
 	progress = gtk_progress_bar_new();
 	gtk_widget_set_size_request(progress, 250, 10);
-	gtk_box_pack_end(GTK_BOX(progress_parent), progress, TRUE, FALSE, 0);
+	gtk_widget_set_vexpand(progress, TRUE);
+	gtk_box_append(GTK_BOX(progress_parent), progress);
 
 	if (type & PURPLE_MEDIA_SEND_AUDIO) {
 		g_signal_connect (G_OBJECT(volume), "value-changed",
@@ -604,7 +601,7 @@
 			G_CALLBACK(destroy_parent_widget_cb),
 			volume_widget);
 
-	gtk_widget_show_all(volume_widget);
+	gtk_widget_show(volume_widget);
 
 	return volume_widget;
 }
@@ -636,7 +633,7 @@
 	g_object_set_data_full(G_OBJECT(win), "session-id",
 		g_strdup(_sid), g_free);
 
-	gtk_widget_show_all(keypad);
+	gtk_widget_show(keypad);
 
 	return keypad;
 }
@@ -652,9 +649,9 @@
 			&& type & (PURPLE_MEDIA_RECV_VIDEO |
 			PURPLE_MEDIA_RECV_AUDIO)) {
 		recv_widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
-		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
-				recv_widget, TRUE, TRUE, 0);
-		gtk_widget_show(recv_widget);
+		gtk_widget_set_vexpand(recv_widget, TRUE);
+		gtk_widget_set_valign(recv_widget, GTK_ALIGN_FILL);
+		gtk_box_append(GTK_BOX(gtkmedia->priv->display), recv_widget);
 	} else {
 		recv_widget = gtkmedia->priv->recv_widget;
 	}
@@ -662,18 +659,17 @@
 			&& type & (PURPLE_MEDIA_SEND_VIDEO |
 			PURPLE_MEDIA_SEND_AUDIO)) {
 		send_widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
-		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
-				send_widget, FALSE, TRUE, 0);
+		gtk_widget_set_valign(send_widget, GTK_ALIGN_FILL);
+		gtk_box_prepend(GTK_BOX(gtkmedia->priv->display), send_widget);
+
 		button_widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
-		gtk_box_pack_end(GTK_BOX(recv_widget), button_widget,
-				FALSE, TRUE, 0);
-		gtk_widget_show(send_widget);
+		gtk_widget_set_valign(button_widget, GTK_ALIGN_FILL);
+		gtk_box_append(GTK_BOX(recv_widget), button_widget);
 
 		/* Hold button */
 		gtkmedia->priv->hold =
 				gtk_toggle_button_new_with_mnemonic(_("_Hold"));
-		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->hold,
-				FALSE, FALSE, 0);
+		gtk_box_append(GTK_BOX(button_widget), gtkmedia->priv->hold);
 		gtk_widget_show(gtkmedia->priv->hold);
 		gtk_actionable_set_action_name(
 				GTK_ACTIONABLE(gtkmedia->priv->hold),
@@ -699,7 +695,11 @@
 		}
 		g_object_get(G_OBJECT(sink), "widget", &remote_video, NULL);
 		gtk_widget_show(remote_video);
-		gtk_box_pack_start(GTK_BOX(recv_widget), remote_video, TRUE, TRUE, 0);
+		gtk_widget_set_halign(remote_video, GTK_ALIGN_FILL);
+		gtk_widget_set_hexpand(remote_video, TRUE);
+		gtk_widget_set_valign(remote_video, GTK_ALIGN_FILL);
+		gtk_widget_set_vexpand(remote_video, TRUE);
+		gtk_box_append(GTK_BOX(recv_widget), remote_video);
 
 		pidgin_media_insert_widget(gtkmedia, remote_video, sid, priv->screenname);
 	}
@@ -720,12 +720,15 @@
 		}
 		g_object_get(G_OBJECT(sink), "widget", &local_video, NULL);
 		gtk_widget_show(local_video);
-		gtk_box_pack_start(GTK_BOX(send_widget), local_video, TRUE, TRUE, 0);
+		gtk_widget_set_halign(local_video, GTK_ALIGN_FILL);
+		gtk_widget_set_hexpand(local_video, TRUE);
+		gtk_widget_set_valign(local_video, GTK_ALIGN_FILL);
+		gtk_widget_set_vexpand(local_video, TRUE);
+		gtk_box_append(GTK_BOX(send_widget), local_video);
 
 		gtkmedia->priv->pause =
 				gtk_toggle_button_new_with_mnemonic(_("_Pause"));
-		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->pause,
-				FALSE, FALSE, 0);
+		gtk_box_append(GTK_BOX(button_widget), gtkmedia->priv->pause);
 		gtk_widget_show(gtkmedia->priv->pause);
 		gtk_actionable_set_action_name(
 				GTK_ACTIONABLE(gtkmedia->priv->pause),
@@ -734,28 +737,29 @@
 		gtkmedia->priv->local_video = local_video;
 	}
 	if (type & PURPLE_MEDIA_RECV_AUDIO) {
-		gtk_box_pack_end(GTK_BOX(recv_widget),
-				pidgin_media_add_audio_widget(gtkmedia,
-				PURPLE_MEDIA_RECV_AUDIO, sid), FALSE, FALSE, 0);
+		GtkWidget *audio = NULL;
+
+		audio = pidgin_media_add_audio_widget(gtkmedia, PURPLE_MEDIA_RECV_AUDIO,
+		                                      sid);
+		gtk_box_prepend(GTK_BOX(recv_widget), audio);
 	}
 
 	if (type & PURPLE_MEDIA_SEND_AUDIO) {
 		gtkmedia->priv->mute =
 				gtk_toggle_button_new_with_mnemonic(_("_Mute"));
-		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->mute,
-				FALSE, FALSE, 0);
+		gtk_box_append(GTK_BOX(button_widget), gtkmedia->priv->mute);
 		gtk_widget_show(gtkmedia->priv->mute);
 		gtk_actionable_set_action_name(
 				GTK_ACTIONABLE(gtkmedia->priv->mute),
 				"win.Mute");
 
-		gtk_box_pack_end(GTK_BOX(recv_widget),
+		gtk_box_prepend(GTK_BOX(recv_widget),
 				pidgin_media_add_audio_widget(gtkmedia,
-				PURPLE_MEDIA_SEND_AUDIO, sid), FALSE, FALSE, 0);
+				PURPLE_MEDIA_SEND_AUDIO, sid));
 
-		gtk_box_pack_end(GTK_BOX(recv_widget),
+		gtk_box_prepend(GTK_BOX(recv_widget),
 				pidgin_media_add_dtmf_widget(gtkmedia,
-				PURPLE_MEDIA_SEND_AUDIO, sid), FALSE, FALSE, 0);
+				PURPLE_MEDIA_SEND_AUDIO, sid));
 	}
 
 	if (type & PURPLE_MEDIA_AUDIO &&
@@ -805,7 +809,7 @@
 		} else if (sid == NULL && name == NULL) {
 			pidgin_media_emit_message(gtkmedia,
 					_("The call has been terminated."));
-			gtk_widget_destroy(GTK_WIDGET(gtkmedia));
+			gtk_window_destroy(GTK_WINDOW(gtkmedia));
 		}
 	} else if (state == PURPLE_MEDIA_STATE_NEW &&
 			sid != NULL && name != NULL) {
diff --git a/pidgin/pidginaccounteditor.c b/pidgin/pidginaccounteditor.c
--- a/pidgin/pidginaccounteditor.c
+++ b/pidgin/pidginaccounteditor.c
@@ -107,7 +107,7 @@
 		pidgin_account_editor_save_account(PIDGIN_ACCOUNT_EDITOR(dialog));
 	}
 
-	gtk_widget_destroy(GTK_WIDGET(dialog));
+	gtk_window_destroy(GTK_WINDOW(dialog));
 }
 
 /******************************************************************************
diff --git a/pidgin/pidginaccountmanager.c b/pidgin/pidginaccountmanager.c
--- a/pidgin/pidginaccountmanager.c
+++ b/pidgin/pidginaccountmanager.c
@@ -217,7 +217,7 @@
 	switch(response_id) {
 		case RESPONSE_ADD:
 			editor = pidgin_account_editor_new(NULL);
-			gtk_widget_show_all(editor);
+			gtk_widget_show(editor);
 			break;
 		case RESPONSE_ADD_OLD:
 			pidgin_account_dialog_show(PIDGIN_ADD_ACCOUNT_DIALOG, NULL);
@@ -226,7 +226,7 @@
 			account = pidgin_account_manager_get_selected_account(manager);
 
 			editor = pidgin_account_editor_new(account);
-			gtk_widget_show_all(editor);
+			gtk_widget_show(editor);
 
 			g_clear_object(&account);
 			break;
diff --git a/pidgin/pidginconversationwindow.c b/pidgin/pidginconversationwindow.c
--- a/pidgin/pidginconversationwindow.c
+++ b/pidgin/pidginconversationwindow.c
@@ -116,7 +116,7 @@
 		}
 	}
 
-	gtk_widget_destroy(GTK_WIDGET(invite_dialog));
+	gtk_window_destroy(GTK_WINDOW(invite_dialog));
 }
 
 /******************************************************************************
@@ -218,7 +218,7 @@
 			                 NULL);
 		}
 
-		gtk_widget_show_all(invite_dialog);
+		gtk_widget_show(invite_dialog);
 	}
 }
 
@@ -424,6 +424,7 @@
 
 static void
 pidgin_conversation_window_init(PidginConversationWindow *window) {
+	GtkEventController *key = NULL;
 	GtkTreeIter iter;
 
 	gtk_widget_init_template(GTK_WIDGET(window));
@@ -434,13 +435,12 @@
 	g_action_map_add_action_entries(G_ACTION_MAP(window), win_entries,
 	                                G_N_ELEMENTS(win_entries), window);
 
-	key = gtk_event_controller_key_new(GTK_WIDGET(window));
+	key = gtk_event_controller_key_new();
 	gtk_event_controller_set_propagation_phase(key, GTK_PHASE_CAPTURE);
 	g_signal_connect(G_OBJECT(key), "key-pressed",
 	                 G_CALLBACK(pidgin_conversation_window_key_pressed_cb),
 	                 window);
-	g_object_set_data_full(G_OBJECT(window), "key-press-controller", key,
-	                       g_object_unref);
+	gtk_widget_add_controller(GTK_WIDGET(window), key);
 
 	/* Add our toplevels to the tree store. */
 	gtk_tree_store_append(window->model, &iter, NULL);
@@ -632,7 +632,7 @@
 			child = gtk_stack_get_child_by_name(GTK_STACK(window->stack),
 			                                    name);
 			if(GTK_IS_WIDGET(child)) {
-				gtk_container_remove(GTK_CONTAINER(window->stack), child);
+				gtk_widget_unparent(child);
 			}
 
 			gtk_tree_store_remove(window->model, &iter);
