[polari] roomListHeader: Use layout manager
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomListHeader: Use layout manager
- Date: Sat, 4 Sep 2021 00:53:06 +0000 (UTC)
commit 323e598ef838226557ee4791ecc0c69340191fc9
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Aug 20 06:29:23 2021 +0200
roomListHeader: Use layout manager
Subclassing random widgets is less of a thing in GTK4 where we can
delegate layout to an existing class.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/235>
data/resources/room-list-header.ui | 15 +++++++++++----
src/roomList.js | 16 +++++++++++++++-
2 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/data/resources/room-list-header.ui b/data/resources/room-list-header.ui
index af87dd18..60c65d87 100644
--- a/data/resources/room-list-header.ui
+++ b/data/resources/room-list-header.ui
@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="Gjs_RoomListHeader" parent="GtkGrid">
+ <template class="Gjs_RoomListHeader" parent="GtkWidget">
<property name="popover">connectionPopover</property>
- <property name="column-spacing">6</property>
- <property name="row-spacing">2</property>
- <property name="margin-top">1</property>
<property name="margin-bottom">4</property>
<property name="focusable">True</property>
+ <property name="margin-top">1</property>
+ <property name="layout-manager">
+ <object class="GtkGridLayout">
+ <property name="column-spacing">6</property>
+ <property name="row-spacing">2</property>
+ </object>
+ </property>
<style>
<class name="room-list-header"/>
<class name="activatable"/>
@@ -24,6 +28,9 @@
<object class="GtkStack" id="iconStack">
<property name="transition-type">crossfade</property>
<property name="valign">center</property>
+ <layout>
+ <property name="column">1</property>
+ </layout>
<child>
<object class="GtkStackPage">
<property name="name">disconnected</property>
diff --git a/src/roomList.js b/src/roomList.js
index 331da07a..9ec04423 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -301,7 +301,15 @@ const RoomListHeader = GObject.registerClass({
GObject.ParamFlags.READWRITE,
Gtk.Popover.$gtype),
},
-}, class RoomListHeader extends Gtk.Grid {
+}, class RoomListHeader extends Gtk.Widget {
+ static _classInit(klass) {
+ klass = Gtk.Widget._classInit(klass);
+
+ Gtk.Widget.set_layout_manager_type = Gtk.GridLayout;
+
+ return klass;
+ }
+
_init(params) {
this._account = params.account;
delete params.account;
@@ -381,6 +389,12 @@ const RoomListHeader = GObject.registerClass({
});
}
+ vfunc_unroot() {
+ [...this].forEach(child => child.unparent());
+
+ super.vfunc_unroot();
+ }
+
get popover() {
return this._popover;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]