From f14eef5880f845fc08345888d27ceb52acba0754 Mon Sep 17 00:00:00 2001 From: birros Date: Wed, 18 Jul 2018 17:18:34 +0200 Subject: [PATCH] DetailsView: refactor to DetailsDialog --- po/POTFILES | 2 +- po/fr.po | 65 +++++++++---------- src/app/meson.build | 2 +- src/app/states/navigation-logic.vala | 1 - src/app/states/route-state.vala | 1 - src/app/states/title-logic.vala | 7 -- src/app/ui/content/content.vala | 9 --- ...{details-view.vala => details-dialog.vala} | 38 +++++------ src/app/ui/content/home-view.vala | 13 +++- src/app/ui/header-bar/header-bar.vala | 1 - 10 files changed, 62 insertions(+), 77 deletions(-) rename src/app/ui/content/{details-view.vala => details-dialog.vala} (86%) diff --git a/po/POTFILES b/po/POTFILES index c07884c..3ace475 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -8,7 +8,7 @@ src/app/utils/tag-formater.vala src/app/ui/content/search-view.vala src/app/ui/content/history-view.vala src/app/ui/content/archive-row.vala -src/app/ui/content/details-view.vala +src/app/ui/content/details-dialog.vala src/app/ui/content/bookmark-view.vala src/app/ui/content/status-label.vala src/app/ui/content/home-view.vala diff --git a/po/fr.po b/po/fr.po index 2739113..7411222 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1,12 +1,12 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-07-17 18:31+0200\n" +"POT-Creation-Date: 2018-07-18 17:11+0200\n" "Content-Type: text/plain; charset=UTF-8\n" #: data/appdata/com.github.birros.WebArchives.appdata.xml.in:7 #: data/desktop/com.github.birros.WebArchives.desktop.in:3 -#: src/app/states/title-logic.vala:17 src/app/ui/window.vala:305 +#: src/app/states/title-logic.vala:17 src/app/ui/window.vala:306 msgid "WebArchives" msgstr "WebArchives" @@ -56,13 +56,13 @@ msgid "Search in page" msgstr "Chercher dans la page" #: data/appdata/com.github.birros.WebArchives.appdata.xml.in:24 -#: src/app/states/title-logic.vala:44 +#: src/app/states/title-logic.vala:37 #: src/app/ui/header-bar/popover-menu.vala:60 msgid "History" msgstr "Historique" #: data/appdata/com.github.birros.WebArchives.appdata.xml.in:25 -#: src/app/states/title-logic.vala:37 +#: src/app/states/title-logic.vala:30 #: src/app/ui/header-bar/popover-menu.vala:54 msgid "Bookmarks" msgstr "Signets" @@ -278,10 +278,6 @@ msgstr "Remettre le zoom à zéro" msgid "Print version number" msgstr "Afficher le numéro de version" -#: src/app/states/title-logic.vala:23 src/app/ui/content/archive-row.vala:121 -msgid "Details" -msgstr "Détails" - #: src/app/utils/language-formater.vala:45 msgid "Unspecified language" msgstr "Langue non spécifiée" @@ -314,70 +310,71 @@ msgstr "Pas d'historique de navigation." msgid "%e %b %y" msgstr "" +#: src/app/ui/content/archive-row.vala:121 +#: src/app/ui/content/details-dialog.vala:11 +msgid "Details" +msgstr "Détails" + #: src/app/ui/content/archive-row.vala:130 msgid "Remove" msgstr "Retirer" -#: src/app/ui/content/details-view.vala:112 +#: src/app/ui/content/details-dialog.vala:120 msgid "Favicon" msgstr "Favicône" -#: src/app/ui/content/details-view.vala:113 +#: src/app/ui/content/details-dialog.vala:121 msgid "Title" msgstr "Titre" -#: src/app/ui/content/details-view.vala:115 +#: src/app/ui/content/details-dialog.vala:123 msgid "Location" msgstr "Emplacement" -#: src/app/ui/content/details-view.vala:117 +#: src/app/ui/content/details-dialog.vala:125 msgid "Date" msgstr "Date" -#: src/app/ui/content/details-view.vala:118 +#: src/app/ui/content/details-dialog.vala:126 msgid "Lang" msgstr "Langue" -#: src/app/ui/content/details-view.vala:120 +#: src/app/ui/content/details-dialog.vala:127 msgid "Size" msgstr "Taille" -#: src/app/ui/content/details-view.vala:121 +#: src/app/ui/content/details-dialog.vala:128 msgid "Name" msgstr "Nom" -#: src/app/ui/content/details-view.vala:122 +#: src/app/ui/content/details-dialog.vala:129 msgid "Id" msgstr "Id" -#: src/app/ui/content/details-view.vala:123 +#: src/app/ui/content/details-dialog.vala:130 msgid "Description" msgstr "Description" -#: src/app/ui/content/details-view.vala:124 +#: src/app/ui/content/details-dialog.vala:131 msgid "Article count" msgstr "Nombre d'articles" -#: src/app/ui/content/details-view.vala:125 +#: src/app/ui/content/details-dialog.vala:132 msgid "Media count" msgstr "Nombre de médias" -#: src/app/ui/content/details-view.vala:126 +#: src/app/ui/content/details-dialog.vala:133 msgid "Creator" msgstr "Créateur" -#: src/app/ui/content/details-view.vala:127 +#: src/app/ui/content/details-dialog.vala:134 msgid "Publisher" msgstr "Éditeur" -#: src/app/ui/content/details-view.vala:131 +#: src/app/ui/content/details-dialog.vala:135 msgid "Tags" msgstr "Étiquettes" -#: src/app/ui/content/details-view.vala:133 -msgid "Url" -msgstr "" - #: src/app/ui/content/bookmark-view.vala:23 msgid "No bookmarks saved." msgstr "Pas de signets sauvegardés." @@ -463,20 +460,20 @@ msgstr "Téléchargement" msgid "No archive available for download." msgstr "Aucune archive disponible en téléchargement." -#: src/app/ui/content/home-view.vala:409 +#: src/app/ui/content/home-view.vala:418 #, c-format msgid "How would you like to download %s ?" msgstr "Comment souhaitez-vous télécharger %s ?" -#: src/app/ui/content/home-view.vala:413 +#: src/app/ui/content/home-view.vala:422 msgid "This will open a third-party application to download the archive." msgstr "Ceci ouvrira une application tierce pour télécharger l'archive." -#: src/app/ui/content/home-view.vala:415 +#: src/app/ui/content/home-view.vala:424 msgid "From a server" msgstr "Depuis un serveur" -#: src/app/ui/content/home-view.vala:416 +#: src/app/ui/content/home-view.vala:425 msgid "Peer-to-peer network" msgstr "Réseau pair à pair" @@ -512,18 +509,18 @@ msgstr "Quitter" msgid "Night mode" msgstr "Mode nuit" -#: src/app/ui/window.vala:306 +#: src/app/ui/window.vala:307 msgid "A Web archives viewer." msgstr "Un visionneur d'archives web." -#: src/app/ui/window.vala:307 +#: src/app/ui/window.vala:308 msgid "Copyright © 2017-2017 - Birros" msgstr "Copyright © 2017-2017 - Birros" -#: src/app/ui/window.vala:387 +#: src/app/ui/window.vala:427 msgid "Please choose a file" msgstr "Veuillez choisir un fichier" -#: src/app/ui/window.vala:457 +#: src/app/ui/window.vala:497 msgid "Are you sure to open external link ?" msgstr "Voulez-vous vraiment ouvrir le lien externe ?" diff --git a/src/app/meson.build b/src/app/meson.build index c46ab76..2fe76b6 100644 --- a/src/app/meson.build +++ b/src/app/meson.build @@ -33,7 +33,7 @@ web_archives_sources = [ 'ui/content/notification-bar.vala', 'ui/content/combo-box-text.vala', 'ui/content/combo-box-row.vala', - 'ui/content/details-view.vala', + 'ui/content/details-dialog.vala', 'ui/content/web-view.vala', 'ui/content/search-view.vala', 'ui/content/search-result-row.vala', diff --git a/src/app/states/navigation-logic.vala b/src/app/states/navigation-logic.vala index 7084c37..d7f6104 100644 --- a/src/app/states/navigation-logic.vala +++ b/src/app/states/navigation-logic.vala @@ -59,7 +59,6 @@ public class WebArchives.NavigationLogic : Object { case RouteState.Route.SEARCH: case RouteState.Route.SEARCHIN: case RouteState.Route.BOOKMARK: - case RouteState.Route.DETAILS: case RouteState.Route.HISTORY: { context.route_state.route = context.route_state.last_route; diff --git a/src/app/states/route-state.vala b/src/app/states/route-state.vala index b02bd4b..493e32c 100644 --- a/src/app/states/route-state.vala +++ b/src/app/states/route-state.vala @@ -4,7 +4,6 @@ public class WebArchives.RouteState : Object { WEB, SEARCH, SEARCHIN, - DETAILS, BOOKMARK, HISTORY } diff --git a/src/app/states/title-logic.vala b/src/app/states/title-logic.vala index cd4cea1..45b3120 100644 --- a/src/app/states/title-logic.vala +++ b/src/app/states/title-logic.vala @@ -18,13 +18,6 @@ public class WebArchives.TitleLogic : Object { context.title_state.subtitle = ""; break; } - case RouteState.Route.DETAILS: - { - context.title_state.title = _("Details"); - context.title_state.subtitle = - context.archive_state.archive.title; - break; - } case RouteState.Route.WEB: { context.title_state.title = context.web_view_state.title; diff --git a/src/app/ui/content/content.vala b/src/app/ui/content/content.vala index 8da34e7..b37eb5f 100644 --- a/src/app/ui/content/content.vala +++ b/src/app/ui/content/content.vala @@ -1,7 +1,6 @@ public class WebArchives.Content : Gtk.Stack { private Context context; private HomeView home_view; - private DetailsView details_view; private WebView web_view; private SearchView search_view; private BookmarkView bookmark_view; @@ -14,9 +13,6 @@ public class WebArchives.Content : Gtk.Stack { home_view = new HomeView (context); add (home_view); - details_view = new DetailsView (context); - add (details_view); - web_view = new WebView (context); add (web_view); @@ -57,11 +53,6 @@ public class WebArchives.Content : Gtk.Stack { set_visible_child (search_view); break; } - case RouteState.Route.DETAILS: - { - set_visible_child (details_view); - break; - } case RouteState.Route.BOOKMARK: { set_visible_child (bookmark_view); diff --git a/src/app/ui/content/details-view.vala b/src/app/ui/content/details-dialog.vala similarity index 86% rename from src/app/ui/content/details-view.vala rename to src/app/ui/content/details-dialog.vala index 3f4f11e..9be7a42 100644 --- a/src/app/ui/content/details-view.vala +++ b/src/app/ui/content/details-dialog.vala @@ -1,29 +1,38 @@ -public class WebArchives.DetailsView : Gtk.Box { - private Context context; +public class WebArchives.DetailsDialog : Gtk.Dialog { private Gtk.Grid grid; - public DetailsView (Context context) { - this.context = context; - set_homogeneous (true); + public DetailsDialog (ArchiveItem archive) { + GLib.Object ( + use_header_bar: 1 + ); + + Gtk.HeaderBar header_bar = (Gtk.HeaderBar) get_header_bar (); + header_bar.show_close_button = true; + header_bar.title = _("Details"); + header_bar.subtitle = archive.title; + + Gtk.Box content_area = get_content_area (); + content_area.set_homogeneous (true); Gtk.ScrolledWindow scrolled_window = new Gtk.ScrolledWindow ( null, null ); - add (scrolled_window); + content_area.add (scrolled_window); Hdy.Column max_width_bin = new Hdy.Column (); - max_width_bin.set_maximum_width (500); + max_width_bin.set_maximum_width (900); scrolled_window.add (max_width_bin); grid = new Gtk.Grid (); grid.orientation = Gtk.Orientation.VERTICAL; + grid.column_homogeneous = true; grid.margin_top = 12; grid.margin_bottom = 12; grid.column_spacing = 24; grid.row_spacing = 12; max_width_bin.add (grid); - context.archive_state.notify["archive"].connect (on_archive); + show_infos (archive); } private void show_text (string label, string content) { @@ -90,16 +99,7 @@ public class WebArchives.DetailsView : Gtk.Box { return label_widget; } - private void on_archive () { - if (context.archive_state.archive == null) { - return; - } - - ArchiveItem archive = context.archive_state.archive; - - grid.forall ((element) => grid.remove (element)); - - + private void show_infos (ArchiveItem archive) { string folder_uri = ""; string folder_path = ""; if (archive.path != "") { @@ -132,7 +132,5 @@ public class WebArchives.DetailsView : Gtk.Box { show_text (_("Creator"), archive.creator); show_text (_("Publisher"), archive.publisher); show_text (_("Tags"), tags_text); - - show_all (); } } diff --git a/src/app/ui/content/home-view.vala b/src/app/ui/content/home-view.vala index 887530e..2c85df0 100644 --- a/src/app/ui/content/home-view.vala +++ b/src/app/ui/content/home-view.vala @@ -386,9 +386,8 @@ public class WebArchives.HomeView : Gtk.Overlay { } }); row.details.connect (() => { - context.archive_state.archive = archive; revealer.reveal_child = false; - context.route_state.route = RouteState.Route.DETAILS; + show_details (archive); }); row.download.connect (() => { ask_for_downloading (archive); @@ -396,6 +395,16 @@ public class WebArchives.HomeView : Gtk.Overlay { return row; } + private void show_details (ArchiveItem archive) { + Gtk.Window win = (Gtk.Window) this.get_toplevel (); + DetailsDialog details_dialog = new DetailsDialog (archive); + details_dialog.modal = true; + details_dialog.set_transient_for (win); + details_dialog.default_width = 600; + details_dialog.default_height = 510; + details_dialog.show_all (); + } + private void ask_for_downloading (ArchiveItem archive) { Gtk.Window win = (Gtk.Window) this.get_toplevel (); string espaced_title = Markup.escape_text (archive.title); diff --git a/src/app/ui/header-bar/header-bar.vala b/src/app/ui/header-bar/header-bar.vala index a1e4848..c861112 100644 --- a/src/app/ui/header-bar/header-bar.vala +++ b/src/app/ui/header-bar/header-bar.vala @@ -167,7 +167,6 @@ public class WebArchives.HeaderBar : Gtk.HeaderBar { context.search_in_state.focus (); break; } - case RouteState.Route.DETAILS: case RouteState.Route.BOOKMARK: case RouteState.Route.HISTORY: {