Skip to content

Commit dde9b73

Browse files
oscfdezdzGeopJr
andauthored
feat: port to adaptive dialogs (#804)
Co-authored-by: Evangelos Paterakis <[email protected]>
1 parent ba8a671 commit dde9b73

37 files changed

+124
-224
lines changed

.github/workflows/msys2.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
msys2:
1111
name: "Windows Builder"
1212
runs-on: windows-latest
13+
if: ${{ false }} # disable until msys2 updates deps to GNOME 46
1314
defaults:
1415
run:
1516
shell: msys2 {0}

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ Package Name | Required Version
4343
:--- |---:|
4444
meson | 0.56
4545
valac | 0.48
46-
libglib-2.0-dev | 2.76.0
4746
libjson-glib-dev | 1.4.4
4847
libxml2-dev | 2.9.10
4948
libgee-0.8-dev | 0.8.5
5049
libsoup3.0-dev | 3.0.0
51-
libgtk-4-dev | 4.11.3
52-
libadwaita-1.0-dev | 1.4
50+
libadwaita-1.0-dev | 1.5
5351
libsecret-1-dev | 0.20
5452

5553
</details>

build-aux/dev.geopjr.Tuba.Devel.json

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"app-id": "dev.geopjr.Tuba",
33
"runtime": "org.gnome.Platform",
4-
"runtime-version": "45beta",
4+
"runtime-version": "46beta",
55
"sdk": "org.gnome.Sdk",
66
"command": "dev.geopjr.Tuba",
77
"finish-args": [
@@ -10,7 +10,6 @@
1010
"--share=network",
1111
"--socket=fallback-x11",
1212
"--socket=wayland",
13-
"--env=GDK_PIXBUF_MODULE_FILE=/app/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache",
1413
"--socket=pulseaudio"
1514
],
1615
"cleanup": [
@@ -26,29 +25,6 @@
2625
"*.a"
2726
],
2827
"modules": [
29-
{
30-
"name" : "webp-pixbuf-loader",
31-
"buildsystem" : "meson",
32-
"config-opts" : [
33-
"-Dgdk_pixbuf_moduledir=/app/lib/gdk-pixbuf-2.0/2.10.0/loaders/"
34-
],
35-
"sources" : [
36-
{
37-
"type" : "git",
38-
"url" : "https://github.com/aruiz/webp-pixbuf-loader.git",
39-
"tag" : "0.2.4",
40-
"commit": "a35014104a226265e44fe30fcdb4df9305af3466"
41-
}
42-
]
43-
},
44-
{
45-
"name" : "update-pixbuf-loaders",
46-
"buildsystem" : "simple",
47-
"build-commands" : [
48-
"GDK_PIXBUF_MODULEDIR=/app/lib/gdk-pixbuf-2.0/2.10.0/loaders/ gdk-pixbuf-query-loaders > /app/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache",
49-
"gdk-pixbuf-query-loaders >> /app/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
50-
]
51-
},
5228
{
5329
"name" : "libspelling",
5430
"buildsystem" : "meson",

build-aux/snap/snapcraft.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ parts:
4242
plugin: nil
4343
build-snaps: # List all content-snaps and base snaps you're using here
4444
- core22
45-
- gnome-42-2204
46-
- gnome-42-2204-sdk
45+
- gnome-46-2404
46+
- gnome-46-2404-sdk
4747
override-prime: |
4848
set -eux
49-
for snap in "core22" "gnome-42-2204" "gnome-42-2204-sdk"; do # List all content-snaps and base snaps you're using here
49+
for snap in "core22" "gnome-46-2404" "gnome-46-2404-sdk"; do # List all content-snaps and base snaps you're using here
5050
cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
5151
done

data/ui/dialogs/compose.ui

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
<interface>
33
<requires lib="gtk" version="4.0" />
44
<requires lib="libadwaita" version="1.0" />
5-
<template class="TubaDialogsCompose" parent="AdwWindow">
6-
<property name="modal">1</property>
7-
<property name="default_width">500</property>
8-
<property name="default_height">400</property>
5+
<template class="TubaDialogsCompose" parent="AdwDialog">
6+
<property name="content_width">500</property>
7+
<property name="content_height">400</property>
98
<property name="width_request">360</property>
109
<property name="height_request">200</property>
1110
<child>

data/ui/dialogs/filter_edit.ui

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
<interface>
33
<requires lib="gtk" version="4.0" />
44
<requires lib="libadwaita" version="1.0" />
5-
<template class="TubaDialogsFilterEdit" parent="AdwWindow">
6-
<property name="modal">1</property>
7-
<property name="default_width">460</property>
8-
<property name="default_height">520</property>
5+
<template class="TubaDialogsFilterEdit" parent="AdwDialog">
6+
<property name="content_width">460</property>
7+
<property name="content_height">520</property>
98
<property name="title" translatable="1">Edit Filter</property>
109
<child>
1110
<object class="AdwToolbarView">

data/ui/dialogs/list_edit.ui

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
</object>
1212
</child>
1313
</object>
14-
<template class="TubaDialogsListEdit" parent="AdwPreferencesWindow">
15-
<signal name="close-request" handler="on_close" swapped="no"/>
16-
<property name="modal">1</property>
17-
<property name="default_width">500</property>
18-
<property name="default_height">400</property>
14+
<template class="TubaDialogsListEdit" parent="AdwPreferencesDialog">
15+
<signal name="closed" handler="on_close" swapped="no"/>
16+
<property name="content-width">500</property>
17+
<property name="content-height">450</property>
1918
<child>
2019
<object class="AdwPreferencesPage">
2120
<property name="icon-name">tuba-settings-symbolic</property>

data/ui/dialogs/preferences.ui

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<property name="step_increment">1</property>
1313
<property name="page_increment">1</property>
1414
</object>
15-
<template class="TubaDialogsPreferences" parent="AdwPreferencesWindow">
15+
<template class="TubaDialogsPreferences" parent="AdwPreferencesDialog">
16+
<property name="search-enabled">True</property>
1617
<child>
1718
<object class="AdwPreferencesPage">
1819
<property name="icon_name">tuba-settings-symbolic</property>

data/ui/dialogs/profile_edit.ui

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
<object class="TubaWidgetsCustomEmojiChooser" id="custom_emoji_picker">
77
<signal name="emoji-picked" handler="on_bio_emoji_picked" swapped="no"/>
88
</object>
9-
<template class="TubaDialogsProfileEdit" parent="AdwWindow">
10-
<property name="modal">1</property>
11-
<property name="default_width">460</property>
12-
<property name="default_height">520</property>
9+
<template class="TubaDialogsProfileEdit" parent="AdwDialog">
10+
<property name="content_width">460</property>
11+
<property name="content_height">520</property>
1312
<property name="title" translatable="1">Edit Profile</property>
1413
<child>
1514
<object class="AdwToolbarView">

meson.build

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ asresources = gnome.compile_resources(
7676
c_name: 'as',
7777
)
7878

79-
libgtk_dep = dependency('gtk4', version: '>=4.11.3', required: true)
80-
libadwaita_dep = dependency('libadwaita-1', version: '>=1.4', required: true)
79+
libadwaita_dep = dependency('libadwaita-1', version: '>=1.5', required: true)
8180
gtksourceview_dep = dependency('gtksourceview-5', required: true, version: '>=5.6.0')
8281
libwebp_dep = dependency('libwebp', required: false)
8382
libspelling = dependency('libspelling-1', required: false)
@@ -86,10 +85,6 @@ if not libwebp_dep.found ()
8685
warning('WebP support might be missing, please install webp-pixbuf-loader.')
8786
endif
8887

89-
if libgtk_dep.version().version_compare('>=4.12.0')
90-
add_project_arguments(['--define=GTK_4_12'], language: 'vala')
91-
endif
92-
9388
if meson.get_compiler('vala').version().version_compare('>=0.56.11')
9489
add_project_arguments(['--define=VALAC_05611'], language: 'vala')
9590
endif
@@ -115,7 +110,7 @@ final_deps = [
115110
dependency('icu-uc'),
116111
libspelling,
117112
gtksourceview_dep,
118-
libgtk_dep,
113+
dependency('gtk4', version: '>=4.13.4', required: true),
119114
libadwaita_dep,
120115
meson.get_compiler('c').find_library('m', required: false)
121116
]

src/API/Announcement.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Tuba.API.Announcement : Entity, Widgetizable {
5353
warning (@"Error while dismissing announcement: $code $message");
5454

5555
var dlg = app.inform (_("Error"), message);
56-
dlg.present ();
56+
dlg.present (app.main_window);
5757
})
5858
.exec ();
5959
}

src/API/Status/PreviewCard.vala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
7878
case BOOKWYRM:
7979
var bookwyrm_instance = GLib.Uri.parse (t_url, GLib.UriFlags.NONE);
8080
special_host = bookwyrm_instance.get_host ();
81-
var bookwyrm_id = Path.get_basename (Path.get_dirname (Path.get_dirname (t_url)));
81+
82+
var bookwyrm_path = bookwyrm_instance.get_path ();
83+
var b_id_start = bookwyrm_path.index_of_char ('/', 1);
84+
var b_id_end = bookwyrm_path.index_of_char ('/', b_id_start + 1) - 1;
85+
if (b_id_end <= -1) b_id_end = bookwyrm_path.length - 1;
86+
var bookwyrm_id = bookwyrm_path.substring (b_id_start + 1, b_id_end - b_id_start);
87+
8288
special_api_url = @"https://$(special_host)/book/$(bookwyrm_id).json";
8389
break;
8490
default:
@@ -169,7 +175,6 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
169175
return;
170176
}
171177

172-
173178
new Request.GET (special_api_url)
174179
.then ((in_stream) => {
175180
bool failed = true;

src/Application.vala

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace Tuba {
8585

8686
#if DEV_MODE
8787
private void dev_only_window_activated () {
88-
new Dialogs.Dev ().show ();
88+
new Dialogs.Dev ().present (main_window);
8989
}
9090
#endif
9191

@@ -143,7 +143,7 @@ namespace Tuba {
143143
warning (msg);
144144

145145
var dlg = inform (_("Error"), msg);
146-
dlg.present ();
146+
dlg.present (app.main_window);
147147
}
148148
});
149149
}
@@ -168,7 +168,7 @@ namespace Tuba {
168168
cache_path = GLib.Path.build_path (GLib.Path.DIR_SEPARATOR_S, GLib.Environment.get_user_cache_dir (), Build.NAME.down ());
169169

170170
try {
171-
bookwyrm_regex = new GLib.Regex ("/book/\\d+/s/[-_a-z0-9]*", GLib.RegexCompileFlags.OPTIMIZE);
171+
bookwyrm_regex = new GLib.Regex ("/book/\\d+(/?$|/s/[-_a-z0-9]*)", GLib.RegexCompileFlags.OPTIMIZE);
172172
} catch (GLib.RegexError e) {
173173
critical (e.message);
174174
}
@@ -237,7 +237,7 @@ namespace Tuba {
237237
catch (Error e) {
238238
var msg = "Could not start application: %s".printf (e.message);
239239
var dlg = inform (_("Error"), msg);
240-
dlg.present ();
240+
dlg.present (app.main_window);
241241
error (msg);
242242
}
243243

@@ -317,7 +317,7 @@ namespace Tuba {
317317
string msg = @"Couldn't open $unparsed_uri: $(e.message)";
318318
warning (msg);
319319
var dlg = inform (_("Error"), msg);
320-
dlg.present ();
320+
dlg.present (app.main_window);
321321
}
322322
}
323323
}
@@ -388,7 +388,7 @@ namespace Tuba {
388388
}
389389

390390
void open_preferences () {
391-
new Dialogs.Preferences ().present ();
391+
new Dialogs.Preferences ().present (main_window);
392392
}
393393

394394
void open_current_account_profile () {
@@ -459,10 +459,7 @@ namespace Tuba {
459459

460460
const string COPYRIGHT = "© 2022 bleak_grey\n© 2022 Evangelos \"GeopJr\" Paterakis";
461461

462-
var dialog = new Adw.AboutWindow () {
463-
transient_for = main_window,
464-
modal = true,
465-
462+
var dialog = new Adw.AboutDialog () {
466463
application_icon = Build.DOMAIN,
467464
application_name = Build.NAME,
468465
version = Build.VERSION,
@@ -489,7 +486,7 @@ namespace Tuba {
489486
// Static functions seem to avoid this peculiar behavior.
490487
// dialog.translator_credits = Build.TRANSLATOR != " " ? Build.TRANSLATOR : null;
491488
492-
dialog.present ();
489+
dialog.present (main_window);
493490
494491
GLib.Idle.add (() => {
495492
var style = Tuba.Celebrate.get_celebration_css_class (new GLib.DateTime.now ());
@@ -499,16 +496,12 @@ namespace Tuba {
499496
});
500497
}
501498
502-
public Adw.MessageDialog inform (string text, string? msg = null, Gtk.Window? win = app.main_window) {
503-
var dlg = new Adw.MessageDialog (
504-
win,
499+
public Adw.AlertDialog inform (string text, string? msg = null) {
500+
var dlg = new Adw.AlertDialog (
505501
text,
506502
msg
507503
);
508504
509-
if (win != null)
510-
dlg.transient_for = win;
511-
512505
dlg.add_response ("ok", _("OK"));
513506

514507
return dlg;
@@ -557,7 +550,7 @@ namespace Tuba {
557550
public async QuestionAnswer question (
558551
QuestionText title,
559552
QuestionText? msg = null,
560-
Gtk.Window? win = app.main_window,
553+
Gtk.Widget? win = app.main_window,
561554
QuestionButtons buttons = {
562555
{ _("Yes"), Adw.ResponseAppearance.DEFAULT },
563556
{ _("Cancel"), Adw.ResponseAppearance.DEFAULT }
@@ -566,8 +559,7 @@ namespace Tuba {
566559
) {
567560
if (skip) return QuestionAnswer.YES;
568561

569-
var dlg = new Adw.MessageDialog (
570-
win,
562+
var dlg = new Adw.AlertDialog (
571563
title.text,
572564
msg == null ? null : msg.text
573565
);
@@ -581,9 +573,7 @@ namespace Tuba {
581573
dlg.add_response ("yes", buttons.yes.label);
582574
dlg.set_response_appearance ("yes", buttons.yes.appearance);
583575

584-
if (win != null)
585-
dlg.transient_for = win;
586-
return QuestionAnswer.from_string (yield dlg.choose (null));
576+
return QuestionAnswer.from_string (yield dlg.choose (win, null));
587577
}
588578

589579
}

src/Dialogs/Composer/AttachmentsPage.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
371371
modal = true,
372372
default_filter = filter
373373
};
374-
chooser.open_multiple.begin (dialog, null, (obj, res) => {
374+
chooser.open_multiple.begin (app.main_window, null, (obj, res) => {
375375
try {
376376
var files = chooser.open_multiple.end (res);
377377

0 commit comments

Comments
 (0)