Skip to content

Commit e76dc9a

Browse files
authored
Merge pull request #30 from yilozt/reset-prefs-dialog
Reset prefs dialog & Default shadow style
2 parents 01108a3 + 30eb3c7 commit e76dc9a

File tree

7 files changed

+268
-24
lines changed

7 files changed

+268
-24
lines changed

resources/schemas/org.gnome.shell.extensions.rounded-window-corners.gschema.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</key>
1111

1212
<key name="black-list" type="as">
13-
<default>["qq.exe", "tim.exe"]</default>
13+
<default>[]</default>
1414
<summary>window here will not be rounded</summary>
1515
<description>
1616
The contents of the list represent the instance part of the window's
@@ -74,10 +74,10 @@
7474
<default>
7575
{
7676
'horizontal_offset': 0,
77-
'vertical_offset': 41,
78-
'blur_offset': 38,
79-
'spread_radius': -15,
80-
'opacity': 53
77+
'vertical_offset': 4,
78+
'blur_offset': 28,
79+
'spread_radius': 4,
80+
'opacity': 60
8181
}
8282
</default>
8383
</key>
@@ -87,10 +87,10 @@
8787
<default>
8888
{
8989
'horizontal_offset': 0,
90-
'vertical_offset': 10,
91-
'blur_offset': 9,
92-
'spread_radius': -5,
93-
'opacity': 62
90+
'vertical_offset': 2,
91+
'blur_offset': 12,
92+
'spread_radius': -1,
93+
'opacity': 65
9494
}
9595
</default>
9696
</key>

resources/stylesheet-prefs.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,16 @@
99

1010
.rotated {
1111
transform: rotate(90deg);
12+
}
13+
14+
.dialog-vbox {
15+
padding: 48px;
16+
}
17+
18+
.dialog-vbox .heading {
19+
padding-bottom: 24px;
20+
}
21+
22+
.dialog-vbox checkbutton {
23+
padding-right: 12px;
1224
}

src/manager/rounded-corners-manager.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ export class RoundedCornersManager {
259259
})
260260
;(shadow.first_child as Bin).add_style_class_name ('shadow')
261261

262-
this._update_shadow_actor_style (actor.meta_window, shadow)
262+
this._update_shadow_actor_style (
263+
actor.meta_window,
264+
shadow,
265+
this.global_rounded_corners?.border_radius,
266+
actor.meta_window.appears_focused
267+
? settings ().focused_shadow
268+
: settings ().unfocused_shadow
269+
)
263270

264271
// We have to clip the shadow because of this issues:
265272
// https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4474
@@ -429,6 +436,7 @@ export class RoundedCornersManager {
429436

430437
// Update shadows and rounded corners bounds
431438
this.on_size_changed (actor)
439+
this._on_focus_changed (actor.meta_window)
432440

433441
// Connect signals of window, those signals will be disconnected
434442
// when window is destroyed

src/preferences/pages/general.ts

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import * as Gio from '@gi/Gio'
55

66
// local modules
77
import settings from '../../utils/settings'
8+
import { SchemasKeys } from '../../utils/settings'
89
import connections from '../../utils/connections'
910
import { list_children } from '../../utils/prefs'
1011
import { template_url } from '../../utils/io'
1112
import { _log } from '../../utils/log'
1213
import RoundedCornersItems from '../widgets/rounded-corners-item'
1314
import EditShadowWindow from '../widgets/edit-shadow-window'
15+
import ResetDialog from '../widgets/reset-dialog'
1416

1517
// types
1618
import * as Gtk from '@gi/Gtk'
@@ -32,6 +34,7 @@ export default GObject.registerClass (
3234
'border_color_button',
3335
'edit_shadow_row',
3436
'applications_group',
37+
'reset_preferences_btn',
3538
],
3639
},
3740
class extends Gtk.Box {
@@ -44,18 +47,26 @@ export default GObject.registerClass (
4447
private _border_color_button !: Gtk.ColorButton
4548
private _edit_shadow_row !: Gtk.ListBoxRow
4649
private _applications_group !: Gtk.ListBox
50+
private _reset_preferences_btn !: Gtk.Button
4751

4852
private config_items !: _Items
49-
private edit_shadow_window !: _Win
5053

5154
_init () {
5255
super._init ()
5356

54-
this.edit_shadow_window = new EditShadowWindow ()
5557
this.config_items = new RoundedCornersItems ()
5658

5759
this.build_ui ()
5860

61+
connections
62+
.get ()
63+
.connect (
64+
settings ().g_settings,
65+
'changed',
66+
(settings: Gio.Settings, key: string) =>
67+
this._on_settings_changed (key)
68+
)
69+
5970
settings ().bind (
6071
'debug-mode',
6172
this._enable_log_switch,
@@ -125,6 +136,12 @@ export default GObject.registerClass (
125136
}
126137
}
127138
)
139+
140+
connections
141+
.get ()
142+
.connect (this._reset_preferences_btn, 'clicked', () => {
143+
new ResetDialog ().show ()
144+
})
128145
}
129146

130147
vfunc_root (): void {
@@ -155,17 +172,42 @@ export default GObject.registerClass (
155172

156173
/** Called when click 'Window Shadow' action row */
157174
_show_edit_shadow_window_cb () {
158-
const win = this.root as Gtk.Window
159-
this.edit_shadow_window.application = win.application
160-
this.edit_shadow_window.present ()
161-
win.hide ()
162-
this.edit_shadow_window.connect ('close-request', () => {
163-
win.show ()
164-
this.edit_shadow_window.hide ()
175+
const root = this.root as Gtk.Window
176+
const win = new EditShadowWindow ()
177+
win.application = root.application
178+
win.present ()
179+
root.hide ()
180+
win.connect ('close-request', () => {
181+
root.show ()
182+
win.destroy ()
165183
})
166184
}
185+
186+
/** Update UI when settings changed */
187+
private _on_settings_changed (key: string) {
188+
switch (key as SchemasKeys) {
189+
case 'border-color':
190+
{
191+
const color = settings ().border_color
192+
this._border_color_button.rgba = new Gdk.RGBA ({
193+
red: color[0],
194+
green: color[1],
195+
blue: color[2],
196+
alpha: color[3],
197+
})
198+
}
199+
break
200+
case 'border-width':
201+
this._border_width_ajustment.value = settings ().border_width
202+
break
203+
case 'global-rounded-corner-settings':
204+
this.config_items.cfg =
205+
settings ().global_rounded_corner_settings
206+
break
207+
default:
208+
}
209+
}
167210
}
168211
)
169212

170213
type _Items = InstanceType<typeof RoundedCornersItems>
171-
type _Win = InstanceType<typeof EditShadowWindow>

src/preferences/pages/general.ui

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,24 @@
271271
</child>
272272
</object>
273273
</child>
274+
<child>
275+
<object class="GtkLabel">
276+
<property name="halign">start</property>
277+
<property name="label" translatable="yes">Reset Preferences</property>
278+
<style>
279+
<class name="heading" />
280+
</style>
281+
</object>
282+
</child>
283+
<child>
284+
<object class="GtkButton" id="reset_preferences_btn">
285+
<property name="label">Reset Preferences</property>
286+
<property name="halign">start</property>
287+
<style>
288+
<class name="destructive-action"/>
289+
</style>
290+
</object>
291+
</child>
274292
</template>
275293

276294
<object class="GtkAdjustment" id="border_width_ajustment">

src/preferences/widgets/edit-shadow-window.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ export default registerClass (
147147

148148
// signal handles
149149

150-
_hide_window_cb () {
151-
this.hide ()
152-
}
153-
154150
on_value_changed () {
155151
this.update_cfg ()
156152
this.update_style ()

0 commit comments

Comments
 (0)