|
7 | 7 |
|
8 | 8 | #include "flutter/generated_plugin_registrant.h" |
9 | 9 |
|
| 10 | +#include <fstream> |
| 11 | +#include <string> |
| 12 | + |
10 | 13 | struct _MyApplication { |
11 | 14 | GtkApplication parent_instance; |
12 | 15 | char** dart_entrypoint_arguments; |
@@ -38,16 +41,35 @@ static void intent_method_call_handler(FlMethodChannel* channel, |
38 | 41 | } |
39 | 42 | } |
40 | 43 |
|
| 44 | +static bool ReadShowSystemTitlebar() { |
| 45 | + const char* home = getenv("HOME"); |
| 46 | + if (!home) return false; |
| 47 | + |
| 48 | + std::string filepath = std::string(home) + "/.local/share/io.github.Predidit.Kazumi/showSystemTitlebar"; |
| 49 | + |
| 50 | + std::ifstream file(filepath); |
| 51 | + if (!file.is_open()) return false; |
| 52 | + |
| 53 | + std::string content; |
| 54 | + std::getline(file, content); |
| 55 | + file.close(); |
| 56 | + |
| 57 | + if (content == "true") return true; |
| 58 | + if (content == "false") return false; |
| 59 | + |
| 60 | + return false; // 默认值 |
| 61 | +} |
| 62 | + |
41 | 63 | // Implements GApplication::activate. |
42 | 64 | static void my_application_activate(GApplication* application) { |
43 | 65 | MyApplication* self = MY_APPLICATION(application); |
44 | 66 | GtkWindow* window = |
45 | 67 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); |
46 | 68 |
|
47 | | - // If have GTK_CSD in env and it is equal to 1 then add the gtk header bar |
48 | | - // to always use client side decorations |
49 | | - const char* GTK_CSD = getenv("GTK_CSD"); |
50 | | - if (GTK_CSD && strcmp(GTK_CSD, "1") == 0) { |
| 69 | + |
| 70 | + // 根据文件决定是否显示系统标题栏 |
| 71 | + bool showSystemTitlebar = ReadShowSystemTitlebar(); |
| 72 | + if (!showSystemTitlebar) { |
51 | 73 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); |
52 | 74 | gtk_widget_show(GTK_WIDGET(header_bar)); |
53 | 75 | gtk_header_bar_set_title(header_bar, "kazumi"); |
|
0 commit comments