feat(gui): ship a themed single-binary desk manager
The CLI, the separate helper and the GUI duplicated entry points, so a launch required two installed executables. pkexec now reuses the same binary through --privileged-launch, and the window adopts the dark landing-page look of the project site instead of the default GTK styling.
This commit is contained in:
10 files changed
+326
-678
No files matched your search
+278
-43
@@ -10,6 +10,194 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// Palette kept in one place: it mirrors the identity used on the FWS website
|
||||
// (dark canvas, violet accent, soft-bordered cards).
|
||||
constexpr const char* kThemeCss = R"CSS(
|
||||
window {
|
||||
background-color: #0a0d14;
|
||||
color: #e7eaf5;
|
||||
font-family: "Inter", "Cantarell", "Noto Sans", sans-serif;
|
||||
}
|
||||
|
||||
headerbar {
|
||||
background-color: #0f131c;
|
||||
background-image: none;
|
||||
border-bottom: 1px solid #1f2634;
|
||||
box-shadow: none;
|
||||
min-height: 48px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.icon-button {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
border: none;
|
||||
border-radius: 999px;
|
||||
box-shadow: none;
|
||||
padding: 6px;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.icon-button:hover {
|
||||
background-color: #1e2434;
|
||||
}
|
||||
|
||||
.wordmark {
|
||||
background-color: #6d5efc;
|
||||
background-image: none;
|
||||
color: #ffffff;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 1px;
|
||||
padding: 4px 8px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.app-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #eef1ff;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 2px;
|
||||
color: #a78bfa;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #f5f7ff;
|
||||
}
|
||||
|
||||
.hero-text {
|
||||
font-size: 13px;
|
||||
color: #8f99af;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 2px;
|
||||
color: #6f7a92;
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: #121724;
|
||||
border: 1px solid #222b3d;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
background-color: #161c2b;
|
||||
border-color: #33415c;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #f4f6ff;
|
||||
}
|
||||
|
||||
.profile-status {
|
||||
font-size: 12px;
|
||||
color: #98a2b8;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 999px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
padding: 6px 16px;
|
||||
}
|
||||
|
||||
/* Own classes rather than the theme's suggested/destructive variants: the
|
||||
installed GTK theme was repainting the buttons and washing the accent out. */
|
||||
button.primary {
|
||||
background-color: #6d5efc;
|
||||
background-image: none;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
button.primary:hover {
|
||||
background-color: #7d6fff;
|
||||
}
|
||||
|
||||
button.primary:active {
|
||||
background-color: #5b4ce6;
|
||||
}
|
||||
|
||||
button.danger {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
border: 1px solid #3d2833;
|
||||
box-shadow: none;
|
||||
color: #f28585;
|
||||
}
|
||||
|
||||
button.danger:hover {
|
||||
background-color: rgba(248, 113, 113, 0.14);
|
||||
border-color: #8a4a52;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 12px;
|
||||
color: #8a94ab;
|
||||
}
|
||||
|
||||
.log-card {
|
||||
background-color: #0d1018;
|
||||
border: 1px solid #232a3a;
|
||||
border-radius: 14px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.log-card textview,
|
||||
.log-card textview text {
|
||||
background-color: transparent;
|
||||
color: #c3cbe0;
|
||||
}
|
||||
|
||||
scrollbar slider {
|
||||
background-color: #2c3547;
|
||||
border-radius: 999px;
|
||||
min-width: 6px;
|
||||
min-height: 6px;
|
||||
}
|
||||
|
||||
spinner {
|
||||
color: #a78bfa;
|
||||
}
|
||||
)CSS";
|
||||
|
||||
// App-level provider: the stylesheet rides along with the window instead of
|
||||
// depending on a theme file installed on the system.
|
||||
void installTheme() {
|
||||
GdkDisplay* display = gdk_display_get_default();
|
||||
if (display == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
GtkCssProvider* provider = gtk_css_provider_new();
|
||||
#if GTK_CHECK_VERSION(4, 12, 0)
|
||||
gtk_css_provider_load_from_string(provider, kThemeCss);
|
||||
#else
|
||||
gtk_css_provider_load_from_data(provider, kThemeCss, -1);
|
||||
#endif
|
||||
gtk_style_context_add_provider_for_display(display, GTK_STYLE_PROVIDER(provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref(provider);
|
||||
}
|
||||
|
||||
enum class RowMode { Install, SwitchTo, Greeter, Launch };
|
||||
|
||||
struct RowWidgets {
|
||||
@@ -39,6 +227,11 @@ private:
|
||||
static void onActivate(GtkApplication* application, gpointer data) {
|
||||
auto* self = static_cast<ManagerWindow*>(data);
|
||||
if (self->window_ == nullptr) {
|
||||
installTheme();
|
||||
// The site is dark; follow it even when the desktop prefers light.
|
||||
if (GtkSettings* settings = gtk_settings_get_default(); settings != nullptr) {
|
||||
g_object_set(settings, "gtk-application-prefer-dark-theme", TRUE, nullptr);
|
||||
}
|
||||
self->buildWindow(application);
|
||||
}
|
||||
gtk_window_present(GTK_WINDOW(self->window_));
|
||||
@@ -147,40 +340,79 @@ private:
|
||||
void buildWindow(GtkApplication* application) {
|
||||
window_ = gtk_application_window_new(application);
|
||||
gtk_window_set_title(GTK_WINDOW(window_), "FWS DeskManager");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window_), 660, 620);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window_), 800, 720);
|
||||
|
||||
GtkWidget* header = gtk_header_bar_new();
|
||||
GtkWidget* title = gtk_label_new(nullptr);
|
||||
gtk_label_set_markup(GTK_LABEL(title), "<b>FWS DeskManager</b>");
|
||||
gtk_header_bar_set_title_widget(GTK_HEADER_BAR(header), title);
|
||||
|
||||
// One line only: a stacked title was taller than the header bar and got
|
||||
// clipped at the top edge of the window.
|
||||
GtkWidget* brand = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_widget_set_valign(brand, GTK_ALIGN_CENTER);
|
||||
GtkWidget* logo = gtk_label_new("FWS");
|
||||
gtk_widget_add_css_class(logo, "wordmark");
|
||||
gtk_widget_set_valign(logo, GTK_ALIGN_CENTER);
|
||||
|
||||
GtkWidget* appTitle = gtk_label_new("DeskManager");
|
||||
gtk_widget_add_css_class(appTitle, "app-title");
|
||||
gtk_widget_set_valign(appTitle, GTK_ALIGN_CENTER);
|
||||
|
||||
gtk_box_append(GTK_BOX(brand), logo);
|
||||
gtk_box_append(GTK_BOX(brand), appTitle);
|
||||
gtk_header_bar_set_title_widget(GTK_HEADER_BAR(header), brand);
|
||||
|
||||
refreshButton_ = gtk_button_new_from_icon_name("view-refresh-symbolic");
|
||||
gtk_widget_add_css_class(refreshButton_, "icon-button");
|
||||
gtk_widget_set_tooltip_text(refreshButton_, "Rafraîchir l'état des environnements");
|
||||
g_signal_connect(refreshButton_, "clicked", G_CALLBACK(&ManagerWindow::onRefreshClicked), this);
|
||||
gtk_header_bar_pack_end(GTK_HEADER_BAR(header), refreshButton_);
|
||||
gtk_window_set_titlebar(GTK_WINDOW(window_), header);
|
||||
|
||||
GtkWidget* root = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start(root, 18);
|
||||
gtk_widget_set_margin_end(root, 18);
|
||||
gtk_widget_set_margin_top(root, 14);
|
||||
gtk_widget_set_margin_bottom(root, 14);
|
||||
GtkWidget* root = gtk_box_new(GTK_ORIENTATION_VERTICAL, 14);
|
||||
// Centred column: on a wide window the rows stay readable instead of
|
||||
// stretching a lone button to the far right edge.
|
||||
gtk_widget_set_halign(root, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_size_request(root, 680, -1);
|
||||
gtk_widget_set_margin_start(root, 20);
|
||||
gtk_widget_set_margin_end(root, 20);
|
||||
gtk_widget_set_margin_top(root, 18);
|
||||
gtk_widget_set_margin_bottom(root, 18);
|
||||
gtk_window_set_child(GTK_WINDOW(window_), root);
|
||||
|
||||
// Banner block: the same role as the site's hero, so the window reads as
|
||||
// part of the same identity before the list of environments.
|
||||
GtkWidget* hero = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
|
||||
GtkWidget* eyebrow = gtk_label_new("FWS ISO");
|
||||
gtk_widget_add_css_class(eyebrow, "eyebrow");
|
||||
gtk_label_set_xalign(GTK_LABEL(eyebrow), 0.0F);
|
||||
|
||||
GtkWidget* heroTitle = gtk_label_new("Choisissez votre environnement");
|
||||
gtk_widget_add_css_class(heroTitle, "hero-title");
|
||||
gtk_label_set_xalign(GTK_LABEL(heroTitle), 0.0F);
|
||||
|
||||
GtkWidget* intro = gtk_label_new(
|
||||
"Installez un environnement puis lancez-le sans passer par l'ecran de connexion : "
|
||||
"la session precedente est fermee au profit de la nouvelle.");
|
||||
gtk_label_set_wrap(GTK_LABEL(intro), TRUE);
|
||||
gtk_label_set_xalign(GTK_LABEL(intro), 0.0F);
|
||||
gtk_widget_add_css_class(intro, "dim-label");
|
||||
gtk_box_append(GTK_BOX(root), intro);
|
||||
gtk_widget_add_css_class(intro, "hero-text");
|
||||
|
||||
gtk_box_append(GTK_BOX(hero), eyebrow);
|
||||
gtk_box_append(GTK_BOX(hero), heroTitle);
|
||||
gtk_box_append(GTK_BOX(hero), intro);
|
||||
gtk_box_append(GTK_BOX(root), hero);
|
||||
|
||||
GtkWidget* sectionTitle = gtk_label_new("ENVIRONNEMENTS");
|
||||
gtk_widget_add_css_class(sectionTitle, "section-title");
|
||||
gtk_label_set_xalign(GTK_LABEL(sectionTitle), 0.0F);
|
||||
gtk_widget_set_margin_top(sectionTitle, 4);
|
||||
gtk_box_append(GTK_BOX(root), sectionTitle);
|
||||
|
||||
GtkWidget* scroller = gtk_scrolled_window_new();
|
||||
gtk_widget_set_vexpand(scroller, TRUE);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller), GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
rowsBox_ = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
|
||||
rowsBox_ = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scroller), rowsBox_);
|
||||
gtk_box_append(GTK_BOX(root), scroller);
|
||||
|
||||
@@ -192,11 +424,12 @@ private:
|
||||
statusLabel_ = gtk_label_new("Prêt.");
|
||||
gtk_label_set_xalign(GTK_LABEL(statusLabel_), 0.0F);
|
||||
gtk_widget_set_hexpand(statusLabel_, TRUE);
|
||||
gtk_widget_add_css_class(statusLabel_, "dim-label");
|
||||
gtk_widget_add_css_class(statusLabel_, "status-text");
|
||||
gtk_box_append(GTK_BOX(footer), statusLabel_);
|
||||
gtk_box_append(GTK_BOX(root), footer);
|
||||
|
||||
logExpander_ = gtk_expander_new("Détails de l'installation");
|
||||
gtk_widget_add_css_class(logExpander_, "log-card");
|
||||
gtk_expander_set_expanded(GTK_EXPANDER(logExpander_), FALSE);
|
||||
GtkWidget* logScroller = gtk_scrolled_window_new();
|
||||
gtk_widget_set_size_request(logScroller, -1, 150);
|
||||
@@ -216,25 +449,23 @@ private:
|
||||
void buildRows() {
|
||||
rows_.reserve(fws::supportedDesktops().size());
|
||||
for (const fws::DesktopProfile& profile : fws::supportedDesktops()) {
|
||||
GtkWidget* frame = gtk_frame_new(nullptr);
|
||||
gtk_widget_add_css_class(frame, "frame");
|
||||
|
||||
GtkWidget* box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_widget_set_margin_start(box, 14);
|
||||
gtk_widget_set_margin_end(box, 14);
|
||||
gtk_widget_set_margin_top(box, 12);
|
||||
gtk_widget_set_margin_bottom(box, 12);
|
||||
GtkWidget* card = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_widget_add_css_class(card, "card");
|
||||
gtk_widget_set_margin_start(card, 18);
|
||||
gtk_widget_set_margin_end(card, 18);
|
||||
gtk_widget_set_margin_top(card, 16);
|
||||
gtk_widget_set_margin_bottom(card, 16);
|
||||
|
||||
GtkWidget* text = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||
gtk_widget_set_hexpand(text, TRUE);
|
||||
gtk_widget_set_valign(text, GTK_ALIGN_CENTER);
|
||||
|
||||
GtkWidget* name = gtk_label_new(nullptr);
|
||||
gchar* markup = g_markup_printf_escaped("<b>%s</b>", profile.name.c_str());
|
||||
gtk_label_set_markup(GTK_LABEL(name), markup);
|
||||
g_free(markup);
|
||||
GtkWidget* name = gtk_label_new(profile.name.c_str());
|
||||
gtk_widget_add_css_class(name, "profile-name");
|
||||
gtk_label_set_xalign(GTK_LABEL(name), 0.0F);
|
||||
|
||||
GtkWidget* status = gtk_label_new("…");
|
||||
gtk_widget_add_css_class(status, "profile-status");
|
||||
gtk_label_set_xalign(GTK_LABEL(status), 0.0F);
|
||||
|
||||
gtk_box_append(GTK_BOX(text), name);
|
||||
@@ -242,13 +473,12 @@ private:
|
||||
|
||||
GtkWidget* action = gtk_button_new_with_label("Installer");
|
||||
gtk_widget_set_valign(action, GTK_ALIGN_CENTER);
|
||||
gtk_widget_add_css_class(action, "suggested-action");
|
||||
gtk_widget_add_css_class(action, "primary");
|
||||
g_signal_connect(action, "clicked", G_CALLBACK(&ManagerWindow::onActionClicked), this);
|
||||
|
||||
gtk_box_append(GTK_BOX(box), text);
|
||||
gtk_box_append(GTK_BOX(box), action);
|
||||
gtk_frame_set_child(GTK_FRAME(frame), box);
|
||||
gtk_box_append(GTK_BOX(rowsBox_), frame);
|
||||
gtk_box_append(GTK_BOX(card), text);
|
||||
gtk_box_append(GTK_BOX(card), action);
|
||||
gtk_box_append(GTK_BOX(rowsBox_), card);
|
||||
|
||||
RowWidgets row;
|
||||
row.profile = &profile;
|
||||
@@ -286,28 +516,28 @@ private:
|
||||
const bool active = installed && fws::findActiveSession(*row.profile, sessionId);
|
||||
const bool isCurrent = active && !current.empty() && sessionId == current;
|
||||
|
||||
gtk_widget_remove_css_class(row.action, "suggested-action");
|
||||
gtk_widget_remove_css_class(row.action, "destructive-action");
|
||||
gtk_widget_remove_css_class(row.action, "primary");
|
||||
gtk_widget_remove_css_class(row.action, "danger");
|
||||
|
||||
if (!installed) {
|
||||
gtk_label_set_markup(GTK_LABEL(row.status),
|
||||
"<span foreground='#e5a50a'>Non installé</span>");
|
||||
"<span foreground='#f5b84d'>Non installé</span>");
|
||||
gtk_button_set_label(GTK_BUTTON(row.action), "Installer");
|
||||
gtk_widget_add_css_class(row.action, "suggested-action");
|
||||
gtk_widget_add_css_class(row.action, "primary");
|
||||
row.mode = RowMode::Install;
|
||||
} else if (isCurrent) {
|
||||
gtk_label_set_markup(GTK_LABEL(row.status),
|
||||
"<span foreground='#26a269'>Installé</span> · session actuelle");
|
||||
"<span foreground='#4ade80'>Installé</span> · session actuelle");
|
||||
// Activating the session already on screen would do nothing, so
|
||||
// the useful action from here is leaving for the greeter.
|
||||
gtk_button_set_label(GTK_BUTTON(row.action), "Écran de connexion");
|
||||
gtk_widget_add_css_class(row.action, "suggested-action");
|
||||
gtk_widget_add_css_class(row.action, "primary");
|
||||
row.mode = RowMode::Greeter;
|
||||
} else if (active) {
|
||||
gtk_label_set_markup(GTK_LABEL(row.status),
|
||||
"<span foreground='#26a269'>Installé</span> · session active");
|
||||
"<span foreground='#4ade80'>Installé</span> · session active");
|
||||
gtk_button_set_label(GTK_BUTTON(row.action), "Basculer");
|
||||
gtk_widget_add_css_class(row.action, "suggested-action");
|
||||
gtk_widget_add_css_class(row.action, "primary");
|
||||
row.mode = RowMode::SwitchTo;
|
||||
} else {
|
||||
// Without a display manager that supports one-shot autologin,
|
||||
@@ -315,14 +545,14 @@ private:
|
||||
std::string reason;
|
||||
if (fws::canStartWithoutGreeter(reason)) {
|
||||
gtk_label_set_markup(GTK_LABEL(row.status),
|
||||
"<span foreground='#26a269'>Installé</span> · aucune "
|
||||
"<span foreground='#4ade80'>Installé</span> · aucune "
|
||||
"session");
|
||||
gtk_button_set_label(GTK_BUTTON(row.action), "Lancer");
|
||||
gtk_widget_set_tooltip_text(
|
||||
row.action,
|
||||
"Démarrer l'environnement sans écran de connexion : la session "
|
||||
"actuelle sera fermée.");
|
||||
gtk_widget_add_css_class(row.action, "suggested-action");
|
||||
gtk_widget_add_css_class(row.action, "primary");
|
||||
row.mode = RowMode::Launch;
|
||||
} else {
|
||||
// The greeter opens on the session it remembered, not on the one
|
||||
@@ -330,11 +560,11 @@ private:
|
||||
const std::string entry = fws::greeterSessionName(row.profile->sessionNames);
|
||||
if (entry.empty()) {
|
||||
gtk_label_set_markup(GTK_LABEL(row.status),
|
||||
"<span foreground='#26a269'>Installé</span> · "
|
||||
"<span foreground='#4ade80'>Installé</span> · "
|
||||
"aucune session");
|
||||
} else {
|
||||
gchar* markup = g_markup_printf_escaped(
|
||||
"<span foreground='#26a269'>Installé</span> · aucune session · "
|
||||
"<span foreground='#4ade80'>Installé</span> · aucune session · "
|
||||
"choisir « %s » au greeter",
|
||||
entry.c_str());
|
||||
gtk_label_set_markup(GTK_LABEL(row.status), markup);
|
||||
@@ -342,7 +572,7 @@ private:
|
||||
}
|
||||
gtk_button_set_label(GTK_BUTTON(row.action), "Écran de connexion");
|
||||
gtk_widget_set_tooltip_text(row.action, nullptr);
|
||||
gtk_widget_add_css_class(row.action, "destructive-action");
|
||||
gtk_widget_add_css_class(row.action, "danger");
|
||||
row.mode = RowMode::Greeter;
|
||||
}
|
||||
}
|
||||
@@ -591,5 +821,10 @@ private:
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// pkexec re-enters the same executable for the privileged launch: GTK is
|
||||
// never initialised on that path.
|
||||
if (argc == 4 && std::string(argv[1]) == "--privileged-launch") {
|
||||
return fws::runLaunchHelper(argv[2], argv[3]);
|
||||
}
|
||||
return ManagerWindow::run(argc, argv);
|
||||
}
|
||||
Reference in new issue
Block a user