[epiphany] Show fallback url when page has no title
- From: Jan-Michael Brummer <jbrummer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Show fallback url when page has no title
- Date: Fri, 12 Apr 2019 21:09:13 +0000 (UTC)
commit 2006f6eb0656d76684677624db25280cd9137262
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Mon Apr 8 21:20:17 2019 +0200
Show fallback url when page has no title
Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/717
embed/ephy-web-view.c | 18 ++++++++++++++++++
src/ephy-notebook.c | 5 +++--
src/ephy-tab-label.c | 47 +++++++++++++++++++++++++++++++++++------------
src/ephy-tab-label.h | 10 +++++-----
4 files changed, 61 insertions(+), 19 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 79b668093..55675a2ef 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -157,6 +157,7 @@ enum {
PROP_TYPED_ADDRESS,
PROP_IS_BLANK,
PROP_READER_MODE,
+ PROP_DISPLAY_ADDRESS,
LAST_PROP
};
@@ -484,6 +485,9 @@ ephy_web_view_get_property (GObject *object,
case PROP_READER_MODE:
g_value_set_boolean (value, view->reader_content != NULL);
break;
+ case PROP_DISPLAY_ADDRESS:
+ g_value_set_string (value, view->display_address);
+ break;
default:
break;
}
@@ -513,6 +517,7 @@ ephy_web_view_set_property (GObject *object,
case PROP_STATUS_MESSAGE:
case PROP_IS_BLANK:
case PROP_READER_MODE:
+ case PROP_DISPLAY_ADDRESS:
/* read only */
break;
default:
@@ -1120,6 +1125,7 @@ ephy_web_view_set_address (EphyWebView *view,
ephy_web_view_set_typed_address (view, NULL);
g_object_notify_by_pspec (object, obj_properties[PROP_ADDRESS]);
+ g_object_notify_by_pspec (object, obj_properties[PROP_DISPLAY_ADDRESS]);
}
static void
@@ -1347,6 +1353,18 @@ ephy_web_view_class_init (EphyWebViewClass *klass)
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+/**
+ * EphyWebView:display-address:
+ *
+ * View's current display address.
+ **/
+ obj_properties[PROP_DISPLAY_ADDRESS] =
+ g_param_spec_string ("display-address",
+ "Display address",
+ "The view's display address",
+ "",
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (gobject_class, LAST_PROP, obj_properties);
/**
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index c612f7eb4..15c80f3d1 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -707,6 +707,7 @@ build_tab_label (EphyNotebook *nb, EphyEmbed *embed)
G_CALLBACK (rebuild_tab_menu_cb), nb, 0);
g_object_bind_property (view, "title", tab_label, "label-text", G_BINDING_DEFAULT);
+ g_object_bind_property (view, "display-address", tab_label, "label-uri", G_BINDING_DEFAULT);
g_object_bind_property (view, "icon", tab_label, "icon-buf", G_BINDING_DEFAULT);
g_object_bind_property (view, "is-loading", tab_label, "spinning", G_BINDING_DEFAULT);
g_object_bind_property (view, "is-playing-audio", tab_label, "audio", G_BINDING_DEFAULT);
@@ -979,7 +980,7 @@ ephy_notebook_tab_set_pinned (EphyNotebook *notebook,
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), embed, !is_pinned);
tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), embed);
- ephy_tab_label_set_pin (tab_label, is_pinned);
+ ephy_tab_label_set_pinned (tab_label, is_pinned);
}
gboolean
@@ -988,5 +989,5 @@ ephy_notebook_tab_is_pinned (EphyNotebook *notebook,
{
GtkWidget *tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), GTK_WIDGET (embed));
- return ephy_tab_label_get_pin (tab_label);
+ return ephy_tab_label_is_pinned (tab_label);
}
diff --git a/src/ephy-tab-label.c b/src/ephy-tab-label.c
index 1bca0ed11..7527287f9 100644
--- a/src/ephy-tab-label.c
+++ b/src/ephy-tab-label.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "ephy-embed.h"
+#include "ephy-embed-utils.h"
#include "ephy-settings.h"
#include "ephy-tab-label.h"
@@ -35,7 +36,8 @@ struct _EphyTabLabel {
GtkWidget *close_button;
GtkWidget *audio_button;
- gboolean pinned;
+ gboolean is_pinned;
+ gboolean is_loading;
};
enum {
@@ -46,6 +48,7 @@ enum {
enum {
PROP_0,
PROP_LABEL_TEXT,
+ PROP_LABEL_URI,
PROP_ICON_BUF,
PROP_SPINNING,
PROP_AUDIO,
@@ -64,6 +67,8 @@ ephy_tab_label_set_spinning (EphyTabLabel *tab_label,
g_object_set (tab_label->spinner, "active", is_spinning, NULL);
g_object_set (tab_label->icon, "visible", !is_spinning, NULL);
g_object_set (tab_label->spinner, "visible", is_spinning, NULL);
+
+ tab_label->is_loading = is_spinning;
}
static void
@@ -73,11 +78,22 @@ ephy_tab_label_set_property (GObject *object,
GParamSpec *pspec)
{
EphyTabLabel *self = EPHY_TAB_LABEL (object);
+ const gchar *str;
switch (prop_id) {
case PROP_LABEL_TEXT:
- gtk_label_set_text (GTK_LABEL (self->label), g_value_get_string((value)));
- gtk_widget_set_tooltip_text (GTK_WIDGET (self), g_value_get_string((value)));
+ str = g_value_get_string (value);
+ if (str && strlen (str) != 0) {
+ gtk_label_set_text (GTK_LABEL (self->label), str);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), str);
+ }
+ break;
+ case PROP_LABEL_URI:
+ str = g_value_get_string (value);
+ if (self->is_loading && !ephy_embed_utils_is_no_show_address (str)) {
+ gtk_label_set_text (GTK_LABEL (self->label), str);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), str);
+ }
break;
case PROP_ICON_BUF:
gtk_image_set_from_pixbuf (GTK_IMAGE (self->icon), g_value_get_object(value));
@@ -148,7 +164,7 @@ style_updated_cb (GtkWidget *widget,
gboolean expanded;
int char_width, h, w;
- if (self->pinned) {
+ if (self->is_pinned) {
gtk_widget_set_hexpand (self->icon, FALSE);
gtk_widget_set_halign (self->icon, GTK_ALIGN_FILL);
gtk_widget_set_size_request (widget, -1, -1);
@@ -190,6 +206,13 @@ ephy_tab_label_class_init (EphyTabLabelClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT);
+ obj_properties[PROP_LABEL_URI] = g_param_spec_string ("label-uri",
+ "Label URI",
+ "The displayed uri",
+ "",
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT);
+
obj_properties[PROP_ICON_BUF] = g_param_spec_object ("icon-buf",
"Icon Buffer",
"Buffer of the icon to be displayed",
@@ -249,26 +272,26 @@ ephy_tab_label_get_text (GtkWidget *widget)
static void
update_label (EphyTabLabel *self)
{
- gtk_widget_set_visible (self->close_button, !self->pinned);
- gtk_widget_set_visible (self->label, !self->pinned);
- gtk_widget_set_halign (GTK_WIDGET (self), self->pinned ? GTK_ALIGN_CENTER : GTK_ALIGN_FILL);
+ gtk_widget_set_visible (self->close_button, !self->is_pinned);
+ gtk_widget_set_visible (self->label, !self->is_pinned);
+ gtk_widget_set_halign (GTK_WIDGET (self), self->is_pinned ? GTK_ALIGN_CENTER : GTK_ALIGN_FILL);
g_signal_emit_by_name (self, "style-updated", G_TYPE_NONE);
}
void
-ephy_tab_label_set_pin (GtkWidget *widget,
- gboolean pinned)
+ephy_tab_label_set_pinned (GtkWidget *widget,
+ gboolean is_pinned)
{
EphyTabLabel *self = EPHY_TAB_LABEL (widget);
- self->pinned = pinned;
+ self->is_pinned = is_pinned;
update_label (self);
}
gboolean
-ephy_tab_label_get_pin (GtkWidget *widget)
+ephy_tab_label_is_pinned (GtkWidget *widget)
{
EphyTabLabel *self = EPHY_TAB_LABEL (widget);
- return self->pinned;
+ return self->is_pinned;
}
diff --git a/src/ephy-tab-label.h b/src/ephy-tab-label.h
index 8e299050a..4df1ef65f 100644
--- a/src/ephy-tab-label.h
+++ b/src/ephy-tab-label.h
@@ -30,10 +30,10 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EphyTabLabel, ephy_tab_label, EPHY, TAB_LABEL, GtkBox);
-GtkWidget *ephy_tab_label_new (void);
-const gchar *ephy_tab_label_get_text (GtkWidget *self);
-void ephy_tab_label_set_pin (GtkWidget *self,
- gboolean pin);
-gboolean ephy_tab_label_get_pin (GtkWidget *self);
+GtkWidget *ephy_tab_label_new (void);
+const gchar *ephy_tab_label_get_text (GtkWidget *self);
+void ephy_tab_label_set_pinned (GtkWidget *self,
+ gboolean is_pinned);
+gboolean ephy_tab_label_is_pinned (GtkWidget *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]