From 73452e649214420d69a4255118347931682dac2a Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Sun, 1 Oct 2023 15:23:27 -0700 Subject: [PATCH] refactor(share): remake the share chooser Port `ValentShareTargetChooser` to `AdwToolbarView` and other toolkit updates. Allow using the chooser for initiating sharing, as well as handling `GApplication::open` events. --- po/POTFILES.in | 2 + po/en.po | 53 +- po/fr.po | 68 +- po/nl.po | 60 +- po/valent.pot | 53 +- po/zh_CN.po | 66 +- .../share/data/share-file-symbolic.svg | 2 + .../share/data/share-link-symbolic.svg | 2 + src/plugins/share/data/share-symbolic.svg | 2 + src/plugins/share/meson.build | 1 + src/plugins/share/share.gresource.xml | 4 + .../share/valent-share-target-chooser.c | 600 ++++++++++++++---- .../share/valent-share-target-chooser.h | 4 +- .../share/valent-share-target-chooser.ui | 267 +++++--- src/plugins/share/valent-share-target-row.c | 348 ++++++++++ src/plugins/share/valent-share-target-row.h | 22 + src/plugins/share/valent-share-target-row.ui | 100 +++ tests/extra/cppcheck.cfg | 15 +- 18 files changed, 1404 insertions(+), 265 deletions(-) create mode 100644 src/plugins/share/data/share-file-symbolic.svg create mode 100644 src/plugins/share/data/share-link-symbolic.svg create mode 100644 src/plugins/share/data/share-symbolic.svg create mode 100644 src/plugins/share/valent-share-target-row.c create mode 100644 src/plugins/share/valent-share-target-row.h create mode 100644 src/plugins/share/valent-share-target-row.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index bdb26a90e9b..c264145f18f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -82,6 +82,8 @@ src/plugins/share/valent-share-preferences.c src/plugins/share/valent-share-preferences.ui src/plugins/share/valent-share-target-chooser.c src/plugins/share/valent-share-target-chooser.ui +src/plugins/share/valent-share-target-row.c +src/plugins/share/valent-share-target-row.ui src/plugins/share/valent-share-text-dialog.c src/plugins/share/valent-share-text-dialog.ui src/plugins/sms/sms.plugin.desktop.in diff --git a/po/en.po b/po/en.po index be9cab58455..eb6205f6dec 100644 --- a/po/en.po +++ b/po/en.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/valent/issues\n" -"POT-Creation-Date: 2023-09-29 20:31-0700\n" +"POT-Creation-Date: 2023-09-30 20:16-0700\n" "PO-Revision-Date: 2022-03-28 11:21-0700\n" "Last-Translator: Andy Holmes \n" "Language-Team: English \n" @@ -464,7 +464,8 @@ msgid "Main Menu" msgstr "" #: src/libvalent/ui/valent-window.ui:85 src/libvalent/ui/valent-window.ui:100 -#: src/plugins/share/valent-share-target-chooser.ui:68 +#: src/plugins/share/valent-share-target-chooser.ui:161 +#: src/plugins/share/valent-share-target-chooser.ui:178 msgid "Devices" msgstr "" @@ -736,7 +737,6 @@ msgstr "" #: src/plugins/notification/valent-notification-dialog.ui:19 #: src/plugins/runcommand/valent-runcommand-editor.ui:17 -#: src/plugins/share/valent-share-target-chooser.ui:22 msgid "_Cancel" msgstr "" @@ -1034,11 +1034,14 @@ msgstr[0] "" msgstr[1] "" #: src/plugins/share/valent-share-plugin.c:671 -#: src/plugins/share/valent-share-target-chooser.ui:8 msgid "Share Files" msgstr "" #: src/plugins/share/valent-share-plugin.c:672 +#: src/plugins/share/valent-share-target-chooser.ui:8 +#: src/plugins/share/valent-share-target-chooser.ui:29 +#: src/plugins/share/valent-share-target-chooser.ui:40 +#: src/plugins/share/valent-share-target-chooser.ui:112 msgid "Share" msgstr "" @@ -1058,20 +1061,48 @@ msgstr "" msgid "Where received files are stored" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:29 -msgid "_Share" +#: src/plugins/share/valent-share-target-chooser.c:261 +#, c-format +msgid "Size: %s" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:294 +#, c-format +msgid "%u files and links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:305 +#, c-format +msgid "%u files" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:315 +#, c-format +msgid "%u links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:41 +msgid "Select files, enter a link or paste text" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:58 -msgid "Choose a device to share the selected files with." +#: src/plugins/share/valent-share-target-chooser.ui:50 +msgid "Pick Files" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:86 +#: src/plugins/share/valent-share-target-chooser.ui:75 +msgid "Enter URL" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:165 +msgid "Share with multiple devices" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:192 msgid "Searching…" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:128 -msgid "Always use this device" +#: src/plugins/share/valent-share-target-chooser.ui:215 +msgid "_Share" msgstr "" #: src/plugins/share/valent-share-text-dialog.c:98 diff --git a/po/fr.po b/po/fr.po index 17c1bcbd511..70e5def6822 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/valent/issues\n" -"POT-Creation-Date: 2023-09-29 20:31-0700\n" +"POT-Creation-Date: 2023-09-30 20:16-0700\n" "PO-Revision-Date: 2023-03-04 17:28+0100\n" "Last-Translator: Valérie Roux \n" "Language-Team: French \n" @@ -483,7 +483,8 @@ msgid "Main Menu" msgstr "Nom de l'appareil" #: src/libvalent/ui/valent-window.ui:85 src/libvalent/ui/valent-window.ui:100 -#: src/plugins/share/valent-share-target-chooser.ui:68 +#: src/plugins/share/valent-share-target-chooser.ui:161 +#: src/plugins/share/valent-share-target-chooser.ui:178 msgid "Devices" msgstr "Appareils" @@ -770,7 +771,6 @@ msgstr "Notification" #: src/plugins/notification/valent-notification-dialog.ui:19 #: src/plugins/runcommand/valent-runcommand-editor.ui:17 -#: src/plugins/share/valent-share-target-chooser.ui:22 msgid "_Cancel" msgstr "Annuler" @@ -1090,11 +1090,14 @@ msgstr[0] "Un fichier envoyé vers %1$s" msgstr[1] "%2$d fichiers envoyés vers %1$s" #: src/plugins/share/valent-share-plugin.c:671 -#: src/plugins/share/valent-share-target-chooser.ui:8 msgid "Share Files" msgstr "Partager des fichiers" #: src/plugins/share/valent-share-plugin.c:672 +#: src/plugins/share/valent-share-target-chooser.ui:8 +#: src/plugins/share/valent-share-target-chooser.ui:29 +#: src/plugins/share/valent-share-target-chooser.ui:40 +#: src/plugins/share/valent-share-target-chooser.ui:112 msgid "Share" msgstr "Partager" @@ -1114,21 +1117,52 @@ msgstr "Dossier de téléchargement" msgid "Where received files are stored" msgstr "Où les fichiers entrants sont stockés" -#: src/plugins/share/valent-share-target-chooser.ui:29 -msgid "_Share" -msgstr "Partager" +#: src/plugins/share/valent-share-target-chooser.c:261 +#, c-format +msgid "Size: %s" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:294 +#, c-format +msgid "%u files and links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:305 +#, fuzzy, c-format +msgid "%u files" +msgstr "Tous les fichiers" + +#: src/plugins/share/valent-share-target-chooser.c:315 +#, c-format +msgid "%u links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:41 +#, fuzzy +msgid "Select files, enter a link or paste text" +msgstr "Partagez des fichiers, des liens et du texte" -#: src/plugins/share/valent-share-target-chooser.ui:58 -msgid "Choose a device to share the selected files with." -msgstr "Choisissez un appareil auquel partager les fichiers seléctionnés." +#: src/plugins/share/valent-share-target-chooser.ui:50 +#, fuzzy +msgid "Pick Files" +msgstr "Système de fichiers local" + +#: src/plugins/share/valent-share-target-chooser.ui:75 +msgid "Enter URL" +msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:86 +#: src/plugins/share/valent-share-target-chooser.ui:165 +#, fuzzy +msgid "Share with multiple devices" +msgstr "Prendre une photo avec l'appareil distant" + +#: src/plugins/share/valent-share-target-chooser.ui:192 msgid "Searching…" msgstr "Recherche..." -#: src/plugins/share/valent-share-target-chooser.ui:128 -msgid "Always use this device" -msgstr "Toujours utiliser cet appareil" +#: src/plugins/share/valent-share-target-chooser.ui:215 +msgid "_Share" +msgstr "Partager" #: src/plugins/share/valent-share-text-dialog.c:98 #: src/plugins/share/valent-share-text-dialog.ui:54 @@ -1363,5 +1397,11 @@ msgstr "Portails" msgid "Integration with desktop portals" msgstr "Intégration avec les portails de bureau" +#~ msgid "Always use this device" +#~ msgstr "Toujours utiliser cet appareil" + +#~ msgid "Choose a device to share the selected files with." +#~ msgstr "Choisissez un appareil auquel partager les fichiers seléctionnés." + #~ msgid "Applications" #~ msgstr "Applications" diff --git a/po/nl.po b/po/nl.po index b9ac661a045..82079569890 100644 --- a/po/nl.po +++ b/po/nl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/valent/issues\n" -"POT-Creation-Date: 2023-09-29 20:31-0700\n" +"POT-Creation-Date: 2023-09-30 20:16-0700\n" "PO-Revision-Date: 2022-09-12 19:59+0200\n" "Last-Translator: Heimen Stoffels \n" "Language-Team: Dutch\n" @@ -477,7 +477,8 @@ msgid "Main Menu" msgstr "Apparaatnaam" #: src/libvalent/ui/valent-window.ui:85 src/libvalent/ui/valent-window.ui:100 -#: src/plugins/share/valent-share-target-chooser.ui:68 +#: src/plugins/share/valent-share-target-chooser.ui:161 +#: src/plugins/share/valent-share-target-chooser.ui:178 msgid "Devices" msgstr "Apparaten" @@ -764,7 +765,6 @@ msgstr "Melding" #: src/plugins/notification/valent-notification-dialog.ui:19 #: src/plugins/runcommand/valent-runcommand-editor.ui:17 -#: src/plugins/share/valent-share-target-chooser.ui:22 msgid "_Cancel" msgstr "_Annuleren" @@ -1085,11 +1085,14 @@ msgstr[0] "Eén bestand verstuurd naar %1$s" msgstr[1] "%2$d bestanden verstuurd naar %1$s" #: src/plugins/share/valent-share-plugin.c:671 -#: src/plugins/share/valent-share-target-chooser.ui:8 msgid "Share Files" msgstr "Bestanden delen" #: src/plugins/share/valent-share-plugin.c:672 +#: src/plugins/share/valent-share-target-chooser.ui:8 +#: src/plugins/share/valent-share-target-chooser.ui:29 +#: src/plugins/share/valent-share-target-chooser.ui:40 +#: src/plugins/share/valent-share-target-chooser.ui:112 msgid "Share" msgstr "Delen" @@ -1109,23 +1112,54 @@ msgstr "Downloadmap" msgid "Where received files are stored" msgstr "Waar ontvangen bestanden dienen te worden opgeslagen" -#: src/plugins/share/valent-share-target-chooser.ui:29 +#: src/plugins/share/valent-share-target-chooser.c:261 +#, c-format +msgid "Size: %s" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:294 +#, c-format +msgid "%u files and links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:305 +#, fuzzy, c-format +msgid "%u files" +msgstr "Alle bestanden" + +#: src/plugins/share/valent-share-target-chooser.c:315 +#, c-format +msgid "%u links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:41 #, fuzzy -msgid "_Share" -msgstr "Delen" +msgid "Select files, enter a link or paste text" +msgstr "Deel bestanden, links en tekst" + +#: src/plugins/share/valent-share-target-chooser.ui:50 +#, fuzzy +msgid "Pick Files" +msgstr "Lokaal bestandssysteem" -#: src/plugins/share/valent-share-target-chooser.ui:58 -msgid "Choose a device to share the selected files with." +#: src/plugins/share/valent-share-target-chooser.ui:75 +msgid "Enter URL" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:86 +#: src/plugins/share/valent-share-target-chooser.ui:165 +#, fuzzy +msgid "Share with multiple devices" +msgstr "Maak een foto met het externe apparaat" + +#: src/plugins/share/valent-share-target-chooser.ui:192 #, fuzzy msgid "Searching…" msgstr "Bezig met zoeken naar apparaten…" -#: src/plugins/share/valent-share-target-chooser.ui:128 -msgid "Always use this device" -msgstr "" +#: src/plugins/share/valent-share-target-chooser.ui:215 +#, fuzzy +msgid "_Share" +msgstr "Delen" #: src/plugins/share/valent-share-text-dialog.c:98 #: src/plugins/share/valent-share-text-dialog.ui:54 diff --git a/po/valent.pot b/po/valent.pot index 2d38ee4f331..8912c68dae1 100644 --- a/po/valent.pot +++ b/po/valent.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/valent/issues\n" -"POT-Creation-Date: 2023-09-29 20:31-0700\n" +"POT-Creation-Date: 2023-09-30 20:16-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -464,7 +464,8 @@ msgid "Main Menu" msgstr "" #: src/libvalent/ui/valent-window.ui:85 src/libvalent/ui/valent-window.ui:100 -#: src/plugins/share/valent-share-target-chooser.ui:68 +#: src/plugins/share/valent-share-target-chooser.ui:161 +#: src/plugins/share/valent-share-target-chooser.ui:178 msgid "Devices" msgstr "" @@ -736,7 +737,6 @@ msgstr "" #: src/plugins/notification/valent-notification-dialog.ui:19 #: src/plugins/runcommand/valent-runcommand-editor.ui:17 -#: src/plugins/share/valent-share-target-chooser.ui:22 msgid "_Cancel" msgstr "" @@ -1034,11 +1034,14 @@ msgstr[0] "" msgstr[1] "" #: src/plugins/share/valent-share-plugin.c:671 -#: src/plugins/share/valent-share-target-chooser.ui:8 msgid "Share Files" msgstr "" #: src/plugins/share/valent-share-plugin.c:672 +#: src/plugins/share/valent-share-target-chooser.ui:8 +#: src/plugins/share/valent-share-target-chooser.ui:29 +#: src/plugins/share/valent-share-target-chooser.ui:40 +#: src/plugins/share/valent-share-target-chooser.ui:112 msgid "Share" msgstr "" @@ -1058,20 +1061,48 @@ msgstr "" msgid "Where received files are stored" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:29 -msgid "_Share" +#: src/plugins/share/valent-share-target-chooser.c:261 +#, c-format +msgid "Size: %s" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:294 +#, c-format +msgid "%u files and links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:305 +#, c-format +msgid "%u files" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:315 +#, c-format +msgid "%u links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:41 +msgid "Select files, enter a link or paste text" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:58 -msgid "Choose a device to share the selected files with." +#: src/plugins/share/valent-share-target-chooser.ui:50 +msgid "Pick Files" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:86 +#: src/plugins/share/valent-share-target-chooser.ui:75 +msgid "Enter URL" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:165 +msgid "Share with multiple devices" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.ui:192 msgid "Searching…" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:128 -msgid "Always use this device" +#: src/plugins/share/valent-share-target-chooser.ui:215 +msgid "_Share" msgstr "" #: src/plugins/share/valent-share-text-dialog.c:98 diff --git a/po/zh_CN.po b/po/zh_CN.po index 8c6357c2d0c..da0d570c527 100755 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: valent\n" "Report-Msgid-Bugs-To: https://github.com/andyholmes/valent/issues\n" -"POT-Creation-Date: 2023-09-29 20:31-0700\n" +"POT-Creation-Date: 2023-09-30 20:16-0700\n" "PO-Revision-Date: 2023-07-03 19:05+0800\n" "Last-Translator: sky96111 \n" "Language-Team: Chinese Simplified\n" @@ -470,7 +470,8 @@ msgid "Main Menu" msgstr "主菜单" #: src/libvalent/ui/valent-window.ui:85 src/libvalent/ui/valent-window.ui:100 -#: src/plugins/share/valent-share-target-chooser.ui:68 +#: src/plugins/share/valent-share-target-chooser.ui:161 +#: src/plugins/share/valent-share-target-chooser.ui:178 msgid "Devices" msgstr "设备" @@ -742,7 +743,6 @@ msgstr "通知" #: src/plugins/notification/valent-notification-dialog.ui:19 #: src/plugins/runcommand/valent-runcommand-editor.ui:17 -#: src/plugins/share/valent-share-target-chooser.ui:22 msgid "_Cancel" msgstr "" @@ -1037,11 +1037,14 @@ msgid_plural "Sent %2$d files to %1$s" msgstr[0] "已发送 %2$d 文件到 %1$s" #: src/plugins/share/valent-share-plugin.c:671 -#: src/plugins/share/valent-share-target-chooser.ui:8 msgid "Share Files" msgstr "共享文件" #: src/plugins/share/valent-share-plugin.c:672 +#: src/plugins/share/valent-share-target-chooser.ui:8 +#: src/plugins/share/valent-share-target-chooser.ui:29 +#: src/plugins/share/valent-share-target-chooser.ui:40 +#: src/plugins/share/valent-share-target-chooser.ui:112 msgid "Share" msgstr "发送" @@ -1061,21 +1064,52 @@ msgstr "下载目录" msgid "Where received files are stored" msgstr "收到的文件储存位置" -#: src/plugins/share/valent-share-target-chooser.ui:29 -msgid "_Share" +#: src/plugins/share/valent-share-target-chooser.c:261 +#, c-format +msgid "Size: %s" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:294 +#, c-format +msgid "%u files and links" +msgstr "" + +#: src/plugins/share/valent-share-target-chooser.c:305 +#, fuzzy, c-format +msgid "%u files" +msgstr "文件" + +#: src/plugins/share/valent-share-target-chooser.c:315 +#, c-format +msgid "%u links" msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:58 -msgid "Choose a device to share the selected files with." -msgstr "选择一个设备来分享所选文件。" +#: src/plugins/share/valent-share-target-chooser.ui:41 +#, fuzzy +msgid "Select files, enter a link or paste text" +msgstr "分享文件、链接和文本" + +#: src/plugins/share/valent-share-target-chooser.ui:50 +#, fuzzy +msgid "Pick Files" +msgstr "本地文件" + +#: src/plugins/share/valent-share-target-chooser.ui:75 +msgid "Enter URL" +msgstr "" -#: src/plugins/share/valent-share-target-chooser.ui:86 +#: src/plugins/share/valent-share-target-chooser.ui:165 +#, fuzzy +msgid "Share with multiple devices" +msgstr "与远程设备共享联系人" + +#: src/plugins/share/valent-share-target-chooser.ui:192 msgid "Searching…" msgstr "搜索中..." -#: src/plugins/share/valent-share-target-chooser.ui:128 -msgid "Always use this device" -msgstr "始终使用这个装置" +#: src/plugins/share/valent-share-target-chooser.ui:215 +msgid "_Share" +msgstr "" #: src/plugins/share/valent-share-text-dialog.c:98 #: src/plugins/share/valent-share-text-dialog.ui:54 @@ -1305,5 +1339,11 @@ msgstr "桌面环境" msgid "Integration with desktop portals" msgstr "与桌面环境集成" +#~ msgid "Always use this device" +#~ msgstr "始终使用这个装置" + +#~ msgid "Choose a device to share the selected files with." +#~ msgstr "选择一个设备来分享所选文件。" + #~ msgid "Applications" #~ msgstr "应用" diff --git a/src/plugins/share/data/share-file-symbolic.svg b/src/plugins/share/data/share-file-symbolic.svg new file mode 100644 index 00000000000..201457c428e --- /dev/null +++ b/src/plugins/share/data/share-file-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/plugins/share/data/share-link-symbolic.svg b/src/plugins/share/data/share-link-symbolic.svg new file mode 100644 index 00000000000..1d5fefea3c0 --- /dev/null +++ b/src/plugins/share/data/share-link-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/plugins/share/data/share-symbolic.svg b/src/plugins/share/data/share-symbolic.svg new file mode 100644 index 00000000000..08551f53c83 --- /dev/null +++ b/src/plugins/share/data/share-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/plugins/share/meson.build b/src/plugins/share/meson.build index 569a3a5523c..46901a4af75 100644 --- a/src/plugins/share/meson.build +++ b/src/plugins/share/meson.build @@ -14,6 +14,7 @@ plugin_share_sources = files([ 'valent-share-preferences.c', 'valent-share-target.c', 'valent-share-target-chooser.c', + 'valent-share-target-row.c', 'valent-share-text-dialog.c', 'valent-share-upload.c', ]) diff --git a/src/plugins/share/share.gresource.xml b/src/plugins/share/share.gresource.xml index 72856749c11..1eb7237e8c0 100644 --- a/src/plugins/share/share.gresource.xml +++ b/src/plugins/share/share.gresource.xml @@ -8,10 +8,14 @@ share.plugin valent-share-preferences.ui valent-share-target-chooser.ui + valent-share-target-row.ui valent-share-text-dialog.ui data/document-send-symbolic.svg + data/share-file-symbolic.svg + data/share-link-symbolic.svg + data/share-symbolic.svg data/valent-share-plugin-symbolic.svg diff --git a/src/plugins/share/valent-share-target-chooser.c b/src/plugins/share/valent-share-target-chooser.c index 148da48ed80..78d5c47be72 100644 --- a/src/plugins/share/valent-share-target-chooser.c +++ b/src/plugins/share/valent-share-target-chooser.c @@ -11,31 +11,257 @@ #include #include "valent-share-target-chooser.h" +#include "valent-share-target-row.h" struct _ValentShareTargetChooser { - GtkWindow parent_instance; + AdwWindow parent_instance; ValentDeviceManager *manager; GListModel *files; unsigned int refresh_id; + unsigned int selection_mode : 1; + + GPtrArray *rows; + GCancellable *cancellable; + guint64 total_size; + unsigned int n_files; + unsigned int n_links; /* template */ + AdwNavigationView *view; + AdwActionRow *single_row; + GtkImage *single_icon; + AdwExpanderRow *multiple_row; + GtkImage *multiple_icon; GtkListBox *device_list; + AdwEntryRow *uri_entry; }; -G_DEFINE_FINAL_TYPE (ValentShareTargetChooser, valent_share_target_chooser, GTK_TYPE_WINDOW) +G_DEFINE_FINAL_TYPE (ValentShareTargetChooser, valent_share_target_chooser, ADW_TYPE_WINDOW) enum { PROP_0, PROP_FILES, + PROP_SELECTION_MODE, N_PROPERTIES }; static GParamSpec *properties[N_PROPERTIES] = { NULL, }; +static void valent_share_target_chooser_set_files (ValentShareTargetChooser *self, + GListModel *files); +static void valent_share_target_chooser_share (ValentShareTargetChooser *self, + ValentShareTargetRow *row); + + +/* + * Summary + */ +typedef struct +{ + ValentShareTargetChooser *self; + GtkWidget *row; + GtkImage *icon; +} EntryData; + +static void +g_file_query_info_cb (GFile *file, + GAsyncResult *result, + gpointer user_data) +{ + g_autofree EntryData *data = (EntryData *)user_data; + GIcon *icon = NULL; + g_autoptr (GFileInfo) info = NULL; + g_autofree char *size_str = NULL; + g_autofree char *size_label = NULL; + gsize size = 0; + + if ((info = g_file_query_info_finish (file, result, NULL)) == NULL) + return; + + if ((icon = g_file_info_get_icon (info)) != NULL) + gtk_image_set_from_gicon (data->icon, icon); + + size = g_file_info_get_size (info); + if ((G_MAXUINT64 - data->self->total_size) < size) + data->self->total_size = G_MAXUINT64; + else + data->self->total_size += size; + + size_str = g_format_size (data->self->total_size); + size_label = g_strdup_printf (_("Size: %s"), size_str); + g_object_set (data->row, "subtitle", size_label, NULL); +} + +static void +valent_share_target_chooser_add_entry (ValentShareTargetChooser *self, + GFile *file, + GCancellable *cancellable) +{ + g_autofree char *title = NULL; + const char *icon_name = NULL; + gboolean is_file = FALSE; + GtkWidget *row; + GtkWidget *icon; + + is_file = g_file_has_uri_scheme (file, "file"); + + if (is_file) + { + self->n_files += 1; + title = g_file_get_basename (file); + icon_name = "share-file-symbolic"; + } + else + { + self->n_links += 1; + title = g_file_get_uri (file); + icon_name = "share-link-symbolic"; + } + + row = g_object_new (ADW_TYPE_ACTION_ROW, + "title", title, + "title-lines", 1, + NULL); + icon = g_object_new (GTK_TYPE_IMAGE, + "accessible-role", GTK_ACCESSIBLE_ROLE_PRESENTATION, + "icon-name", icon_name, + "css-classes", VALENT_STRV_INIT ("lowres-icon"), + NULL); + adw_action_row_add_prefix (ADW_ACTION_ROW (row), icon); + adw_expander_row_add_row (self->multiple_row, row); + g_ptr_array_add (self->rows, row); + + if (is_file) + { + EntryData *data = NULL; + + data = g_new0 (EntryData, 1); + data->self = self; + data->row = (GtkWidget *)self->multiple_row; + data->icon = (GtkImage *)icon; + + g_file_query_info_async (file, + G_FILE_ATTRIBUTE_STANDARD_SIZE"," + G_FILE_ATTRIBUTE_STANDARD_ICON, + G_FILE_QUERY_INFO_NONE, + G_PRIORITY_DEFAULT_IDLE, + cancellable, + (GAsyncReadyCallback)g_file_query_info_cb, + g_steal_pointer (&data)); + } +} + +static void +valent_share_target_chooser_add_entries (ValentShareTargetChooser *self) +{ + unsigned int n_items = 0; + + /* Reset */ + g_cancellable_cancel (self->cancellable); + g_clear_object (&self->cancellable); + self->cancellable = g_cancellable_new (); + self->n_files = 0; + self->n_links = 0; + self->total_size = 0; + + g_object_set (self->single_row, + "title", NULL, + "subtitle", NULL, + NULL); + g_object_set (self->multiple_row, + "title", NULL, + "subtitle", NULL, + NULL); + gtk_editable_set_text (GTK_EDITABLE (self->uri_entry), ""); + + if (self->rows != NULL) + { + for (unsigned int i = 0; i < self->rows->len; i++) + { + adw_expander_row_remove (self->multiple_row, + g_ptr_array_index (self->rows, i)); + } + g_clear_pointer (&self->rows, g_ptr_array_unref); + } + + if (self->files != NULL) + n_items = g_list_model_get_n_items (self->files); + + if (n_items > 1) + { + g_autofree char *title = NULL; + + self->rows = g_ptr_array_sized_new (n_items); + + for (unsigned int i = 0; i < n_items; i++) + { + g_autoptr (GFile) file = NULL; + + file = g_list_model_get_item (self->files, i); + valent_share_target_chooser_add_entry (self, file, self->cancellable); + } + + if (self->n_files > 0 && self->n_links > 0) + title = g_strdup_printf (_("%u files and links"), n_items); + else if (self->n_files > 0) + title = g_strdup_printf (_("%u files"), n_items); + else if (self->n_links > 0) + title = g_strdup_printf (_("%u links"), n_items); + g_object_set (self->multiple_row, + "title", title, + "visible", TRUE, + NULL); + } + else if (n_items > 0) + { + g_autofree char *title = NULL; + g_autoptr (GFile) entry = NULL; + const char *icon_name = NULL; + + entry = g_list_model_get_item (self->files, 0); + + if (g_file_has_uri_scheme (entry, "file")) + { + EntryData *data; + + data = g_new0 (EntryData, 1); + data->self = self; + data->row = (GtkWidget *)self->single_row; + data->icon = self->single_icon; + + g_file_query_info_async (entry, + G_FILE_ATTRIBUTE_STANDARD_SIZE"," + G_FILE_ATTRIBUTE_STANDARD_ICON, + G_FILE_QUERY_INFO_NONE, + G_PRIORITY_DEFAULT_IDLE, + self->cancellable, + (GAsyncReadyCallback)g_file_query_info_cb, + g_steal_pointer (&data)); + + title = g_file_get_basename (entry); + icon_name = "share-symbolic"; + } + else + { + title = g_file_get_uri (entry); + icon_name = "share-link-symbolic"; + } + + g_object_set (self->single_row, + "title", title, + "visible", TRUE, + NULL); + gtk_image_set_from_icon_name (self->single_icon, icon_name); + } +} + +/* + * Devices + */ static void on_action_added (GActionGroup *action_group, const char *action_name, @@ -66,6 +292,59 @@ on_action_enabled_changed (GActionGroup *action_group, gtk_widget_set_visible (widget, enabled); } +static void +on_device_activated (GtkListBox *box, + ValentShareTargetRow *row, + ValentShareTargetChooser *self) +{ + g_assert (GTK_IS_LIST_BOX (box)); + g_assert (VALENT_IS_SHARE_TARGET_ROW (row)); + g_assert (VALENT_IS_SHARE_TARGET_CHOOSER (self)); + + if (self->selection_mode) + { + gboolean selected; + + selected = valent_share_target_row_get_selected (row); + valent_share_target_row_set_selected (row, !selected); + } + else + { + valent_share_target_chooser_share (self, row); + } +} + +static void +on_selected_changed (ValentShareTargetChooser *self) +{ + GtkWidget *child; + gboolean enabled = FALSE; + + if (!self->selection_mode) + { + gtk_widget_action_set_enabled (GTK_WIDGET (self), + "chooser.share", + enabled); + return; + } + + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->device_list)); + child != NULL; + child = gtk_widget_get_next_sibling (child)) + { + if (!VALENT_IS_SHARE_TARGET_ROW (child)) + continue; + + if (valent_share_target_row_get_selected (VALENT_SHARE_TARGET_ROW (child))) + { + enabled = TRUE; + break; + } + } + + gtk_widget_action_set_enabled (GTK_WIDGET (self), "chooser.share", enabled); +} + static GtkWidget * valent_share_target_chooser_create_row (gpointer item, gpointer user_data) @@ -76,25 +355,17 @@ valent_share_target_chooser_create_row (gpointer item, g_assert (VALENT_IS_DEVICE (device)); - row = g_object_new (ADW_TYPE_ACTION_ROW, - "activatable", TRUE, - "selectable", FALSE, + row = g_object_new (VALENT_TYPE_SHARE_TARGET_ROW, + "device", device, + "selection-mode", self->selection_mode, NULL); - - g_object_bind_property (self->device_list, "activate-on-single-click", - row, "selectable", - G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); - g_object_bind_property (device, "icon-name", - row, "icon-name", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - g_object_bind_property (device, "name", - row, "title", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - g_object_set_data_full (G_OBJECT (row), - "device", - g_object_ref (device), - g_object_unref); - + g_object_bind_property (self, "selection-mode", + row, "selection-mode", + G_BINDING_SYNC_CREATE); + g_signal_connect_object (row, + "notify::selected", + G_CALLBACK (on_selected_changed), + self, G_CONNECT_SWAPPED); g_signal_connect_object (device, "action-added::share.uris", G_CALLBACK (on_action_added), @@ -142,126 +413,216 @@ on_items_changed (GListModel *list, gtk_list_box_insert (self->device_list, widget, position + i); } + + on_selected_changed (self); } +static gboolean +valent_share_target_chooser_refresh (gpointer data) +{ + ValentDeviceManager *manager = VALENT_DEVICE_MANAGER (data); + + g_assert (VALENT_IS_DEVICE_MANAGER (manager)); + + valent_device_manager_refresh (manager); + + return G_SOURCE_CONTINUE; +} + +/* + * URI Selector + */ static void -on_row_activated (GtkListBox *box, - GtkListBoxRow *row, +on_uri_activated (GtkEditable *editable, ValentShareTargetChooser *self) { - ValentDevice *device = NULL; - GVariantBuilder builder; - unsigned int n_files = 0; + const char *text = NULL; - g_assert (GTK_IS_LIST_BOX (box)); - g_assert (GTK_IS_LIST_BOX_ROW (row)); g_assert (VALENT_IS_SHARE_TARGET_CHOOSER (self)); - g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY); - n_files = g_list_model_get_n_items (self->files); + text = gtk_editable_get_text (editable); + if (text == NULL || *text == '\0') + return; - for (unsigned int i = 0; i < n_files; i++) + if (!gtk_widget_has_css_class (GTK_WIDGET (self->uri_entry), "error")) { - g_autoptr (GFile) file = g_list_model_get_item (self->files, i); - GVariant *uri = g_variant_new_take_string (g_file_get_uri (file)); + g_autoptr (GListStore) files = NULL; + g_autoptr (GFile) file = NULL; - g_variant_builder_add_value (&builder, uri); - } + file = g_file_new_for_uri (text); + files = g_list_store_new (G_TYPE_FILE); + g_list_store_append (files, file); - device = g_object_get_data (G_OBJECT (row), "device"); - g_action_group_activate_action (G_ACTION_GROUP (device), - "share.uris", - g_variant_builder_end (&builder)); - - gtk_window_close (GTK_WINDOW (self)); + valent_share_target_chooser_set_files (self, G_LIST_MODEL (files)); + } } static void -on_selected_rows_changed (GtkListBox *box, - ValentShareTargetChooser *self) +on_uri_changed (GtkEditable *editable, + ValentShareTargetChooser *self) { - g_autoptr (GList) rows = NULL; - unsigned int n_rows = 0; - unsigned int n_files = 0; + const char *text = NULL; + const char *scheme = NULL; - g_assert (GTK_IS_LIST_BOX (box)); g_assert (VALENT_IS_SHARE_TARGET_CHOOSER (self)); - if ((rows = gtk_list_box_get_selected_rows (box)) != NULL) - n_rows = g_list_length (rows); - - if (self->files != NULL) - n_files = g_list_model_get_n_items (self->files); + text = gtk_editable_get_text (editable); + if (text == NULL || *text == '\0') + { + gtk_widget_remove_css_class (GTK_WIDGET (self->uri_entry), "error"); + gtk_accessible_reset_state (GTK_ACCESSIBLE (self->uri_entry), + GTK_ACCESSIBLE_STATE_INVALID); + return; + } - gtk_widget_action_set_enabled (GTK_WIDGET (self), "chooser.open", - (n_rows > 0 && n_files == 1)); - gtk_widget_action_set_enabled (GTK_WIDGET (self), "chooser.share", - (n_rows > 0 && n_files >= 1)); + scheme = g_uri_peek_scheme (text); + if (scheme != NULL && !g_str_equal (scheme, "file")) + { + gtk_widget_remove_css_class (GTK_WIDGET (self->uri_entry), "error"); + gtk_accessible_reset_state (GTK_ACCESSIBLE (self->uri_entry), + GTK_ACCESSIBLE_STATE_INVALID); + } + else + { + gtk_widget_add_css_class (GTK_WIDGET (self->uri_entry), "error"); + gtk_accessible_update_state (GTK_ACCESSIBLE (self->uri_entry), + GTK_ACCESSIBLE_STATE_INVALID, TRUE, + -1); + } } -static gboolean -valent_share_target_chooser_refresh (gpointer data) +/* + * GAction + */ +static void +gtk_file_dialog_open_multiple_cb (GtkFileDialog *dialog, + GAsyncResult *result, + ValentShareTargetChooser *self) { - ValentDeviceManager *manager = VALENT_DEVICE_MANAGER (data); + g_autoptr (GListModel) files = NULL; + g_autoptr (GError) error = NULL; - g_assert (VALENT_IS_DEVICE_MANAGER (manager)); + files = gtk_file_dialog_open_multiple_finish (dialog, result, &error); - valent_device_manager_refresh (manager); + if (files == NULL) + { + if (!g_error_matches (error, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED) && + !g_error_matches (error, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED)) + g_warning ("%s(): %s", G_STRFUNC, error->message); - return G_SOURCE_CONTINUE; + return; + } + + valent_share_target_chooser_set_files (self, files); } -/* - * GAction - */ static void -chooser_cancel_action (GtkWidget *widget, - const char *action_name, - GVariant *parameter) +chooser_select_files_action (GtkWidget *widget, + const char *action_name, + GVariant *parameter) { ValentShareTargetChooser *self = VALENT_SHARE_TARGET_CHOOSER (widget); + g_autoptr (GtkFileDialog) dialog = NULL; g_assert (VALENT_IS_SHARE_TARGET_CHOOSER (self)); - gtk_window_destroy (GTK_WINDOW (self)); + dialog = gtk_file_dialog_new (); + gtk_file_dialog_open_multiple (dialog, + GTK_WINDOW (self), + NULL, + (GAsyncReadyCallback)gtk_file_dialog_open_multiple_cb, + self); } static void -chooser_open_action (GtkWidget *widget, - const char *action_name, - GVariant *parameter) +chooser_share_action (GtkWidget *widget, + const char *action_name, + GVariant *parameter) { ValentShareTargetChooser *self = VALENT_SHARE_TARGET_CHOOSER (widget); - GtkListBoxRow *row; - ValentDevice *device = NULL; - g_autoptr (GFile) file = NULL; - GVariant *target = NULL; + GtkWidget *child; + + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->device_list)); + child != NULL; + child = gtk_widget_get_next_sibling (child)) + { + if (!VALENT_IS_SHARE_TARGET_ROW (child)) + continue; + + if (!valent_share_target_row_get_selected (VALENT_SHARE_TARGET_ROW (child))) + continue; + valent_share_target_chooser_share (self, VALENT_SHARE_TARGET_ROW (child)); + } +} + +/* + * ValentShareTargetChooser + */ +static void +valent_share_target_chooser_set_files (ValentShareTargetChooser *self, + GListModel *files) +{ g_assert (VALENT_IS_SHARE_TARGET_CHOOSER (self)); + g_assert (files == NULL || G_IS_LIST_MODEL (files)); - if ((row = gtk_list_box_get_selected_row (self->device_list)) == NULL || - g_list_model_get_n_items (self->files) == 0) + if (!g_set_object (&self->files, files)) return; - device = g_object_get_data (G_OBJECT (row), "device"); - file = g_list_model_get_item (self->files, 0); - target = g_variant_new_take_string (g_file_get_uri (file)); + valent_share_target_chooser_add_entries (self); - g_action_group_activate_action (G_ACTION_GROUP (device), "share.open", target); + if (self->files != NULL && g_list_model_get_n_items (files) > 0) + adw_navigation_view_push_by_tag (self->view, "device"); + else + adw_navigation_view_pop (self->view); - gtk_window_close (GTK_WINDOW (self)); + g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FILES]); } static void -chooser_share_action (GtkWidget *widget, - const char *action_name, - GVariant *parameter) +valent_share_target_chooser_set_selection_mode (ValentShareTargetChooser *self, + gboolean selection_mode) { - ValentShareTargetChooser *self = VALENT_SHARE_TARGET_CHOOSER (widget); - GtkListBoxRow *row; + g_assert (VALENT_IS_SHARE_TARGET_CHOOSER (self)); + + selection_mode = !!selection_mode; + if (self->selection_mode == selection_mode) + return; + + gtk_list_box_set_selection_mode (self->device_list, + selection_mode + ? GTK_SELECTION_MULTIPLE + : GTK_SELECTION_NONE); - row = gtk_list_box_get_selected_row (self->device_list); - on_row_activated (self->device_list, row, self); + self->selection_mode = selection_mode; + g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SELECTION_MODE]); +} + +static void +valent_share_target_chooser_share (ValentShareTargetChooser *self, + ValentShareTargetRow *row) +{ + ValentDevice *device = NULL; + GVariantBuilder builder; + unsigned int n_files = 0; + + g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY); + n_files = g_list_model_get_n_items (self->files); + + for (unsigned int i = 0; i < n_files; i++) + { + g_autoptr (GFile) file = g_list_model_get_item (self->files, i); + GVariant *uri = g_variant_new_take_string (g_file_get_uri (file)); + + g_variant_builder_add_value (&builder, uri); + } + + device = valent_share_target_row_get_device (row); + g_action_group_activate_action (G_ACTION_GROUP (device), + "share.uris", + g_variant_builder_end (&builder)); + + gtk_window_close (GTK_WINDOW (self)); } /* @@ -272,8 +633,6 @@ valent_share_target_chooser_constructed (GObject *object) { ValentShareTargetChooser *self = VALENT_SHARE_TARGET_CHOOSER (object); - g_assert (G_IS_LIST_MODEL (self->files)); - self->manager = valent_device_manager_get_default (); g_signal_connect_object (self->manager, "items-changed", @@ -284,7 +643,6 @@ valent_share_target_chooser_constructed (GObject *object) 0, g_list_model_get_n_items (G_LIST_MODEL (self->manager)), self); - on_selected_rows_changed (self->device_list, self); /* Broadcast every 5 seconds to re-connect devices that may have gone idle */ valent_device_manager_refresh (self->manager); @@ -310,22 +668,21 @@ valent_share_target_chooser_dispose (GObject *object) self->manager = NULL; } + if (self->cancellable != NULL) + { + g_cancellable_cancel (self->cancellable); + g_clear_object (&self->cancellable); + } + + g_clear_object (&self->files); + g_clear_pointer (&self->rows, g_ptr_array_unref); + gtk_widget_dispose_template (GTK_WIDGET (object), VALENT_TYPE_SHARE_TARGET_CHOOSER); G_OBJECT_CLASS (valent_share_target_chooser_parent_class)->dispose (object); } -static void -valent_share_target_chooser_finalize (GObject *object) -{ - ValentShareTargetChooser *self = VALENT_SHARE_TARGET_CHOOSER (object); - - g_clear_object (&self->files); - - G_OBJECT_CLASS (valent_share_target_chooser_parent_class)->finalize (object); -} - static void valent_share_target_chooser_get_property (GObject *object, guint prop_id, @@ -340,6 +697,10 @@ valent_share_target_chooser_get_property (GObject *object, g_value_set_object (value, self->files); break; + case PROP_SELECTION_MODE: + g_value_set_boolean (value, self->selection_mode); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -356,7 +717,11 @@ valent_share_target_chooser_set_property (GObject *object, switch (prop_id) { case PROP_FILES: - self->files = g_value_dup_object (value); + valent_share_target_chooser_set_files (self, g_value_get_object (value)); + break; + + case PROP_SELECTION_MODE: + valent_share_target_chooser_set_selection_mode (self, g_value_get_boolean (value)); break; default: @@ -372,18 +737,23 @@ valent_share_target_chooser_class_init (ValentShareTargetChooserClass *klass) object_class->constructed = valent_share_target_chooser_constructed; object_class->dispose = valent_share_target_chooser_dispose; - object_class->finalize = valent_share_target_chooser_finalize; object_class->get_property = valent_share_target_chooser_get_property; object_class->set_property = valent_share_target_chooser_set_property; gtk_widget_class_set_template_from_resource (widget_class, "/plugins/share/valent-share-target-chooser.ui"); + gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, view); gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, device_list); - gtk_widget_class_bind_template_callback (widget_class, on_row_activated); - gtk_widget_class_bind_template_callback (widget_class, on_selected_rows_changed); + gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, single_row); + gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, single_icon); + gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, multiple_row); + gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, multiple_icon); + gtk_widget_class_bind_template_child (widget_class, ValentShareTargetChooser, uri_entry); + gtk_widget_class_bind_template_callback (widget_class, on_device_activated); + gtk_widget_class_bind_template_callback (widget_class, on_uri_activated); + gtk_widget_class_bind_template_callback (widget_class, on_uri_changed); - gtk_widget_class_install_action (widget_class, "chooser.cancel", NULL, chooser_cancel_action); - gtk_widget_class_install_action (widget_class, "chooser.open", NULL, chooser_open_action); gtk_widget_class_install_action (widget_class, "chooser.share", NULL, chooser_share_action); + gtk_widget_class_install_action (widget_class, "chooser.select-files", NULL, chooser_select_files_action); /** * ValentShareTargetChooser:files: @@ -398,6 +768,19 @@ valent_share_target_chooser_class_init (ValentShareTargetChooserClass *klass) G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + /** + * ValentShareTargetChooser:selection-mode: + * + * The URIs to pass to the selected [class@Valent.Device]. + */ + properties [PROP_SELECTION_MODE] = + g_param_spec_boolean ("selection-mode", NULL, NULL, + FALSE, + (G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_EXPLICIT_NOTIFY | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties (object_class, N_PROPERTIES, properties); } @@ -405,5 +788,6 @@ static void valent_share_target_chooser_init (ValentShareTargetChooser *self) { gtk_widget_init_template (GTK_WIDGET (self)); + gtk_widget_add_css_class (GTK_WIDGET (self), "share-chooser"); } diff --git a/src/plugins/share/valent-share-target-chooser.h b/src/plugins/share/valent-share-target-chooser.h index 566510f2087..016aa268b84 100644 --- a/src/plugins/share/valent-share-target-chooser.h +++ b/src/plugins/share/valent-share-target-chooser.h @@ -3,13 +3,13 @@ #pragma once -#include +#include G_BEGIN_DECLS #define VALENT_TYPE_SHARE_TARGET_CHOOSER (valent_share_target_chooser_get_type()) -G_DECLARE_FINAL_TYPE (ValentShareTargetChooser, valent_share_target_chooser, VALENT, SHARE_TARGET_CHOOSER, GtkWindow) +G_DECLARE_FINAL_TYPE (ValentShareTargetChooser, valent_share_target_chooser, VALENT, SHARE_TARGET_CHOOSER, AdwWindow) G_END_DECLS diff --git a/src/plugins/share/valent-share-target-chooser.ui b/src/plugins/share/valent-share-target-chooser.ui index c4ab7bbdbe9..3c77ab99aaa 100644 --- a/src/plugins/share/valent-share-target-chooser.ui +++ b/src/plugins/share/valent-share-target-chooser.ui @@ -4,77 +4,183 @@ -