SUPERCILEX / gnome-clipboard-history

Gnome Clipboard History is a clipboard manager Gnome extension that saves what you've copied into an easily accessible, searchable history panel.
https://extensions.gnome.org/extension/4839/clipboard-history/
MIT License
470 stars 46 forks source link

Breaks on Gnome 46 #160

Closed Mershl closed 8 months ago

Mershl commented 8 months ago

Describe the bug

gnome-clipboard-history as of extension version 34 shows the following error when trying to load on Gnome 46.

Extension clipboard-history@alexsaveau.dev: TypeError: hbox.add is not a function

Stack trace:
  _init@file:///var/home/jondoe/.local/share/gnome-shell/extensions/clipboard-history@alexsaveau.dev/extension.js:87:10
  ButtonBox@resource:///org/gnome/shell/ui/panelMenu.js:13:1
  PanelMenuButton@resource:///org/gnome/shell/ui/panelMenu.js:99:4
  ClipboardIndicator@file:///var/home/jondoe/.local/share/gnome-shell/extensions/clipboard-history@alexsaveau.dev/extension.js:64:1
  enable@file:///var/home/jondoe/.local/share/gnome-shell/extensions/clipboard-history@alexsaveau.dev/extension.js:1311:31
  _callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:263:38
  loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:473:32
  async*_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:780:24
  async*_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:786:48
  _sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:821:20
  async*init@resource:///org/gnome/shell/ui/extensionSystem.js:76:14
  _initializeUI@resource:///org/gnome/shell/ui/main.js:302:22
  start@resource:///org/gnome/shell/ui/main.js:176:11
  @resource:///org/gnome/shell/ui/init.js:12:47
  @resource:///org/gnome/shell/ui/init.js:21:20
bulletmark commented 8 months ago

GNOME 46 released mainstream on Arch now so this bug is very prominent.

SUPERCILEX commented 8 months ago

Does everything work if you put add_child here instead: https://github.com/SUPERCILEX/gnome-clipboard-history/blob/9a4d9c0beca6f49b97f613c77022b2f650c3ba2a/extension.js#L87

bulletmark commented 8 months ago

@SUPERCILEX I'll try stuff for you but I am not clear what you want. You mean swap the order of lines 87 and 88?

SUPERCILEX commented 8 months ago

No, the stack trace is saying that the add method was deleted (if you know where I can find release notes, that would be amazing), so I'm just hoping that calling add_child instead will work. Basically replace the word add with add_child.

bulletmark commented 8 months ago

Doesn't seem to be that simple. I changed that line but got the same problem with line 128. Then changed that line (from add to add_child and next got "add_actor" is not a function on line 156.

bulletmark commented 8 months ago

BTW, there is a GNOME doc which seems to talk about this (at least the add_actor change) at https://gjs.guide/extensions/upgrading/gnome-shell-46.html#gjs

bulletmark commented 8 months ago

See this comment from an extension developer also: https://www.reddit.com/r/gnome/comments/1bkwcsv/comment/kw246wq/

bulletmark commented 8 months ago

Made quite a few iterative changes and seems to work ok now. Tested config screen changes etc. Can't be bothered making a PR so here is my diff:

diff --git a/extension.js b/extension.js
index f76b43c..f730b79 100644
--- a/extension.js
+++ b/extension.js
@@ -84,7 +84,7 @@ class ClipboardIndicator extends PanelMenu.Button {
     });
     hbox.add_child(this._buttonText);
     this._downArrow = PopupMenu.arrowIcon(St.Side.BOTTOM);
-    hbox.add(this._downArrow);
+    hbox.add_child(this._downArrow);
     this.add_child(hbox);

     this._fetchSettings();
@@ -125,7 +125,7 @@ class ClipboardIndicator extends PanelMenu.Button {
       reactive: false,
       can_focus: false,
     });
-    entryItem.add(this.searchEntry);
+    entryItem.add_child(this.searchEntry);
     this.menu.addMenuItem(entryItem);

     this.menu.connect('open-state-changed', (self, open) => {
@@ -153,9 +153,9 @@ class ClipboardIndicator extends PanelMenu.Button {
       style_class: 'ci-history-menu-section',
       overlay_scrollbars: true,
     });
-    favoritesScrollView.add_actor(this.favoritesSection.actor);
+    favoritesScrollView.add_child(this.favoritesSection.actor);

-    this.scrollViewFavoritesMenuSection.actor.add_actor(favoritesScrollView);
+    this.scrollViewFavoritesMenuSection.actor.add_child(favoritesScrollView);
     this.menu.addMenuItem(this.scrollViewFavoritesMenuSection);
     this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

@@ -167,9 +167,9 @@ class ClipboardIndicator extends PanelMenu.Button {
       style_class: 'ci-history-menu-section',
       overlay_scrollbars: true,
     });
-    this.historyScrollView.add_actor(this.historySection.actor);
+    this.historyScrollView.add_child(this.historySection.actor);

-    this.scrollViewMenuSection.actor.add_actor(this.historyScrollView);
+    this.scrollViewMenuSection.actor.add_child(this.historyScrollView);

     this.menu.addMenuItem(this.scrollViewMenuSection);

@@ -181,7 +181,7 @@ class ClipboardIndicator extends PanelMenu.Button {
       vertical: false,
     });

-    actionsSection.actor.add(actionsBox);
+    actionsSection.actor.add_child(actionsBox);
     this.menu.addMenuItem(actionsSection);

     const prevPage = new PopupMenu.PopupBaseMenuItem();
@@ -192,7 +192,7 @@ class ClipboardIndicator extends PanelMenu.Button {
       }),
     );
     prevPage.connect('activate', this._navigatePrevPage.bind(this));
-    actionsBox.add(prevPage);
+    actionsBox.add_child(prevPage);

     const nextPage = new PopupMenu.PopupBaseMenuItem();
     nextPage.add_child(
@@ -202,9 +202,9 @@ class ClipboardIndicator extends PanelMenu.Button {
       }),
     );
     nextPage.connect('activate', this._navigateNextPage.bind(this));
-    actionsBox.add(nextPage);
+    actionsBox.add_child(nextPage);

-    actionsBox.add(new St.BoxLayout({ x_expand: true }));
+    actionsBox.add_child(new St.BoxLayout({ x_expand: true }));

     this.privateModeMenuItem = new PopupMenu.PopupSwitchMenuItem(
       _('Private mode'),
@@ -217,7 +217,7 @@ class ClipboardIndicator extends PanelMenu.Button {
         this.privateModeMenuItem.state,
       );
     });
-    actionsBox.add(this.privateModeMenuItem);
+    actionsBox.add_child(this.privateModeMenuItem);
     this._updatePrivateModeState();

     const clearMenuItem = new PopupMenu.PopupBaseMenuItem();
@@ -227,7 +227,7 @@ class ClipboardIndicator extends PanelMenu.Button {
         style_class: 'popup-menu-icon',
       }),
     );
-    actionsBox.add(clearMenuItem);
+    actionsBox.add_child(clearMenuItem);

     const settingsMenuItem = new PopupMenu.PopupBaseMenuItem();
     settingsMenuItem.add_child(
@@ -237,7 +237,7 @@ class ClipboardIndicator extends PanelMenu.Button {
       }),
     );
     settingsMenuItem.connect('activate', this._openSettings.bind(this));
-    actionsBox.add(settingsMenuItem);
+    actionsBox.add_child(settingsMenuItem);

     if (ENABLE_KEYBINDING) {
       this._bindShortcuts();
@@ -1018,7 +1018,7 @@ class ClipboardIndicator extends PanelMenu.Button {
     this._notifSource.connect('destroy', () => {
       this._notifSource = undefined;
     });
-    Main.messageTray.add(this._notifSource);
+    Main.messageTray.add_child(this._notifSource);
   }

   _showNotification(title, message, transformFn) {
road2react commented 8 months ago

I put changes into #161

SUPERCILEX commented 8 months ago

So fast, thanks everybody! I put up the extension for review, will let y'all know when it goes through.

SUPERCILEX commented 8 months ago

Just went live, can you two confirm stuff works?

bulletmark commented 8 months ago

Seems ok.

arinc9 commented 8 months ago

Version 35 breaks the clipboard item list on Gnome 45.2. The list won't appear now.

Screenshot from 2024-03-24 10-40-00

sarowarhosen03 commented 8 months ago

same issu i faced after upgrading it into v 35 ; then i'm manualy intalled the v34 ; butw im gnome 45 user

mh-saeed commented 8 months ago

same issue ... image image

SUPERCILEX commented 8 months ago

Whoops, ok I submitted a revert of the changes for gnome 45 review.

SUPERCILEX commented 8 months ago

Went live.

arinc9 commented 8 months ago

It works again, thanks.

SUPERCILEX commented 8 months ago

Sweet, sounds like everything is settled then.