Skip to content

Commit

Permalink
Merge pull request #345 from hardpixel/gnome45
Browse files Browse the repository at this point in the history
Port to gnome 45
  • Loading branch information
jonian authored Oct 15, 2023
2 parents ecd29f7 + a7292e2 commit 06b2f2e
Show file tree
Hide file tree
Showing 22 changed files with 457 additions and 2,121 deletions.
71 changes: 51 additions & 20 deletions [email protected]/buttons.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
const GObject = imports.gi.GObject
const St = imports.gi.St
const Clutter = imports.gi.Clutter
const Main = imports.ui.main
const AppMenu = Main.panel.statusArea.appMenu
const PanelMenu = imports.ui.panelMenu

var DesktopLabel = GObject.registerClass(
import GObject from 'gi://GObject'
import St from 'gi://St'
import Clutter from 'gi://Clutter'
import { AppMenu } from 'resource:///org/gnome/shell/ui/appMenu.js'
import * as Main from 'resource:///org/gnome/shell/ui/main.js'
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'

export const AppmenuLabel = GObject.registerClass(
class UniteAppmenuLabel extends PanelMenu.Button {
_init(text) {
super._init(0.0, null, true)

const menu = new AppMenu(this)
this.setMenu(menu)

this._menuManager = Main.panel.menuManager
this._menuManager.addMenu(menu)

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

this.reactive = false
this.label_actor = this._label

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

setApp(app) {
this.setText(app ? app.get_name() : '')
this.menu.setApp(app)
}

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

setReactive(reactive) {
this.reactive = reactive
}

setVisible(visible) {
this.container.visible = visible
}
}
)

export const DesktopLabel = GObject.registerClass(
class UniteDesktopLabel extends PanelMenu.Button {
_init(text) {
super._init(0.0, null, true)
Expand All @@ -26,17 +66,14 @@ var DesktopLabel = GObject.registerClass(

setVisible(visible) {
this.container.visible = visible
AppMenu.container.visible = !visible
}
}
)

var TrayIndicator = GObject.registerClass(
export const TrayIndicator = GObject.registerClass(
class UniteTrayIndicator extends PanelMenu.Button {
_init(size) {
this._size = size || 20
_init() {
this._icons = []

super._init(0.0, null, true)

this._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' })
Expand All @@ -46,11 +83,6 @@ var TrayIndicator = GObject.registerClass(
this._sync()
}

get size() {
const context = St.ThemeContext.get_for_stage(global.stage)
return this._size * context.scale_factor
}

_sync() {
this.visible = this._icons.length > 0
}
Expand All @@ -67,7 +99,6 @@ var TrayIndicator = GObject.registerClass(
ibtn.connect('button-release-event', (actor, event) => icon.click(event))

icon.set_reactive(true)
icon.set_size(this.size, this.size)
icon.set_x_align(Clutter.ActorAlign.CENTER)
icon.set_y_align(Clutter.ActorAlign.CENTER)

Expand All @@ -90,7 +121,7 @@ var TrayIndicator = GObject.registerClass(
}
)

var WindowControls = GObject.registerClass(
export const WindowControls = GObject.registerClass(
class UniteWindowControls extends PanelMenu.Button {
_init() {
super._init(0.0, null, true)
Expand Down
52 changes: 20 additions & 32 deletions [email protected]/convenience.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const Gettext = imports.gettext
const GObject = imports.gi.GObject
const Gio = imports.gi.Gio
const Config = imports.misc.config
const Me = imports.misc.extensionUtils.getCurrentExtension()
import GObject from 'gi://GObject'
import Gio from 'gi://Gio'

var SettingsObject = GObject.registerClass(
export const SettingsObject = GObject.registerClass(
class UniteSettingsObject extends Gio.Settings {
exists(key) {
return this.settings_schema.has_key(key)
Expand All @@ -20,7 +17,7 @@ var SettingsObject = GObject.registerClass(
}
)

var SettingsManager = GObject.registerClass(
export const SettingsManager = GObject.registerClass(
class UniteSettings extends Gio.Settings {
get DEFAULT_BINDING() {
return Gio.SettingsBindFlags.DEFAULT
Expand All @@ -31,22 +28,18 @@ var SettingsManager = GObject.registerClass(
'autofocus-windows': 'boolean',
'hide-activities-button': 'enum',
'show-window-title': 'enum',
'show-appmenu-button': 'boolean',
'show-desktop-name': 'boolean',
'desktop-name-text': 'string',
'extend-left-box': 'boolean',
'notifications-position': 'enum',
'use-system-fonts': 'boolean',
'show-legacy-tray': 'boolean',
'greyscale-tray-icons': 'boolean',
'show-window-buttons': 'enum',
'window-buttons-theme': 'select',
'hide-window-titlebars': 'enum',
'enable-titlebar-actions': 'boolean',
'window-buttons-placement': 'enum',
'hide-dropdown-arrows': 'boolean',
'hide-aggregate-menu-arrow': 'boolean',
'hide-app-menu-arrow': 'boolean',
'hide-app-menu-icon': 'boolean',
'reduce-panel-spacing': 'boolean',
'restrict-to-primary-screen': 'boolean',
'app-menu-max-width': 'int',
Expand Down Expand Up @@ -88,7 +81,7 @@ var SettingsManager = GObject.registerClass(
}
)

var PreferencesManager = GObject.registerClass(
export const PreferencesManager = GObject.registerClass(
class UnitePreferences extends Gio.Settings {
get window_buttons_position() {
let setting = this.get_string('button-layout')
Expand Down Expand Up @@ -118,24 +111,11 @@ var PreferencesManager = GObject.registerClass(
}
)

function initTranslations(domain) {
let textDomain = domain || Me.metadata['gettext-domain']
let localeDir = Me.dir.get_child('locale')

if (localeDir.query_exists(null)) {
localeDir = localeDir.get_path()
} else {
localeDir = Config.LOCALEDIR
}

Gettext.bindtextdomain(textDomain, localeDir)
}

function getSettings(schema) {
schema = schema || Me.metadata['settings-schema']
export function getSettings(schema) {
schema = schema || 'org.gnome.shell.extensions.unite'

let gioSSS = Gio.SettingsSchemaSource
let schemaDir = Me.dir.get_child('schemas')
let schemaDir = getDir().get_child('schemas')
let schemaSource = gioSSS.get_default()

if (schemaDir.query_exists(null)) {
Expand All @@ -146,7 +126,7 @@ function getSettings(schema) {
let schemaObj = schemaSource.lookup(schema, true)

if (!schemaObj) {
let metaId = Me.metadata.uuid
let metaId = '[email protected]'
let message = `Schema ${schema} could not be found for extension ${metaId}.`

throw new Error(`${message} Please check your installation.`)
Expand All @@ -155,12 +135,20 @@ function getSettings(schema) {
return new SettingsManager({ settings_schema: schemaObj })
}

function getPreferences() {
export function getPreferences() {
let schemaId = 'org.gnome.desktop.wm.preferences'
return new PreferencesManager({ schema_id: schemaId })
}

function getInterface() {
export function getInterface() {
let schemaId = 'org.gnome.desktop.interface'
return new SettingsObject({ schema_id: schemaId })
}

export function getDir() {
return Gio.File.new_for_uri(import.meta.url).get_parent()
}

export function getPath() {
return getDir().get_path()
}
83 changes: 36 additions & 47 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,40 @@
const GObject = imports.gi.GObject
const Main = imports.ui.main
const Me = imports.misc.extensionUtils.getCurrentExtension()
const Handlers = Me.imports.handlers
const PanelManager = Me.imports.panel.PanelManager
const LayoutManager = Me.imports.layout.LayoutManager
const WindowManager = Me.imports.window.WindowManager

var UniteExtension = GObject.registerClass(
class UniteExtension extends GObject.Object {
_init() {
this.panelManager = new PanelManager()
this.layoutManager = new LayoutManager()
this.windowManager = new WindowManager()
}

get focusWindow() {
return this.windowManager.focusWindow
}

activate() {
Handlers.resetGtkStyles()

this.panelManager.activate()
this.layoutManager.activate()
this.windowManager.activate()

Main.panel.add_style_class_name('unite-shell')
}

destroy() {
Handlers.resetGtkStyles()

this.panelManager.destroy()
this.layoutManager.destroy()
this.windowManager.destroy()

Main.panel.remove_style_class_name('unite-shell')
}
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'
import * as Main from 'resource:///org/gnome/shell/ui/main.js'
import * as Handlers from './handlers.js'
import { PanelManager } from './panel.js'
import { LayoutManager } from './layout.js'
import { WindowManager } from './window.js'

export default class UniteExtension extends Extension {
enable() {
global.unite = this

this.panelManager = new PanelManager()
this.layoutManager = new LayoutManager()
this.windowManager = new WindowManager()

Handlers.resetGtkStyles()

this.panelManager.activate()
this.layoutManager.activate()
this.windowManager.activate()

Main.panel.add_style_class_name('unite-shell')
}
)

function enable() {
global.unite = new UniteExtension()
global.unite.activate()
}
disable() {
Handlers.resetGtkStyles()

function disable() {
global.unite.destroy()
global.unite = null
this.panelManager.destroy()
this.layoutManager.destroy()
this.windowManager.destroy()

Main.panel.remove_style_class_name('unite-shell')

global.unite = null
}

get focusWindow() {
return this.windowManager.focusWindow
}
}
Loading

0 comments on commit 06b2f2e

Please sign in to comment.