2024-02-20 02:15:24 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2024 elementary, Inc. (https://elementary.io)
|
|
|
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
2024-07-05 21:14:35 +03:00
|
|
|
public class Gala.Daemon.MonitorLabel : Gtk.Window {
|
2024-02-20 02:15:24 +03:00
|
|
|
private const int SPACING = 12;
|
|
|
|
private const string COLORED_STYLE_CSS = """
|
2024-02-21 14:09:54 +03:00
|
|
|
.%s {
|
|
|
|
background-color: alpha(%s, 0.8);
|
|
|
|
color: %s;
|
|
|
|
}
|
2024-02-20 02:15:24 +03:00
|
|
|
""";
|
|
|
|
|
|
|
|
public MonitorLabelInfo info { get; construct; }
|
|
|
|
|
|
|
|
public MonitorLabel (MonitorLabelInfo info) {
|
|
|
|
Object (info: info);
|
|
|
|
}
|
|
|
|
|
|
|
|
construct {
|
2024-02-21 14:09:54 +03:00
|
|
|
child = new Gtk.Label (info.label);
|
2024-02-20 02:15:24 +03:00
|
|
|
|
|
|
|
title = "LABEL-%i".printf (info.monitor);
|
|
|
|
|
|
|
|
decorated = false;
|
|
|
|
resizable = false;
|
|
|
|
deletable = false;
|
|
|
|
can_focus = false;
|
2024-07-05 21:14:35 +03:00
|
|
|
titlebar = new Gtk.Grid ();
|
2024-02-20 02:15:24 +03:00
|
|
|
|
|
|
|
var provider = new Gtk.CssProvider ();
|
|
|
|
try {
|
2024-07-05 21:14:35 +03:00
|
|
|
provider.load_from_string (COLORED_STYLE_CSS.printf (title, info.background_color, info.text_color));
|
2024-02-21 14:09:54 +03:00
|
|
|
get_style_context ().add_class (title);
|
|
|
|
get_style_context ().add_class ("monitor-label");
|
|
|
|
|
2024-07-05 21:14:35 +03:00
|
|
|
Gtk.StyleContext.add_provider_for_display (
|
|
|
|
Gdk.Display.get_default (),
|
2024-02-21 14:09:54 +03:00
|
|
|
provider,
|
|
|
|
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
|
|
|
);
|
2024-02-20 02:15:24 +03:00
|
|
|
} catch (Error e) {
|
|
|
|
warning ("Failed to load CSS: %s", e.message);
|
|
|
|
}
|
|
|
|
|
2024-07-05 21:14:35 +03:00
|
|
|
present ();
|
2024-02-20 02:15:24 +03:00
|
|
|
}
|
|
|
|
}
|