misc: make eslint happy & use newer APIs
Bilal Elmoussaoui
2 years ago
17 | 17 | * |
18 | 18 | */ |
19 | 19 | |
20 | const { Gdk, Gio, GLib, GObject, Gst, Gtk, Adw } = imports.gi; | |
20 | const { Adw, Gio, GLib, GObject, Gst, Gtk } = imports.gi; | |
21 | 21 | |
22 | 22 | var RecordingsDir = Gio.file_new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), pkg.name])); |
23 | 23 | var CacheDir = Gio.file_new_for_path(GLib.build_filenamev([GLib.get_user_cache_dir(), pkg.name])); |
103 | 103 | vfunc_activate() { |
104 | 104 | this.window = new Window({ application: this }); |
105 | 105 | if (pkg.name.endsWith('Devel')) |
106 | this.window.get_style_context().add_class('devel'); | |
106 | this.window.add_css_class('devel'); | |
107 | 107 | this.window.show(); |
108 | 108 | } |
109 | 109 |
0 | 0 | /* exported RecorderState RecorderWidget */ |
1 | const { Gdk, Gio, GObject, Gtk } = imports.gi; | |
1 | const { Gio, GObject, Gtk } = imports.gi; | |
2 | 2 | const { formatTime } = imports.utils; |
3 | 3 | const { WaveForm, WaveType } = imports.waveform; |
4 | 4 | |
97 | 97 | dialog.set_default_response(Gtk.ResponseType.NO); |
98 | 98 | dialog.add_button(_('Resume'), Gtk.ResponseType.NO); |
99 | 99 | dialog.add_button(_('Delete'), Gtk.ResponseType.YES) |
100 | .get_style_context().add_class('destructive-action'); | |
100 | .add_css_class('destructive-action'); | |
101 | 101 | |
102 | 102 | dialog.set_transient_for(Gio.Application.get_default().get_active_window()); |
103 | 103 | dialog.connect('response', (_, response) => { |
135 | 135 | this.actionsGroup.lookup('pause').enabled = false; |
136 | 136 | this.actionsGroup.lookup('resume').enabled = true; |
137 | 137 | this._resumeBtn.grab_focus(); |
138 | this._recorderTime.get_style_context().add_class('paused'); | |
138 | this._recorderTime.add_css_class('paused'); | |
139 | 139 | break; |
140 | 140 | case RecorderState.RECORDING: |
141 | 141 | this.actionsGroup.lookup('start').enabled = false; |
143 | 143 | this.actionsGroup.lookup('resume').enabled = false; |
144 | 144 | this.actionsGroup.lookup('pause').enabled = true; |
145 | 145 | this._pauseBtn.grab_focus(); |
146 | this._recorderTime.get_style_context().remove_class('paused'); | |
146 | this._recorderTime.remove_css_class('paused'); | |
147 | 147 | break; |
148 | 148 | case RecorderState.STOPPED: |
149 | 149 | this.actionsGroup.lookup('start').enabled = true; |
123 | 123 | |
124 | 124 | if (expanded) { |
125 | 125 | if (current) |
126 | current.get_style_context().add_class('expanded'); | |
126 | current.add_css_class('expanded'); | |
127 | 127 | if (before) |
128 | before.get_style_context().add_class('expanded-before'); | |
128 | before.add_css_class('expanded-before'); | |
129 | 129 | if (after) |
130 | after.get_style_context().add_class('expanded-after'); | |
130 | after.add_css_class('expanded-after'); | |
131 | 131 | } else { |
132 | 132 | if (current) |
133 | current.get_style_context().remove_class('expanded'); | |
133 | current.remove_css_class('expanded'); | |
134 | 134 | if (before) |
135 | before.get_style_context().remove_class('expanded-before'); | |
135 | before.remove_css_class('expanded-before'); | |
136 | 136 | if (after) |
137 | after.get_style_context().remove_class('expanded-after'); | |
137 | after.remove_css_class('expanded-after'); | |
138 | 138 | } |
139 | 139 | } |
140 | 140 | }); |
133 | 133 | |
134 | 134 | this.keyController = Gtk.EventControllerKey.new(); |
135 | 135 | this.keyController.connect('key-pressed', (controller, key, _code, _state) => { |
136 | this._entry.get_style_context().remove_class('error'); | |
137 | ||
138 | if (key === Gdk.KEY_Escape) { | |
136 | this._entry.remove_css_class('error'); | |
137 | ||
138 | if (key === Gdk.KEY_Escape) | |
139 | 139 | this.editMode = false; |
140 | } | |
141 | 140 | }); |
142 | 141 | this._entry.add_controller(this.keyController); |
143 | 142 | |
172 | 171 | |
173 | 172 | this.editMode = false; |
174 | 173 | this.renameAction.enabled = true; |
175 | this._entry.get_style_context().remove_class('error'); | |
174 | this._entry.remove_css_class('error'); | |
176 | 175 | } catch (e) { |
177 | this._entry.get_style_context().add_class('error'); | |
176 | this._entry.add_css_class('error'); | |
178 | 177 | } |
179 | 178 | } |
180 | 179 |
22 | 22 | |
23 | 23 | // based on code from Pitivi |
24 | 24 | |
25 | const { Gdk, Gio, GObject, Gtk } = imports.gi; | |
25 | const { Gio, GObject, Gtk } = imports.gi; | |
26 | 26 | const Cairo = imports.cairo; |
27 | 27 | |
28 | 28 | var WaveType = { |
79 | 79 | this.show(); |
80 | 80 | } |
81 | 81 | |
82 | gesturePressed(n_press, x, y) { | |
82 | gesturePressed(nPress, x) { | |
83 | 83 | this._startX = x; |
84 | 84 | this.emit('gesture-pressed'); |
85 | 85 | } |
86 | 86 | |
87 | onMotion(x, y) { | |
87 | onMotion(x) { | |
88 | 88 | this._position = this._clamped(x - this._startX + this._lastX); |
89 | 89 | this.queue_draw(); |
90 | 90 | } |
91 | 91 | |
92 | gestureReleased(n_press, x, y) { | |
92 | gestureReleased() { | |
93 | 93 | this._lastX = this._position; |
94 | 94 | this.emit('position-changed', this.position); |
95 | 95 | } |