1
1
/*
2
2
* SPDX-License-Identifier: GPL-3.0-or-later
3
- * SPDX-FileCopyrightText: 2020–2023 Cassidy James Blaede <c@ssidyjam.es>
3
+ * SPDX-FileCopyrightText: 2020–2024 Cassidy James Blaede <c@ssidyjam.es>
4
4
*/
5
5
6
6
public class Plausible.MainWindow : Adw .ApplicationWindow {
@@ -17,6 +17,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
17
17
public MainWindow (Gtk .Application application ) {
18
18
Object (
19
19
application: application,
20
+ height_request: 180 ,
20
21
icon_name: APP_ID ,
21
22
resizable: true ,
22
23
title: App . NAME ,
@@ -29,7 +30,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
29
30
var sites_button = new Gtk .Button .with_label (" Sites" ) {
30
31
valign = Gtk . Align . CENTER
31
32
};
32
- sites_button. get_style_context () . add_class (" back-button" );
33
+ sites_button. add_css_class (" back-button" );
33
34
34
35
sites_revealer = new Gtk .Revealer () {
35
36
transition_duration = 200 ,
@@ -38,12 +39,12 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
38
39
sites_revealer. child = sites_button;
39
40
40
41
var site_menu = new Menu ();
41
- site_menu. append (_(" Account Settings " ), " win.account_settings" );
42
- site_menu. append (_(" Log Out…" ), " win.log_out" );
42
+ site_menu. append (_(" Account _Settings " ), " win.account_settings" );
43
+ site_menu. append (_(" _Log Out…" ), " win.log_out" );
43
44
44
45
var app_menu = new Menu ();
45
- app_menu. append (_(" Custom Domain…" ), " win.custom_domain" );
46
- app_menu. append (_(" About %s " ). printf (App . NAME ), " win.about" );
46
+ app_menu. append (_(" _Custom Domain…" ), " win.custom_domain" );
47
+ app_menu. append (_(" _About %s " ). printf (App . NAME ), " win.about" );
47
48
48
49
var menu = new Menu ();
49
50
menu. append_section (null , site_menu);
@@ -52,13 +53,12 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
52
53
var menu_button = new Gtk .MenuButton () {
53
54
icon_name = " open-menu-symbolic" ,
54
55
menu_model = menu,
55
- tooltip_text = _ ("Menu "),
56
+ tooltip_text = _ ("Main Menu "),
56
57
};
57
58
58
59
var header = new Adw .HeaderBar ();
59
60
header.pack_start (sites_revealer );
60
61
header.pack_end (menu_button );
61
- // header.pack_end (account_revealer);
62
62
63
63
web_view = new Plausible .WebView ();
64
64
@@ -82,7 +82,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
82
82
transition_duration = 400 ,
83
83
transition_type = Gtk . StackTransitionType . UNDER_UP
84
84
};
85
- stack.get_style_context () .add_class ("loading ");
85
+ stack.add_css_class ("loading ");
86
86
stack.add_named (status_page , "loading ");
87
87
stack.add_named (web_view , "web ");
88
88
@@ -153,21 +153,6 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
153
153
web_view. uri != " https://" + domain + " /sites"
154
154
);
155
155
156
- // TODO: Figure out how to disable the relevant actions when on
157
- // these URIs.
158
- //
159
- // account_revealer.reveal_child = (
160
- // web_view.uri != "https://" + domain + "/login" &&
161
- // web_view.uri != "https://" + domain + "/register" &&
162
- // web_view.uri != "https://" + domain + "/password/request-reset"
163
- // );
164
- //
165
- // if (web_view.uri == "https://" + domain + "/settings") {
166
- // account_stack.visible_child_name = "logout";
167
- // } else {
168
- // account_stack.visible_child_name = "account";
169
- // }
170
-
171
156
App . settings. set_string (" current-url" , web_view. uri);
172
157
}
173
158
}
@@ -226,20 +211,19 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
226
211
domain_grid. attach (domain_label, 0 , 0 );
227
212
domain_grid. attach (domain_entry, 1 , 0 );
228
213
229
- var domain_dialog = new Adw .MessageDialog (
230
- this ,
214
+ var domain_dialog = new Adw .AlertDialog (
231
215
" Set a Custom Domain" ,
232
- " If you’re self-hosting Plausible or using an instance other than <b>%s </b>, set the domain name here ." . printf (domain)
216
+ " If you’re self-hosting Plausible or using an instance other than <b>%s </b>, set the domain name." . printf (domain)
233
217
) {
234
218
body_use_markup = true ,
235
219
default_response = " save" ,
236
220
extra_child = domain_grid,
237
221
};
238
- domain_dialog. add_response (" close" , " Cancel " );
239
- domain_dialog. add_response (" save" , _(" Set Domain" ));
222
+ domain_dialog. add_response (" close" , " _Cancel " );
223
+ domain_dialog. add_response (" save" , _(" _Set Domain" ));
240
224
domain_dialog. set_response_appearance (" save" , Adw . ResponseAppearance . SUGGESTED );
241
225
242
- domain_dialog. present ();
226
+ domain_dialog. present (this );
243
227
244
228
domain_dialog. response. connect ((response_id) = > {
245
229
if (response_id == " save" ) {
@@ -262,19 +246,18 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
262
246
private void on_log_out_activate () {
263
247
string domain = App . settings. get_string (" domain" );
264
248
265
- var log_out_dialog = new Adw .MessageDialog (
266
- this ,
249
+ var log_out_dialog = new Adw .AlertDialog (
267
250
" Log out of Plausible?" ,
268
251
" You will need to re-enter your email and password for <b>%s </b> to log back in." . printf (domain)
269
252
) {
270
253
body_use_markup = true ,
271
254
default_response = " log_out"
272
255
};
273
- log_out_dialog. add_response (" close" , " Stay Logged In" );
274
- log_out_dialog. add_response (" log_out" , _(" Log Out" ));
256
+ log_out_dialog. add_response (" close" , " _Stay Logged In" );
257
+ log_out_dialog. add_response (" log_out" , _(" _Log Out" ));
275
258
log_out_dialog. set_response_appearance (" log_out" , Adw . ResponseAppearance . DESTRUCTIVE );
276
259
277
- log_out_dialog. present ();
260
+ log_out_dialog. present (this );
278
261
279
262
log_out_dialog. response. connect ((response_id) = > {
280
263
if (response_id == " log_out" ) {
@@ -284,7 +267,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
284
267
// Instead, we clear cookies then load /sites, which will prompt for
285
268
// login before showing the dashboard once again.
286
269
287
- web_view. get_website_data_manager (). clear. begin (
270
+ web_view. network_session . get_website_data_manager (). clear. begin (
288
271
WebKit . WebsiteDataTypes . COOKIES , 0 , null , () = > {
289
272
debug (" Cleared cookies; going home." );
290
273
web_view. load_uri (" https://" + domain + " /sites" );
@@ -295,8 +278,8 @@ public class Plausible.MainWindow : Adw.ApplicationWindow {
295
278
}
296
279
297
280
private void on_about_activate () {
298
- var about_window = new Adw .AboutWindow () {
299
- transient_for = this ,
281
+ var about_window = new Adw .AboutDialog () {
282
+ // transient_for = this,
300
283
301
284
application_icon = APP_ID ,
302
285
application_name = _ ("%s for Plausible ").printf (App .NAME ),
@@ -333,6 +316,6 @@ Email: hello@plausible.io
333
316
"""
334
317
);
335
318
336
- about_window.present ();
319
+ about_window.present (this );
337
320
}
338
321
}
0 commit comments