[polari] entryArea: Stop using MenuButton for nick button
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] entryArea: Stop using MenuButton for nick button
- Date: Fri, 3 Sep 2021 09:45:13 +0000 (UTC)
commit a427b8aadde0fc9d7906bab2e0eac31519daca7e
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Aug 23 21:24:09 2021 +0200
entryArea: Stop using MenuButton for nick button
In GTK4, we don't have access to a menu button's label without poking
at internals. The less ugly alternative is to use a regular toggle
button and take care of popping up the popover ourselves.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/225>
data/resources/entry-area.ui | 2 +-
src/entryArea.js | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/data/resources/entry-area.ui b/data/resources/entry-area.ui
index 5d4c2f75..dd0c33ef 100644
--- a/data/resources/entry-area.ui
+++ b/data/resources/entry-area.ui
@@ -17,7 +17,7 @@
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<child>
- <object class="GtkMenuButton" id="nickButton">
+ <object class="GtkToggleButton" id="nickButton">
<property name="visible">True</property>
<property name="receives-default">True</property>
<property name="focus-on-click">False</property>
diff --git a/src/entryArea.js b/src/entryArea.js
index 4836a30c..304c8624 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -177,6 +177,7 @@ export default GObject.registerClass({
this._ircParser = new IrcParser(this._room);
this._maxNickChars = MAX_NICK_CHARS;
this._nickChangedId = 0;
+ this._popoverClosedId = 0;
super._init(params);
@@ -191,11 +192,14 @@ export default GObject.registerClass({
this._onKeyPressed.bind(this));
});
this.connect('map', () => {
- this._nickButton.popover = EntryArea._nickPopover;
+ EntryArea._nickPopover.relative_to = this._nickButton;
if (this._nickChangedId)
return;
+ this._popoverCloseId = EntryArea._nickPopover.connect('closed',
+ () => (this._nickButton.active = false));
+
this._nickChangedId = EntryArea._nickPopover.connect('nick-changed',
() => {
this._setNick(EntryArea._nickPopover.nick);
@@ -207,6 +211,16 @@ export default GObject.registerClass({
if (this._nickChangedId)
EntryArea._nickPopover.disconnect(this._nickChangedId);
this._nickChangedId = 0;
+
+ if (this._popoverClosedId)
+ EntryArea._nickPopover.disconnect(this._popoverClosedId);
+ this._popoverClosedId = 0;
+ });
+ this._nickButton.connect('toggled', () => {
+ if (this._nickButton.active)
+ EntryArea._nickPopover.popup();
+ else
+ EntryArea._nickPopover.popdown();
});
this._nickLabel.width_chars = this._maxNickChars;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]