diff options
author | Jan-Michael Brummer <jan.brummer@tabos.org> | 2018-06-05 22:43:40 +0200 |
---|---|---|
committer | Jan-Michael Brummer <jan.brummer@tabos.org> | 2018-06-07 07:19:40 +0200 |
commit | 349587cff9c234d46411f691a2305846a951b79a (patch) | |
tree | 99ea796a93e21a1a62ab2ea41a01fb520eda54b2 /src/ephy-header-bar.c | |
parent | dfca5570f7ee8d1209647a2345a0d241320452ac (diff) | |
download | epiphany-349587cff9c234d46411f691a2305846a951b79a.tar.gz |
Add clean reader mode
Main part is Readability.js which does the page magic on every page load. Idea based on Eolie implementation.
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=772831
Diffstat (limited to 'src/ephy-header-bar.c')
-rw-r--r-- | src/ephy-header-bar.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c index 87a67beb6..3a5b4c906 100644 --- a/src/ephy-header-bar.c +++ b/src/ephy-header-bar.c @@ -66,6 +66,8 @@ struct _EphyHeaderBar { EphyWindow *window; EphyTitleWidget *title_widget; GtkWidget *navigation_box; + GtkWidget *reader_mode_revealer; + GtkWidget *reader_mode_button; GtkWidget *new_tab_revealer; GtkWidget *new_tab_button; GtkWidget *combined_stop_reload_button; @@ -606,6 +608,18 @@ 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) { EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object); @@ -813,6 +827,23 @@ 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); } @@ -891,3 +922,20 @@ 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)); +} |