os-js / osjs-client

OS.js Client Module
https://manual.os-js.org/
Other
31 stars 31 forks source link

Adding text to application window header #157

Closed mahsashadi closed 3 years ago

mahsashadi commented 3 years ago

I need some text to be added beside application name in window header.

when I open a file in my application, with open dialog it will be done, but I need the same when I open my application through right-click on file in file-manager application.

andersevenrud commented 3 years ago

Just change your initial window title, i.e. in the window option where it takes the title from metadata normally.

andersevenrud commented 3 years ago

Here's a handy function:

function setWindowTitleSuffixed(core, proc, win) {
  // This also does translations... nice!
  const {translatableFlat} = this.core.make('osjs/locale');
  const prefix = translatableFlat(proc.metadata.title);

  return (suffix)  => suffix ? win.setTitle(`${prefix} - ${suffix}`) : prefix
}

// usage
const setTitle = setWindowTitleSuffixed(core, proc, win)
setTitle('something') // -> 'Application Name - something'

You can use that for your basic application as well (this is actually very close to what it does internally). If you wanna override that behaviour, you can just hook into the instance:

basic.updateWindowTitle = function() {
  // this.win here
}
mahsashadi commented 3 years ago

Just change your initial window title

Oops! sorry,I did not check the win.setTitle() function.

Here's a handy function:

Thanks a lot :+1: