Skip to content

Commit

Permalink
Upgrade to Libadwaita 1.6
Browse files Browse the repository at this point in the history
- Use the `.inline` class for GtkTextView
- Migrate to adaptive dialogs. However the "About This Book" dialog has
  not been ported yet.
  • Loading branch information
johnfactotum committed Oct 12, 2024
1 parent ae66187 commit 8a8818e
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Read books in style.

- `gjs` (>= 1.76)
- `gtk4` (>= 4.12)
- `libadwaita` (>= 1.4; `gir1.2-adw-1` in Debian-based distros)
- `libadwaita` (>= 1.6; `gir1.2-adw-1` in Debian-based distros)
- `webkitgtk-6.0` (`webkitgtk6.0` in Fedora; `gir1.2-webkit-6.0` in Debian-based distros)

#### Optional Dependencies
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ i18n = import('i18n')

gjs = dependency('gjs-1.0', version: '>= 1.76')
dependency('gtk4', version: '>= 4.12')
dependency('libadwaita-1', version: '>= 1.4')
dependency('libadwaita-1', version: '>= 1.6')
dependency('webkitgtk-6.0', version: '>= 2.40.1')

subdir('data')
Expand Down
17 changes: 4 additions & 13 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ const ApplicationWindow = GObject.registerClass({
this.content.add_toast(toast)
}
error(heading, body) {
const dialog = new Adw.MessageDialog({
const dialog = new Adw.AlertDialog({
heading, body,
modal: true,
transient_for: this,
})
dialog.add_response('close', _('Close'))
dialog.present()
dialog.present(this)
}
actionDialog() {
const window = new Adw.Window({
Expand Down Expand Up @@ -242,11 +240,6 @@ export const Application = GObject.registerClass({
padding: 0;
}
/* fix dark mode background in popovers */
textview {
background: none;
}
.large-button {
padding: 6px;
}
Expand Down Expand Up @@ -392,7 +385,7 @@ export const Application = GObject.registerClass({
window.run_dispose()
}
about() {
const win = new Adw.AboutWindow({
const win = new Adw.AboutDialog({
application_name: pkg.localeName,
application_icon: pkg.name,
version: pkg.version,
Expand All @@ -408,8 +401,6 @@ export const Application = GObject.registerClass({
issue_url: 'https://github.com/johnfactotum/foliate/issues',
support_url: 'https://github.com/johnfactotum/foliate/blob/gtk4/docs/faq.md',
debug_info: getDebugInfo(),
modal: true,
transient_for: this.active_window,
})
win.add_link(_('Source Code'), 'https://github.com/johnfactotum/foliate')
win.add_legal_section('foliate-js', null, Gtk.License.MIT_X11, null)
Expand All @@ -422,6 +413,6 @@ export const Application = GObject.registerClass({
win.add_legal_section('PDF.js',
'©Mozilla and individual contributors',
Gtk.License.APACHE_2_0, null)
win.present()
win.present(this.active_window)
}
})
6 changes: 2 additions & 4 deletions src/book-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const ViewPreferencesWindow = GObject.registerClass({
'theme-flow-box',
'reduce-animation',
],
}, class extends Adw.PreferencesWindow {
}, class extends Adw.PreferencesDialog {
constructor(params) {
super(params)
this.font_settings.bindProperties({
Expand Down Expand Up @@ -980,10 +980,8 @@ export const BookViewer = GObject.registerClass({
const win = new ViewPreferencesWindow({
view_settings: this._view.viewSettings,
font_settings: this._view.fontSettings,
modal: true,
transient_for: this.root,
})
win.present()
win.present(this.root)
}
bookmark() {
this._bookmark_view.toggle()
Expand Down
6 changes: 2 additions & 4 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,16 +432,14 @@ GObject.registerClass({
})
}
removeBook(file) {
const dialog = new Adw.MessageDialog({
transient_for: this.get_root(),
modal: true,
const dialog = new Adw.AlertDialog({
heading: _('Remove Book?'),
body: _('Reading progress, annotations, and bookmarks will be permanently lost'),
})
dialog.add_response('cancel', _('_Cancel'))
dialog.add_response('remove', _('_Remove'))
dialog.set_response_appearance('remove', Adw.ResponseAppearance.DESTRUCTIVE)
dialog.present()
dialog.present(this.get_root())
dialog.connect('response', (_, response) => {
if (response === 'remove') getBooks().delete(file)
})
Expand Down
1 change: 1 addition & 0 deletions src/ui/annotation-popover.ui
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<property name="right-margin">9</property>
<property name="left-margin">9</property>
<property name="wrap-mode">word</property>
<style><class name="inline"/></style>
</object>
</child>
</object>
Expand Down
8 changes: 1 addition & 7 deletions src/ui/book-viewer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,7 @@
<object class="GtkStackPage">
<property name="name">loading</property>
<property name="child">
<object class="GtkSpinner">
<property name="spinning">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="width-request">32</property>
<property name="height-request">32</property>
</object>
<object class="AdwSpinner"/>
</property>
</object>
</child>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/view-preferences-window.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><interface>
<template class="FoliateViewPreferencesWindow" parent="AdwPreferencesWindow">
<template class="FoliateViewPreferencesWindow" parent="AdwPreferencesDialog">
<child>
<object class="AdwPreferencesPage">
<property name="title" translatable="yes">Font</property>
Expand Down

0 comments on commit 8a8818e

Please sign in to comment.