Skip to content

Commit

Permalink
fix: Support v46 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantehemerson authored Jun 3, 2024
1 parent dd2377e commit 1a50a3d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: all clean remake

all: schemas/gschemas.compiled

schemas/gschemas.compiled: schemas/org.gnome.shell.extensions.one-thing.gschema.xml
glib-compile-schemas schemas/

clean:
rm -f schemas/gschemas.compiled

remake: clean all
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ dconf write /org/gnome/shell/extensions/one-thing/thing-value "'My todo'"
- Place this folder in **~/.local/share/gnome-shell/extensions**
- Rename the folder to **one-thing<span>@</span>github.com** so the gnome
shell will find it
- Build schemas with:
```
npm run build-schemas
```
- **Debug extension:**
* X11: Reload gnome shell by pressing **Alt-F2** and then submit the
**r** command
Expand Down
7 changes: 6 additions & 1 deletion entryMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export class EntryMenu extends PopupMenu.PopupMenu {
});
this.addMenuItem(item);

Main.uiGroup.add_actor(this.actor);
if (typeof Main.uiGroup.add_child === 'function') {
Main.uiGroup.add_child(this.actor);
} else {
Main.uiGroup.add_actor(this.actor);
}

this.actor.hide();
}

Expand Down
8 changes: 7 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Shell from 'gi://Shell';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import {Extension, InjectionManager} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as Config from 'resource:///org/gnome/shell/misc/config.js';

const [major] = Config.PACKAGE_VERSION.split('.');
const GNOME_MAJOR_VERSION = Number.parseInt(major);

import Widget from './widget.js';

Expand Down Expand Up @@ -82,7 +86,9 @@ export default class OneThingGnome extends Extension {
_checkIfRightBoxIsSelected() {
let isRightBoxChosen = this._settings.get_int('location-in-status-bar') === 2;
if (isRightBoxChosen) {
this._actorAddedSignal = Main.panel._rightBox.connect('actor-added', () => {
const childAddedName = GNOME_MAJOR_VERSION >= 46 ? 'child-added' : 'actor-added';
this._actorAddedSignal = Main.panel._rightBox.connect(childAddedName
, () => {
this._insertChildToPanel();
});
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"scripts": {
"pack": "rm -rf [email protected] && zip [email protected] LICENSE assets/* entryMenu.js extension.js metadata.json prefs.js prefs/* schemas/* stylesheet.css widget.js"
"build-schemas": "make",
"pack": "rm -rf [email protected] && zip [email protected] LICENSE assets/* entryMenu.js extension.js metadata.json prefs.js prefs/* schemas/*.xml stylesheet.css widget.js"
},
"devDependencies": {
"eslint-plugin-jsdoc": "^46.8.2"
Expand Down
23 changes: 19 additions & 4 deletions widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ const Widget = new GObject.registerClass(
reactive: false,
});

menuItem.add_actor(this.inputText);
if (typeof menuItem.add_child === 'function') {
menuItem.add_child(this.inputText);
} else {
menuItem.add_actor(this.inputText);
}

this.menu.addMenuItem(menuItem);
}

Expand All @@ -104,13 +109,23 @@ const Widget = new GObject.registerClass(
gicon: Gio.icon_new_for_string(path),
});

oneThingContainer.add(this.icon);
oneThingContainer.add(this.panelText);
if (typeof oneThingContainer.add_child === 'function') {
oneThingContainer.add_child(this.icon);
oneThingContainer.add_child(this.panelText);
} else {
oneThingContainer.add(this.icon);
oneThingContainer.add(this.panelText);
}


const textValue = this.panelText.get_text();
this._showIconIfTextEmpty(textValue);

this.add_actor(oneThingContainer);
if (typeof this.add_child === 'function') {
this.add_child(oneThingContainer);
} else {
this.add_actor(oneThingContainer);
}
}

_initEvents() {
Expand Down

0 comments on commit 1a50a3d

Please sign in to comment.