[epiphany] Get web app window title from desktop file, not web view
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Get web app window title from desktop file, not web view
- Date: Sat, 17 Sep 2016 20:02:51 +0000 (UTC)
commit b5b77d4be3ece8305171e606fd26a084dd23bd89
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Sep 17 13:35:38 2016 -0500
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.
lib/ephy-web-app-utils.c | 39 +++++++++++++++++++++++++++------------
src/ephy-title-box.c | 38 +-------------------------------------
src/ephy-title-box.h | 3 ---
src/ephy-window.c | 3 ---
4 files changed, 28 insertions(+), 55 deletions(-)
---
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index fd7b71b..1057f95 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)) {
diff --git a/src/ephy-title-box.c b/src/ephy-title-box.c
index a0de247..fff17aa 100644
--- a/src/ephy-title-box.c
+++ b/src/ephy-title-box.c
@@ -88,6 +88,7 @@ ephy_title_box_constructed (GObject *object)
gtk_label_set_line_wrap (GTK_LABEL (title_box->title), FALSE);
gtk_label_set_single_line_mode (GTK_LABEL (title_box->title), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (title_box->title), PANGO_ELLIPSIZE_END);
+ gtk_label_set_text (GTK_LABEL (title_box->title), g_get_application_name ());
gtk_box_pack_start (GTK_BOX (vbox), title_box->title, FALSE, FALSE, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
@@ -114,18 +115,6 @@ ephy_title_box_constructed (GObject *object)
}
static void
-ephy_title_box_dispose (GObject *object)
-{
- EphyTitleBox *title_box = EPHY_TITLE_BOX (object);
-
- LOG ("EphyTitleBox dispose %p", title_box);
-
- ephy_title_box_set_web_view (title_box, NULL);
-
- G_OBJECT_CLASS (ephy_title_box_parent_class)->dispose (object);
-}
-
-static void
ephy_title_box_get_preferred_width (GtkWidget *widget,
gint *minimum_width,
gint *natural_width)
@@ -143,7 +132,6 @@ ephy_title_box_class_init (EphyTitleBoxClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->dispose = ephy_title_box_dispose;
object_class->constructed = ephy_title_box_constructed;
widget_class->button_press_event = ephy_title_box_button_press_event;
widget_class->get_preferred_width = ephy_title_box_get_preferred_width;
@@ -187,30 +175,6 @@ ephy_title_box_new (void)
}
/**
- * ephy_title_box_set_web_view:
- * @title_box: an #EphyTitleBox
- * @web_view: a #WebKitWebView
- *
- * Sets the web view of the @title_box.
- **/
-void
-ephy_title_box_set_web_view (EphyTitleBox *title_box,
- WebKitWebView *web_view)
-{
- g_return_if_fail (EPHY_IS_TITLE_BOX (title_box));
-
- LOG ("ephy_title_box_set_web_view title-box %p web_view %p", title_box, web_view);
-
- g_clear_object (&title_box->title_binding);
-
- if (web_view) {
- title_box->title_binding = g_object_bind_property (web_view, "title",
- title_box->title, "label",
- G_BINDING_SYNC_CREATE);
- }
-}
-
-/**
* ephy_title_box_set_security_level:
* @title_box: an #EphyTitleBox
* @mode: an #EphySecurityLevel
diff --git a/src/ephy-title-box.h b/src/ephy-title-box.h
index 211af6a..6163d95 100644
--- a/src/ephy-title-box.h
+++ b/src/ephy-title-box.h
@@ -31,9 +31,6 @@ G_DECLARE_FINAL_TYPE (EphyTitleBox, ephy_title_box, EPHY, TITLE_BOX, GtkEventBox
EphyTitleBox *ephy_title_box_new (void);
-void ephy_title_box_set_web_view (EphyTitleBox *title_box,
- WebKitWebView *web_view);
-
void ephy_title_box_set_security_level (EphyTitleBox *title_box,
EphySecurityLevel security_level);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 66b4833..1a372f8 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2557,9 +2557,6 @@ notebook_switch_page_cb (GtkNotebook *notebook,
/* update new tab */
ephy_window_set_active_tab (window, embed);
-
- ephy_title_box_set_web_view (ephy_header_bar_get_title_box (EPHY_HEADER_BAR (window->header_bar)),
- EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
}
static GtkNotebook *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]