Skip to content

feat: port to adaptive dialogs #804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
msys2:
name: "Windows Builder"
runs-on: windows-latest
if: ${{ false }} # disable until msys2 updates deps to GNOME 46
defaults:
run:
shell: msys2 {0}
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ Package Name | Required Version
:--- |---:|
meson | 0.56
valac | 0.48
libglib-2.0-dev | 2.76.0
libjson-glib-dev | 1.4.4
libxml2-dev | 2.9.10
libgee-0.8-dev | 0.8.5
libsoup3.0-dev | 3.0.0
libgtk-4-dev | 4.11.3
libadwaita-1.0-dev | 1.4
libadwaita-1.0-dev | 1.5
libsecret-1-dev | 0.20

</details>
Expand Down
26 changes: 1 addition & 25 deletions build-aux/dev.geopjr.Tuba.Devel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "dev.geopjr.Tuba",
"runtime": "org.gnome.Platform",
"runtime-version": "45beta",
"runtime-version": "46beta",
"sdk": "org.gnome.Sdk",
"command": "dev.geopjr.Tuba",
"finish-args": [
Expand All @@ -10,7 +10,6 @@
"--share=network",
"--socket=fallback-x11",
"--socket=wayland",
"--env=GDK_PIXBUF_MODULE_FILE=/app/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache",
"--socket=pulseaudio"
],
"cleanup": [
Expand All @@ -26,29 +25,6 @@
"*.a"
],
"modules": [
{
"name" : "webp-pixbuf-loader",
"buildsystem" : "meson",
"config-opts" : [
"-Dgdk_pixbuf_moduledir=/app/lib/gdk-pixbuf-2.0/2.10.0/loaders/"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/aruiz/webp-pixbuf-loader.git",
"tag" : "0.2.4",
"commit": "a35014104a226265e44fe30fcdb4df9305af3466"
}
]
},
{
"name" : "update-pixbuf-loaders",
"buildsystem" : "simple",
"build-commands" : [
"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",
"gdk-pixbuf-query-loaders >> /app/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
]
},
{
"name" : "libspelling",
"buildsystem" : "meson",
Expand Down
6 changes: 3 additions & 3 deletions build-aux/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ parts:
plugin: nil
build-snaps: # List all content-snaps and base snaps you're using here
- core22
- gnome-42-2204
- gnome-42-2204-sdk
- gnome-46-2404
- gnome-46-2404-sdk
override-prime: |
set -eux
for snap in "core22" "gnome-42-2204" "gnome-42-2204-sdk"; do # List all content-snaps and base snaps you're using here
for snap in "core22" "gnome-46-2404" "gnome-46-2404-sdk"; do # List all content-snaps and base snaps you're using here
cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
done
7 changes: 3 additions & 4 deletions data/ui/dialogs/compose.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<interface>
<requires lib="gtk" version="4.0" />
<requires lib="libadwaita" version="1.0" />
<template class="TubaDialogsCompose" parent="AdwWindow">
<property name="modal">1</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<template class="TubaDialogsCompose" parent="AdwDialog">
<property name="content_width">500</property>
<property name="content_height">400</property>
<property name="width_request">360</property>
<property name="height_request">200</property>
<child>
Expand Down
7 changes: 3 additions & 4 deletions data/ui/dialogs/filter_edit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<interface>
<requires lib="gtk" version="4.0" />
<requires lib="libadwaita" version="1.0" />
<template class="TubaDialogsFilterEdit" parent="AdwWindow">
<property name="modal">1</property>
<property name="default_width">460</property>
<property name="default_height">520</property>
<template class="TubaDialogsFilterEdit" parent="AdwDialog">
<property name="content_width">460</property>
<property name="content_height">520</property>
<property name="title" translatable="1">Edit Filter</property>
<child>
<object class="AdwToolbarView">
Expand Down
9 changes: 4 additions & 5 deletions data/ui/dialogs/list_edit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
</object>
</child>
</object>
<template class="TubaDialogsListEdit" parent="AdwPreferencesWindow">
<signal name="close-request" handler="on_close" swapped="no"/>
<property name="modal">1</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<template class="TubaDialogsListEdit" parent="AdwPreferencesDialog">
<signal name="closed" handler="on_close" swapped="no"/>
<property name="content-width">500</property>
<property name="content-height">450</property>
<child>
<object class="AdwPreferencesPage">
<property name="icon-name">tuba-settings-symbolic</property>
Expand Down
3 changes: 2 additions & 1 deletion data/ui/dialogs/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<property name="step_increment">1</property>
<property name="page_increment">1</property>
</object>
<template class="TubaDialogsPreferences" parent="AdwPreferencesWindow">
<template class="TubaDialogsPreferences" parent="AdwPreferencesDialog">
<property name="search-enabled">True</property>
<child>
<object class="AdwPreferencesPage">
<property name="icon_name">tuba-settings-symbolic</property>
Expand Down
7 changes: 3 additions & 4 deletions data/ui/dialogs/profile_edit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
<object class="TubaWidgetsCustomEmojiChooser" id="custom_emoji_picker">
<signal name="emoji-picked" handler="on_bio_emoji_picked" swapped="no"/>
</object>
<template class="TubaDialogsProfileEdit" parent="AdwWindow">
<property name="modal">1</property>
<property name="default_width">460</property>
<property name="default_height">520</property>
<template class="TubaDialogsProfileEdit" parent="AdwDialog">
<property name="content_width">460</property>
<property name="content_height">520</property>
<property name="title" translatable="1">Edit Profile</property>
<child>
<object class="AdwToolbarView">
Expand Down
9 changes: 2 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ asresources = gnome.compile_resources(
c_name: 'as',
)

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

if libgtk_dep.version().version_compare('>=4.12.0')
add_project_arguments(['--define=GTK_4_12'], language: 'vala')
endif

if meson.get_compiler('vala').version().version_compare('>=0.56.11')
add_project_arguments(['--define=VALAC_05611'], language: 'vala')
endif
Expand All @@ -115,7 +110,7 @@ final_deps = [
dependency('icu-uc'),
libspelling,
gtksourceview_dep,
libgtk_dep,
dependency('gtk4', version: '>=4.13.4', required: true),
libadwaita_dep,
meson.get_compiler('c').find_library('m', required: false)
]
Expand Down
2 changes: 1 addition & 1 deletion src/API/Announcement.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Tuba.API.Announcement : Entity, Widgetizable {
warning (@"Error while dismissing announcement: $code $message");

var dlg = app.inform (_("Error"), message);
dlg.present ();
dlg.present (app.main_window);
})
.exec ();
}
Expand Down
9 changes: 7 additions & 2 deletions src/API/Status/PreviewCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
case BOOKWYRM:
var bookwyrm_instance = GLib.Uri.parse (t_url, GLib.UriFlags.NONE);
special_host = bookwyrm_instance.get_host ();
var bookwyrm_id = Path.get_basename (Path.get_dirname (Path.get_dirname (t_url)));

var bookwyrm_path = bookwyrm_instance.get_path ();
var b_id_start = bookwyrm_path.index_of_char ('/', 1);
var b_id_end = bookwyrm_path.index_of_char ('/', b_id_start + 1) - 1;
if (b_id_end <= -1) b_id_end = bookwyrm_path.length - 1;
var bookwyrm_id = bookwyrm_path.substring (b_id_start + 1, b_id_end - b_id_start);

special_api_url = @"https://$(special_host)/book/$(bookwyrm_id).json";
break;
default:
Expand Down Expand Up @@ -169,7 +175,6 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
return;
}


new Request.GET (special_api_url)
.then ((in_stream) => {
bool failed = true;
Expand Down
36 changes: 13 additions & 23 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace Tuba {

#if DEV_MODE
private void dev_only_window_activated () {
new Dialogs.Dev ().show ();
new Dialogs.Dev ().present (main_window);
}
#endif

Expand Down Expand Up @@ -143,7 +143,7 @@ namespace Tuba {
warning (msg);

var dlg = inform (_("Error"), msg);
dlg.present ();
dlg.present (app.main_window);
}
});
}
Expand All @@ -168,7 +168,7 @@ namespace Tuba {
cache_path = GLib.Path.build_path (GLib.Path.DIR_SEPARATOR_S, GLib.Environment.get_user_cache_dir (), Build.NAME.down ());

try {
bookwyrm_regex = new GLib.Regex ("/book/\\d+/s/[-_a-z0-9]*", GLib.RegexCompileFlags.OPTIMIZE);
bookwyrm_regex = new GLib.Regex ("/book/\\d+(/?$|/s/[-_a-z0-9]*)", GLib.RegexCompileFlags.OPTIMIZE);
} catch (GLib.RegexError e) {
critical (e.message);
}
Expand Down Expand Up @@ -237,7 +237,7 @@ namespace Tuba {
catch (Error e) {
var msg = "Could not start application: %s".printf (e.message);
var dlg = inform (_("Error"), msg);
dlg.present ();
dlg.present (app.main_window);
error (msg);
}

Expand Down Expand Up @@ -317,7 +317,7 @@ namespace Tuba {
string msg = @"Couldn't open $unparsed_uri: $(e.message)";
warning (msg);
var dlg = inform (_("Error"), msg);
dlg.present ();
dlg.present (app.main_window);
}
}
}
Expand Down Expand Up @@ -388,7 +388,7 @@ namespace Tuba {
}

void open_preferences () {
new Dialogs.Preferences ().present ();
new Dialogs.Preferences ().present (main_window);
}

void open_current_account_profile () {
Expand Down Expand Up @@ -459,10 +459,7 @@ namespace Tuba {

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

var dialog = new Adw.AboutWindow () {
transient_for = main_window,
modal = true,

var dialog = new Adw.AboutDialog () {
application_icon = Build.DOMAIN,
application_name = Build.NAME,
version = Build.VERSION,
Expand All @@ -489,7 +486,7 @@ namespace Tuba {
// Static functions seem to avoid this peculiar behavior.
// dialog.translator_credits = Build.TRANSLATOR != " " ? Build.TRANSLATOR : null;

dialog.present ();
dialog.present (main_window);

GLib.Idle.add (() => {
var style = Tuba.Celebrate.get_celebration_css_class (new GLib.DateTime.now ());
Expand All @@ -499,16 +496,12 @@ namespace Tuba {
});
}

public Adw.MessageDialog inform (string text, string? msg = null, Gtk.Window? win = app.main_window) {
var dlg = new Adw.MessageDialog (
win,
public Adw.AlertDialog inform (string text, string? msg = null) {
var dlg = new Adw.AlertDialog (
text,
msg
);

if (win != null)
dlg.transient_for = win;

dlg.add_response ("ok", _("OK"));

return dlg;
Expand Down Expand Up @@ -557,7 +550,7 @@ namespace Tuba {
public async QuestionAnswer question (
QuestionText title,
QuestionText? msg = null,
Gtk.Window? win = app.main_window,
Gtk.Widget? win = app.main_window,
QuestionButtons buttons = {
{ _("Yes"), Adw.ResponseAppearance.DEFAULT },
{ _("Cancel"), Adw.ResponseAppearance.DEFAULT }
Expand All @@ -566,8 +559,7 @@ namespace Tuba {
) {
if (skip) return QuestionAnswer.YES;

var dlg = new Adw.MessageDialog (
win,
var dlg = new Adw.AlertDialog (
title.text,
msg == null ? null : msg.text
);
Expand All @@ -581,9 +573,7 @@ namespace Tuba {
dlg.add_response ("yes", buttons.yes.label);
dlg.set_response_appearance ("yes", buttons.yes.appearance);

if (win != null)
dlg.transient_for = win;
return QuestionAnswer.from_string (yield dlg.choose (null));
return QuestionAnswer.from_string (yield dlg.choose (win, null));
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/Composer/AttachmentsPage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public class Tuba.AttachmentsPage : ComposerPage {
modal = true,
default_filter = filter
};
chooser.open_multiple.begin (dialog, null, (obj, res) => {
chooser.open_multiple.begin (app.main_window, null, (obj, res) => {
try {
var files = chooser.open_multiple.end (res);

Expand Down
Loading