[polari] Replace Gtk.Popover.relative_to



commit 337d24c745ed9219c4d7372dfce3d7a084779189
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 8 01:14:30 2021 +0200

    Replace Gtk.Popover.relative_to
    
    It's gone in GTK4.
    
    Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/228>

 src/chatView.js      |  4 ++--
 src/entryArea.js     |  3 ++-
 src/mainWindow.js    |  2 ++
 src/roomList.js      | 12 +++++-------
 src/tabCompletion.js |  2 +-
 5 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 8587b472..2157649b 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -837,10 +837,10 @@ export default GObject.registerClass({
             _('Copy Link Address'), `chatlog.copy-url("${url}")`);
 
         const menu = new Gtk.PopoverMenu({
-            relative_to: this,
             position: Gtk.PositionType.BOTTOM,
             pointing_to: new Gdk.Rectangle({ x, y }),
         });
+        menu.set_parent(this);
         menu.bind_model(section, null);
         menu.popup();
     }
@@ -1483,10 +1483,10 @@ export default GObject.registerClass({
 
         if (!tag._popover) {
             tag._popover = new UserPopover({
-                relative_to: this._view,
                 userTracker: this._userTracker,
                 room: this._room,
             });
+            tag._popover.set_parent(this._view);
         }
 
         tag._popover.nickname = actualNickName;
diff --git a/src/entryArea.js b/src/entryArea.js
index 17629849..37bedb4e 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -182,7 +182,8 @@ export default GObject.registerClass({
                 this._onKeyPressed.bind(this));
         });
         this.connect('map', () => {
-            EntryArea._nickPopover.relative_to = this._nickButton;
+            EntryArea._nickPopover.unparent();
+            EntryArea._nickPopover.set_parent(this._nickButton);
 
             if (this._nickChangedId)
                 return;
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 8b2ac156..81e6dca0 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -126,6 +126,8 @@ export default GObject.registerClass({
 
         super._init(params);
 
+        this._userListPopover.set_parent(this._showUserListButton);
+
         this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
         this._gtkSettings = Gtk.Settings.get_default();
 
diff --git a/src/roomList.js b/src/roomList.js
index 7f25f971..04daed72 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -13,9 +13,9 @@ const MIN_SPINNER_TIME = 1000000;   // in microsecond
 
 function _onPopoverVisibleChanged(popover) {
     if (popover.visible)
-        popover.relative_to.add_css_class('has-open-popup');
+        popover.get_parent().add_css_class('has-open-popup');
     else
-        popover.relative_to.remove_css_class('has-open-popup');
+        popover.get_parent().remove_css_class('has-open-popup');
 }
 
 const RoomRow = GObject.registerClass({
@@ -232,9 +232,9 @@ const RoomRowPopover = GObject.registerClass(
 class RoomRowPopover extends Gtk.Popover {
     _init(row) {
         super._init({
-            relative_to: row,
             position: Gtk.PositionType.BOTTOM,
         });
+        this.set_parent(row);
 
         this.connect('notify::visible', _onPopoverVisibleChanged);
 
@@ -390,14 +390,12 @@ const RoomListHeader = GObject.registerClass({
         if (this._popover === popover)
             return;
 
-        if (this._popover)
-            this._popover.relative_to = null;
+        this._popover?.unparent();
         this._popover?.run_dispose();
 
         this._popover = popover;
 
-        if (this._popover)
-            this._popover.relative_to = this;
+        this._popover?.set_parent(this);
 
         this.notify('popover');
     }
diff --git a/src/tabCompletion.js b/src/tabCompletion.js
index 7d4784a5..6ee6e1a0 100644
--- a/src/tabCompletion.js
+++ b/src/tabCompletion.js
@@ -21,8 +21,8 @@ export default class TabCompletion {
         this._popup = new Gtk.Popover({
             position: Gtk.PositionType.TOP,
             modal: false,
-            relative_to: this._entry,
         });
+        this._popup.set_parent(this._entry);
 
         this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.SINGLE });
         this._list.set_filter_func(this._filter.bind(this));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]