Skip to content

Allow custom theming of the headerbar

Tom Meyers requested to merge foxedb/blackbox:feature/239-context-coloring into main

This merge request attempts to implement #239 (closed).

Currently it's still in an early stage and might require some refactoring, depending on the style-guide of Black Box.

The MR consists of 4 parts:

  1. Adding the ability to change the context coloring via css classes
  2. Allowing to specify the context switching from outside the BaseHeaderBar class, so we can hook it up to Terminal
  3. Having a way to detect the different contexts (normal, root & SSH)
  4. Hooking all parts together and listing for context switching

Example:

Normal mode:

image

Root mode:

image

SSH mode:

image

A few things to note:

The context switching correctly detects if a user is running a normal session, root session or is in ssh, however we are currently listening for context on the key_pressed event, which is less than ideal.

A better approach would be to listen for child process events and see when one 'spawns' and 'exists' and update the context based on those. I'm currently still looking for a way to do that with the VTE api, but I'm not all to familiar with vala so that might take some time.

The reason key_pressed is not ideal is the following:

  1. We listen for 'Enter' and then check the context which doesn't update the context on processes crashing or exiting
  2. Inherently the context could change independent of a key event e.g. sleep 5 && sudo su Since we check the context at the beginning we miss the context change later on

More details can be found in the individual commits.

FYI: If anything in this MR isn't idiomatic vala, please inform me and I will change it, as I'm not to familiar with the language and I'm a huge fan of the context being shown in the header.

Merge request reports