diff options
author | Michael Catanzaro <mcatanzaro@gnome.org> | 2016-09-17 13:35:38 -0500 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@gnome.org> | 2016-09-17 13:35:38 -0500 |
commit | b5b77d4be3ece8305171e606fd26a084dd23bd89 (patch) | |
tree | efdba350f7dc34747923f0ee8f99ef11aa27d573 /lib/ephy-web-app-utils.c | |
parent | 543745bbb9c4f645c7a9c6756d326d601cc4d3a3 (diff) | |
download | epiphany-b5b77d4be3ece8305171e606fd26a084dd23bd89.tar.gz |
Get web app window title from desktop file, not web view
Since I gutted EphyTitleBox, we no longer switch to location entry view
when no title is available for the web view. This looks bad, since the
URL gets displayed under an empty title when the page is loading. To fix
this, stop updating the title dynamically, just get it from the web
app's desktop file.
Note this breaks web apps created by Software, since there will be no
way for Epiphany to find the desktop file. Software will need to be
updated. All web apps that have ever been created by Epiphany will still
work fine, since Epiphany always creates a desktop file in the profile
directory when creating a web app; Software hasn't been doing this, but
we clearly can't support that anymore, as we need to get the app's name
somehow.
Diffstat (limited to 'lib/ephy-web-app-utils.c')
-rw-r--r-- | lib/ephy-web-app-utils.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c index fd7b71b2f..1057f956a 100644 --- a/lib/ephy-web-app-utils.c +++ b/lib/ephy-web-app-utils.c @@ -26,6 +26,7 @@ #include <gio/gio.h> #include <glib/gstdio.h> #include <libsoup/soup.h> +#include <stdlib.h> #include <string.h> #include <webkit2/webkit2.h> @@ -406,47 +407,61 @@ ephy_web_application_ensure_for_app_info (GAppInfo *app_info) void ephy_web_application_setup_from_profile_directory (const char *profile_directory) { - char *app_name; + const char *app_name; char *app_icon; + char *desktop_basename; + char *desktop_filename; + GDesktopAppInfo *desktop_info; g_return_if_fail (profile_directory != NULL); app_name = g_strrstr (profile_directory, EPHY_WEB_APP_PREFIX); - if (!app_name) - return; + if (!app_name) { + g_warning ("Profile directory %s does not begin with required web app prefix %s", profile_directory, EPHY_WEB_APP_PREFIX); + exit (1); + } /* Skip the 'app-' part */ app_name += strlen (EPHY_WEB_APP_PREFIX); g_set_prgname (app_name); - g_set_application_name (app_name); + + /* Get display name from desktop file */ + desktop_basename = g_strconcat (app_name, ".desktop", NULL); + desktop_filename = g_build_filename (profile_directory, desktop_basename, NULL); + desktop_info = g_desktop_app_info_new_from_filename (desktop_filename); + if (!desktop_info) { + g_warning ("Required desktop file not present at %s", desktop_filename); + exit (1); + } + g_set_application_name (g_app_info_get_name (G_APP_INFO (desktop_info))); + app_icon = g_build_filename (profile_directory, EPHY_WEB_APP_ICON_NAME, NULL); gtk_window_set_default_icon_from_file (app_icon, NULL); - g_free (app_icon); /* We need to re-set this because we have already parsed the * options, which inits GTK+ and sets this as a side effect. */ gdk_set_program_class (app_name); + + g_free (app_icon); + g_free (desktop_basename); + g_free (desktop_filename); + g_object_unref (desktop_info); } void ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info) { GAppInfo *app_info; - const char *app_name; const char *wm_class; GIcon *icon; g_return_if_fail (G_IS_DESKTOP_APP_INFO (desktop_info)); app_info = G_APP_INFO (desktop_info); - app_name = g_app_info_get_name (app_info); - if (!app_name) - return; - - g_set_prgname (app_name); - g_set_application_name (app_name); + g_set_prgname (g_app_info_get_name (app_info)); + g_set_application_name (g_app_info_get_display_name (app_info)); icon = g_app_info_get_icon (app_info); if (G_IS_FILE_ICON (icon)) { |