notifications: Introduce MessageList.Source object
This object contains only the `title` and `icon` of a `MessageTray.Source` which allows using it for sources that aren't notification sources like mpris. The old `MessageTray.Source` isn't renamed to something less generic to not break API. Once we have a good reason we should rename it to something more specific. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3103>
This commit is contained in:
parent
932ccac1c2
commit
ff76584937
@ -306,6 +306,34 @@ const LabelExpanderLayout = GObject.registerClass({
|
||||
}
|
||||
});
|
||||
|
||||
export const Source = GObject.registerClass({
|
||||
Properties: {
|
||||
'title': GObject.ParamSpec.string(
|
||||
'title', 'title', 'title',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null),
|
||||
'icon': GObject.ParamSpec.object(
|
||||
'icon', 'icon', 'icon',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
Gio.Icon),
|
||||
'icon-name': GObject.ParamSpec.string(
|
||||
'icon-name', 'icon-name', 'icon-name',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null),
|
||||
},
|
||||
}, class Source extends GObject.Object {
|
||||
get iconName() {
|
||||
if (this.gicon instanceof Gio.ThemedIcon)
|
||||
return this.gicon.iconName;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
set iconName(iconName) {
|
||||
this.icon = new Gio.ThemedIcon({name: iconName});
|
||||
}
|
||||
});
|
||||
|
||||
const TimeLabel = GObject.registerClass(
|
||||
class TimeLabel extends St.Label {
|
||||
_init() {
|
||||
|
@ -12,6 +12,7 @@ import * as Calendar from './calendar.js';
|
||||
import * as GnomeSession from '../misc/gnomeSession.js';
|
||||
import * as Layout from './layout.js';
|
||||
import * as Main from './main.js';
|
||||
import * as MessageList from './messageList.js';
|
||||
import * as Params from '../misc/params.js';
|
||||
import * as SignalTracker from '../misc/signalTracker.js';
|
||||
|
||||
@ -590,25 +591,13 @@ export const Source = GObject.registerClass({
|
||||
'policy', 'policy', 'policy',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
NotificationPolicy.$gtype),
|
||||
'title': GObject.ParamSpec.string(
|
||||
'title', 'title', 'title',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null),
|
||||
'icon': GObject.ParamSpec.object(
|
||||
'icon', 'icon', 'icon',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
Gio.Icon),
|
||||
'icon-name': GObject.ParamSpec.string(
|
||||
'icon-name', 'icon-name', 'icon-name',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null),
|
||||
},
|
||||
Signals: {
|
||||
'destroy': {param_types: [GObject.TYPE_UINT]},
|
||||
'notification-added': {param_types: [Notification.$gtype]},
|
||||
'notification-show': {param_types: [Notification.$gtype]},
|
||||
},
|
||||
}, class Source extends GObject.Object {
|
||||
}, class Source extends MessageList.Source {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
@ -657,17 +646,6 @@ export const Source = GObject.registerClass({
|
||||
return new NotificationBanner(notification);
|
||||
}
|
||||
|
||||
get iconName() {
|
||||
if (this.gicon instanceof Gio.ThemedIcon)
|
||||
return this.gicon.iconName;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
set iconName(iconName) {
|
||||
this.icon = new Gio.ThemedIcon({name: iconName});
|
||||
}
|
||||
|
||||
_onNotificationDestroy(notification) {
|
||||
let index = this.notifications.indexOf(notification);
|
||||
if (index < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user