mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
feat(ui): modernize GTK styling and add appearance settings (#144)
* feat(ui): modernize GTK styling and add appearance settings * fix(ui): address review and avoid cached Cairo surface in smoke tests
This commit is contained in:
13 files changed
+434
-90
No files matched your search
@@ -9,27 +9,9 @@
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
#include "i18n.h"
|
||||
#include "ui_theme.h"
|
||||
static void on_language(GtkComboBox *c, gpointer note);
|
||||
|
||||
static const char *CSS =
|
||||
"window { background-color: #f5f6f8; }\n"
|
||||
"* { font-family: 'Noto Sans CJK SC', 'Noto Sans SC', sans-serif; }\n"
|
||||
".card { background-color: #ffffff; border-radius: 10px; border: 1px solid #e5e7eb; }\n"
|
||||
".heading { font-size: 20px; font-weight: 700; color: #1d1d1f; }\n"
|
||||
".key { font-size: 14px; color: #4b5563; }\n"
|
||||
".big { font-size: 32px; font-weight: 800; color: #111111; }\n"
|
||||
".note { font-size: 13px; color: #9ca3af; }\n"
|
||||
".hint { font-size: 13px; color: #6b7280; }\n"
|
||||
".footer { font-size: 12px; color: #9ca3af; }\n"
|
||||
"button.flat { padding: 4px 8px; }\n"
|
||||
"button.share { background-image: none; background-color: #ffffff; border: 1px solid #d1d5db;"
|
||||
" border-radius: 6px; padding: 6px 14px; font-size: 14px; }\n"
|
||||
"separator { background-color: #e5e7eb; min-height: 1px; }\n"
|
||||
".user { font-size: 22px; font-weight: 700; color: #111111; }\n"
|
||||
".status { font-size: 13px; color: #2f6bff; }\n"
|
||||
".status.ok { color: #16a34a; }\n"
|
||||
".status.error { color: #dc2626; }\n";
|
||||
|
||||
enum { CMD_NONE = 0, CMD_ALLOW = 1, CMD_DENY = 2, CMD_RESET = 3, CMD_STOP = 4, CMD_VERIFY = 5, CMD_REFRESH = 6, CMD_CUSTOM = 7, CMD_LOGOUT = 8, CMD_QUIT = 9 };
|
||||
enum { VERIFY_TEMPORARY = 0, VERIFY_CUSTOM = 1, VERIFY_BOTH = 2 };
|
||||
|
||||
@@ -387,11 +369,7 @@ static void build_tray(void) {
|
||||
}
|
||||
|
||||
static void build_window(void) {
|
||||
GtkCssProvider *css = gtk_css_provider_new();
|
||||
gtk_css_provider_load_from_data(css, CSS, -1, NULL);
|
||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref(css);
|
||||
uu_theme_init();
|
||||
|
||||
gtk_window_set_default_icon_name("uu-remote-linux"); // contrib/desktop icon, when installed
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
@@ -522,6 +500,7 @@ static void build_window(void) {
|
||||
gtk_box_pack_start(GTK_BOX(lang_row), lang, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(lang_row), lang_note, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end(GTK_BOX(root), lang_row, FALSE, FALSE, 6);
|
||||
gtk_box_pack_end(GTK_BOX(lang_row), uu_theme_settings_button(GTK_WINDOW(window)), FALSE, FALSE, 0);
|
||||
if (close_hides) gtk_label_set_text(GTK_LABEL(footer_label), L("开源 Linux 被控端 · 非网易官方客户端 · 关闭窗口后远程协助仍在后台运行", "Open-source Linux host · not an official NetEase client · remote assistance keeps running after the window closes"));
|
||||
render_code();
|
||||
if (close_hides) build_tray();
|
||||
@@ -544,8 +523,6 @@ static void on_language(GtkComboBox *c, gpointer note) {
|
||||
static void *ui_main(void *arg) {
|
||||
(void)arg;
|
||||
int ok = gtk_init_check(NULL, NULL);
|
||||
// The CSS hard-codes a light palette; a dark system theme would turn unstyled text white on white (#43).
|
||||
if (ok) g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||
if (ok) build_window();
|
||||
pthread_mutex_lock(&init_lock);
|
||||
init_state = ok ? 1 : -1;
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
// One palette for all GTK windows. Named GTK colors also follow live system theme changes.
|
||||
#include "ui_theme.h"
|
||||
#include "i18n.h"
|
||||
#include <glib/gstdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int initialized, mode;
|
||||
static const char *modes[] = {"system", "light", "dark"};
|
||||
static const char *CSS =
|
||||
"* { font-family: 'Noto Sans CJK SC', 'Noto Sans SC', sans-serif; }\n"
|
||||
"@define-color uu_bg mix(@theme_bg_color, @theme_base_color, 0.5);\n"
|
||||
"@define-color uu_surface @theme_base_color;\n"
|
||||
"@define-color uu_fg @theme_fg_color;\n"
|
||||
"@define-color uu_muted mix(@theme_fg_color, @theme_bg_color, 0.25);\n"
|
||||
"@define-color uu_border mix(@theme_bg_color, @theme_fg_color, 0.18);\n"
|
||||
"@define-color uu_accent @theme_selected_bg_color;\n"
|
||||
"@define-color uu_accent_fg @theme_selected_fg_color;\n"
|
||||
"@define-color uu_tint mix(@theme_base_color, @theme_selected_bg_color, 0.12);\n"
|
||||
"@define-color uu_success mix(@theme_fg_color, #16a34a, 0.55);\n"
|
||||
"@define-color uu_error mix(@theme_fg_color, #dc2626, 0.65);\n"
|
||||
"window { background-color: @uu_bg; color: @uu_fg; }\n"
|
||||
"headerbar { background-image: none; background-color: @uu_bg; box-shadow: none; border-bottom: 1px solid @uu_border; }\n"
|
||||
"button { background-image: none; background-color: @uu_surface; color: @uu_fg; border: 1px solid @uu_border; border-radius: 8px; box-shadow: none; text-shadow: none; padding: 7px 12px; }\n"
|
||||
"button:hover { background-color: @uu_tint; border-color: @uu_accent; }\n"
|
||||
"button:active, button:checked { background-color: @uu_tint; border-color: @uu_accent; }\n"
|
||||
"button:disabled { color: mix(@uu_fg, @uu_surface, 0.55); background-color: @uu_bg; border-color: @uu_border; }\n"
|
||||
"button:focus, entry:focus { border-color: @uu_accent; outline-color: @uu_accent; outline-style: solid; outline-width: 2px; outline-offset: 2px; }\n"
|
||||
"entry { background-image: none; background-color: @uu_surface; color: @uu_fg; border: 1px solid @uu_border; border-radius: 8px; box-shadow: none; padding: 7px 10px; }\n"
|
||||
"entry:disabled { color: @uu_muted; background-color: @uu_bg; }\n"
|
||||
"separator { background-color: @uu_border; min-height: 1px; min-width: 1px; }\n"
|
||||
".card, .cardbtn, .banner { background-color: @uu_surface; border: 1px solid @uu_border; border-radius: 12px; }\n"
|
||||
".heading, .title, .h2, .user { font-size: 22px; font-weight: 700; color: @uu_fg; }\n"
|
||||
".section, .group { font-size: 16px; font-weight: 600; color: @uu_fg; }\n"
|
||||
".big { font-size: 32px; font-weight: 700; color: @uu_fg; }\n"
|
||||
".key, .hint, .empty { font-size: 14px; color: @uu_muted; }\n"
|
||||
".note, .footer { font-size: 13px; color: @uu_muted; }\n"
|
||||
".status { font-size: 13px; color: @uu_muted; }\n"
|
||||
".status.ok, .online, .dot { color: @uu_success; }\n"
|
||||
".status.error { color: @uu_error; }\n"
|
||||
".tag { background-color: @uu_tint; color: @uu_fg; border-radius: 6px; padding: 3px 8px; font-size: 12px; }\n"
|
||||
".tag.remote { color: @uu_success; }\n"
|
||||
"button.primary, button.enter { background-color: @uu_accent; color: @uu_accent_fg; border-color: transparent; font-weight: 600; padding: 9px 24px; }\n"
|
||||
"button.primary:hover, button.enter:hover { background-color: shade(@uu_accent, 0.9); }\n"
|
||||
"button.primary:active, button.enter:active { background-color: shade(@uu_accent, 0.8); }\n"
|
||||
"button.primary:disabled, button.enter:disabled { background-color: @uu_bg; color: @uu_muted; border-color: @uu_border; }\n"
|
||||
"button.flat, button.hbtn, button.tool { background-color: transparent; border-color: transparent; }\n"
|
||||
"button.flat:hover, button.hbtn:hover, button.tool:hover, button.cardbtn:hover { background-color: @uu_tint; border-color: @uu_border; }\n"
|
||||
".toast { background-color: @uu_fg; color: @uu_surface; border-radius: 10px; padding: 12px 18px; font-size: 14px; }\n"
|
||||
".qrbox { background-color: white; border: 1px solid @uu_border; border-radius: 12px; padding: 14px; }\n";
|
||||
|
||||
void uu_theme_load_css(const char *css) {
|
||||
GtkCssProvider *provider = gtk_css_provider_new();
|
||||
GError *error = NULL;
|
||||
if (gtk_css_provider_load_from_data(provider, css, -1, &error))
|
||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
else { g_warning("Could not load UI stylesheet"); g_clear_error(&error); }
|
||||
g_object_unref(provider);
|
||||
}
|
||||
|
||||
static char *theme_path(void) {
|
||||
return g_build_filename(g_get_user_config_dir(), "uuremote", "theme", NULL);
|
||||
}
|
||||
|
||||
static void apply_mode(void) {
|
||||
GtkSettings *settings = gtk_settings_get_default();
|
||||
if (!mode) {
|
||||
// Reset the application override, so subsequent desktop changes still propagate.
|
||||
gtk_settings_reset_property(settings, "gtk-theme-name");
|
||||
gtk_settings_reset_property(settings, "gtk-application-prefer-dark-theme");
|
||||
} else {
|
||||
g_object_set(settings, "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", mode == 2, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void uu_theme_init(void) {
|
||||
if (initialized) return;
|
||||
initialized = 1;
|
||||
char *path = theme_path(), *value = NULL;
|
||||
if (g_file_get_contents(path, &value, NULL, NULL)) {
|
||||
g_strstrip(value);
|
||||
for (int i = 0; i < 3; i++) if (!strcmp(value, modes[i])) mode = i;
|
||||
}
|
||||
g_free(value); g_free(path);
|
||||
apply_mode();
|
||||
uu_theme_load_css(CSS);
|
||||
}
|
||||
|
||||
static void on_theme(GtkComboBox *combo, gpointer note) {
|
||||
int selected = gtk_combo_box_get_active(combo);
|
||||
if (selected < 0 || selected > 2) return;
|
||||
mode = selected;
|
||||
apply_mode();
|
||||
char *path = theme_path(), *dir = g_path_get_dirname(path);
|
||||
gboolean saved = g_mkdir_with_parents(dir, 0700) == 0 && g_file_set_contents(path, modes[mode], -1, NULL);
|
||||
gtk_label_set_text(GTK_LABEL(note), saved ? "" : L("无法保存外观设置", "Could not save appearance"));
|
||||
gtk_widget_set_visible(GTK_WIDGET(note), !saved);
|
||||
g_free(dir); g_free(path);
|
||||
}
|
||||
|
||||
GtkWidget *uu_theme_selector(void) {
|
||||
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6), *row = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
|
||||
GtkWidget *label = gtk_label_new(L("外观", "Appearance")), *combo = gtk_combo_box_text_new(), *note = gtk_label_new("");
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(label), "key");
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(note), "status");
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(note), "error");
|
||||
gtk_label_set_line_wrap(GTK_LABEL(note), TRUE);
|
||||
gtk_widget_set_no_show_all(note, TRUE);
|
||||
gtk_widget_set_halign(note, GTK_ALIGN_START);
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), L("跟随系统", "System"));
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), L("浅色", "Light"));
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), L("深色", "Dark"));
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), mode);
|
||||
atk_object_set_name(gtk_widget_get_accessible(combo), L("外观", "Appearance"));
|
||||
g_signal_connect(combo, "changed", G_CALLBACK(on_theme), note);
|
||||
gtk_box_pack_start(GTK_BOX(row), label, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end(GTK_BOX(row), combo, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(box), row, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(box), note, FALSE, FALSE, 0);
|
||||
return box;
|
||||
}
|
||||
|
||||
static void open_settings(GtkButton *button, gpointer parent) {
|
||||
(void)button;
|
||||
GtkWidget *dialog = gtk_dialog_new_with_buttons(L("设置", "Settings"), GTK_WINDOW(parent),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, L("关闭", "Close"), GTK_RESPONSE_CLOSE, NULL);
|
||||
GtkWidget *area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
gtk_window_set_default_size(GTK_WINDOW(dialog), 360, -1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(area), 24);
|
||||
gtk_box_pack_start(GTK_BOX(area), uu_theme_selector(), FALSE, FALSE, 0);
|
||||
g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
|
||||
gtk_widget_show_all(dialog);
|
||||
}
|
||||
|
||||
GtkWidget *uu_theme_settings_button(GtkWindow *parent) {
|
||||
GtkWidget *button = gtk_button_new_from_icon_name("preferences-system-symbolic", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_style_context_add_class(gtk_widget_get_style_context(button), "flat");
|
||||
gtk_widget_set_tooltip_text(button, L("设置", "Settings"));
|
||||
atk_object_set_name(gtk_widget_get_accessible(button), L("设置", "Settings"));
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(open_settings), parent);
|
||||
return button;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef UU_UI_THEME_H
|
||||
#define UU_UI_THEME_H
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
// Call on the GTK thread, after gtk_init_check. Shared by the host and viewer tools.
|
||||
void uu_theme_init(void);
|
||||
GtkWidget *uu_theme_selector(void);
|
||||
GtkWidget *uu_theme_settings_button(GtkWindow *parent);
|
||||
void uu_theme_load_css(const char *css);
|
||||
#endif
|
||||
+6
-16
@@ -10,6 +10,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "i18n.h"
|
||||
#include "ui_theme.h"
|
||||
|
||||
#define QSIZE 64
|
||||
static char queue[QSIZE][4096];
|
||||
@@ -46,26 +47,17 @@ static gboolean toast_idle(gpointer d) { show_toast(d); g_free(d); return G_SOUR
|
||||
void uu_tools_ui_toast(const char *text) { g_idle_add(toast_idle, g_strdup(text)); }
|
||||
static gboolean on_delete(GtkWidget *w, GdkEvent *e, gpointer d) { (void)e; (void)d; gtk_widget_hide(w); atomic_store(&closed, 1); return TRUE; }
|
||||
|
||||
static const char *css =
|
||||
"window { background: #f5f6f8; }\n"
|
||||
".title { font-size: 22px; font-weight: bold; color: #111827; }\n"
|
||||
".tag { background: #e5e7eb; color: #4b5563; border-radius: 6px; padding: 2px 8px; }\n"
|
||||
".tag.remote { background: #d1fae5; color: #047857; }\n"
|
||||
".card { background: white; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px; }\n"
|
||||
".section { font-size: 17px; font-weight: bold; }\n"
|
||||
".toast { background: rgba(17,24,39,0.88); color: white; border-radius: 8px; padding: 10px 18px; }\n"
|
||||
".primary { background-image: none; background-color: #10b981; color: white; border: none; }\n"
|
||||
".empty { color: #6b7280; font-size: 15px; }\n"
|
||||
".online { color: #10b981; }\n";
|
||||
|
||||
static GtkWidget *frame(const char *title, GtkWidget **content) {
|
||||
GtkCssProvider *p = gtk_css_provider_new(); gtk_css_provider_load_from_data(p, css, -1, NULL);
|
||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(p), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
uu_theme_init();
|
||||
uu_theme_load_css(".card { padding: 12px; } treeview.view { padding: 6px; }");
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), title);
|
||||
g_signal_connect(window, "delete-event", G_CALLBACK(on_delete), NULL);
|
||||
GtkWidget *overlay = gtk_overlay_new(); *content = vbox(14);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(*content), 22);
|
||||
GtkWidget *appearance = uu_theme_settings_button(GTK_WINDOW(window));
|
||||
gtk_widget_set_halign(appearance, GTK_ALIGN_END);
|
||||
gtk_box_pack_start(GTK_BOX(*content), appearance, FALSE, FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER(overlay), *content);
|
||||
toast = label("", "toast"); gtk_widget_set_halign(toast, GTK_ALIGN_CENTER); gtk_widget_set_valign(toast, GTK_ALIGN_END);
|
||||
gtk_widget_set_margin_bottom(toast, 30); gtk_widget_set_no_show_all(toast, TRUE);
|
||||
@@ -476,8 +468,6 @@ static void *ui_thread(void *d) {
|
||||
(void)d;
|
||||
if (!gtk_init_check(NULL, NULL)) { pthread_mutex_lock(&init_lock); init_state = -1; pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); return NULL; }
|
||||
gtk_window_set_default_icon_name("uu-remote-linux"); // same taskbar icon as the host (#13)
|
||||
// Light palette in CSS; keep a dark system theme from making unstyled text white on white (#43).
|
||||
g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||
show_window(NULL); gtk_main(); return NULL;
|
||||
}
|
||||
/* Hidden windows retain their widgets so queued idle callbacks stay valid. */
|
||||
|
||||
+33
-46
@@ -11,45 +11,32 @@
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include "i18n.h"
|
||||
#include "ui_theme.h"
|
||||
|
||||
static const char *CSS =
|
||||
"window { background-color: #ffffff; }\n"
|
||||
"* { font-family: 'Noto Sans CJK SC', 'Noto Sans SC', sans-serif; }\n"
|
||||
".sidebar { background-color: #e9e9ec; }\n"
|
||||
".section { font-size: 16px; font-weight: 600; color: #1d1d1f; }\n"
|
||||
".sidebar { background-color: @theme_bg_color; border-right: 1px solid @uu_border; }\n"
|
||||
".sidebar list, .sidebar row { background-color: transparent; }\n"
|
||||
".sidebar row { border-radius: 8px; margin: 1px 10px; padding: 8px 10px; }\n"
|
||||
".sidebar row:selected { background-color: #d4d4d9; color: #1d1d1f; }\n"
|
||||
".devname { font-size: 15px; color: #1d1d1f; }\n"
|
||||
".offline { color: #9ca3af; }\n"
|
||||
".dot { color: #22c55e; font-size: 10px; }\n"
|
||||
".sidebar row { border-radius: 8px; margin: 3px 12px; padding: 10px 12px; }\n"
|
||||
".sidebar row:hover { background-color: @uu_tint; }\n"
|
||||
".sidebar row:selected { background-color: @uu_tint; color: @uu_fg; }\n"
|
||||
".devname { font-size: 15px; color: @uu_fg; }\n"
|
||||
".offline { color: @uu_muted; }\n"
|
||||
".dot { font-size: 10px; }\n"
|
||||
".dot.off { color: transparent; }\n"
|
||||
".icon { background-color: #2f7bff; color: #ffffff; border-radius: 6px; font-size: 11px; font-weight: 700; padding: 2px 5px; }\n"
|
||||
".icon.off { background-color: #c4c7cf; }\n"
|
||||
".tag { background-color: #e8f0ff; color: #2f6bff; border-radius: 4px; font-size: 12px; padding: 1px 6px; }\n"
|
||||
".title { font-size: 20px; font-weight: 700; color: #1d1d1f; }\n"
|
||||
".header { border-bottom: 1px solid #e5e7eb; padding: 12px 22px; background-color: #f7f7f8; }\n"
|
||||
".badge { background-color: #1d1d1f; color: #ffffff; border-radius: 12px; padding: 3px 12px; font-size: 13px; }\n"
|
||||
".badge.off { background-color: #9ca3af; }\n"
|
||||
".hbtn { background-image: none; background-color: transparent; border: none; font-size: 17px; color: #4b5563; padding: 4px 10px; }\n"
|
||||
".preview { background-image: linear-gradient(135deg, #a8c0ff 0%, #e2c2f2 50%, #f6c8a8 100%); border-radius: 12px 12px 0 0; }\n"
|
||||
".enter { background-image: none; background-color: rgba(0,0,0,0.18); color: #ffffff; border: none; font-size: 19px; padding: 8px 20px; border-radius: 8px; }\n"
|
||||
".toolbar { border: 1px solid #e5e7eb; border-top: none; border-radius: 0 0 12px 12px; padding: 4px; }\n"
|
||||
".tool { background-image: none; background-color: transparent; border: none; font-size: 15px; color: #374151; padding: 10px; }\n"
|
||||
".dashed { border: 1px dashed #d1d5db; border-radius: 12px; padding: 36px; }\n"
|
||||
".round { background-image: none; background-color: #f3f4f6; border: none; border-radius: 40px; font-size: 26px; min-width: 64px; min-height: 64px; }\n"
|
||||
".card { background-color: #fafafa; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 18px; }\n"
|
||||
".cardbtn { background-image: none; background-color: #fafafa; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 16px; }\n"
|
||||
".banner { background-color: #f7f8fa; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 18px; }\n"
|
||||
".group { font-size: 16px; font-weight: 600; color: #1d1d1f; }\n"
|
||||
".h2 { font-size: 19px; font-weight: 700; color: #1d1d1f; }\n"
|
||||
".big { font-size: 30px; font-weight: 800; color: #111111; }\n"
|
||||
".hint { font-size: 14px; color: #6b7280; }\n"
|
||||
".primary { background-image: none; background-color: #3b82f6; color: #ffffff; border: none; border-radius: 8px; font-size: 16px; padding: 8px 26px; }\n"
|
||||
".secondary { background-image: none; background-color: #ffffff; border: 1px solid #d1d5db; border-radius: 8px; padding: 6px 16px; }\n"
|
||||
".qrbox { background-color: #ffffff; border-radius: 12px; border: 1px solid #e5e7eb; padding: 14px; }\n"
|
||||
".status { font-size: 13px; color: #2f6bff; }\n"
|
||||
".toast { background-color: #ffffff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 18px; font-size: 15px; }\n";
|
||||
".icon { background-color: @uu_accent; color: @uu_accent_fg; border-radius: 6px; font-size: 11px; font-weight: 700; padding: 3px 6px; }\n"
|
||||
".icon.off { background-color: @uu_border; color: @uu_muted; }\n"
|
||||
".header { border-bottom: 1px solid @uu_border; padding: 16px 24px; }\n"
|
||||
".badge { background-color: @uu_tint; color: @uu_success; border-radius: 8px; padding: 4px 10px; font-size: 13px; }\n"
|
||||
".badge.off { background-color: @theme_bg_color; color: @uu_muted; }\n"
|
||||
".hbtn { font-size: 17px; padding: 6px 10px; }\n"
|
||||
".preview { background-image: none; background-color: @uu_tint; border-radius: 12px 12px 0 0; }\n"
|
||||
".enter { font-size: 18px; }\n"
|
||||
".toolbar { background-color: @uu_surface; border: 1px solid @uu_border; border-top: none; border-radius: 0 0 12px 12px; padding: 6px; }\n"
|
||||
".tool { font-size: 15px; padding: 10px; }\n"
|
||||
".dashed { border: 1px dashed @uu_border; border-radius: 12px; padding: 36px; }\n"
|
||||
".round { background-color: @uu_tint; border: none; border-radius: 16px; font-size: 26px; min-width: 64px; min-height: 64px; }\n"
|
||||
".card, .banner { padding: 18px 20px; }\n"
|
||||
".cardbtn { padding: 14px 18px; }\n";
|
||||
|
||||
typedef struct { char id[64]; char name[128]; int platform, online, current; char thumb[512]; } Device;
|
||||
static Device devices[64];
|
||||
@@ -217,7 +204,7 @@ static void show_device(int index) {
|
||||
pthread_mutex_unlock(&d_lock);
|
||||
load_thumb(thumb);
|
||||
set_header(name, 1);
|
||||
gtk_label_set_markup(GTK_LABEL(badge), online ? L("<span foreground='#22c55e'>●</span> 在线", "<span foreground='#22c55e'>●</span> Online") : L("离线", "Offline"));
|
||||
gtk_label_set_text(GTK_LABEL(badge), online ? L("● 在线", "● Online") : L("离线", "Offline"));
|
||||
GtkStyleContext *ctx = gtk_widget_get_style_context(badge);
|
||||
if (online) gtk_style_context_remove_class(ctx, "off"); else gtk_style_context_add_class(ctx, "off");
|
||||
gtk_stack_set_visible_child_name(GTK_STACK(stack), "device");
|
||||
@@ -574,6 +561,10 @@ static void open_settings(void) {
|
||||
GtkWidget *g0[] = { acct };
|
||||
gtk_box_pack_start(GTK_BOX(general), settings_card(g0, 1), FALSE, FALSE, 0);
|
||||
refresh_account();
|
||||
const char *languages[] = {"中文", "English"}; GtkWidget *language = combo(languages, 2);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(language), uu_i18n_english()); g_signal_connect(language, "changed", G_CALLBACK(on_language), NULL);
|
||||
GtkWidget *g4[] = { setting_row("语言 / Language", NULL, language), uu_theme_selector() };
|
||||
gtk_box_pack_start(GTK_BOX(general), settings_card(g4, 2), FALSE, FALSE, 0);
|
||||
const char *wake[] = {L("永不", "Never"), L("接通电源时", "When plugged in"), L("始终", "Always")}, *close_opts[] = {L("最小化", "Minimize"), L("退出程序", "Quit")};
|
||||
GtkWidget *g1[] = { setting_row(L("开机自启动", "Start at login"), NULL, gtk_switch_new()),
|
||||
setting_row(L("保持唤醒状态", "Stay awake"), L("防止电脑进入睡眠状态,导致无法远程访问。", "Keep the computer from sleeping so it stays reachable."), combo(wake, 3)),
|
||||
@@ -587,11 +578,10 @@ static void open_settings(void) {
|
||||
GtkWidget *real = button(L("在手机 App 中查看", "View in the mobile app"), "secondary"); gtk_widget_set_sensitive(real, FALSE);
|
||||
GtkWidget *g3[] = { setting_row(L("实名认证", "Identity verification"), NULL, real) };
|
||||
gtk_box_pack_start(GTK_BOX(general), settings_card(g3, 1), FALSE, FALSE, 0);
|
||||
const char *languages[] = {"中文", "English"}; GtkWidget *language = combo(languages, 2);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(language), uu_i18n_english()); g_signal_connect(language, "changed", G_CALLBACK(on_language), NULL);
|
||||
GtkWidget *g4[] = { setting_row("语言 / Language", NULL, language) };
|
||||
gtk_box_pack_start(GTK_BOX(general), settings_card(g4, 1), FALSE, FALSE, 0);
|
||||
gtk_stack_add_titled(GTK_STACK(tabs), general, "general", L("⚙ 常规", "⚙ General"));
|
||||
GtkWidget *gscroll = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gscroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add(GTK_CONTAINER(gscroll), general);
|
||||
gtk_stack_add_titled(GTK_STACK(tabs), gscroll, "general", L("⚙ 常规", "⚙ General"));
|
||||
// 安全
|
||||
GtkWidget *security = settings_page();
|
||||
const char *verify[] = {L("仅使用临时验证码", "Temporary code only"), L("仅使用自定义验证码", "Custom code only"), L("临时与自定义验证码", "Temporary and custom codes")};
|
||||
@@ -666,12 +656,9 @@ static void *run(void *arg) {
|
||||
(void)arg;
|
||||
int ok = gtk_init_check(NULL, NULL);
|
||||
if (ok) { gtk_window_set_default_icon_name("uu-remote-linux"); } // same taskbar icon as the host (#13)
|
||||
// The CSS hard-codes a light palette; a dark system theme would turn unstyled text white on white (#43).
|
||||
if (ok) g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||
if (ok) {
|
||||
GtkCssProvider *css = gtk_css_provider_new();
|
||||
gtk_css_provider_load_from_data(css, CSS, -1, NULL);
|
||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
uu_theme_init();
|
||||
uu_theme_load_css(CSS);
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(window), L("UU 远程 Linux 控制端(非官方)", "UU Remote Linux viewer (unofficial)"));
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 1180, 780);
|
||||
|
||||
Reference in new issue
Block a user