cleanup: Replace signal connections with virtual functions
Inheriting from actors allows to use virtual functions instead of signal connections for multiple cases, so just use them when possible. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
This commit is contained in:

committed by
Florian Müllner

parent
320df13b65
commit
55b57421dc
@ -42,9 +42,6 @@ class TodayButton extends St.Button {
|
||||
can_focus: true,
|
||||
reactive: false
|
||||
});
|
||||
this.connect('clicked', () => {
|
||||
this._calendar.setDate(new Date(), false);
|
||||
});
|
||||
|
||||
let hbox = new St.BoxLayout({ vertical: true });
|
||||
this.add_actor(hbox);
|
||||
@ -64,6 +61,10 @@ class TodayButton extends St.Button {
|
||||
});
|
||||
}
|
||||
|
||||
vfunc_clicked() {
|
||||
this._calendar.setDate(new Date(), false);
|
||||
}
|
||||
|
||||
setDate(date) {
|
||||
this._dayLabel.set_text(date.toLocaleFormat('%A'));
|
||||
|
||||
@ -97,14 +98,6 @@ class WorldClocksSection extends St.Button {
|
||||
|
||||
this._locations = [];
|
||||
|
||||
this.connect('clicked', () => {
|
||||
if (this._clocksApp)
|
||||
this._clocksApp.activate();
|
||||
|
||||
Main.overview.hide();
|
||||
Main.panel.closeCalendar();
|
||||
});
|
||||
|
||||
let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
|
||||
this._grid = new St.Widget({ style_class: 'world-clocks-grid',
|
||||
layout_manager: layout });
|
||||
@ -133,6 +126,14 @@ class WorldClocksSection extends St.Button {
|
||||
this._sync();
|
||||
}
|
||||
|
||||
vfunc_clicked() {
|
||||
if (this._clocksApp)
|
||||
this._clocksApp.activate();
|
||||
|
||||
Main.overview.hide();
|
||||
Main.panel.closeCalendar();
|
||||
}
|
||||
|
||||
_sync() {
|
||||
this._clocksApp = this._appSystem.lookup_app('org.gnome.clocks.desktop');
|
||||
this.visible = this._clocksApp != null;
|
||||
@ -257,17 +258,6 @@ class WeatherSection extends St.Button {
|
||||
|
||||
this._weatherClient = new Weather.WeatherClient();
|
||||
|
||||
this.connect('clicked', () => {
|
||||
this._weatherClient.activateApp();
|
||||
|
||||
Main.overview.hide();
|
||||
Main.panel.closeCalendar();
|
||||
});
|
||||
this.connect('notify::mapped', () => {
|
||||
if (this.mapped)
|
||||
this._weatherClient.update();
|
||||
});
|
||||
|
||||
let box = new St.BoxLayout({ style_class: 'weather-box',
|
||||
vertical: true });
|
||||
|
||||
@ -294,6 +284,18 @@ class WeatherSection extends St.Button {
|
||||
this._sync();
|
||||
}
|
||||
|
||||
vfunc_map() {
|
||||
this._weatherClient.update();
|
||||
super.vfunc_map();
|
||||
}
|
||||
|
||||
vfunc_clicked() {
|
||||
this._weatherClient.activateApp();
|
||||
|
||||
Main.overview.hide();
|
||||
Main.panel.closeCalendar();
|
||||
}
|
||||
|
||||
_getInfos() {
|
||||
let info = this._weatherClient.info;
|
||||
let forecasts = info.get_forecast_list();
|
||||
|
Reference in New Issue
Block a user