feat: add about panel customization on linux (#15658)

This commit is contained in:
Shelley Vohr 2018-11-13 17:12:24 -05:00 committed by GitHub
parent bc9a7806a5
commit 787dbbe610
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 20 deletions

View file

@ -142,4 +142,44 @@ bool Browser::IsUnityRunning() {
return unity::IsRunning();
}
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", &copyright))
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)) {
GError* error = nullptr;
GdkPixbuf* icon = gdk_pixbuf_new_from_file(icon_path.c_str(), &error);
if (error != nullptr) {
g_warning("%s", error->message);
g_clear_error(&error);
} else {
gtk_about_dialog_set_logo(dialog, icon);
g_clear_object(&icon);
}
}
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());
}
}
} // namespace atom