Thank you @fmuellner for your quick response, I tried it and it did not work. I tried to show what is the result of extension by Main.notify(JSON.stringify(extension)) and I got null
gnome-shell imports the extension.js file from your extension
when loading the module, the result of lookupByURL() is assigned to a global variable (the return value is null because there is no such extension yet. The file is only being imported by gnome-shell at the moment)
gnome-shell looks up the default import and instantiates it
the new extension is added to the extensionManager (from now on, lookupByURL() will return the expected extension)
when the extension should be enabled, gnome-shell calls the extension object’s enable() method
That is, don’t try to store the extension in a global variable. Either do the lookup locally (it’s cheap), do it in the ActivitiesButton constructor, or pass the extension object (this) as parameter in enable().
Unrelated, but what is the check for? I don’t see your prefs.js using it (and why would it?), so all the check does is artificially breaking your prefs when the tool is installed in a different location or not installed at all.
Thanks @fmuellner , I have put the lookup extension by url in ActivitiesButton’s constructor and it is working.
Also thanks for the info on check for the tool, I understood that and removed that check.
can you help me with one more thing please, if needs, I will raise a new topic. How to control the width of the extensions preferences window, rite now It is opening like a half the width what I wanted.
Below is some of the code from prefs.js file
export default class MyExtensionPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
this._settings = this.getSettings();
const page = new Adw.PreferencesPage();
const group = new Adw.PreferencesGroup({
title: 'Change Activities Text with Logo and Your Preferred Text',
description: new Date().toLocaleString()
});
this._textColorButton = new Gtk.ColorButton();
this._iconColorButton = new Gtk.ColorButton();
this.setButtonColor(this._iconColorButton, 'icon-color');
this.setButtonColor(this._textColorButton, 'text-color');
this._noTextButton = new Gtk.Button({ margin_start: 5 });
this.widget = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
margin_top: 10,
margin_bottom: 10,
margin_start: 10,
margin_end: 10,
hexpand: true,
});
...
}
You can call window.set_default_size(...) on the window, or the default-width property individually.
However I would strongly recommend to take a good look at the design guidelines.
The window is extremely overloaded, and there is no alignment between widgets from different settings, which gives the whole thing a very chaotic feeling.
You should be able to do a lot better using the existing list row widgets in libadwaita, with probably less code.