Skip to content

Commit

Permalink
fix gnome 45 compatibility issues with St.ScrollView
Browse files Browse the repository at this point in the history
  • Loading branch information
Totto16 committed Apr 19, 2024
1 parent 7dacd09 commit 5fb7c42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/panoScrollView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import St1 from '@girs/st-14';
import { PanoItem } from '@pano/components/panoItem';
import { SearchBox } from '@pano/components/searchBox';
import { ClipboardContent, ClipboardManager } from '@pano/utils/clipboardManager';
import { scrollViewAddChild } from '@pano/utils/compatibility';
import { ClipboardQueryBuilder, db, ItemType } from '@pano/utils/db';
import { registerGObjectClass, SignalRepresentationType, SignalsDefinition } from '@pano/utils/gjs';
import { createPanoItem, createPanoItemFromDb, removeItemResources } from '@pano/utils/panoItemFactory';
Expand Down Expand Up @@ -88,7 +89,7 @@ export class PanoScrollView extends St1.ScrollView {
this.setScrollbarPolicy();
this.list.set_vertical(isVertical(this.settings.get_uint('window-position')));
});
this.add_child(this.list);
scrollViewAddChild(this, this.list);

const shouldFocusOut = (symbol: number) => {
const isPanoVertical = isVertical(this.settings.get_uint('window-position'));
Expand Down
17 changes: 16 additions & 1 deletion src/utils/compatibility.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Clutter from '@girs/clutter-14';
import type Gda5 from '@girs/gda-5.0';
import type Gda6 from '@girs/gda-6.0';
import GLib from '@girs/glib-2.0';
import { Source as MessageTraySource } from '@girs/gnome-shell/dist/ui/messageTray';
import { Notification } from '@girs/gnome-shell/dist/ui/messageTray';
import St1 from '@girs/st-14';

// compatibility functions for Gda 5.0 and 6.0

Expand All @@ -27,7 +29,11 @@ export function add_expr_value(builder: Gda5.SqlBuilder | Gda6.SqlBuilder, value
// compatibility functions for gnome 45 / 46

function isGnome45(): boolean {
return MessageTraySource.prototype.addNotification === undefined;
// be 100% sure which version we use, and not using Config.PACKAGE_VERSION
return (
MessageTraySource.prototype.addNotification === undefined ||
(Clutter as any as { Container: undefined | any }).Container === undefined
);
}

export function newNotification(
Expand Down Expand Up @@ -70,3 +76,12 @@ export function addNotification(source: MessageTraySource, notification: Notific
(source as MessageTraySource).addNotification(notification as Notification);
}
}

export function scrollViewAddChild(scrollView: St1.ScrollView, actor: St1.Scrollable): void {
if ((scrollView as any as { add_actor: undefined | any }).add_actor !== undefined) {
// @ts-expect-error gnome 45 type, or even some gnome 46 distros do support that, so using this check, instead of isGnome45()!
scrollView.add_actor(actor);
} else {
scrollView.set_child(actor);
}
}

0 comments on commit 5fb7c42

Please sign in to comment.