### Build and Install GNOME Extensions App Source: https://github.com/gnome/gnome-shell/blob/main/subprojects/extensions-app/README.md Commands to set up, compile, and install the project using Meson. For development, the prefix can be set to a temporary directory. ```sh $ meson setup --prefix=/usr _build $ meson compile -C _build $ meson install -C _build $ /usr/bin/gnome-extensions-app ``` -------------------------------- ### Install System Extension with toolbox-sysext-install.sh Source: https://github.com/gnome/gnome-shell/blob/main/tools/toolbox/README.md Extracts a prepared system extension directory from the toolbox and installs it on the host. Ensure the host OS matches the extension, typically the most recent Fedora release for toolboxes created with create-toolbox.sh. Mutter must be sufficiently up-to-date if building manually. ```bash $ cd path/to/mutter; meson-build.sh --sysext $ cd path/to/gnome-shell; meson-build.sh --sysext $ toolbox-sysext-install.sh ``` -------------------------------- ### Example Commit Message Source: https://github.com/gnome/gnome-shell/blob/main/docs/commit-messages.md Demonstrates the recommended format for a commit message, including a topic prefix, a concise subject line, and a detailed body explaining the changes and referencing issues. ```text status/volume: Automatically mute in vacuum In space, no one can hear you scream. There is no point in emitting sound that cannot be perceived, so automatically mute all output streams. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1234 ``` -------------------------------- ### Header File Function Signature Formatting Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Provides examples of correct function signature formatting for header files, including spacing between return type, function name, and parameters. ```c gboolean st_icon_theme_has_icon (StIconTheme *icon_theme, const char *icon_name); ``` ```c GList * st_icon_theme_list_icons (StIconTheme *icon_theme, const char *context); ``` ```c StIconInfo * st_icon_info_new_for_pixbuf (StIconTheme *icon_theme, GdkPixbuf *pixbuf); ``` -------------------------------- ### Indentation, Braces, and Whitespace Example Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Demonstrates the preferred style for indentation (four spaces), brace placement (same line), and whitespace around control structures and function calls. Braces can be omitted only if both sides of the statement are on a single line. ```javascript function foo(a, b) { let bar; if (a > b) bar = do_thing(a); else bar = do_thing(b); if (bar === 5) { for (let i = 0; i < 10; i++) print(i); } else { print(20); } } ``` -------------------------------- ### Define Signal Callback with 'on_' Prefix Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Example of a signal callback function prefixed with 'on_', typically used for event handlers. ```c static void on_realize (ClutterActor *actor, gpointer user_data) { /* ... */ } ``` -------------------------------- ### ES6 Class Definition Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Provides an example of defining a standard ES6 class when not inheriting from GObjects. This follows modern JavaScript syntax for class creation. ```javascript export class IconLabelMenuItem extends PopupMenu.PopupMenuBaseItem { constructor(icon, label) { super({reactive: false}); this.actor.add_child(icon); this.actor.add_child(label); } open() { log('menu opened!'); } } ``` -------------------------------- ### Define Signal Callback with '_cb' Suffix Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Example of a signal callback function suffixed with '_cb', also used for event handlers. ```c static void destroy_cb (ClutterActor *actor, gpointer user_data) { /* ... */ } ``` -------------------------------- ### Auxiliary Function for Type Conversion Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md An example of an auxiliary function used for type conversion, which may exceptionally include a class prefix. ```c static StFoo * st_foo_from_bar (Bar *bar) { /* ... */ } ``` -------------------------------- ### Define Custom GObject Class with GObject.registerClass Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Use `GObject.registerClass` to define a new class that inherits from a GObject type, enabling native bindings for libraries. This example shows how to override virtual methods for custom drawing and preferred size calculation. ```javascript export const MyClutterActor = GObject.registerClass( class MyClutterActor extends Clutter.Actor { vfunc_get_preferred_width(forHeight) { return [100, 100]; } vfunc_get_preferred_height(forWidth) { return [100, 100]; } vfunc_paint(paintContext) { const framebuffer = paintContext.get_framebuffer(); const coglContext = framebuffer.get_context(); const alloc = this.get_allocation_box(); const pipeline = Cogl.Pipeline.new(coglContext); pipeline.set_color4ub(255, 0, 0, 255); framebuffer.draw_rectangle(pipeline, alloc.x1, alloc.y1, alloc.x2, alloc.y2); } }); ``` -------------------------------- ### Build gnome-shell with Meson Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Use these commands to set up the build environment and compile gnome-shell using the Meson build system. ```sh $ meson setup _build $ meson compile -C _build ``` -------------------------------- ### Create a Toolbox container for development Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md This script sets up a new container that satisfies all build and runtime dependencies for gnome-shell development. ```sh $ tools/toolbox/create-toolbox.sh ``` -------------------------------- ### Build and run gnome-shell within a Toolbox container Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Use these scripts to build and execute gnome-shell once a working Toolbox container has been established. ```sh $ tools/toolbox/meson-build.sh $ tools/toolbox/run-gnome-shell.sh ``` -------------------------------- ### Implement Interface Init Function Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Define the interface init function using snake_case and the _iface_init suffix. This is used in conjunction with G_IMPLEMENT_INTERFACE. ```c static void st_foo_iface_init (StFooInterface *foo_iface); G_DEFINE_TYPE_WITH_CODE (StBar, st_bar, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (ST_TYPE_FOO, st_foo_iface_init)); ``` -------------------------------- ### Generate Translations Script Source: https://github.com/gnome/gnome-shell/blob/main/subprojects/extensions-app/README.md Run this script to populate the po directory with translations from gnome-shell before building. ```sh $ ./generate-translations.sh ``` -------------------------------- ### Source File Include Order Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Specifies the recommended order for including header files in source files to maintain consistency and clarity. ```c #include "config.h" #include "st-example-private.h" #include #include #ifdef HAVE_MALLINFO2 #include #endif #include "st-private.h" #include "st-dbus-file-generated-by-gdbus-codegen.h" ``` -------------------------------- ### Edit systemd user service for Valgrind session Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Create a drop-in configuration file for the user systemd service to run gnome-shell under Valgrind. This command opens an editor for the configuration. ```sh $ systemctl --user edit org.gnome.Shell@user.service --drop-in valgrind ``` -------------------------------- ### GObject Class Registration Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Demonstrates how to define and register classes that inherit from GObjects using `GObject.registerClass()`. This is the standard approach for GObject-based inheritance in gjs. ```javascript export const MyActor = GObject.registerClass( class MyActor extends Clutter.Actor { constructor(params) { super(params); this.name = 'MyCustomActor'; } }); ``` -------------------------------- ### Generate Translations Script Source: https://github.com/gnome/gnome-shell/blob/main/subprojects/extensions-tool/README.md Run this script to populate the po directory with translations, which is a prerequisite for building the project stand-alone. ```sh ./generate-translations.sh ``` -------------------------------- ### Valgrind systemd drop-in configuration Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Add this content to the systemd user service drop-in file to configure gnome-shell to run under Valgrind with specific logging and timeout settings. ```ini [Service] ExecStart= ExecStart=/usr/bin/valgrind --log-file=/tmp/gs-valgrind.txt --enable-debuginfod=no --leak-check=full --show-leak-kinds=definite /usr/bin/gnome-shell TimeoutStartSec=300 TimeoutStopSec=300 ``` -------------------------------- ### Object Instance Pointer Naming Convention Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Shows the recommended naming convention for object instance pointers, using descriptive names instead of generic terms like 'self'. ```c G_DEFINE_TYPE (StPlaceholder, st_placeholder, G_TYPE_OBJECT) ... void st_placeholder_hold_place (StPlaceholder *placeholder) { ... } ``` -------------------------------- ### Run gnome-shell on native Wayland backend Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Switch to a tty and use this command to run gnome-shell on the native Wayland backend. Note that some functionality, like logout, is unavailable in this mode. ```sh $ dbus-run-session gnome-shell --wayland ``` -------------------------------- ### Importing Modules Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Illustrates the recommended way to import modules using UpperCamelCase for module names. Imports are categorized into 'environment imports' (gobject-introspection or gjs modules) and 'application imports' (internal GNOME Shell JS code), sorted alphabetically within each block. ```javascript import GLib from 'gi://GLib'; import Gio from 'gi://Gio'; import St from 'gi://St'; import * as Main from './main.js'; import * as Params from '../misc/params.js'; import * as Util from '../misc/util.js'; ``` -------------------------------- ### Memory Management with g_autofree and g_autoptr Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Demonstrates the usage of g_autofree and g_autoptr for automatic memory management. Use these macros to simplify resource handling and prevent memory leaks. ```c g_autofree char *text = NULL; g_autoptr (StSomeThing) thing = NULL; text = g_strdup_printf ("The text: %d", a_number); thing = g_object_new (ST_TYPE_SOME_THING, "text", text, NULL); thinger_use_thing (rocket, thing); ``` -------------------------------- ### Structure Field Formatting Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Demonstrates the formatting for structure fields, where each field has a space after its type name and fields are not aligned. ```c struct _StFooBar { StFoo parent; StBar *bar; StSomething *something; }; ``` -------------------------------- ### Animate Actor Position with Convenience Wrapper Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Use this convenience wrapper for smoothly animating an actor's x and y coordinates. It simplifies setting duration and animation mode. ```javascript moveActor(actor, x, y) { actor.ease({ x, y, duration: 500, // ms mode: Clutter.AnimationMode.EASE_OUT_QUAD, }); } ``` -------------------------------- ### Run gnome-shell as a nested Wayland instance with Devkit Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Execute gnome-shell as a nested instance using Devkit. This command is automatically used by the `run-gnome-shell` script in a graphical session. ```sh $ dbus-run-session gnome-shell --wayland --devkit ``` -------------------------------- ### Implement Interface VFuncs Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Implement virtual functions (vfuncs) for an interface, assigning specific function pointers within the interface init structure. ```c static void st_bar_do_something (StFoo *foo) { /* ... */ } static void st_foo_iface_init (StFooInterface *foo_iface) { foo_iface->do_something = st_bar_do_something; } ``` -------------------------------- ### VFunc Overrides in Class Initialization Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Illustrates how to override parent class virtual functions (vfuncs) and implement interface methods within the class_init function. Vfunc overrides are named using the current class prefix followed by the vfunc name. ```c static void st_bar_spawn_unicorn (StParent *parent) { /* ... */ } static void st_bar_dispose (GObject *object) { /* ... */ } static void st_bar_finalize (GObject *object) { /* ... */ } static void st_bar_class_init (StBarClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); StParentClass *parent_class = ST_PARENT_CLASS (klass); object_class->dispose = st_bar_dispose; object_class->finalize = st_bar_finalize; parent_class->spawn_unicorn = st_bar_spawn_unicorn; } ``` -------------------------------- ### Use Auxiliary Function in Random Functions Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Illustrates the usage of a common auxiliary function within different functions to avoid code duplication. ```c static void random_function (Foo *foo) { do_something_on_data (foo, bar); } static void another_random_function (Foo *foo) { do_something_on_data (foo, bar); } ``` -------------------------------- ### Variable Declaration with const and let Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Demonstrates the use of `const` and `let` for variable declarations, adhering to block scope. `const` should be used for variables that are not reassigned, and `let` for those that are. ```javascript // Iterating over an array for (let i = 0; i < arr.length; ++i) { const item = arr[i]; } // Iterating over an object's properties for (const prop in someobj) { const val = someobj[prop]; } ``` -------------------------------- ### Run cldr2json Script Source: https://github.com/gnome/gnome-shell/blob/main/data/cldr2json/README.md Execute the cldr2json script by providing the input file or directory and the output directory. ```bash ./cldr2json ``` ```bash ./cldr2json cldr/keyboards/android/ json_layouts/ ``` -------------------------------- ### Defining Constants Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Shows the convention for defining constants using CONSTANTS_CASE. Constants should be declared directly after the import statements. ```javascript const MY_DBUS_INTERFACE = 'org.my.Interface'; ``` -------------------------------- ### Defining Flags with Typedef Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Illustrates how to define custom flags using a typedef for enum. This is preferred over boolean arguments for better expressiveness in function parameters. ```c typedef _StSomeThingFlags { ST_SOME_THING_FLAG_NONE = 0, ST_SOME_THING_FLAG_ALTER_REALITY = 1 << 0, ST_SOME_THING_FLAG_MANIPULATE_PERCEPTION = 1 << 1, } StSomeThingFlags; ``` -------------------------------- ### Update mutter dependency in Toolbox Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Run this command inside a Toolbox container to update the mutter dependency if build or run errors occur. ```sh $ toolbox run --container gnome-shell-devel update-mutter ``` -------------------------------- ### Define Callback Function Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Defines a callback function with an imperative name and a '_func' suffix, used for actions with optional user data. ```c static void filter_something_func (Foo *foo, Bar *bar, gpointer user_data) { /* ... */ } ``` -------------------------------- ### Revert systemd user service changes Source: https://github.com/gnome/gnome-shell/blob/main/docs/building-and-running.md Remove the Valgrind drop-in configuration from the systemd user service. This command should be run from a VT after the Valgrind session. ```sh $ systemctl --user revert org.gnome.Shell@user.service ``` -------------------------------- ### Dynamic Module Imports in Evaluator Source: https://github.com/gnome/gnome-shell/blob/main/docs/looking-glass.md Load additional modules using dynamic imports. Ensure the path is correct relative to the shell's context. ```javascript Util = await import('../misc/util.js') {Panel} = await import('./panel.js') {default: Pango} = await import('gi://Pango') ``` -------------------------------- ### Use Git Alias to Generate 'Fixes:' Tag Source: https://github.com/gnome/gnome-shell/blob/main/docs/commit-messages.md After configuring the 'fixes' alias, use it to generate the 'Fixes:' tag for a specific commit. This is a convenient shortcut for the longer git show command. ```bash git fixes ``` -------------------------------- ### Animate Actor Position with Direct Clutter API Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md This snippet demonstrates the more verbose, direct usage of the Clutter API for animating actor properties. It requires manual state management for easing. ```javascript moveActor(actor, x, y) { actor.save_easing_state(); actor.set_easing_duration(500); actor.set_easing_mode(Clutter.AnimationMode.EASE_OUT_QUAD); actor.set({ x, y, }); actor.restore_easing_state(); } ``` -------------------------------- ### Log JavaScript Stacktrace on Warning Source: https://github.com/gnome/gnome-shell/blob/main/docs/debugging.md Set the `SHELL_DEBUG` environment variable to `backtrace-warning` to automatically log a JavaScript stacktrace whenever a warning is issued. This helps identify the source of warnings in JavaScript code. ```shell export SHELL_DEBUG=backtrace-warning ``` -------------------------------- ### Configure Git Alias for 'Fixes:' Tag Source: https://github.com/gnome/gnome-shell/blob/main/docs/commit-messages.md Create a global Git alias to simplify the process of generating 'Fixes:' tags. This alias can then be used with the commit hash as an argument. ```bash git config --global alias.fixes "show -s --pretty='format:Fixes: %h (\"%s\")'" ``` -------------------------------- ### Handle Closures with bind or Arrow Notation Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Ensure `this` context is correctly maintained within closures by using `Function.prototype.bind` or arrow function syntax. This is crucial when connecting to signals or using methods within callbacks. ```javascript const closure1 = () => this._fnorbate(); const closure2 = this._fnorbate.bind(this); ``` ```javascript import * as FnorbLib from './fborbLib.js'; export class MyClass { constructor() { const fnorb = new FnorbLib.Fnorb(); fnorb.connect('frobate', this._onFnorbFrobate.bind(this)); } _onFnorbFrobate(fnorb) { this._updateFnorb(); } } ``` -------------------------------- ### Basic JavaScript Expressions in Evaluator Source: https://github.com/gnome/gnome-shell/blob/main/docs/looking-glass.md Type arbitrary JavaScript at the prompt for evaluation. Common modules like Clutter, GObject, and Main are pre-imported. ```javascript 1+1 ``` ```javascript global.get_window_actors() ``` ```javascript global.get_window_actors().forEach(w => w.ease({duration: 3000, mode: Clutter.AnimationMode.EASE_OUT_QUAD, scale_x: 0.3, scale_y: 0.3})) ``` ```javascript global.get_window_actors().forEach(w => w.set_scale(1, 1)) ``` ```javascript global.get_window_actors()[0] ``` ```javascript it.scale_x ``` -------------------------------- ### Print JavaScript Stacktrace in GDB Source: https://github.com/gnome/gnome-shell/blob/main/docs/debugging.md Use the `gjs_dumpstack()` command within GDB to print the current JavaScript stacktrace. This is useful when debugging interactions between C and JavaScript code. ```gdb gjs_dumpstack() ``` -------------------------------- ### Insert Manual JavaScript Stacktrace Log Source: https://github.com/gnome/gnome-shell/blob/main/docs/debugging.md Insert `console.trace()` into your JavaScript code to log a stacktrace at a specific point. This is helpful for debugging the execution flow of particular JavaScript functions. ```javascript console.trace('trace from doSomething()') ``` -------------------------------- ### Animate Actor Property with ease_property Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Animate specific actor properties, such as effects, using the ease_property method. This is useful for properties not directly animatable via implicit animations. ```javascript desaturateActor(actor, desaturate) { const factor = desaturate ? 1.0 : 0.0; actor.ease_property('@effects.desaturate.factor', factor, { duration: 500, // ms mode: Clutter.AnimationMode.EASE_OUT_QUAD, }); } ``` -------------------------------- ### Generate 'Fixes:' Tag with Git Source: https://github.com/gnome/gnome-shell/blob/main/docs/commit-messages.md Use this command to generate a 'Fixes:' tag for a commit message, which helps in automatically closing issues when merged. Ensure the commit hash is correctly provided. ```bash git show -s --pretty='format:Fixes: %h ("%s")' ``` -------------------------------- ### Set Delegate Property for Actor Interaction Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md When creating wrapper classes or custom actors, set the `_delegate` property to `this` to ensure proper interaction with systems like drag and drop. This allows the actor to be treated as a drop target. ```javascript export const MyActor = GObject.registerClass( class MyActor extends Clutter.Actor { constructor(params) { super(params); this._delegate = this; } }); ``` ```javascript export class MyClass { constructor() { this.actor = new St.Button({text: 'This is a button'}); this.actor._delegate = this; this.actor.connect('clicked', this._onClicked.bind(this)); } _onClicked(actor) { actor.set_label('You clicked the button!'); } } ``` -------------------------------- ### Object Literal Syntax for Hash Table-like Objects Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md When using objects conceptually like hash tables, especially with keys that might contain special characters, use brackets for property access. Object definition can still omit quotes if keys are valid identifiers. ```javascript foo = {'bar': 42}; ``` ```javascript b = foo['bar']; ``` -------------------------------- ### Object Literal Syntax for Member Variables Source: https://github.com/gnome/gnome-shell/blob/main/docs/js-coding-style.md Use the no-quotes, no-brackets syntax for object literals when defining member variables. This applies to both object creation and property access. ```javascript foo = {bar: 42}; ``` ```javascript b = foo.bar; ``` -------------------------------- ### Define Auxiliary Function for Data Operations Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Define an auxiliary function to perform operations on data, typically placed above other functions to minimize prototypes. This function can be factored out from multiple other functions. ```c static void do_something_on_data (Foo *data, Bar *bar) { /* ... */ } ``` -------------------------------- ### Slowing Down Shell Animations Source: https://github.com/gnome/gnome-shell/blob/main/docs/looking-glass.md Adjust the `slow_down_factor` property of `St.Settings` to make shell animations slower. Useful for implementing and debugging new animation behaviors. A value greater than 1 is required. ```javascript St.Settings.get().slow_down_factor = 5 ``` -------------------------------- ### Log JavaScript Stacktrace on Segfault Source: https://github.com/gnome/gnome-shell/blob/main/docs/debugging.md Set the `SHELL_DEBUG` environment variable to `backtrace-segfault` to automatically log a JavaScript stacktrace when a segmentation fault occurs. This aids in debugging crashes originating from JavaScript code. ```shell export SHELL_DEBUG=backtrace-segfault ``` -------------------------------- ### Define Signal Callback with Passive Voice Source: https://github.com/gnome/gnome-shell/blob/main/docs/c-coding-style.md Callback function named using passive voice when referring to the object and signal, often suffixed with '_cb'. ```c static void click_action_clicked_cb (ClutterClickAction *click_action, ClutterActor *actor, gpointer user_data) { /* ... */ } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.