The current code looks like:
AddOrangeBorderToFocusedWindow() {
let win = Display.get_focus_window();
if (!win) {
return;
}
// Get the window actor
let windowActor = win.get_compositor_private();
if (!windowActor) {
return;
}
// Add a CSS class to style the border
windowActor.add_style_class_name('focused-orange-border');
}
stylesheet.css
looks like:
.focused-orange-border {
border: 2px solid orange !important;
border-radius: 4px;
}
I am getting error Error org.gnome.gjs.JSError.TypeError: windowActor.add_style_class_name is not a function
What i want to do is, one function will add the css to the window. Another function will remove the css class, restoring the previous state.
To give some context, I want to mark few windows (will mark one focused window at a time). Then run an operation on marked windows.
I am doing it using:
_get_marked_windows = function () {
let markedWindows = [];
try {
let markedWindowsVariant = global.get_persistent_state('ai', 'marked_windows');
if (markedWindowsVariant) {
markedWindows = markedWindowsVariant.deep_unpack();
}
} catch (error) {
log(`Error : ${error}`);
// Set default value for persistent state if needed
// global.set_persistent_state('marked_windows', GLib.Variant.new('ai', markedWindows));
}
return markedWindows;
}
MarkWindows() {
let win = Display.get_focus_window();
let winID = win.get_id();
let markedWindows = this._get_marked_windows();
// log(`Marked Windows : ${markedWindows}`);
let mySet = new Set(markedWindows);
if (mySet.has(winID)) {
mySet.delete(winID);
} else {
mySet.add(winID);
}
markedWindows = Array.from(mySet);
let variantArray = GLib.Variant.new('ai', markedWindows);
// Save the variant array to persistent state
global.set_persistent_state('marked_windows', variantArray);
let jsonResult = JSON.stringify(markedWindows);
return jsonResult;
}
Now i need a visual indicator so that I know which window is marked. As you can see, MarkWindows
toggle the mark. So, when it is marked, it will have orange border, when mark removed it will be on previous state.
How can I do that?