[epiphany] Let the location controller control the title box address
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Let the location controller control the title box address
- Date: Sun, 31 Aug 2014 14:05:56 +0000 (UTC)
commit db37eb4975a4eea351f242f859711b8a2863475e
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Thu Aug 28 08:38:45 2014 -0500
Let the location controller control the title box address
By binding the title box's address directly to the URI property of the
web view, we bypass all our custom logic for displaying the URI,
sometimes leading to desyncs between the URI shown by the location entry
and the URI shown by the title box.
Also, with this change the title of the page now changes at the same
time the displayed address does, whereas previously we would change the
address on the start of load and the title on completion, which looked
odd.
https://bugzilla.gnome.org/show_bug.cgi?id=732713
src/ephy-location-controller.c | 23 +++++++++++++-
src/ephy-title-box.c | 65 +++++++++++++++++++--------------------
src/ephy-title-box.h | 3 ++
src/ephy-window.c | 1 +
4 files changed, 58 insertions(+), 34 deletions(-)
---
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index a7ed552..38773d8 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -31,6 +31,7 @@
#include "ephy-dnd.h"
#include "ephy-location-entry.h"
#include "ephy-shell.h"
+#include "ephy-title-box.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
@@ -49,6 +50,7 @@ struct _EphyLocationControllerPrivate
{
EphyWindow *window;
EphyLocationEntry *location_entry;
+ EphyTitleBox *title_box;
GList *actions;
char *address;
EphyNode *smart_bmks;
@@ -76,7 +78,8 @@ enum
PROP_ICON,
PROP_SHOW_ICON,
PROP_WINDOW,
- PROP_LOCATION_ENTRY
+ PROP_LOCATION_ENTRY,
+ PROP_TITLE_BOX
};
enum
@@ -289,6 +292,7 @@ sync_address (EphyLocationController *controller,
g_signal_handlers_block_by_func (widget, G_CALLBACK (user_changed_cb), controller);
ephy_location_entry_set_location (lentry, priv->address);
+ ephy_title_box_set_address (priv->title_box, priv->address);
g_signal_handlers_unblock_by_func (widget, G_CALLBACK (user_changed_cb), controller);
}
@@ -514,6 +518,9 @@ ephy_location_controller_set_property (GObject *object,
case PROP_LOCATION_ENTRY:
priv->location_entry = EPHY_LOCATION_ENTRY (g_value_get_object (value));
break;
+ case PROP_TITLE_BOX:
+ priv->title_box = EPHY_TITLE_BOX (g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -680,6 +687,20 @@ ephy_location_controller_class_init (EphyLocationControllerClass *class)
G_PARAM_WRITABLE | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
G_PARAM_CONSTRUCT_ONLY));
+ /**
+ * EphyLocationController:title-box:
+ *
+ * The #EphyLocationController sets the address of this title box.
+ */
+ g_object_class_install_property (object_class,
+ PROP_TITLE_BOX,
+ g_param_spec_object ("title-box",
+ "Title box",
+ "The title box whose address will be managed",
+ G_TYPE_OBJECT,
+ G_PARAM_WRITABLE | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_type_class_add_private (object_class, sizeof (EphyLocationControllerPrivate));
}
diff --git a/src/ephy-title-box.c b/src/ephy-title-box.c
index 3fddcc4..3c4366b 100644
--- a/src/ephy-title-box.c
+++ b/src/ephy-title-box.c
@@ -65,7 +65,6 @@ typedef struct
GtkWidget *uri;
GBinding *title_binding;
- GBinding *uri_binding;
guint location_disabled;
guint button_down : 1;
@@ -477,31 +476,6 @@ ephy_title_box_title_changed_cb (GObject *gobject,
ephy_title_box_set_mode (title_box, EPHY_TITLE_BOX_MODE_TITLE);
}
-static gboolean
-ephy_title_box_transform_uri_to_label (GBinding *binding,
- const GValue *from_value,
- GValue *to_value,
- gpointer user_data)
-{
- const gchar *label;
- gchar *uri;
- EphyEmbedShellMode mode;
-
- label = g_value_get_string (from_value);
- mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
-
- if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION) {
- uri = g_strdup (label);
- } else {
- gboolean rtl;
- rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;
- uri = g_strconcat (rtl ? "▾ " : label, rtl ? label : " ▾", NULL);
- }
- g_value_take_string (to_value, uri);
-
- return TRUE;
-}
-
/**
* ephy_title_box_new:
* @window: an #EphyWindow
@@ -558,7 +532,6 @@ ephy_title_box_set_web_view (EphyTitleBox *title_box,
g_signal_handler_disconnect (priv->web_view, priv->title_sig_id);
g_clear_object (&priv->title_binding);
- g_clear_object (&priv->uri_binding);
g_object_remove_weak_pointer (G_OBJECT (priv->web_view), (gpointer *)&priv->web_view);
}
@@ -579,12 +552,6 @@ ephy_title_box_set_web_view (EphyTitleBox *title_box,
priv->title, "label",
G_BINDING_SYNC_CREATE);
- priv->uri_binding = g_object_bind_property_full (priv->web_view, "uri",
- priv->uri, "label",
- G_BINDING_SYNC_CREATE,
- ephy_title_box_transform_uri_to_label,
- NULL, NULL, NULL);
-
priv->title_sig_id = g_signal_connect (priv->web_view, "notify::title",
G_CALLBACK (ephy_title_box_title_changed_cb),
title_box);
@@ -701,3 +668,35 @@ ephy_title_box_get_location_entry (EphyTitleBox *title_box)
return priv->entry;
}
+
+/**
+ * ephy_title_box_set_address:
+ * @title_box: an #EphyTitleBox
+ * @address: (nullable): the URI to display as the subtitle of this #EphyTitleBox
+ *
+ * Sets the address of @title_box to @address
+ */
+void
+ephy_title_box_set_address (EphyTitleBox *title_box,
+ const char *address)
+{
+ EphyTitleBoxPrivate *priv;
+ EphyEmbedShellMode mode;
+
+ g_return_if_fail (EPHY_IS_TITLE_BOX (title_box));
+
+ priv = ephy_title_box_get_instance_private (title_box);
+ mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
+
+ if (address == NULL || mode == EPHY_EMBED_SHELL_MODE_APPLICATION) {
+ gtk_label_set_text (GTK_LABEL (priv->uri), address);
+ } else {
+ gboolean rtl;
+ char *uri;
+
+ rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;
+ uri = g_strconcat (rtl ? "▾ " : address, rtl ? address : " ▾", NULL);
+ gtk_label_set_text (GTK_LABEL (priv->uri), uri);
+ g_free (uri);
+ }
+}
diff --git a/src/ephy-title-box.h b/src/ephy-title-box.h
index ba2038a..b813047 100644
--- a/src/ephy-title-box.h
+++ b/src/ephy-title-box.h
@@ -73,6 +73,9 @@ void ephy_title_box_set_security_level (EphyTitleBox *t
GtkWidget *ephy_title_box_get_location_entry (EphyTitleBox *title_box);
+void ephy_title_box_set_address (EphyTitleBox *title_box,
+ const char *address);
+
G_END_DECLS
#endif /* __EPHY_TITLE_BOX_H__ */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index df1b129..618350b 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3266,6 +3266,7 @@ setup_location_controller (EphyWindow *window,
g_object_new (EPHY_TYPE_LOCATION_CONTROLLER,
"window", window,
"location-entry", ephy_toolbar_get_location_entry (toolbar),
+ "title-box", ephy_toolbar_get_title_box (toolbar),
NULL);
g_signal_connect (location_controller, "notify::address",
G_CALLBACK (sync_user_input_cb), window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]