[dconf-editor] Rework about dialog and in-window panel.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Rework about dialog and in-window panel.
- Date: Sun, 20 Jan 2019 10:35:45 +0000 (UTC)
commit 289f3486e4eb9be0361d5445a73abce36d22c232
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jan 16 22:39:05 2019 +0100
Rework about dialog and in-window panel.
Store the About informations in the application.
editor/about-list.vala | 127 ++++++++++++++++++++++++++++++++-----------
editor/base-headerbar.vala | 6 +--
editor/base-view.vala | 22 +++++---
editor/base-window.vala | 132 ++++++++++++++++++++++++++++++++-------------
editor/dconf-editor.vala | 39 ++++++++++++++
editor/dconf-window.vala | 24 ---------
6 files changed, 249 insertions(+), 101 deletions(-)
---
diff --git a/editor/about-list.vala b/editor/about-list.vala
index 47dbf90..24149f9 100644
--- a/editor/about-list.vala
+++ b/editor/about-list.vala
@@ -19,6 +19,20 @@ using Gtk;
private class AboutList : OverlayedList
{
+ // same as about dialog; skipped: wrap_license, license, logo
+ public string [] artists { private get; protected construct; default = {}; }
+ public string [] authors { private get; protected construct; default = {}; }
+ public string comments { private get; protected construct; default = ""; }
+ public string copyright { private get; protected construct; default = ""; }
+ public string [] documenters { private get; protected construct; default = {}; }
+ private License license_type { private get { return License.GPL_3_0; }} // forced, 2/3
+ public string logo_icon_name { private get; protected construct; default = ""; }
+ public string program_name { private get; protected construct; default = ""; }
+ public string translator_credits { private get; protected construct; default = ""; }
+ public string version { private get; protected construct; default = ""; }
+ public string website { private get; protected construct; default = ""; }
+ public string website_label { private get; protected construct; default = ""; }
+
construct
{
install_action_entries ();
@@ -35,11 +49,24 @@ private class AboutList : OverlayedList
show_apropos (ref main_list_store);
}
- internal AboutList (bool needs_shadows, bool big_placeholder)
+ internal AboutList (bool needs_shadows,
+ bool big_placeholder,
+ ref string [] artists,
+ ref string [] authors,
+ ref string comments,
+ ref string copyright,
+ ref string [] documenters,
+ ref string logo_icon_name,
+ ref string program_name,
+ ref string translator_credits,
+ ref string version,
+ ref string website,
+ ref string website_label)
{
Object (needs_shadows : needs_shadows,
big_placeholder : big_placeholder,
- edit_mode_action_prefix : "about");
+ edit_mode_action_prefix : "about",
+ artists: artists, authors: authors, comments: comments, copyright: copyright, documenters:
documenters, logo_icon_name: logo_icon_name, program_name: program_name, translator_credits:
translator_credits, version: version, website: website, website_label: website_label);
}
internal override void reset ()
@@ -81,54 +108,88 @@ private class AboutList : OverlayedList
show_apropos (ref main_list_store);
}
- private static inline void show_apropos (ref GLib.ListStore main_list_store)
+ private inline void show_apropos (ref GLib.ListStore main_list_store)
{
main_list_store.remove_all ();
- main_list_store.append (new AboutListItem.from_icon_name (AboutDialogInfos.logo_icon_name,
AboutDialogInfos.program_name));
- AboutListItem program = new AboutListItem.from_label (AboutDialogInfos.program_name,
"bold-label");
+ if (program_name == "")
+ assert_not_reached ();
+ if (logo_icon_name != "")
+ main_list_store.append (new AboutListItem.from_icon_name (logo_icon_name, program_name));
+ AboutListItem program = new AboutListItem.from_label (program_name, "bold-label");
main_list_store.append (program);
- main_list_store.append (new AboutListItem.from_label (AboutDialogInfos.version));
- main_list_store.append (new AboutListItem.from_label (AboutDialogInfos.comments));
- main_list_store.append (new AboutListItem.from_link (AboutDialogInfos.website,
- AboutDialogInfos.website_label));
- main_list_store.append (new AboutListItem.from_label (AboutDialogInfos.copyright,
"small-label"));
-
- // TODO support all licenses type
- if (AboutDialogInfos.license_type != License.GPL_3_0)
+
+ if (version != "")
+ main_list_store.append (new AboutListItem.from_label (version));
+ if (comments != "")
+ main_list_store.append (new AboutListItem.from_label (comments));
+ if (website != "")
+ main_list_store.append (new AboutListItem.from_link (website, website_label)); //
website_label can be empty
+ if (copyright != "")
+ main_list_store.append (new AboutListItem.from_label (copyright, "small-label"));
+
+ // forced, 3/3 // TODO support all licenses type
+ if (license_type != License.GPL_3_0)
assert_not_reached ();
/* Translators: on really small windows, the about dialog is replaced by an in-window view; here is
the label of the link to the GPL license; TODO better text, as in the usual about dialog */
- main_list_store.append (new AboutListItem.from_link
("https://www.gnu.org/licenses/gpl-3.0.html", _("GNU General Public License\nversion 3 or later")));
+ main_list_store.append (new AboutListItem.from_link
("https://www.gnu.org/licenses/gpl-3.0.html", _("GNU General Public License\nversion 3 or later")));
program.grab_focus ();
}
- private static inline void show_credits (ref GLib.ListStore main_list_store)
+ private inline void show_credits (ref GLib.ListStore main_list_store)
{
main_list_store.remove_all ();
- main_list_store.append (new AboutListItem.from_icon_name (AboutDialogInfos.logo_icon_name,
AboutDialogInfos.program_name));
- AboutListItem program = new AboutListItem.from_label (AboutDialogInfos.program_name,
"bold-label");
+ if (program_name == "")
+ assert_not_reached ();
+ if (logo_icon_name != "")
+ main_list_store.append (new AboutListItem.from_icon_name (logo_icon_name, program_name));
+ AboutListItem program = new AboutListItem.from_label (program_name, "bold-label");
main_list_store.append (program);
- string authors = "";
- uint position = 0;
- uint max_position = AboutDialogInfos.authors.length - 1;
- foreach (string author in AboutDialogInfos.authors)
+ if (authors.length > 0)
{
- authors += author;
- if (position < max_position)
- authors += "\n";
- position++;
+ string authors_string = get_multiline_string_from_string_array (authors);
+ /* Translators: on really small windows, the about dialog is replaced by an in-window view; here
is the header of the programmers names */
+ main_list_store.append (new AboutListItem.with_title (authors_string, _("Creators")));
+ }
+
+ if (documenters.length > 0)
+ {
+ string documenters_string = get_multiline_string_from_string_array (documenters);
+ /* Translators: on really small windows, the about dialog is replaced by an in-window view; here
is the header of the documenters names */
+// main_list_store.append (new AboutListItem.with_title (documenters_string,
_("Documenters")));
}
- /* Translators: on really small windows, the about dialog is replaced by an in-window view; here is
the header of the programmers names */
- main_list_store.append (new AboutListItem.with_title (authors, _("Creators")));
+ if (translator_credits != "")
+ /* Translators: on really small windows, the about dialog is replaced by an in-window view; here
is the header of the translators names */
+ main_list_store.append (new AboutListItem.with_title (translator_credits,
_("Translators")));
- /* Translators: on really small windows, the about dialog is replaced by an in-window view; here is
the header of the translators names */
- main_list_store.append (new AboutListItem.with_title (AboutDialogInfos.translator_credits,
_("Translators")));
+ if (artists.length > 0)
+ {
+ string artists_string = get_multiline_string_from_string_array (artists);
+ /* Translators: on really small windows, the about dialog is replaced by an in-window view; here
is the header of the pictural artists names */
+// main_list_store.append (new AboutListItem.with_title (artists_string, _("Artists")));
+ }
program.grab_focus ();
}
+ private static string get_multiline_string_from_string_array (string [] string_array)
+ {
+ if (string_array.length <= 0)
+ return "";
+ string multiline_string = "";
+ uint position = 0;
+ uint max_position = string_array.length - 1;
+ foreach (string string_item in string_array)
+ {
+ multiline_string += string_item;
+ if (position < max_position)
+ multiline_string += "\n";
+ position++;
+ }
+ return multiline_string;
+ }
}
private class AboutListItem : OverlayedListRow
@@ -169,11 +230,15 @@ private class AboutListItem : OverlayedListRow
add (image);
}
- internal AboutListItem.from_link (string link, string text) // TODO do not allow button focus, and
activate it on row activation
+ internal AboutListItem.from_link (string link, string text_or_empty) // TODO do not allow button focus,
and activate it on row activation
{
Object (copy_text: link);
- LinkButton button = new LinkButton.with_label (link, text);
+ LinkButton button;
+ if (text_or_empty == "")
+ button = new LinkButton (link);
+ else
+ button = new LinkButton.with_label (link, text_or_empty);
button.visible = true;
button.hexpand = true;
diff --git a/editor/base-headerbar.vala b/editor/base-headerbar.vala
index 98263f1..f92550b 100644
--- a/editor/base-headerbar.vala
+++ b/editor/base-headerbar.vala
@@ -68,9 +68,9 @@ private class BaseHeaderBar : NightTimeAwareHeaderBar, AdaptativeWidget
* * hamburger menu
\*/
- [CCode (notify = false)] public string about_action_label { private get; protected construct; } //
TODO add default = _("About");
- [CCode (notify = false)] public bool has_help { private get; protected construct;
default = false; }
- [CCode (notify = false)] public bool has_keyboard_shortcuts { private get; protected construct;
default = false; }
+ [CCode (notify = false)] public string about_action_label { internal get; protected construct; } //
TODO add default = _("About");
+ [CCode (notify = false)] public bool has_help { private get; protected construct;
default = false; }
+ [CCode (notify = false)] public bool has_keyboard_shortcuts { private get; protected construct;
default = false; }
protected override void update_hamburger_menu ()
{
diff --git a/editor/base-view.vala b/editor/base-view.vala
index edd5d9a..42a9ed5 100644
--- a/editor/base-view.vala
+++ b/editor/base-view.vala
@@ -75,10 +75,21 @@ private class BaseView : Stack, AdaptativeWidget
private bool about_list_created = false;
private AboutList about_list;
- private void create_about_list ()
+ internal void create_about_list (ref string [] artists,
+ ref string [] authors,
+ ref string comments,
+ ref string copyright,
+ ref string [] documenters,
+ ref string logo_icon_name,
+ ref string program_name,
+ ref string translator_credits,
+ ref string version,
+ ref string website,
+ ref string website_label)
{
about_list = new AboutList (/* needs shadows */ false,
- /* big placeholder */ true);
+ /* big placeholder */ true,
+ ref artists, ref authors, ref comments, ref copyright, ref documenters,
ref logo_icon_name, ref program_name, ref translator_credits, ref version, ref website, ref website_label);
about_list.set_window_size (saved_window_size);
about_list.show ();
add (about_list);
@@ -86,13 +97,10 @@ private class BaseView : Stack, AdaptativeWidget
}
internal void show_about_view ()
+ requires (about_list_created == true)
requires (in_window_about == false)
{
- if (about_list_created)
- about_list.reset ();
- else
- create_about_list ();
-
+ about_list.reset ();
set_visible_child (about_list);
in_window_about = true;
}
diff --git a/editor/base-window.vala b/editor/base-window.vala
index 2d8abf1..1343384 100644
--- a/editor/base-window.vala
+++ b/editor/base-window.vala
@@ -20,6 +20,19 @@ using Gtk;
private interface BaseApplication : Gtk.Application
{
internal abstract void copy (string text);
+
+ // same as about dialog; skipped: wrap_license, license, license_type (forced at GPL v3+ ==
License.GPL_3_0), logo
+ internal abstract void get_about_dialog_infos (out string [] artists,
+ out string [] authors,
+ out string comments,
+ out string copyright,
+ out string [] documenters,
+ out string logo_icon_name,
+ out string program_name,
+ out string translator_credits,
+ out string version,
+ out string website,
+ out string website_label);
}
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/base-window.ui")]
@@ -273,8 +286,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
}
private static bool _on_key_press_event (Widget widget, Gdk.EventKey event)
{
- uint keyval = event.keyval;
- string name = (!) (Gdk.keyval_name (keyval) ?? "");
+ string name = (!) (Gdk.keyval_name (event.keyval) ?? "");
if (name == "F1") // TODO fix dance done with the F1 & <Primary>F1 shortcuts that show help overlay
{
@@ -320,50 +332,110 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
show_default_view ();
}
+ protected virtual void show_default_view (/* SimpleAction action, Variant? path_variant */)
+ {
+ if (in_window_about)
+ {
+ in_window_about = false;
+ headerbar.show_default_view ();
+ main_view.show_default_view ();
+ }
+ else
+ assert_not_reached ();
+ }
+
/*\
- * * about action and dialog
+ * * about dialog
\*/
- private void about (/* SimpleAction action, Variant? path_variant */)
+ private AboutDialog about_dialog;
+ private void show_about_dialog ()
{
- if (disable_popovers)
- toggle_in_window_about ();
- else
- show_about_dialog (); // TODO hide the dialog if visible
+ if (should_init_about_dialog)
+ {
+ create_about_dialog ();
+ about_dialog.response.connect ((_about_dialog, response) => _about_dialog.hide ());
+ about_dialog.key_press_event.connect (about_dialog_key_press_event);
+ about_dialog.set_transient_for (this);
+ should_init_about_dialog = false;
+ }
+ about_dialog.run ();
+ }
+ private static bool about_dialog_key_press_event (Widget _about_dialog_widget, Gdk.EventKey event)
+ {
+ if (((!) (Gdk.keyval_name (event.keyval) ?? "") == "F1")
+ && ((event.state & Gdk.ModifierType.SHIFT_MASK) != 0))
+ {
+ ((Dialog) _about_dialog_widget).response (ResponseType.CANCEL);
+ return true;
+ }
+ return false;
}
- private void show_about_dialog ()
+ private bool should_init_about_dialog = true;
+ private void create_about_dialog ()
{
- string [] authors = AboutDialogInfos.authors;
- Gtk.show_about_dialog (this,
- "program-name", AboutDialogInfos.program_name,
- "version", AboutDialogInfos.version,
- "comments", AboutDialogInfos.comments,
- "copyright", AboutDialogInfos.copyright,
- "license-type", AboutDialogInfos.license_type,
- "wrap-license", true,
- "authors", authors,
- "translator-credits", AboutDialogInfos.translator_credits,
- "logo-icon-name", AboutDialogInfos.logo_icon_name,
- "website", AboutDialogInfos.website,
- "website-label", AboutDialogInfos.website_label,
- null);
+ string [] artists, authors, documenters;
+ string comments, copyright, logo_icon_name, program_name, translator_credits, version, website,
website_label;
+
+ ((BaseApplication) get_application ()).get_about_dialog_infos (out artists, out authors, out
comments, out copyright, out documenters, out logo_icon_name, out program_name, out translator_credits, out
version, out website, out website_label);
+
+ about_dialog = new AboutDialog ();
+ about_dialog.set_title (headerbar.about_action_label);
+ about_dialog.set_wrap_license (true);
+ about_dialog.set_license_type (License.GPL_3_0); // forced, 1/3
+ if (artists.length > 0) about_dialog.set_artists (artists);
+ if (authors.length > 0) about_dialog.set_authors (authors);
+ if (comments != "") about_dialog.set_comments (comments);
+ if (copyright != "") about_dialog.set_copyright (copyright);
+ if (documenters.length > 0) about_dialog.set_documenters (documenters);
+ if (logo_icon_name != "") about_dialog.set_logo_icon_name (logo_icon_name);
+ if (program_name != "") about_dialog.set_program_name (program_name); else
assert_not_reached ();
+ if (translator_credits != "") about_dialog.set_translator_credits (translator_credits);
+ if (version != "") about_dialog.set_version (version);
+ if (website != "") about_dialog.set_website (website);
+ if (website_label != "") about_dialog.set_website_label (website_label);
}
/*\
* * in-window about
\*/
+ private void about (/* SimpleAction action, Variant? path_variant */)
+ {
+ if (disable_popovers)
+ toggle_in_window_about ();
+ else
+ show_about_dialog ();
+ }
+
[CCode (notify = false)] protected bool in_window_about { protected get; private set; default = false; }
private void toggle_in_window_about ()
{
- if (in_window_about)
+ if (should_init_in_window_about)
+ {
+ init_in_window_about ();
+ should_init_in_window_about = false;
+ show_about_view ();
+ }
+ else if (in_window_about)
show_default_view ();
else
show_about_view ();
}
+ private bool should_init_in_window_about = true;
+ private void init_in_window_about ()
+ {
+ string [] artists, authors, documenters;
+ string comments, copyright, logo_icon_name, program_name, translator_credits, version, website,
website_label;
+
+ ((BaseApplication) get_application ()).get_about_dialog_infos (out artists, out authors, out
comments, out copyright, out documenters, out logo_icon_name, out program_name, out translator_credits, out
version, out website, out website_label);
+
+ main_view.create_about_list (ref artists, ref authors, ref
comments, ref copyright, ref documenters, ref logo_icon_name, ref program_name, ref translator_credits, ref
version, ref website, ref website_label);
+ }
+
private inline void show_about_view ()
requires (in_window_about == false)
{
@@ -375,18 +447,6 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
set_focus_visible (false); // about-list grabs focus
}
- protected virtual void show_default_view (/* SimpleAction action, Variant? path_variant */)
- {
- if (in_window_about)
- {
- in_window_about = false;
- headerbar.show_default_view ();
- main_view.show_default_view ();
- }
- else
- assert_not_reached ();
- }
-
/*\
* * notifications
\*/
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 4eaf869..cd9bee2 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -621,4 +621,43 @@ private class ConfigurationEditor : Gtk.Application, BaseApplication
((DConfWindow) (!) window).apply_pending_changes_and_quit ();
base.quit ();
}
+
+ /*\
+ * * about dialog infos
+ \*/
+
+ internal void get_about_dialog_infos (out string [] artists,
+ out string [] authors,
+ out string comments,
+ out string copyright,
+ out string [] documenters,
+ out string logo_icon_name,
+ out string program_name,
+ out string translator_credits,
+ out string version,
+ out string website,
+ out string website_label)
+ {
+ /* Translators: about dialog text */
+ comments = _("A graphical viewer and editor of applications’ internal settings.");
+
+ artists = {};
+ authors = { "Robert Ancell", "Arnaud Bonatti" };
+
+ /* Translators: about dialog text */
+ copyright = _("Copyright \xc2\xa9 2010-2014 – Canonical Ltd\nCopyright \xc2\xa9 2017-2018 – Davi da
Silva Böger\nCopyright \xc2\xa9 2015-2019 – Arnaud Bonatti");
+
+ documenters = {};
+ logo_icon_name = "ca.desrt.dconf-editor";
+ program_name = ConfigurationEditor.PROGRAM_NAME;
+
+ /* Translators: about dialog text; this string should be replaced by a text crediting yourselves and
your translation team, or should be left empty. Do not translate literally! */
+ translator_credits = _("translator-credits");
+
+ version = Config.VERSION;
+ website = "https://wiki.gnome.org/Apps/DconfEditor";
+
+ /* Translators: about dialog text; label of the website link */
+ website_label = _("Page on GNOME wiki");
+ }
}
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 027e4f7..63e8596 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -796,27 +796,3 @@ private class DConfWindow : BookmarksWindow, AdaptativeWidget
show_notification (_("There’s nothing in requested folder “%s”.").printf (full_name));
}
}
-
-namespace AboutDialogInfos
-{
- // strings
- internal const string program_name = ConfigurationEditor.PROGRAM_NAME;
- internal const string version = Config.VERSION;
-
- /* Translators: about dialog text */
- internal const string comments = _("A graphical viewer and editor of applications’ internal settings.");
-
- /* Translators: about dialog text */
- internal const string copyright = _("Copyright \xc2\xa9 2010-2014 – Canonical Ltd\nCopyright \xc2\xa9
2017-2018 – Davi da Silva Böger\nCopyright \xc2\xa9 2015-2019 – Arnaud Bonatti");
-
- /* Translators: about dialog text; this string should be replaced by a text crediting yourselves and
your translation team, or should be left empty. Do not translate literally! */
- internal const string translator_credits = _("translator-credits");
-
- // various
- internal const string logo_icon_name = "ca.desrt.dconf-editor";
- internal const string website = "https://wiki.gnome.org/Apps/DconfEditor";
- /* Translators: about dialog text; label of the website link */
- internal const string website_label = _("Page on GNOME wiki");
- internal const string [] authors = { "Robert Ancell", "Arnaud Bonatti" };
- internal const License license_type = License.GPL_3_0; /* means "version 3.0 or later" */
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]