[epiphany] Add unified url bar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Add unified url bar
- Date: Tue, 19 Jun 2018 20:57:48 +0000 (UTC)
commit 689d6db29966ed903074d5b926a400008bdd2f01
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Fri Jun 8 18:58:52 2018 +0200
Add unified url bar
Unified URL bar moves reader mode button into the url bar.
Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/39
lib/widgets/ephy-location-entry.c | 259 +++++++++++++++++++---------
lib/widgets/ephy-location-entry.h | 16 +-
src/bookmarks/ephy-add-bookmark-popover.c | 4 +-
src/ephy-header-bar.c | 46 -----
src/ephy-location-controller.c | 47 ++++-
src/ephy-window.c | 27 ++-
src/resources/ephy-reader-mode-symbolic.svg | 35 ++++
src/resources/epiphany.gresource.xml | 1 +
src/resources/themes/shared.css | 5 +-
src/resources/themes/shared.scss | 4 +-
10 files changed, 304 insertions(+), 140 deletions(-)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index e9fee1dcd..6b51590b4 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -54,8 +54,13 @@
*/
struct _EphyLocationEntry {
- GtkEntry parent_instance;
+ GtkOverlay parent_instance;
+ GtkWidget *url_entry;
+ GtkWidget *bookmark;
+ GtkWidget *bookmark_event_box;
+ GtkWidget *reader_mode;
+ GtkWidget *reader_mode_event_box;
GtkTreeModel *model;
GSList *search_terms;
@@ -64,6 +69,8 @@ struct _EphyLocationEntry {
GtkPopover *add_bookmark_popover;
+ gboolean reader_mode_active;
+
char *before_completion;
char *saved_text;
@@ -115,7 +122,7 @@ static gint signals[LAST_SIGNAL] = { 0 };
static void ephy_location_entry_title_widget_interface_init (EphyTitleWidgetInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_ENTRY,
+G_DEFINE_TYPE_WITH_CODE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_OVERLAY,
G_IMPLEMENT_INTERFACE (EPHY_TYPE_TITLE_WIDGET,
ephy_location_entry_title_widget_interface_init))
@@ -124,7 +131,7 @@ update_address_state (EphyLocationEntry *entry)
{
const char *text;
- text = gtk_entry_get_text (GTK_ENTRY (entry));
+ text = gtk_entry_get_text (GTK_ENTRY (entry->url_entry));
entry->original_address = text != NULL &&
g_str_hash (text) == entry->hash;
}
@@ -136,7 +143,7 @@ ephy_location_entry_title_widget_get_address (EphyTitleWidget *widget)
g_assert (entry);
- return gtk_entry_get_text (GTK_ENTRY (widget));
+ return gtk_entry_get_text (GTK_ENTRY (entry->url_entry));
}
static void
@@ -157,14 +164,14 @@ ephy_location_entry_title_widget_set_address (EphyTitleWidget *widget,
* the location entry.
*/
if (gtk_widget_get_realized (GTK_WIDGET (entry))) {
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (entry),
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (entry->url_entry),
GDK_SELECTION_PRIMARY);
g_assert (clipboard != NULL);
- if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry) &&
- gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
+ if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry->url_entry) &&
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (entry->url_entry),
&start, &end)) {
- selection = gtk_editable_get_chars (GTK_EDITABLE (entry),
+ selection = gtk_editable_get_chars (GTK_EDITABLE (entry->url_entry),
start, end);
}
}
@@ -182,7 +189,7 @@ ephy_location_entry_title_widget_set_address (EphyTitleWidget *widget,
entry->hash = g_str_hash (effective_text ? effective_text : text);
entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), effective_text ? effective_text : text);
+ gtk_entry_set_text (GTK_ENTRY (entry->url_entry), effective_text ? effective_text : text);
entry->block_update = FALSE;
g_free (effective_text);
@@ -221,7 +228,7 @@ ephy_location_entry_title_widget_set_security_level (EphyTitleWidget *widget,
g_assert (entry);
icon_name = ephy_security_level_to_icon_name (security_level);
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry->url_entry),
GTK_ENTRY_ICON_PRIMARY,
icon_name);
@@ -273,10 +280,12 @@ ephy_location_entry_get_property (GObject *object,
static void
ephy_location_entry_constructed (GObject *object)
{
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
+
G_OBJECT_CLASS (ephy_location_entry_parent_class)->constructed (object);
#if GTK_CHECK_VERSION(3, 22, 20)
- gtk_entry_set_input_hints (GTK_ENTRY (object), GTK_INPUT_HINT_NO_EMOJI);
+ gtk_entry_set_input_hints (GTK_ENTRY (entry->url_entry), GTK_INPUT_HINT_NO_EMOJI);
#endif
}
@@ -290,28 +299,6 @@ ephy_location_entry_finalize (GObject *object)
G_OBJECT_CLASS (ephy_location_entry_parent_class)->finalize (object);
}
-static void
-ephy_location_entry_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (widget);
-
- if (gtk_widget_is_visible (widget)) {
- GdkRectangle pointing_to;
-
- gtk_entry_get_icon_area (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- &pointing_to);
- /* FIXME: GTK+ sets "margin-left: 6px" for the icon. Add 3px to the
- * rectangle so the popover is centered on the star.
- */
- pointing_to.x = pointing_to.x + 3;
- gtk_popover_set_pointing_to (entry->add_bookmark_popover, &pointing_to);
- }
-
- GTK_WIDGET_CLASS (ephy_location_entry_parent_class)->size_allocate (widget, allocation);
-}
-
static void
ephy_location_entry_get_preferred_width (GtkWidget *widget,
gint *minimum_width,
@@ -325,7 +312,18 @@ ephy_location_entry_get_preferred_width (GtkWidget *widget,
}
static void
-ephy_location_entry_copy_clipboard (GtkEntry *entry)
+ephy_location_entry_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (widget);
+
+ gtk_widget_get_preferred_height (entry->url_entry, minimum_height, natural_height);
+}
+
+static void
+ephy_location_entry_copy_clipboard (GtkEntry *entry,
+ gpointer user_data)
{
char *text;
gint start;
@@ -356,7 +354,7 @@ ephy_location_entry_cut_clipboard (GtkEntry *entry)
return;
}
- ephy_location_entry_copy_clipboard (entry);
+ ephy_location_entry_copy_clipboard (entry, NULL);
gtk_editable_delete_selection (GTK_EDITABLE (entry));
}
@@ -374,18 +372,14 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkEntryClass *entry_class = GTK_ENTRY_CLASS (klass);
object_class->get_property = ephy_location_entry_get_property;
object_class->set_property = ephy_location_entry_set_property;
object_class->constructed = ephy_location_entry_constructed;
object_class->finalize = ephy_location_entry_finalize;
- widget_class->size_allocate = ephy_location_entry_size_allocate;
widget_class->get_preferred_width = ephy_location_entry_get_preferred_width;
-
- entry_class->copy_clipboard = ephy_location_entry_copy_clipboard;
- entry_class->cut_clipboard = ephy_location_entry_cut_clipboard;
+ widget_class->get_preferred_height = ephy_location_entry_get_preferred_height;
g_object_class_override_property (object_class, PROP_ADDRESS, "address");
g_object_class_override_property (object_class, PROP_SECURITY_LEVEL, "security-level");
@@ -562,7 +556,7 @@ match_selected_cb (GtkEntryCompletion *completion,
ephy_title_widget_set_address (EPHY_TITLE_WIDGET (entry), item);
/* gtk_im_context_reset (GTK_ENTRY (entry)->im_context); */
- g_signal_emit_by_name (entry, "activate");
+ g_signal_emit_by_name (entry->url_entry, "activate");
g_free (item);
@@ -589,7 +583,7 @@ entry_clear_activate_cb (GtkMenuItem *item,
EphyLocationEntry *entry)
{
entry->block_update = TRUE;
- gtk_entry_set_text (GTK_ENTRY (entry), "");
+ gtk_entry_set_text (GTK_ENTRY (entry->url_entry), "");
entry->block_update = FALSE;
entry->user_changed = TRUE;
}
@@ -600,8 +594,8 @@ paste_received (GtkClipboard *clipboard,
EphyLocationEntry *entry)
{
if (text) {
- gtk_entry_set_text (GTK_ENTRY (entry), text);
- g_signal_emit_by_name (entry, "activate");
+ gtk_entry_set_text (GTK_ENTRY (entry->url_entry), text);
+ g_signal_emit_by_name (entry->url_entry, "activate");
}
}
@@ -718,17 +712,17 @@ entry_populate_popup_cb (GtkEntry *entry,
}
static gboolean
-icon_button_icon_press_event_cb (GtkWidget *entry,
+icon_button_icon_press_event_cb (GtkWidget *widget,
GtkEntryIconPosition position,
GdkEventButton *event,
- EphyLocationEntry *lentry)
+ EphyLocationEntry *entry)
{
if (((event->type == GDK_BUTTON_PRESS &&
event->button == 1) ||
(event->type == GDK_TOUCH_BEGIN))) {
if (position == GTK_ENTRY_ICON_PRIMARY) {
GdkRectangle lock_position;
- gtk_entry_get_icon_area (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, &lock_position);
+ gtk_entry_get_icon_area (GTK_ENTRY (entry->url_entry), GTK_ENTRY_ICON_PRIMARY, &lock_position);
g_signal_emit_by_name (entry, "lock-clicked", &lock_position);
} else {
g_signal_emit (entry, signals[BOOKMARK_CLICKED], 0);
@@ -739,28 +733,92 @@ icon_button_icon_press_event_cb (GtkWidget *entry,
return FALSE;
}
+static gboolean
+bookmark_icon_button_press_event_cb (GtkWidget *entry,
+ GdkEventButton *event,
+ EphyLocationEntry *lentry)
+{
+ if (((event->type == GDK_BUTTON_PRESS &&
+ event->button == 1) ||
+ (event->type == GDK_TOUCH_BEGIN))) {
+ g_signal_emit (lentry, signals[BOOKMARK_CLICKED], 0);
+ }
+
+ return TRUE;
+}
+
static void
-ephy_location_entry_construct_contents (EphyLocationEntry *lentry)
+button_box_size_allocated_cb (GtkWidget *widget,
+ GdkRectangle *allocation,
+ gint baseline,
+ GdkRectangle *out_clip,
+ gpointer user_data)
{
- GtkWidget *entry = GTK_WIDGET (lentry);
+ GtkCssProvider *css_provider = gtk_css_provider_new();
+ gchar *css;
+
+ css = g_strdup_printf (".url_entry { padding-right: %dpx; }", allocation->width + 5);
+ gtk_css_provider_load_from_data (css_provider, css, -1, NULL);
- LOG ("EphyLocationEntry constructing contents %p", lentry);
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- "non-starred-symbolic");
+ g_object_unref (css_provider);
+ g_free (css);
+}
- g_object_connect (entry,
- "signal::icon-press", G_CALLBACK (icon_button_icon_press_event_cb), lentry,
- "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
- "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
- "signal::changed", G_CALLBACK (editable_changed_cb), lentry,
+static void
+ephy_location_entry_construct_contents (EphyLocationEntry *entry)
+{
+ GtkWidget *button_box;
+
+ LOG ("EphyLocationEntry constructing contents %p", entry);
+
+ /* URL entry */
+ entry->url_entry = gtk_entry_new ();
+ gtk_style_context_add_class (gtk_widget_get_style_context (entry->url_entry), "url_entry");
+ g_signal_connect (G_OBJECT (entry->url_entry), "copy-clipboard", G_CALLBACK
(ephy_location_entry_copy_clipboard), NULL);
+ g_signal_connect (G_OBJECT (entry->url_entry), "cut-clipboard", G_CALLBACK
(ephy_location_entry_cut_clipboard), NULL);
+ gtk_widget_show (entry->url_entry);
+ gtk_overlay_add_overlay (GTK_OVERLAY (entry), entry->url_entry);
+
+ /* Button Box */
+ button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_box_set_homogeneous (GTK_BOX (button_box), FALSE);
+ g_signal_connect (G_OBJECT (button_box), "size-allocate", G_CALLBACK (button_box_size_allocated_cb), NULL);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_EXPAND);
+ gtk_widget_set_halign (button_box, GTK_ALIGN_END);
+ gtk_widget_set_margin_end (button_box, 5);
+ gtk_widget_show (button_box);
+ gtk_overlay_add_overlay (GTK_OVERLAY (entry), button_box);
+
+ /* Bookmark */
+ entry->bookmark_event_box = gtk_event_box_new ();
+ entry->bookmark = gtk_image_new_from_icon_name ("non-starred-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (entry->bookmark);
+ g_signal_connect (G_OBJECT (entry->bookmark_event_box), "button_press_event", G_CALLBACK
(bookmark_icon_button_press_event_cb), entry);
+ gtk_container_add (GTK_CONTAINER(entry->bookmark_event_box), entry->bookmark);
+ gtk_box_pack_end (GTK_BOX (button_box), entry->bookmark_event_box, FALSE, FALSE, 6);
+
+ /* Reader Mode */
+ entry->reader_mode_event_box = gtk_event_box_new ();
+ entry->reader_mode = gtk_image_new_from_icon_name ("ephy-reader-mode-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (entry->reader_mode);
+ gtk_container_add (GTK_CONTAINER(entry->reader_mode_event_box), entry->reader_mode);
+ gtk_box_pack_end (GTK_BOX (button_box), entry->reader_mode_event_box, FALSE, FALSE, 6);
+
+ g_object_connect (entry->url_entry,
+ "signal::icon-press", G_CALLBACK (icon_button_icon_press_event_cb), entry,
+ "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), entry,
+ "signal::key-press-event", G_CALLBACK (entry_key_press_cb), entry,
+ "signal::changed", G_CALLBACK (editable_changed_cb), entry,
NULL);
- g_signal_connect_after (entry, "key-press-event",
- G_CALLBACK (entry_key_press_after_cb), lentry);
- g_signal_connect_after (entry, "activate",
- G_CALLBACK (entry_activate_after_cb), lentry);
+ g_signal_connect_after (entry->url_entry, "key-press-event",
+ G_CALLBACK (entry_key_press_after_cb), entry);
+ g_signal_connect_after (entry->url_entry, "activate",
+ G_CALLBACK (entry_activate_after_cb), entry);
}
static void
@@ -914,7 +972,7 @@ ephy_location_entry_set_match_func (EphyLocationEntry *entry,
{
GtkEntryCompletion *completion;
- completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+ completion = gtk_entry_get_completion (GTK_ENTRY (entry->url_entry));
gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
}
@@ -1065,7 +1123,7 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
g_signal_connect (completion, "cursor-on-match",
G_CALLBACK (cursor_on_match_cb), entry);
- gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+ gtk_entry_set_completion (GTK_ENTRY (entry->url_entry), completion);
g_object_unref (completion);
}
@@ -1111,7 +1169,7 @@ ephy_location_entry_reset_internal (EphyLocationEntry *entry,
g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
text = url != NULL ? url : "";
- old_text = gtk_entry_get_text (GTK_ENTRY (entry));
+ old_text = gtk_entry_get_text (GTK_ENTRY (entry->url_entry));
old_text = old_text != NULL ? old_text : "";
g_free (entry->saved_text);
@@ -1142,7 +1200,7 @@ ephy_location_entry_reset_internal (EphyLocationEntry *entry,
void
ephy_location_entry_undo_reset (EphyLocationEntry *entry)
{
- gtk_entry_set_text (GTK_ENTRY (entry), entry->saved_text);
+ gtk_entry_set_text (GTK_ENTRY (entry->url_entry), entry->saved_text);
entry->can_redo = FALSE;
entry->user_changed = TRUE;
}
@@ -1175,11 +1233,11 @@ ephy_location_entry_reset (EphyLocationEntry *entry)
void
ephy_location_entry_activate (EphyLocationEntry *entry)
{
- GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
+ GtkWidget *toplevel, *widget = GTK_WIDGET (entry->url_entry);
toplevel = gtk_widget_get_toplevel (widget);
- gtk_editable_select_region (GTK_EDITABLE (entry),
+ gtk_editable_select_region (GTK_EDITABLE (entry->url_entry),
0, -1);
gtk_window_set_focus (GTK_WINDOW (toplevel),
widget);
@@ -1193,27 +1251,27 @@ ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry
g_assert (EPHY_IS_LOCATION_ENTRY (entry));
- context = gtk_widget_get_style_context (GTK_WIDGET (entry));
+ context = gtk_widget_get_style_context (GTK_WIDGET (entry->bookmark));
switch (state) {
case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_HIDDEN:
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- NULL);
+ gtk_widget_set_visible (entry->bookmark_event_box, FALSE);
gtk_style_context_remove_class (context, "starred");
gtk_style_context_remove_class (context, "non-starred");
break;
case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_EMPTY:
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- "non-starred-symbolic");
+ gtk_widget_set_visible (entry->bookmark_event_box, TRUE);
+ gtk_image_set_from_icon_name (GTK_IMAGE (entry->bookmark),
+ "non-starred-symbolic",
+ GTK_ICON_SIZE_MENU);
gtk_style_context_remove_class (context, "starred");
gtk_style_context_add_class (context, "non-starred");
break;
case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_BOOKMARKED:
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
- GTK_ENTRY_ICON_SECONDARY,
- "starred-symbolic");
+ gtk_widget_set_visible (entry->bookmark_event_box, TRUE);
+ gtk_image_set_from_icon_name (GTK_IMAGE (entry->bookmark),
+ "starred-symbolic",
+ GTK_ICON_SIZE_MENU);
gtk_style_context_remove_class (context, "non-starred");
gtk_style_context_add_class (context, "starred");
break;
@@ -1234,7 +1292,7 @@ void
ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
const char *tooltip)
{
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry->url_entry),
GTK_ENTRY_ICON_PRIMARY,
tooltip);
}
@@ -1270,3 +1328,46 @@ ephy_location_entry_get_search_terms (EphyLocationEntry *entry)
{
return entry->search_terms;
}
+
+GtkWidget *
+ephy_location_entry_get_entry (EphyLocationEntry *entry)
+{
+ return entry->url_entry;
+}
+
+GtkWidget *
+ephy_location_entry_get_bookmark_widget (EphyLocationEntry *entry)
+{
+ return entry->bookmark_event_box;
+}
+
+GtkWidget *
+ephy_location_entry_get_reader_mode_widget (EphyLocationEntry *entry)
+{
+ return entry->reader_mode_event_box;
+}
+
+void
+ephy_location_entry_set_reader_mode_visible (EphyLocationEntry *entry,
+ gboolean visible)
+{
+ gtk_widget_set_visible (entry->reader_mode_event_box, visible);
+}
+
+void
+ephy_location_entry_set_reader_mode_state (EphyLocationEntry *entry,
+ gboolean active)
+{
+ if (active)
+ gtk_style_context_add_class (gtk_widget_get_style_context (entry->reader_mode), "selected");
+ else
+ gtk_style_context_remove_class (gtk_widget_get_style_context (entry->reader_mode), "selected");
+
+ entry->reader_mode_active = active;
+}
+
+gboolean
+ephy_location_entry_get_reader_mode_state (EphyLocationEntry *entry)
+{
+ return entry->reader_mode_active;
+}
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 490524a09..013a65a8f 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
#define EPHY_TYPE_LOCATION_ENTRY (ephy_location_entry_get_type())
-G_DECLARE_FINAL_TYPE (EphyLocationEntry, ephy_location_entry, EPHY, LOCATION_ENTRY, GtkEntry)
+G_DECLARE_FINAL_TYPE (EphyLocationEntry, ephy_location_entry, EPHY, LOCATION_ENTRY, GtkOverlay)
typedef enum {
EPHY_LOCATION_ENTRY_BOOKMARK_ICON_HIDDEN,
@@ -79,4 +79,18 @@ void ephy_location_entry_set_add_bookmark_popover (EphyLocationEntr
GtkPopover *ephy_location_entry_get_add_bookmark_popover (EphyLocationEntry *entry);
+GtkWidget *ephy_location_entry_get_entry (EphyLocationEntry *entry);
+
+GtkWidget *ephy_location_entry_get_bookmark_widget (EphyLocationEntry *entry);
+
+GtkWidget *ephy_location_entry_get_reader_mode_widget (EphyLocationEntry *entry);
+
+void ephy_location_entry_set_reader_mode_visible (EphyLocationEntry *entry,
+ gboolean visible);
+
+void ephy_location_entry_set_reader_mode_state (EphyLocationEntry *entry,
+ gboolean active);
+
+gboolean ephy_location_entry_get_reader_mode_state (EphyLocationEntry *entry);
+
G_END_DECLS
diff --git a/src/bookmarks/ephy-add-bookmark-popover.c b/src/bookmarks/ephy-add-bookmark-popover.c
index c30350e00..3cdd198cf 100644
--- a/src/bookmarks/ephy-add-bookmark-popover.c
+++ b/src/bookmarks/ephy-add-bookmark-popover.c
@@ -81,13 +81,15 @@ ephy_add_bookmark_popover_constructed (GObject *object)
{
EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
GtkWidget *location_entry;
+ GtkWidget *bookmark;
G_OBJECT_CLASS (ephy_add_bookmark_popover_parent_class)->constructed (object);
location_entry = GTK_WIDGET (ephy_header_bar_get_title_widget (self->header_bar));
g_assert (EPHY_IS_LOCATION_ENTRY (location_entry));
+ bookmark = ephy_location_entry_get_bookmark_widget (EPHY_LOCATION_ENTRY (location_entry));
- gtk_popover_set_relative_to (GTK_POPOVER (self), location_entry);
+ gtk_popover_set_relative_to (GTK_POPOVER (self), bookmark);
}
static void
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 3a5b4c906..3f529813d 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -607,18 +607,6 @@ notebook_show_tabs_changed_cb (GtkNotebook *notebook,
}
}
-static void
-reader_mode_button_toggled_cb (GtkWidget *button,
- gpointer user_data)
-{
- EphyHeaderBar *header_bar = EPHY_HEADER_BAR (user_data);
- EphyWindow *window = ephy_header_bar_get_window (header_bar);
- EphyEmbed *embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- EphyWebView *view = ephy_embed_get_web_view (embed);
-
- ephy_web_view_toggle_reader_mode (view, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
-}
-
static void
ephy_header_bar_constructed (GObject *object)
{
@@ -827,23 +815,6 @@ ephy_header_bar_constructed (GObject *object)
G_CALLBACK (downloads_estimated_progress_cb),
object, 0);
- /* Reader Mode */
- header_bar->reader_mode_revealer = gtk_revealer_new ();
- gtk_revealer_set_transition_type (GTK_REVEALER (header_bar->reader_mode_revealer),
GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
- gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), header_bar->reader_mode_revealer);
-
- button = gtk_toggle_button_new ();
- g_signal_connect_object (button, "toggled",
- G_CALLBACK (reader_mode_button_toggled_cb),
- object, 0);
- header_bar->reader_mode_button = button;
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_icon_name ("view-dual-symbolic", GTK_ICON_SIZE_BUTTON));
- gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- gtk_container_add (GTK_CONTAINER (header_bar->reader_mode_revealer), button);
- gtk_widget_show (button);
- gtk_widget_show (header_bar->reader_mode_revealer);
-
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), header_bar->downloads_revealer);
gtk_widget_show (header_bar->downloads_revealer);
}
@@ -922,20 +893,3 @@ ephy_header_bar_get_window (EphyHeaderBar *header_bar)
{
return header_bar->window;
}
-
-void
-ephy_header_bar_set_reader_mode_state (EphyHeaderBar *header_bar,
- EphyWebView *view)
-{
- EphyWindow *window = ephy_header_bar_get_window (header_bar);
- EphyEmbed *embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- EphyWebView *active_view = ephy_embed_get_web_view (embed);
- gboolean available = ephy_web_view_is_reader_mode_available (view);
-
- if (active_view != view)
- return;
-
- gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->reader_mode_revealer), available);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (header_bar->reader_mode_button),
- ephy_web_view_get_reader_mode_state (view));
-}
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 1d28b83b1..cb9440097 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -200,12 +200,14 @@ user_changed_cb (GtkWidget *widget, EphyLocationController *controller)
const char *address;
GtkTreeModel *model;
GtkEntryCompletion *completion;
+ GtkWidget *entry;
address = ephy_title_widget_get_address (EPHY_TITLE_WIDGET (widget));
LOG ("user_changed_cb, address %s", address);
- completion = gtk_entry_get_completion (GTK_ENTRY (widget));
+ entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (widget));
+ completion = gtk_entry_get_completion (GTK_ENTRY (entry));
model = gtk_entry_completion_get_model (completion);
ephy_completion_model_update_for_string (EPHY_COMPLETION_MODEL (model), address,
@@ -343,7 +345,8 @@ static void
add_completion_actions (EphyLocationController *controller,
EphyLocationEntry *lentry)
{
- GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
+ GtkWidget *entry = ephy_location_entry_get_entry (lentry);
+ GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (entry));
fill_entry_completion_with_actions (completion, controller);
g_signal_connect (completion, "action_activated",
@@ -356,9 +359,11 @@ search_engines_changed_cb (EphySearchEngineManager *manager,
{
EphyLocationController *controller;
GtkEntryCompletion *completion;
+ GtkWidget *entry;
controller = EPHY_LOCATION_CONTROLLER (data);
- completion = gtk_entry_get_completion (GTK_ENTRY (controller->title_widget));
+ entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (controller->title_widget));
+ completion = gtk_entry_get_completion (GTK_ENTRY (entry));
for (guint i = 0; i < controller->num_search_engines_actions; i++)
gtk_entry_completion_delete_action (completion, 0);
@@ -371,12 +376,32 @@ longpress_gesture_cb (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
gpointer user_data)
+{
+ GtkWidget *entry = user_data;
+
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
+}
+
+static void
+reader_mode_button_press_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
{
EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (user_data);
+ EphyWindow *window = controller->window;
+ EphyEmbed *embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ EphyWebView *view = ephy_embed_get_web_view (embed);
+ EphyLocationEntry *lentry;
+
+ g_assert (EPHY_IS_LOCATION_ENTRY (controller->title_widget));
+
+ lentry = EPHY_LOCATION_ENTRY (controller->title_widget);
- gtk_editable_select_region (GTK_EDITABLE (controller->title_widget), 0, -1);
+ ephy_location_entry_set_reader_mode_state (lentry, !ephy_location_entry_get_reader_mode_state (lentry));
+ ephy_web_view_toggle_reader_mode (view, ephy_location_entry_get_reader_mode_state (lentry));
}
+
static void
ephy_location_controller_constructed (GObject *object)
{
@@ -384,7 +409,7 @@ ephy_location_controller_constructed (GObject *object)
EphyHistoryService *history_service;
EphyBookmarksManager *bookmarks_manager;
EphyCompletionModel *model;
- GtkWidget *notebook, *widget;
+ GtkWidget *notebook, *widget, *reader_mode, *entry;
G_OBJECT_CLASS (ephy_location_controller_parent_class)->constructed (object);
@@ -401,9 +426,10 @@ ephy_location_controller_constructed (GObject *object)
if (!EPHY_IS_LOCATION_ENTRY (controller->title_widget))
return;
- controller->longpress_gesture = gtk_gesture_long_press_new (widget);
+ entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (controller->title_widget));
+ controller->longpress_gesture = gtk_gesture_long_press_new (entry);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller->longpress_gesture), TRUE);
- g_signal_connect (controller->longpress_gesture, "pressed", G_CALLBACK (longpress_gesture_cb), controller);
+ g_signal_connect (controller->longpress_gesture, "pressed", G_CALLBACK (longpress_gesture_cb), entry);
history_service = ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ());
bookmarks_manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
@@ -429,14 +455,17 @@ ephy_location_controller_constructed (GObject *object)
g_signal_connect_object (controller->search_engine_manager, "changed",
G_CALLBACK (search_engines_changed_cb), controller, 0);
+ reader_mode = ephy_location_entry_get_reader_mode_widget (EPHY_LOCATION_ENTRY (controller->title_widget));
+ g_signal_connect (G_OBJECT (reader_mode), "button-press-event", G_CALLBACK
(reader_mode_button_press_event_cb), controller);
+
g_object_bind_property (controller, "editable",
- controller->title_widget, "editable",
+ entry, "editable",
G_BINDING_SYNC_CREATE);
g_signal_connect_object (widget, "drag-data-received",
G_CALLBACK (entry_drag_data_received_cb),
controller, 0);
- g_signal_connect_object (widget, "activate",
+ g_signal_connect_object (entry, "activate",
G_CALLBACK (entry_activate_cb),
controller, 0);
g_signal_connect_object (widget, "user-changed",
diff --git a/src/ephy-window.c b/src/ephy-window.c
index f4819b8b0..1522126eb 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2435,12 +2435,35 @@ download_only_load_cb (EphyWebView *view,
g_idle_add (delayed_remove_child, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view));
}
+static void
+update_reader_mode (EphyWindow *window,
+ EphyWebView *view)
+{
+ EphyEmbed *embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ EphyWebView *active_view = ephy_embed_get_web_view (embed);
+ gboolean available = ephy_web_view_is_reader_mode_available (view);
+ GtkWidget *title_widget = GTK_WIDGET (ephy_header_bar_get_title_widget (EPHY_HEADER_BAR
(window->header_bar)));
+ EphyLocationEntry *lentry;
+
+ if (!EPHY_IS_LOCATION_ENTRY (title_widget))
+ return;
+
+ if (active_view != view)
+ return;
+
+ lentry = EPHY_LOCATION_ENTRY (title_widget);
+ ephy_location_entry_set_reader_mode_visible (lentry, available);
+
+ if (available)
+ ephy_location_entry_set_reader_mode_state (lentry, ephy_web_view_get_reader_mode_state (view));
+}
+
static void
reader_mode_cb (EphyWebView *view,
GParamSpec *pspec,
EphyWindow *window)
{
- ephy_header_bar_set_reader_mode_state (EPHY_HEADER_BAR (window->header_bar), view);
+ update_reader_mode (window, view);
}
static void
@@ -2603,7 +2626,7 @@ notebook_switch_page_cb (GtkNotebook *notebook,
action = g_action_map_lookup_action (G_ACTION_MAP (group), "show-tab");
g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_uint32 (page_num));
- ephy_header_bar_set_reader_mode_state (EPHY_HEADER_BAR (window->header_bar), view);
+ update_reader_mode (window, view);
}
static GtkNotebook *
diff --git a/src/resources/ephy-reader-mode-symbolic.svg b/src/resources/ephy-reader-mode-symbolic.svg
new file mode 100644
index 000000000..5e0f71554
--- /dev/null
+++ b/src/resources/ephy-reader-mode-symbolic.svg
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8' standalone='no'?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg xmlns:cc='http://creativecommons.org/ns#' xmlns:dc='http://purl.org/dc/elements/1.1/'
sodipodi:docname='view-dual-symbolic.svg' height='16' id='svg7384'
xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:svg='http://www.w3.org/2000/svg'
inkscape:version='0.48.3.1 r9886' version='1.1' width='16' xmlns='http://www.w3.org/2000/svg'>
+ <metadata id='metadata90'>
+ <rdf:RDF>
+ <cc:Work rdf:about=''>
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/>
+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview inkscape:bbox-nodes='true' inkscape:bbox-paths='true' bordercolor='#666666'
borderopacity='1' inkscape:current-layer='layer12' inkscape:cx='8.341015' inkscape:cy='-17.299448'
gridtolerance='10' inkscape:guide-bbox='true' guidetolerance='10' id='namedview88'
inkscape:object-nodes='false' inkscape:object-paths='false' objecttolerance='10' pagecolor='#3a3b39'
inkscape:pageopacity='1' inkscape:pageshadow='2' showborder='false' showgrid='false' showguides='true'
inkscape:snap-bbox='true' inkscape:snap-bbox-midpoints='false' inkscape:snap-global='true'
inkscape:snap-grids='true' inkscape:snap-nodes='false' inkscape:snap-others='false'
inkscape:snap-to-guides='true' inkscape:window-height='709' inkscape:window-maximized='1'
inkscape:window-width='1366' inkscape:window-x='0' inkscape:window-y='27' inkscape:zoom='1'>
+ <inkscape:grid empspacing='2' enabled='true' id='grid4866' originx='60.0002px' originy='650.00012px'
snapvisiblegridlinesonly='true' spacingx='1px' spacingy='1px' type='xygrid' visible='true'/>
+ </sodipodi:namedview>
+ <title id='title9167'>Gnome Symbolic Icon Theme</title>
+ <defs id='defs7386'/>
+ <g inkscape:groupmode='layer' id='layer9' inkscape:label='status' style='display:inline'
transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='layer10' inkscape:label='devices'
transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='layer11' inkscape:label='apps' transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='layer13' inkscape:label='places' transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='layer14' inkscape:label='mimetypes'
transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='layer15' inkscape:label='emblems' style='display:inline'
transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='g71291' inkscape:label='emotes' style='display:inline'
transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='g4953' inkscape:label='categories' style='display:inline'
transform='translate(-181,-867.00012)'/>
+ <g inkscape:groupmode='layer' id='layer12' inkscape:label='actions' style='display:inline'
transform='translate(-181,-867.00012)'>
+
+ <path inkscape:connector-curvature='0' d='m 181,868 0,1 0,11 0,1 1,0 5,0 c 0.1754,0 0.52538,0.15166
0.8125,0.34375 0.28712,0.19209 0.46875,0.375 0.46875,0.375 L 189,882.4375 l 0.71875,-0.75 c 0,0
0.8963,-0.6875 1.28125,-0.6875 l 5,0 1,0 0,-1 0,-11 0,-1 -1,0 -5,0 c -0.87652,0 -1.56017,0.34756
-2.03125,0.6875 -0.0301,-0.0207 -0.031,-0.0105 -0.0625,-0.0312 C 188.44557,868.35254 187.82811,868 187,868 l
-5,0 -1,0 z m 2,2 4,0 c 0.13821,0 0.51476,0.14746 0.8125,0.34375 0.29774,0.19629 0.5,0.375 0.5,0.375 l
0.71875,0.6875 0.6875,-0.71875 c 0,0 0.89975,-0.6875 1.28125,-0.6875 l 4,0 0,9 -4,0 c -0.87693,0
-1.56008,0.34735 -2.03125,0.6875 -0.0196,-0.0135 -0.011,-0.0177 -0.0312,-0.0312 C 188.47725,879.34834
187.83512,879 187,879 l -4,0 0,-9 z' id='rect7352-28-4-8'
style='opacity:0.65;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:nor
mal;text
-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans'/>
+ <rect height='2' id='rect42942-5-3-1-4-4-5-9' inkscape:label='a' rx='0.375' ry='0.375'
style='opacity:0.35;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible'
transform='scale(-1,1)' width='3.0000136' x='-187.00021' y='871.99976'/>
+ <rect height='2.0002136' id='rect42944-7-5-3-5-1-5-0-2-62-5' inkscape:label='a' rx='0.375' ry='0.375'
style='opacity:0.35;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible'
transform='scale(-1,1)' width='3.0000129' x='-187.00021' y='874.99976'/>
+ <rect height='2.0002136' id='rect42942-5-3-1-4-4-6-0-1' inkscape:label='a' rx='0.375' ry='0.375'
style='opacity:0.35;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible'
transform='scale(-1,1)' width='3.0000136' x='-194.00021' y='871.99976'/>
+ <rect height='2.0002136' id='rect42944-7-5-3-5-1-5-0-2-6-4-6' inkscape:label='a' rx='0.375' ry='0.375'
style='opacity:0.35;color:#bebebe;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible'
transform='scale(-1,1)' width='3.0000129' x='-194.00021' y='874.99976'/>
+ </g>
+</svg>
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 651edeb5c..09f5d634d 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -36,6 +36,7 @@
<gresource prefix="/org/gnome/Epiphany/icons">
<file compressed="true"
alias="scalable/actions/ephy-bookmarks-symbolic.svg">ephy-bookmarks-symbolic.svg</file>
<file compressed="true"
alias="scalable/actions/ephy-bookmark-tag-symbolic.svg">ephy-bookmark-tag-symbolic.svg</file>
+ <file compressed="true"
alias="scalable/actions/ephy-reader-mode-symbolic.svg">ephy-reader-mode-symbolic.svg</file>
</gresource>
<gresource prefix="/org/gnome/Epiphany">
<file compressed="true">themes/shared.css</file>
diff --git a/src/resources/themes/shared.css b/src/resources/themes/shared.css
index 0709b845e..e2aa4c9e9 100644
--- a/src/resources/themes/shared.css
+++ b/src/resources/themes/shared.css
@@ -30,8 +30,11 @@ button.active-menu {
background-size: 64px 64px;
color: rgba(0, 0, 0, 0.35); }
+.selected {
+ color: @theme_selected_bg_color; }
+
/* Bookmarks */
-.titlebar entry.starred image.right {
+.starred {
color: orange; }
.bookmarks-row button {
diff --git a/src/resources/themes/shared.scss b/src/resources/themes/shared.scss
index ba7fec81c..73be89e85 100644
--- a/src/resources/themes/shared.scss
+++ b/src/resources/themes/shared.scss
@@ -44,9 +44,11 @@ button.active-menu {
}
}
+.selected {
+ color: @theme_selected_bg_color; }
/* Bookmarks */
-.titlebar entry.starred image.right {
+.starred {
color: orange;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]