diff --git a/docs/api/app.md b/docs/api/app.md index 2094c1e117..6492a48532 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1178,8 +1178,9 @@ Show the app's about panel options. These options can be overridden with `app.se * `applicationName` String (optional) - The app's name. * `applicationVersion` String (optional) - The app's version. * `copyright` String (optional) - Copyright information. - * `version` String (optional) - The app's build version number. _macOS_ + * `version` String (optional) - The app's build version number. * `credits` String (optional) - Credit information. _macOS_ + * `authors` String[] (optional) - List of app authors. _Linux_ * `website` String (optional) - The app's website. _Linux_ * `iconPath` String (optional) - Path to the app's icon. _Linux_ diff --git a/shell/browser/browser.h b/shell/browser/browser.h index 4c5e216b48..e2379aedf5 100644 --- a/shell/browser/browser.h +++ b/shell/browser/browser.h @@ -159,9 +159,9 @@ class Browser : public WindowListObserver { const base::DictionaryValue& user_info); // Bounce the dock icon. - enum class BounceType { - CRITICAL = 0, // NSCriticalRequest - INFORMATIONAL = 10, // NSInformationalRequest + enum class BounceType{ + CRITICAL = 0, // NSCriticalRequest + INFORMATIONAL = 10, // NSInformationalRequest }; int DockBounce(BounceType type); void DockCancelBounce(int request_id); @@ -305,7 +305,9 @@ class Browser : public WindowListObserver { std::unique_ptr ready_promise_; -#if defined(OS_LINUX) || defined(OS_MACOSX) +#if defined(OS_LINUX) + base::Value about_panel_options_; +#elif defined(OS_MACOSX) base::DictionaryValue about_panel_options_; #endif diff --git a/shell/browser/browser_linux.cc b/shell/browser/browser_linux.cc index b3a6bd07a7..8689beddf6 100644 --- a/shell/browser/browser_linux.cc +++ b/shell/browser/browser_linux.cc @@ -147,21 +147,27 @@ bool Browser::IsEmojiPanelSupported() { } void Browser::ShowAboutPanel() { - std::string app_name, version, copyright, icon_path, website; - GtkAboutDialog* dialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); - if (about_panel_options_.GetString("applicationName", &app_name)) - gtk_about_dialog_set_program_name(dialog, app_name.c_str()); - if (about_panel_options_.GetString("applicationVersion", &version)) - gtk_about_dialog_set_version(dialog, version.c_str()); - if (about_panel_options_.GetString("copyright", ©right)) - gtk_about_dialog_set_copyright(dialog, copyright.c_str()); - if (about_panel_options_.GetString("website", &website)) - gtk_about_dialog_set_website(dialog, website.c_str()); - if (about_panel_options_.GetString("iconPath", &icon_path)) { + const auto& opts = about_panel_options_; + const std::string* str; + const base::Value* val; + + if ((str = opts.FindStringKey("applicationName"))) { + gtk_about_dialog_set_program_name(dialog, str->c_str()); + } + if ((str = opts.FindStringKey("applicationVersion"))) { + gtk_about_dialog_set_version(dialog, str->c_str()); + } + if ((str = opts.FindStringKey("copyright"))) { + gtk_about_dialog_set_copyright(dialog, str->c_str()); + } + if ((str = opts.FindStringKey("website"))) { + gtk_about_dialog_set_website(dialog, str->c_str()); + } + if ((str = opts.FindStringKey("iconPath"))) { GError* error = nullptr; - GdkPixbuf* icon = gdk_pixbuf_new_from_file(icon_path.c_str(), &error); + GdkPixbuf* icon = gdk_pixbuf_new_from_file(str->c_str(), &error); if (error != nullptr) { g_warning("%s", error->message); g_clear_error(&error); @@ -171,19 +177,27 @@ void Browser::ShowAboutPanel() { } } + if ((val = opts.FindListKey("authors"))) { + std::vector cstrs; + for (const auto& authorVal : val->GetList()) { + if (authorVal.is_string()) { + cstrs.push_back(authorVal.GetString().c_str()); + } + } + if (cstrs.empty()) { + LOG(WARNING) << "No author strings found in 'authors' array"; + } else { + cstrs.push_back(nullptr); // null-terminated char* array + gtk_about_dialog_set_authors(dialog, cstrs.data()); + } + } + gtk_dialog_run(GTK_DIALOG(dialog)); g_clear_object(&dialog); } void Browser::SetAboutPanelOptions(const base::DictionaryValue& options) { - about_panel_options_.Clear(); - - for (const auto& pair : options) { - const std::string& key = pair.first; - const auto& val = pair.second; - if (!key.empty() && val->is_string()) - about_panel_options_.SetString(key, val->GetString()); - } + about_panel_options_ = options.Clone(); } } // namespace electron