# HG changeset patch
# Node ID 864b0ad62269
# Parent  dfaaf63fc318
diff --git a/pidgin/pidginconversationwindow.c b/pidgin/pidginconversationwindow.c
--- a/pidgin/pidginconversationwindow.c
+++ b/pidgin/pidginconversationwindow.c
@@ -115,7 +115,7 @@
 	}
 
 	/* If ALT (or whatever) was held down... */
-	else if (state & GDK_MOD1_MASK) {
+	else if (state & GDK_ALT_MASK) {
 		if ('1' <= keyval && keyval <= '9') {
 			guint switchto = keyval - '1';
 			pidgin_conversation_window_select_nth(window, switchto);
@@ -168,7 +168,6 @@
 
 static void
 pidgin_conversation_window_init(PidginConversationWindow *window) {
-	GtkEventController *key = NULL;
 	GtkTreeIter iter;
 
 	gtk_widget_init_template(GTK_WIDGET(window));
@@ -176,14 +175,6 @@
 	gtk_window_set_application(GTK_WINDOW(window),
 	                           GTK_APPLICATION(g_application_get_default()));
 
-	key = gtk_event_controller_key_new(GTK_WIDGET(window));
-	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);
-
 	/* Add our toplevels to the tree store. */
 	gtk_tree_store_append(window->model, &iter, NULL);
 	gtk_tree_store_set(window->model, &iter,
@@ -231,6 +222,9 @@
 
 	gtk_widget_class_bind_template_callback(widget_class,
 	                                        pidgin_conversation_window_selection_changed);
+
+	gtk_widget_class_bind_template_callback(widget_class,
+	                                        pidgin_conversation_window_key_pressed_cb);
 }
 
 /******************************************************************************
@@ -285,11 +279,11 @@
 
 		if(GTK_IS_WIDGET(parent)) {
 			g_object_ref(gtkconv->tab_cont);
-			gtk_container_remove(GTK_CONTAINER(parent), gtkconv->tab_cont);
+			gtk_widget_unparent(gtkconv->tab_cont);
 		}
 
 		gtk_stack_add_named(GTK_STACK(window->stack), gtkconv->tab_cont, markup);
-		gtk_widget_show_all(gtkconv->tab_cont);
+		gtk_widget_show(gtkconv->tab_cont);
 
 		if(GTK_IS_WIDGET(parent)) {
 			g_object_unref(gtkconv->tab_cont);
@@ -310,7 +304,7 @@
 
 
 	if(!gtk_widget_is_visible(GTK_WIDGET(window))) {
-		gtk_widget_show_all(GTK_WIDGET(window));
+		gtk_widget_show(GTK_WIDGET(window));
 	}
 }
 
@@ -356,16 +350,16 @@
 
 guint
 pidgin_conversation_window_get_count(PidginConversationWindow *window) {
-	GList *children = NULL;
+	GtkSelectionModel *model = NULL;
 	guint count = 0;
 
 	g_return_val_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window), 0);
 
-	children = gtk_container_get_children(GTK_CONTAINER(window));
-	while(children != NULL) {
-		children = g_list_delete_link(children, children);
-		count++;
-	}
+	model = gtk_stack_get_pages(GTK_STACK(window->stack));
+
+	count = g_list_model_get_n_items(G_LIST_MODEL(model));
+
+	g_object_unref(model);
 
 	return count;
 }
diff --git a/pidgin/resources/Conversations/window.ui b/pidgin/resources/Conversations/window.ui
--- a/pidgin/resources/Conversations/window.ui
+++ b/pidgin/resources/Conversations/window.ui
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 
-
+<!--
 Pidgin - Internet Messenger
 Copyright (C) Pidgin Developers <devel@pidgin.im>
 
@@ -15,12 +14,10 @@
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
+along with this library; if not, see <https://www.gnu.org/licenses/>.
 -->
 <interface>
-  <requires lib="gtk+" version="3.24"/>
+  <requires lib="gtk" version="4.0"/>
   <requires lib="pidgin" version="3.0"/>
   <!-- interface-license-type gplv2 -->
   <!-- interface-name Pidgin -->
@@ -37,48 +34,42 @@
     </columns>
   </object>
   <template class="PidginConversationWindow" parent="GtkApplicationWindow">
-    <property name="can-focus">False</property>
-    <property name="role">conversation</property>
+    <child>
+      <object class="GtkEventControllerKey">
+        <property name="propagation-phase">GTK_PHASE_CAPTURE</property>
+        <signal name="key-pressed" handler="pidgin_conversation_window_key_pressed_cb"/>
+      </object>
+    </child>
     <child>
       <object class="GtkBox" id="vbox">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <child>
           <object class="GtkPaned" id="paned">
-            <property name="visible">True</property>
-            <property name="can-focus">True</property>
+            <property name="vexpand">1</property>
+            <property name="focusable">1</property>
             <property name="position">100</property>
             <child>
               <object class="GtkBox">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="border-width">6</property>
+                <property name="margin-top">6</property>
+                <property name="margin-start">6</property>
+                <property name="margin-end">6</property>
+                <property name="margin-bottom">6</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="PidginStatusBox">
-                    <property name="visible">True</property>
                     <property name="can-focus">False</property>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="shadow-type">out</property>
-                    <property name="propagate-natural-width">True</property>
-                    <child>
+                    <property name="vexpand">1</property>
+                    <property name="focusable">1</property>
+                    <property name="propagate-natural-width">1</property>
+                    <property name="child">
                       <object class="GtkTreeView" id="view">
-                        <property name="visible">True</property>
-                        <property name="can-focus">True</property>
+                        <property name="focusable">1</property>
                         <property name="model">model</property>
-                        <property name="headers-visible">False</property>
                         <property name="search-column">2</property>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection">
@@ -102,48 +93,27 @@
                           </object>
                         </child>
                       </object>
-                    </child>
+                    </property>
                   </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="resize">True</property>
-                <property name="shrink">True</property>
-              </packing>
             </child>
             <child>
               <object class="GtkStack" id="stack">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
                 <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
-                    <property name="label" translatable="yes">Select a conversation to chat!</property>
+                  <object class="GtkStackPage">
+                    <property name="name">__empty__</property>
+                    <property name="title" translatable="0">__empty__</property>
+                    <property name="child">
+                      <object class="GtkLabel">
+                        <property name="label" translatable="1">Select a conversation to chat!</property>
+                      </object>
+                    </property>
                   </object>
-                  <packing>
-                    <property name="name">__empty__</property>
-                    <property name="title" translatable="yes">__empty__</property>
-                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="resize">True</property>
-                <property name="shrink">True</property>
-              </packing>
             </child>
           </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">0</property>
-          </packing>
         </child>
       </object>
     </child>
