[epiphany/gnome-3-34] web-app-utils: fix changing webapp icon
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-34] web-app-utils: fix changing webapp icon
- Date: Thu, 9 Jan 2020 15:59:16 +0000 (UTC)
commit 2025461fdddb144e93185eca74fbfc624238eb34
Author: ignapk <automat script gmail com>
Date: Wed Jan 8 15:47:53 2020 +0000
web-app-utils: fix changing webapp icon
Currently preferences dialog in webapps changes icons by modifying the
Icon= line in the desktop file instead of updating the saved icon.
This causes the new icon to disappear once the source image file is
deleted/renamed and system is restarted.
To fix this situation, overwrite the app-icon.png in the profile
directory with the selected file and don't change the icon path in the
desktop file.
Closes https://gitlab.gnome.org/GNOME/epiphany/issues/810
(cherry picked from commit b6f7b0ece4a45b373cbada53499f002e8e86ed77)
lib/ephy-web-app-utils.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 08017cfb0..cc00a2ba1 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -818,6 +818,18 @@ ephy_web_application_is_uri_allowed (const char *uri)
return matched;
}
+static void
+ephy_web_icon_copy_cb (GFile *file,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ if (!g_file_copy_finish (file, result, &error)) {
+ g_warning ("Failed to update web app icon: %s", error->message);
+ g_error_free (error);
+ }
+}
+
gboolean
ephy_web_application_save (EphyWebApplication *app)
{
@@ -850,8 +862,14 @@ ephy_web_application_save (EphyWebApplication *app)
icon = g_key_file_get_string (key, "Desktop Entry", "Icon", NULL);
if (g_strcmp0 (icon, app->icon_url) != 0) {
+ GFile *new_icon;
+ GFile *old_icon;
changed = TRUE;
- g_key_file_set_string (key, "Desktop Entry", "Icon", app->icon_url);
+ new_icon = g_file_new_for_path (app->icon_url);
+ old_icon = g_file_new_for_path (icon);
+ g_file_copy_async (new_icon, old_icon, G_FILE_COPY_OVERWRITE,
+ G_PRIORITY_DEFAULT, NULL, NULL, NULL,
+ (GAsyncReadyCallback)ephy_web_icon_copy_cb, NULL);
}
g_free (icon);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]