Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration Gnome Shell 45 #110

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.git*
_build
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { GObject, St, Clutter, Gtk, Pango } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'
import Pango from 'gi://Pango'

var ButtonGroup = GObject.registerClass({

export const ButtonGroup = GObject.registerClass({
GTypeName: 'TaskWhisperer_ButtonGroup',
Signals: {
'clicked': {
Expand All @@ -15,7 +19,7 @@ var ButtonGroup = GObject.registerClass({
})

if (!enableScrollbar) {
this.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
this.set_policy(St.PolicyType.NEVER, St.PolicyType.NEVER)
}

this._selectedButton = buttons.find(item => item.selected)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { GObject, St, Clutter } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
const ComponentsHelper = Me.imports.helpers.components
import * as ComponentsHelper from '../../helpers/components.js'

var IconButton = GObject.registerClass({
export const IconButton = GObject.registerClass({
GTypeName: 'TaskWhisperer_IconButton'
}, class IconButton extends St.Button {
_init ({ icon_name, isCustomIcon, onClick, icon_size = 18, text, style_class, asButton, ...props }
Expand Down
19 changes: 9 additions & 10 deletions taskwhisperer-extension@infinicode.de/components/cards/taskCard.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const { Clutter, GObject, St } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import { isNullOrEmpty } from '../../helpers/data.js'
import { IconButton } from '../buttons/iconButton.js'
import { TaskPriority } from '../../services/meta/taskWarrior.js'
import { setTaskDone, setTaskUndone, startTask, stopTask } from '../../services/taskService.js'

const { isNullOrEmpty } = Me.imports.helpers.data
const { IconButton } = Me.imports.components.buttons.iconButton
const { TaskPriority } = Me.imports.services.meta.taskWarrior
const { setTaskDone, setTaskUndone, startTask, stopTask } = Me.imports.services.taskService

var TaskCard = GObject.registerClass({
export const TaskCard = GObject.registerClass({
GTypeName: 'TaskWhisperer_TaskCard'
}, class TaskCard extends St.Button {
_init (quoteSummary, mainEventHandler) {
Expand Down Expand Up @@ -38,7 +37,7 @@ var TaskCard = GObject.registerClass({
const cardContentBox = new St.BoxLayout({
style_class: 'content-box',
x_expand: true,
y_align: St.Align.MIDDLE
y_align: Clutter.ActorAlign.CENTER
})

const statusIconBin = this._createStatusIconBin()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const { Clutter, GObject, Graphene, St, Gtk } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'
import Graphene from 'gi://Graphene'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import { ScaleLayout } from '../scaleLayout/scaleLayout.js'
import { Translations } from '../../helpers/translations.js'

const { ScaleLayout } = Me.imports.components.scaleLayout.scaleLayout
const { Translations } = Me.imports.helpers.translations
export const MESSAGE_ANIMATION_TIME = 100

var MESSAGE_ANIMATION_TIME = 100

var FlatList = GObject.registerClass({
export const FlatList = GObject.registerClass({
GTypeName: 'TaskWhisperer_FlatList',
Signals: {
'clicked-item': {
Expand All @@ -23,8 +23,8 @@ var FlatList = GObject.registerClass({
x_expand: true,
y_expand: true,
clip_to_allocation: true,
hscrollbar_policy: Gtk.PolicyType.NEVER,
vscrollbar_policy: Gtk.PolicyType.AUTOMATIC
hscrollbar_policy: St.PolicyType.NEVER,
vscrollbar_policy: St.PolicyType.AUTOMATIC
})

this._content = new St.BoxLayout({
Expand Down
10 changes: 4 additions & 6 deletions taskwhisperer-extension@infinicode.de/components/icon/icon.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const { GObject, St } = imports.gi
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import * as ComponentsHelper from '../../helpers/components.js'

const ComponentsHelper = Me.imports.helpers.components

var Icon = GObject.registerClass({
export const Icon = GObject.registerClass({
GTypeName: 'TaskWhisperer_Icon'
}, class Icon extends St.Icon {
_init ({ icon_name, isCustomIcon, ...props }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
const { Clutter, GObject, St } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()

const { SettingsHandler, TASKWHISPERER_SHOW_PANEL_ICON, TASKWHISPERER_SHOW_TEXT_IN_PANEL } = Me.imports.helpers.settings
const { Translations } = Me.imports.helpers.translations
const ComponentsHelper = Me.imports.helpers.components
import { SettingsHandler, TASKWHISPERER_SHOW_PANEL_ICON, TASKWHISPERER_SHOW_TEXT_IN_PANEL } from '../../helpers/settings.js'
import { Translations } from '../../helpers/translations.js'
import * as ComponentsHelper from '../../helpers/components.js'

const SETTING_KEYS_TO_REFRESH = [
TASKWHISPERER_SHOW_PANEL_ICON,
TASKWHISPERER_SHOW_TEXT_IN_PANEL
]

var MenuItem = GObject.registerClass({
export const MenuItem = GObject.registerClass({
GTypeName: 'TaskWhisperer_MenuItem'
}, class MenuItem extends St.BoxLayout {
_init (mainEventHandler) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { Clutter, GObject } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'

var ScaleLayout = GObject.registerClass({
export const ScaleLayout = GObject.registerClass({
GTypeName: 'TaskWhisperer_ScaleLayout'
}, class ScaleLayout extends Clutter.BinLayout {
_init (params) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { GObject, St } = imports.gi
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
const { TaskOverviewScreen } = Me.imports.components.screens.taskOverviewScreen.taskOverviewScreen
const { EditTaskScreen } = Me.imports.components.screens.editTaskScreen.editTaskScreen
import { TaskOverviewScreen } from '../screens/taskOverviewScreen/taskOverviewScreen.js'
import { EditTaskScreen } from '../screens/editTaskScreen/editTaskScreen.js'

var ScreenWrapper = GObject.registerClass({
export const ScreenWrapper = GObject.registerClass({
GTypeName: 'TaskWhisperer_ScreenWrapper'
},
class ScreenWrapper extends St.Widget {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const { Clutter, GObject, St } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import { ButtonGroup } from '../../buttons/buttonGroup.js'
import { SearchBar } from '../../searchBar/searchBar.js'
import { Translations } from '../../../helpers/translations.js'
import { TaskPriority } from '../../../services/meta/taskWarrior.js'
import { createTask, modifyTask } from '../../../services/taskService.js'

const { ButtonGroup } = Me.imports.components.buttons.buttonGroup
const { SearchBar } = Me.imports.components.searchBar.searchBar
const { Translations } = Me.imports.helpers.translations
const { TaskPriority } = Me.imports.services.meta.taskWarrior
const { createTask, modifyTask } = Me.imports.services.taskService

var EditTaskScreen = GObject.registerClass({}, class EditTaskScreen extends St.BoxLayout {
export const EditTaskScreen = GObject.registerClass({}, class EditTaskScreen extends St.BoxLayout {
_init (taskItem, mainEventHandler) {
super._init({
style_class: 'screen edit-task-screen',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
const { Clutter, GObject, St } = imports.gi

const Mainloop = imports.mainloop

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()

const { ButtonGroup } = Me.imports.components.buttons.buttonGroup
const { IconButton } = Me.imports.components.buttons.iconButton
const { FlatList } = Me.imports.components.flatList.flatList
const { TaskCard } = Me.imports.components.cards.taskCard
const { SearchBar } = Me.imports.components.searchBar.searchBar
const { setTimeout, clearTimeout } = Me.imports.helpers.components
const { clearCache } = Me.imports.helpers.data
const { SettingsHandler, TASKWHISPERER_PROJECT, TASKWHISPERER_TASK_ORDER, TASKWHISPERER_TASK_STATUS } = Me.imports.helpers.settings
const { Translations } = Me.imports.helpers.translations
const { TaskOrder, TaskStatus } = Me.imports.services.meta.taskWarrior
const { loadProjectsData, loadTaskData } = Me.imports.services.taskService
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'
import { clearCache } from '../../../helpers/data.js'
import { SettingsHandler, TASKWHISPERER_PROJECT, TASKWHISPERER_TASK_ORDER, TASKWHISPERER_TASK_STATUS } from '../../../helpers/settings.js'
import { Translations } from '../../../helpers/translations.js'
import { TaskOrder, TaskStatus } from '../../../services/meta/taskWarrior.js'
import { loadProjectsData, loadTaskData } from '../../../services/taskService.js'

import { ButtonGroup } from '../../buttons/buttonGroup.js'
import { IconButton } from '../../buttons/iconButton.js'
import { TaskCard } from '../../cards/taskCard.js'
import { FlatList } from '../../flatList/flatList.js'
import { SearchBar } from '../../searchBar/searchBar.js'

const SETTING_KEYS_TO_REFRESH = [
TASKWHISPERER_PROJECT,
TASKWHISPERER_TASK_ORDER,
TASKWHISPERER_TASK_STATUS
]

var TaskOverviewScreen = GObject.registerClass({}, class TaskOverviewScreen extends St.BoxLayout {
export const TaskOverviewScreen = GObject.registerClass({}, class TaskOverviewScreen extends St.BoxLayout {
_init (mainEventHandler) {
super._init({
style_class: 'screen task-overview-screen',
Expand Down Expand Up @@ -105,14 +101,12 @@ var TaskOverviewScreen = GObject.registerClass({}, class TaskOverviewScreen exte

_registerTimeout () {
if (this._autoRefreshTimeoutId) {
Mainloop.source_remove(this._autoRefreshTimeoutId)
clearInterval(this._autoRefreshTimeoutId)
}

this._autoRefreshTimeoutId = Mainloop.timeout_add_seconds(this._settings.ticker_interval || 30, () => {
this._autoRefreshTimeoutId = setInterval(() => {
this._loadData()

return true
})
}, (this._settings.ticker_interval || 30) * 1000)
}

async _loadData () {
Expand Down Expand Up @@ -272,7 +266,7 @@ var TaskOverviewScreen = GObject.registerClass({}, class TaskOverviewScreen exte

_onDestroy () {
if (this._autoRefreshTimeoutId) {
Mainloop.source_remove(this._autoRefreshTimeoutId)
clearInterval(this._autoRefreshTimeoutId)
}

if (this._settingsChangedId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { GObject, St } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import { IconButton } from '../buttons/iconButton.js'
import { Translations } from '../../helpers/translations.js'
import { SettingsHandler } from '../../helpers/settings.js'

const { IconButton } = Me.imports.components.buttons.iconButton
const { Translations } = Me.imports.helpers.translations

var SearchBar = GObject.registerClass({
export const SearchBar = GObject.registerClass({
GTypeName: 'TaskWhisperer_SearchBar',
Signals: {
'text-change': {
Expand Down Expand Up @@ -83,7 +83,7 @@ var SearchBar = GObject.registerClass({
_createButtonBox () {
let buttonBox = new St.BoxLayout({
style_class: 'button-box',
x_align: St.Align.END
x_align: Clutter.ActorAlign.END
})

if (this.additionalIcons) {
Expand All @@ -105,8 +105,9 @@ var SearchBar = GObject.registerClass({
icon_name: 'emblem-system-symbolic',
icon_size: 18,
onClick: () => {
const settings = new SettingsHandler()
this._mainEventHandler.emit('hide-panel')
ExtensionUtils.openPrefs();
settings.extensionObject.openPreferences();
}
})
buttonBox.add_child(settingsIconButton)
Expand Down
64 changes: 38 additions & 26 deletions taskwhisperer-extension@infinicode.de/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@
*
*/

const { Clutter, GObject, St } = imports.gi
import Clutter from 'gi://Clutter'
import GObject from 'gi://GObject'
import St from 'gi://St'

const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import { Extension, gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js'
import * as Main from 'resource:///org/gnome/shell/ui/main.js'
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'

const { MenuItem } = Me.imports.components.panel.menuItem
const { ScreenWrapper } = Me.imports.components.screenWrapper.screenWrapper
const { EventHandler } = Me.imports.helpers.eventHandler
const { SettingsHandler } = Me.imports.helpers.settings

const Gettext = imports.gettext
const _ = Gettext.gettext

const Main = imports.ui.main
const PanelMenu = imports.ui.panelMenu
import { MenuItem } from './components/panel/menuItem.js'
import { ScreenWrapper } from './components/screenWrapper/screenWrapper.js'
import { EventHandler } from './helpers/eventHandler.js'
import { initSettings, SettingsHandler } from './helpers/settings.js'
import { CLEANUP_PROCEDURES as SUBPROCESS_CLEANUP_PROCEDURES } from './helpers/subprocess.js'

const MenuPosition = {
CENTER: 0,
Expand Down Expand Up @@ -125,21 +123,35 @@ let TaskWhispererMenuButton = GObject.registerClass(class TaskWhispererMenuButto
}
})

var taskWhispererMenu
let _taskWhispererMenu = null

function init (extensionMeta) {
ExtensionUtils.initTranslations()
}
export default class KubectlExtension extends Extension {
enable () {
initSettings(this)

function enable () {
taskWhispererMenu = new TaskWhispererMenuButton()
Main.panel.addToStatusArea('taskWhispererMenu', taskWhispererMenu)
taskWhispererMenu.checkPositionInPanel()
}
_taskWhispererMenu = new TaskWhispererMenuButton()
Main.panel.addToStatusArea('taskWhispererMenu', _taskWhispererMenu)
_taskWhispererMenu.checkPositionInPanel()
}

function disable () {
if (taskWhispererMenu) {
taskWhispererMenu.destroy()
taskWhispererMenu = null
disable () {
if (_taskWhispererMenu) {
this.cleanUp()
_taskWhispererMenu.destroy()
_taskWhispererMenu = null
}
}

cleanUp () {
[SUBPROCESS_CLEANUP_PROCEDURES].forEach(procedureMap => {
Object.keys(procedureMap).forEach(timeoutId => {
try {
clearTimeout(timeoutId)
procedureMap[timeoutId].call()
} catch (e) {

}
})
})
}
}
Loading
Loading