/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * Copyright © 2012 Igalia S.L. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "config.h" #include "ephy-about-handler.h" #include "ephy-embed-shell.h" #include "ephy-file-helpers.h" #include "ephy-smaps.h" #include "ephy-web-app-utils.h" #include #include #include static gchar *css_style = NULL; static void read_css_style (void) { GError *error = NULL; const gchar *file; if (css_style) return; file = ephy_file ("about.css"); if (file && !g_file_get_contents (file, &css_style, NULL, &error)) { g_debug ("%s", error->message); g_error_free (error); } } void _ephy_about_handler_handle_plugins (GString *data_str, GList *plugin_list) { GList *p; read_css_style (); g_string_append_printf (data_str, "%s" \ "", _("Installed plugins"), css_style); g_string_append_printf (data_str, "

%s

", _("Installed plugins")); for (p = plugin_list; p; p = p->next) { WebKitPlugin *plugin = WEBKIT_PLUGIN (p->data); GList *m, *mime_types; /* TODO: Enable/disable plugins in WebKit2 */ g_string_append_printf (data_str, "

%s

%s
%s: %s" \ "" \ " ", webkit_plugin_get_name (plugin), webkit_plugin_get_description (plugin), _("Enabled"), /*webkit_plugin_get_enabled (plugin)*/ TRUE ? _("Yes") : _("No"), _("MIME type"), _("Description"), _("Suffixes")); mime_types = webkit_plugin_get_mime_info_list (plugin); for (m = mime_types; m; m = m->next) { WebKitMimeInfo *mime_info = (WebKitMimeInfo *) m->data; const gchar * const *extensions; guint i; g_string_append_printf (data_str, ""); } g_string_append (data_str, "
%s%s%s
%s%s", webkit_mime_info_get_mime_type (mime_info), webkit_mime_info_get_description (mime_info)); extensions = webkit_mime_info_get_extensions (mime_info); for (i = 0; extensions && extensions[i] != NULL; i++) g_string_append_printf (data_str, "%s%c", extensions[i], extensions[i + 1] ? ',' : ' '); g_string_append (data_str, "
"); } g_string_append (data_str, ""); } static void ephy_about_handler_handle_plugins (GString *data_str) { g_string_append (data_str, ""); } static void ephy_about_handler_handle_memory (GString *data_str) { char *memory; static EphySMaps *smaps = NULL; if (!smaps) smaps = ephy_smaps_new (); memory = ephy_smaps_to_html (smaps); if (memory) { g_string_append_printf (data_str, "%s" \ "", _("Memory usage"), css_style); g_string_append_printf (data_str, "

%s

", _("Memory usage")); g_string_append (data_str, memory); g_free (memory); } } static void ephy_about_handler_handle_epiphany (GString *data_str) { g_string_append_printf (data_str, "Epiphany" \ "" \ "", css_style); g_string_append (data_str, "
" \ "Il semble que la perfection soit atteinte non quand il n'y a plus rien à" \ " ajouter, mais quand il n'y a plus rien à retrancher." \ "
" \ "
" \ "" \ "Antoine de Saint-Exupéry" \ "
"); } static void ephy_about_handler_handle_applications (GString *data_str) { GList *applications, *p; g_string_append_printf (data_str, "%s" \ "" \ "

%s

" \ "

%s

", _("Applications"), css_style, _("Applications"), _("List of installed web applications")); g_string_append (data_str, ""); applications = ephy_web_application_get_application_list (); for (p = applications; p; p = p->next) { char *img_data = NULL, *img_data_base64 = NULL; gsize data_length; EphyWebApplication *app = (EphyWebApplication*)p->data; if (g_file_get_contents (app->icon_url, &img_data, &data_length, NULL)) img_data_base64 = g_base64_encode ((guchar*)img_data, data_length); g_string_append_printf (data_str, "" \ "" \ "" \ "" \ "", img_data_base64, app->name, app->url, app->name, app->name, /* Note for translators: this refers to the installation date. */ _("Installed on:"), app->install_date); g_free (img_data_base64); g_free (img_data); } g_string_append (data_str, "
%s
%s
" \ "%s
%s
"); ephy_web_application_free_application_list (applications); } static void ephy_about_handler_handle_incognito (GString *data_str) { const char *filename; char *img_data = NULL, *img_data_base64 = NULL; gsize data_length; filename = ephy_file ("incognito.png"); if (filename) { g_file_get_contents (filename, &img_data, &data_length, NULL); img_data_base64 = g_base64_encode ((guchar*)img_data, data_length); } g_string_append_printf (data_str, \ "\n" \ "%s\n" \ "\n" \ "\n" \ "\n" \ "
\n" \ "
\n" \ "

%s

\n" \ "

%s

\n" \ "
\n" \ "
\n" \ "\n", _("Private Browsing"), css_style, img_data_base64 ? img_data_base64 : "", _("Private Browsing"), _("You are currently browsing incognito. Pages viewed in this " "mode will not show up in your browsing history and all stored " "information will be cleared when you close the window.")); g_free (img_data_base64); g_free (img_data); } GString * ephy_about_handler_handle (const char *about) { GString *data_str = g_string_new(""); read_css_style (); if (!g_strcmp0 (about, "plugins")) ephy_about_handler_handle_plugins (data_str); else if (!g_strcmp0 (about, "memory")) ephy_about_handler_handle_memory (data_str); else if (!g_strcmp0 (about, "epiphany")) ephy_about_handler_handle_epiphany (data_str); else if (!g_strcmp0 (about, "applications")) ephy_about_handler_handle_applications (data_str); else if (!g_strcmp0 (about, "incognito") && ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_INCOGNITO) ephy_about_handler_handle_incognito (data_str); g_string_append (data_str, ""); return data_str; }