✨ Tweak clang-format style

This commit is contained in:
Simon Schneegans
2022-03-04 20:39:12 +01:00
parent 28c1cb6d72
commit 77310f9e65
7 changed files with 109 additions and 114 deletions
+2
View File
@@ -1,4 +1,6 @@
BasedOnStyle: Google
AlignConsecutiveAssignments: true
AlignAfterOpenBracket: Align
ContinuationIndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
ColumnLimit: 90
+25 -25
View File
@@ -101,26 +101,26 @@ class Extension {
// anyways, we override the actors ease() method once - the next time it will be
// called by the _mapWindow(), we will intercept it!
this._windowCreatedConnection =
global.display.connect('window-created', (d, metaWin) => {
let actor = metaWin.get_compositor_private();
global.display.connect('window-created', (d, metaWin) => {
let actor = metaWin.get_compositor_private();
const orig = actor.ease;
actor.ease = function(...params) {
orig.apply(actor, params);
actor.ease = orig;
const orig = actor.ease;
actor.ease = function(...params) {
orig.apply(actor, params);
actor.ease = orig;
// There are cases where the ease() is called prior to mapping the actor. If
// the actor is not yet mapped, we defer the effect creation.
if (actor.mapped) {
// There are cases where the ease() is called prior to mapping the actor. If
// the actor is not yet mapped, we defer the effect creation.
if (actor.mapped) {
extensionThis._setupEffect(actor, true);
} else {
const connectionID = actor.connect('notify::mapped', () => {
extensionThis._setupEffect(actor, true);
} else {
const connectionID = actor.connect('notify::mapped', () => {
extensionThis._setupEffect(actor, true);
actor.disconnect(connectionID);
});
}
};
});
actor.disconnect(connectionID);
});
}
};
});
// Some of the effects require that the window's actor is enlarged to provide a bigger
// canvas to draw the effects. Outside the overview we can simply increase the scale
@@ -324,8 +324,8 @@ class Extension {
// Only add effects to normal windows and dialog windows.
const isNormalWindow = actor.meta_window.window_type == Meta.WindowType.NORMAL;
const isDialogWindow =
actor.meta_window.window_type == Meta.WindowType.MODAL_DIALOG ||
actor.meta_window.window_type == Meta.WindowType.DIALOG;
actor.meta_window.window_type == Meta.WindowType.MODAL_DIALOG ||
actor.meta_window.window_type == Meta.WindowType.DIALOG;
if (!isNormalWindow && !isDialogWindow) {
return;
@@ -390,8 +390,8 @@ class Extension {
// modifications to this behavior by the effects.
const config = this._currentEffect.tweakTransition(actor, this._settings, forOpening);
const duration = testMode ?
5000 :
this._settings.get_int(this._currentEffect.getNick() + '-animation-time');
5000 :
this._settings.get_int(this._currentEffect.getNick() + '-animation-time');
// All animations are relative to the window's center.
actor.set_pivot_point(0.5, 0.5);
@@ -461,8 +461,8 @@ class Extension {
// Update uniforms at each frame.
transition.connect('new-frame', (t) => {
shader.set_uniform_value('uProgress', testMode ? 0.5 : t.get_progress());
shader.set_uniform_value(
'uTime', testMode ? duration / 2 : 0.001 * t.get_elapsed_time());
shader.set_uniform_value('uTime',
testMode ? duration / 2 : 0.001 * t.get_elapsed_time());
shader.set_uniform_value('uSizeX', actor.width);
shader.set_uniform_value('uSizeY', actor.height);
});
@@ -491,10 +491,10 @@ class Extension {
if (!forOpening) {
if (isDialogWindow) {
imports.ui.windowManager.DIALOG_DESTROY_WINDOW_ANIMATION_TIME =
duration != null ? duration : this._origDialogTime;
duration != null ? duration : this._origDialogTime;
} else {
imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME =
duration != null ? duration : this._origWindowTime;
duration != null ? duration : this._origWindowTime;
}
}
}
+68 -73
View File
@@ -64,13 +64,11 @@ var PreferencesDialog = class PreferencesDialog {
const styleProvider = Gtk.CssProvider.new();
styleProvider.load_from_resource('/css/gtk.css');
if (utils.isGTK4()) {
Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(), styleProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), styleProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} else {
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), styleProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), styleProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
// Make sure custom icons are found.
@@ -481,80 +479,77 @@ var PreferencesDialog = class PreferencesDialog {
// Each effect page is based on a template widget. This template contains the title
// and the preview button.
// clang-format off
if (GObject.type_from_name('BurnMyWindowsEffectPage') == null) {
BurnMyWindowsEffectPage =
GObject.registerClass({
GTypeName: 'BurnMyWindowsEffectPage',
Template: `resource:///ui/${utils.getGTKString()}/effectPage.ui`,
InternalChildren: ['label', 'button'],
},
class BurnMyWindowsEffectPage extends Gtk.Box {
_init(Effect, dialog) {
super._init();
BurnMyWindowsEffectPage = GObject.registerClass(
{
GTypeName: 'BurnMyWindowsEffectPage',
Template: `resource:///ui/${utils.getGTKString()}/effectPage.ui`,
InternalChildren: ['label', 'button'],
},
class BurnMyWindowsEffectPage extends Gtk.Box { // ------------------------------
_init(Effect, dialog) {
super._init();
// Set the effect's name as label.
this._label.label = Effect.getLabel();
// Set the effect's name as label.
this._label.label = Effect.getLabel();
// Open the preview window once the preview button is clicked.
this._button.connect('clicked', () => {
// Open the preview window once the preview button is clicked.
this._button.connect('clicked', () => {
// Set the to-be-previewed effect.
dialog.getSettings().set_string('open-preview-effect', Effect.getNick());
dialog.getSettings().set_string('close-preview-effect', Effect.getNick());
// Set the to-be-previewed effect.
dialog.getSettings().set_string('open-preview-effect', Effect.getNick());
dialog.getSettings().set_string('close-preview-effect', Effect.getNick());
// Make sure that the window.show() firther below "sees" this change.
Gio.Settings.sync();
// Make sure that the window.show() firther below "sees" this change.
Gio.Settings.sync();
// Create the preview-window.
const window = new Gtk.Window({
// Translators: %s will be replaced by the effect's name.
title: _('Preview for %s').replace('%s', Effect.getLabel()),
default_width: 800,
default_height: 450,
modal: true,
transient_for: utils.isGTK4() ? this._button.get_root() :
this._button.get_toplevel()
});
// Create the preview-window.
const window = new Gtk.Window({
// Translators: %s will be replaced by the effect's name.
title: _('Preview for %s').replace("%s", Effect.getLabel()),
default_width: 800,
default_height: 450,
modal: true,
transient_for: utils.isGTK4() ? this._button.get_root() :
this._button.get_toplevel()
// Add a header bar to the window.
if (utils.isGTK4()) {
const header = Gtk.HeaderBar.new();
window.set_titlebar(header);
}
const box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER,
spacing: 10,
margin_start: 50,
margin_end: 50
});
const label = Gtk.Label.new(_('Close this Window to Preview the Effect!'));
label.wrap = true;
label.justify = Gtk.Justification.CENTER;
label.get_style_context().add_class('large-title');
const image = new Gtk.Image({
icon_name: 'burn-my-windows-symbolic',
pixel_size: 128,
});
dialog.gtkBoxAppend(box, image);
dialog.gtkBoxAppend(box, label);
if (utils.isGTK4()) {
window.set_child(box);
window.show();
} else {
window.add(box);
window.show_all();
}
});
// Add a header bar to the window.
if (utils.isGTK4()) {
const header = Gtk.HeaderBar.new();
window.set_titlebar(header);
}
const box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER,
spacing: 10,
margin_start:50,
margin_end:50
});
const label = Gtk.Label.new(_('Close this Window to Preview the Effect!'));
label.wrap = true;
label.justify = Gtk.Justification.CENTER;
label.get_style_context().add_class('large-title');
const image = new Gtk.Image({
icon_name: 'burn-my-windows-symbolic',
pixel_size: 128,
});
dialog.gtkBoxAppend(box, image);
dialog.gtkBoxAppend(box, label);
if (utils.isGTK4()) {
window.set_child(box);
window.show();
} else {
window.add(box);
window.show_all();
}
});
}
});
// clang-format on
}
});
}
}
}
+4 -5
View File
@@ -134,9 +134,8 @@ if (utils.isInShellProcess()) {
// this texture is also re-created each time. This could be improved in the future!
const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png');
this._shardTexture = new Clutter.Image();
this._shardTexture.set_data(
shardData.get_pixels(), Cogl.PixelFormat.RGB_888, shardData.width,
shardData.height, shardData.rowstride);
this._shardTexture.set_data(shardData.get_pixels(), Cogl.PixelFormat.RGB_888,
shardData.width, shardData.height, shardData.rowstride);
// Usually, the shards fly away from the center of the window.
let epicenterX = 0.5;
@@ -232,8 +231,8 @@ if (utils.isInShellProcess()) {
const pipeline = this.get_pipeline();
// Use linear filtering for the window texture.
pipeline.set_layer_filters(
0, Cogl.PipelineFilter.LINEAR, Cogl.PipelineFilter.LINEAR);
pipeline.set_layer_filters(0, Cogl.PipelineFilter.LINEAR,
Cogl.PipelineFilter.LINEAR);
// Bind the shard texture.
pipeline.set_layer_texture(1, this._shardTexture.get_texture());
+2 -2
View File
@@ -233,9 +233,9 @@ if (utils.isInShellProcess()) {
const gradient = [];
for (let i = 1; i <= 5; i++) {
const color =
Clutter.Color.from_string(settings.get_string('fire-color-' + i))[1];
Clutter.Color.from_string(settings.get_string('fire-color-' + i))[1];
gradient.push(`vec4(${color.red / 255}, ${color.green / 255}, ${
color.blue / 255}, ${color.alpha / 255})`);
color.blue / 255}, ${color.alpha / 255})`);
}
this.set_shader_source(`
+5 -5
View File
@@ -129,14 +129,14 @@ if (utils.isInShellProcess()) {
const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png');
this._fontTexture = new Clutter.Image();
this._fontTexture.set_data(
fontData.get_pixels(),
fontData.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888,
fontData.width, fontData.height, fontData.rowstride);
fontData.get_pixels(),
fontData.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888,
fontData.width, fontData.height, fontData.rowstride);
const trailColor =
Clutter.Color.from_string(settings.get_string('matrix-trail-color'))[1];
Clutter.Color.from_string(settings.get_string('matrix-trail-color'))[1];
const tipColor =
Clutter.Color.from_string(settings.get_string('matrix-tip-color'))[1];
Clutter.Color.from_string(settings.get_string('matrix-tip-color'))[1];
// The technique for this effect was inspired by
// https://www.shadertoy.com/view/ldccW4, however the implementation is quite
+3 -4
View File
@@ -125,12 +125,11 @@ if (utils.isInShellProcess()) {
// See assets/README.md for how this texture was created.
const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png');
this._clawTexture = new Clutter.Image();
this._clawTexture.set_data(
clawData.get_pixels(), Cogl.PixelFormat.RGB_888, clawData.width,
clawData.height, clawData.rowstride);
this._clawTexture.set_data(clawData.get_pixels(), Cogl.PixelFormat.RGB_888,
clawData.width, clawData.height, clawData.rowstride);
const color =
Clutter.Color.from_string(settings.get_string('claw-scratch-color'))[1];
Clutter.Color.from_string(settings.get_string('claw-scratch-color'))[1];
// If we are currently performing integration test, the animation uses a fixed seed.
const testMode = settings.get_boolean('test-mode');