Skip to content

Commit

Permalink
appmenu: add support for application icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Oct 17, 2023
1 parent 1d6cef1 commit eb08c83
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions unite@hardpixel.eu/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export const AppmenuLabel = GObject.registerClass(
this._container = new St.BoxLayout({ style_class: 'panel-status-menu-box' })
bin.set_child(this._container)

this._icon = new St.Icon()
this._icon.set_icon_size(16, 16)
this._icon.set_fallback_gicon(null)

this._iconBox = new St.Bin({ style_class: 'app-menu-icon', y_align: Clutter.ActorAlign.CENTER })
this._iconBox.set_child(this._icon)
this._container.add_actor(this._iconBox)

this._label = new St.Label({ y_align: Clutter.ActorAlign.CENTER })
this._container.add_actor(this._label)

Expand All @@ -32,15 +40,28 @@ export const AppmenuLabel = GObject.registerClass(
this._menuManager = Main.panel.menuManager
this._menuManager.addMenu(menu)

const iconEffect = new Clutter.DesaturateEffect()
this._iconBox.add_effect(iconEffect)

this._iconBox.connect('style-changed', () => {
const themeNode = this._iconBox.get_theme_node()
iconEffect.enabled = themeNode.get_icon_style() === St.IconStyle.SYMBOLIC
})

this.setText(text || '')
this.add_style_class_name('app-menu-label')
}

setApp(app) {
this.setIcon(app.get_icon())
this.setText(app.get_name())
this.menu.setApp(app)
}

setIcon(icon) {
this._icon.set_gicon(icon)
}

setText(text) {
this._label.set_text(text)
}
Expand Down

0 comments on commit eb08c83

Please sign in to comment.