Skip to content

Commit

Permalink
gnome 46 compatiblity fixes #102 (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
cinatic authored Apr 23, 2024
1 parent 6786dc6 commit 7944f24
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 50 deletions.
2 changes: 1 addition & 1 deletion stocks@infinicode.de/components/buttons/buttonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ButtonGroup = GObject.registerClass({
})
innerContentBox.add_child(this._content)

this.add_actor(innerContentBox)
this.add_child(innerContentBox)

this.connect('destroy', this._onDestroy.bind(this))

Expand Down
5 changes: 3 additions & 2 deletions stocks@infinicode.de/components/cards/stockCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export const StockCard = GObject.registerClass({
vertical: true
})

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.TODAY),
this._createDetailItemValueForChange(transactionResult.today, quoteSummary.CurrencySymbol, transactionResult.todayPercent)
))
Expand All @@ -296,7 +296,7 @@ export const StockCard = GObject.registerClass({
vertical: true
})

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.TOTAL),
this._createDetailItemValueForChange(transactionResult.total, quoteSummary.CurrencySymbol, transactionResult.totalPercent)
))
Expand All @@ -322,6 +322,7 @@ export const StockCard = GObject.registerClass({
style_class: 'detail-item-label-bin',
x_expand: true,
y_expand: false,
x_align: Clutter.ActorAlign.START,
child: new St.Label({ style_class: 'detail-item-label small-text fwb', text })
})

Expand Down
12 changes: 7 additions & 5 deletions stocks@infinicode.de/components/cards/transactionCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ export const TransactionCard = GObject.registerClass({
vertical: true
})

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.TODAY),
this._createDetailItemValueForChange(transaction.today, quoteSummary.CurrencySymbol, transaction.todayPercent)
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.VALUE),
this._createDetailItemValue(`${roundOrDefault(transaction.value, '--')} ${quoteSummary.CurrencySymbol}`)
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.REALIZED),
this._createDetailItemValueForChange(transaction.realized, quoteSummary.CurrencySymbol, transaction.realizedPercent)
))
Expand All @@ -165,12 +165,12 @@ export const TransactionCard = GObject.registerClass({
vertical: true
})

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.TOTAL),
this._createDetailItemValueForChange(transaction.total, quoteSummary.CurrencySymbol, transaction.totalPercent)
))

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.COST),
this._createDetailItemValue(`${roundOrDefault(transaction.cost, '--')} ${quoteSummary.CurrencySymbol}`)
))
Expand All @@ -196,6 +196,7 @@ export const TransactionCard = GObject.registerClass({
style_class: 'detail-item-label-bin',
x_expand: true,
y_expand: false,
x_align: Clutter.ActorAlign.START,
child: new St.Label({ style_class: 'detail-item-label', text })
})

Expand All @@ -207,6 +208,7 @@ export const TransactionCard = GObject.registerClass({
style_class: 'detail-item-value-bin',
x_expand: true,
y_expand: false,
x_align: Clutter.ActorAlign.END,
child: new St.Label({ style_class: `detail-item-value tar ${additionalStyleClass || ''}`, text: text.toString() })
})

Expand Down
14 changes: 8 additions & 6 deletions stocks@infinicode.de/components/cards/transactionSummaryCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ export const TransactionSummaryCard = GObject.registerClass({
vertical: true
})

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.TODAY),
this._createDetailItemValueForChange(transactionResult.today, quoteSummary.CurrencySymbol, transactionResult.todayPercent)
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.VALUE),
this._createDetailItemValue(`${roundOrDefault(transactionResult.value, '--')} ${quoteSummary.CurrencySymbol}`)
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.ALLTIME),
this._createDetailItemValueForChange(transactionResult.alltime, quoteSummary.CurrencySymbol, transactionResult.alltimePercent)
))
Expand All @@ -178,17 +178,17 @@ export const TransactionSummaryCard = GObject.registerClass({
vertical: true
})

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.MISC.TOTAL),
this._createDetailItemValueForChange(transactionResult.total, quoteSummary.CurrencySymbol, transactionResult.totalPercent)
))

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.COST),
this._createDetailItemValue(`${roundOrDefault(transactionResult.unrealizedCost, '--')} ${quoteSummary.CurrencySymbol}`)
))

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.REALIZED),
this._createDetailItemValueForChange(transactionResult.realized, quoteSummary.CurrencySymbol, transactionResult.realizedPercent)
))
Expand All @@ -214,6 +214,7 @@ export const TransactionSummaryCard = GObject.registerClass({
style_class: 'detail-item-label-bin',
x_expand: true,
y_expand: false,
x_align: Clutter.ActorAlign.START,
child: new St.Label({ style_class: 'detail-item-label', text })
})

Expand All @@ -225,6 +226,7 @@ export const TransactionSummaryCard = GObject.registerClass({
style_class: 'detail-item-value-bin',
x_expand: true,
y_expand: false,
x_align: Clutter.ActorAlign.END,
child: new St.Label({ style_class: `detail-item-value tar ${additionalStyleClass || ''}`, text: text.toString() })
})

Expand Down
11 changes: 5 additions & 6 deletions stocks@infinicode.de/components/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Chart = GObject.registerClass({
const fgColor = themeNode.get_foreground_color()

const newColorString = getComplementaryColor(fgColor.to_string().slice(1, 7), false)
const secondaryColor = Clutter.color_from_string(`${newColorString}ff`)[1]
const secondaryColor = Clutter.Color.from_string(`${newColorString}ff`)[1]

const baseParams = {
cairoContext,
Expand All @@ -87,7 +87,7 @@ export const Chart = GObject.registerClass({
// scale data to width / height of our cairo canvas
const seriesData = this._transformSeriesData(this.data, width, height)

Clutter.cairo_set_source_color(cairoContext, primaryColor)
cairoContext.setSourceRGBA(primaryColor.red, primaryColor.green, primaryColor.blue, 0.4);

// get first data
const [firstValueX, firstValueY] = [0, 0]
Expand Down Expand Up @@ -127,7 +127,7 @@ export const Chart = GObject.registerClass({
const barWidth = 3
const barWidthPerSide = barWidth / 3 // left, middle, right

Clutter.cairo_set_source_color(cairoContext, secondaryColor)
cairoContext.setSourceRGBA(secondaryColor.red, secondaryColor.green, secondaryColor.blue, 0.5);

cairoContext.moveTo(0, height)

Expand Down Expand Up @@ -190,15 +190,14 @@ export const Chart = GObject.registerClass({
y1,
y2,
cairoContext,
color: Clutter.color_from_string('#ff0000ff')[1],
color: Clutter.Color.from_string('#ff0000ff')[1],
lineWidth: 1.5
})
})
}

draw_line ({ x1, x2, y1, y2, cairoContext, color, dashed, lineWidth = 0.5 }) {
Clutter.cairo_set_source_color(cairoContext, color)

cairoContext.setSourceRGBA(color.red, color.green, color.blue, 1);
cairoContext.setLineWidth(lineWidth)

if (dashed) {
Expand Down
14 changes: 5 additions & 9 deletions stocks@infinicode.de/components/flatList/flatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const FlatList = GObject.registerClass({
this.enable_persistent_scroll_position()
}

this.add_actor(this._content)
this.add_child(this._content)

this.connect('destroy', this._onDestroy.bind(this))
}
Expand All @@ -59,19 +59,15 @@ export const FlatList = GObject.registerClass({
enable_persistent_scroll_position () {
const cacheKey = `${this._id}_scroll_position`;
this.connect('scroll-event', () => {
cacheOrDefault(cacheKey, () => this.vscroll.adjustment.value, -1)
})

this.vscroll.connect('scroll-stop', () => {
cacheOrDefault(cacheKey, () => this.vscroll.adjustment.value, -1)
cacheOrDefault(cacheKey, () => this.vadjustment.value, -1)
})

this._content.connect('stage-views-changed', async () => {
const savedScrollPosition = await cacheOrDefault(cacheKey, () => this.vscroll.adjustment.value, 365 * 24 * 60 * 60 * 1000)
const savedScrollPosition = await cacheOrDefault(cacheKey, () => this.vadjustment.value, 365 * 24 * 60 * 60 * 1000)

this._resetScrollPositionTimeoutId = setTimeout(() => {
if (this.vscroll.adjustment.value !== savedScrollPosition) {
this.vscroll.adjustment.value = savedScrollPosition
if (this.vadjustment.value !== savedScrollPosition) {
this.vadjustment.value = savedScrollPosition
}
}, 150)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const ScreenWrapper = GObject.registerClass({

this.destroy_all_children()

this.add_actor(screen)
this.add_child(screen)
}

_onDestroy () {
Expand Down
3 changes: 2 additions & 1 deletion stocks@infinicode.de/components/searchBar/searchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const SearchBar = GObject.registerClass({
_createSearchArea ({ showFilterInputBox }) {
const searchInputBox = new St.BoxLayout({
style_class: 'search-area-box',
x_expand: true
x_expand: true,
x_align: Clutter.ActorAlign.START
})

if (this.back_screen_name) {
Expand Down
30 changes: 16 additions & 14 deletions stocks@infinicode.de/components/stocks/stockDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,41 +136,41 @@ export const StockDetails = GObject.registerClass({
vertical: true
})

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.SYMBOL),
this._createDetailItemValue(quoteSummary.Symbol)
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.CHANGE),
this._createDetailItemValueForChange(quoteSummary.Change, quoteSummary.CurrencySymbol, quoteSummary.ChangePercent)
))

if (quoteSummary.MarketState === MARKET_STATES.PRE) {
leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.CHANGE_PRE_MARKET),
this._createDetailItemValueForChange(quoteSummary.PreMarketChange, quoteSummary.CurrencySymbol, quoteSummary.PreMarketChangePercent)
))
}

if (quoteSummary.MarketState === MARKET_STATES.POST) {
leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.CHANGE_POST_MARKET),
this._createDetailItemValueForChange(quoteSummary.PostMarketChange, quoteSummary.CurrencySymbol, quoteSummary.PostMarketChangePercent)
))
}

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.OPEN),
this._createDetailItemValue(roundOrDefault(quoteSummary.Open))
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.HIGH),
this._createDetailItemValue(roundOrDefault(quoteSummary.High))
))

leftDetailBox.add(this._createDetailItem(
leftDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.TIME),
this._createDetailItemValue(toLocalDateFormat(quoteSummary.Timestamp, Translations.FORMATS.DEFAULT_DATE_TIME))
))
Expand All @@ -186,41 +186,41 @@ export const StockDetails = GObject.registerClass({
vertical: true
})

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.EXCHANGE),
this._createDetailItemValue(quoteSummary.ExchangeName || Translations.UNKNOWN)
))

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.PREVIOUS_CLOSE),
this._createDetailItemValue(roundOrDefault(quoteSummary.PreviousClose))
))

if (quoteSummary.MarketState === MARKET_STATES.PRE) {
rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.TIME_PRE_MARKET),
this._createDetailItemValue(toLocalDateFormat(quoteSummary.PreMarketTimestamp, Translations.FORMATS.DEFAULT_DATE_TIME))
))
}

if (quoteSummary.MarketState === MARKET_STATES.POST) {
rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.TIME_POST_MARKET),
this._createDetailItemValue(toLocalDateFormat(quoteSummary.PostMarketTimestamp, Translations.FORMATS.DEFAULT_DATE_TIME))
))
}

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.CLOSE),
this._createDetailItemValue(roundOrDefault(quoteSummary.Close))
))

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.LOW),
this._createDetailItemValue(roundOrDefault(quoteSummary.Low))
))

rightDetailBox.add(this._createDetailItem(
rightDetailBox.add_child(this._createDetailItem(
this._createDetailItemLabel(Translations.STOCKS.VOLUME),
this._createDetailItemValue(fallbackIfNaN(quoteSummary.Volume))
))
Expand All @@ -246,6 +246,7 @@ export const StockDetails = GObject.registerClass({
style_class: 'detail-item-label-bin',
x_expand: true,
y_expand: true,
x_align: Clutter.ActorAlign.START,
child: new St.Label({ style_class: 'detail-item-label', text })
})

Expand All @@ -257,6 +258,7 @@ export const StockDetails = GObject.registerClass({
style_class: 'detail-item-value-bin',
x_expand: true,
y_expand: true,
x_align: Clutter.ActorAlign.END,
child: new St.Label({ style_class: `detail-item-value tar ${additionalStyleClass || ''}`, text: text.toString() })
})

Expand Down
6 changes: 3 additions & 3 deletions stocks@infinicode.de/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ let StocksMenuButton = GObject.registerClass(class StocksMenuButton extends Pane
super._init(menuAlignment, _('Stocks'))
this.add_style_class_name('stocks-extension')

this.add_actor(new MenuStockTicker())
this.add_child(new MenuStockTicker())

const bin = new St.Widget({ style_class: 'stocks-extension' })
bin._delegate = this
this.menu.box.add_child(bin)

this._screenWrapper = new ScreenWrapper(this._mainEventHandler)
bin.add_actor(this._screenWrapper)
bin.add_child(this._screenWrapper)

// Bind events
// FIXME: figure out and fix why this triggers
Expand Down Expand Up @@ -100,7 +100,7 @@ let StocksMenuButton = GObject.registerClass(class StocksMenuButton extends Pane
return
}

parent.remove_actor(container)
parent.remove_child(container)

let children = null

Expand Down
4 changes: 2 additions & 2 deletions stocks@infinicode.de/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"settings-schema": "org.gnome.shell.extensions.stocks",
"gettext-domain": "stocks@infinicode.de",
"shell-version": [
"45"
"46"
],
"url": "https://github.com/cinatic/stocks-extension",
"uuid": "stocks@infinicode.de",
"version": 33
"version": 9999
}
Loading

0 comments on commit 7944f24

Please sign in to comment.