1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  *  Copyright © 2012 Igalia S.L
4  *  Copyright © 2013 Yosef Or Boczko <yoseforb@gmail.com>
5  *  Copyright © 2016 Iulian-Gabriel Radu <iulian.radu67@gmail.com>
6  *
7  *  This file is part of Epiphany.
8  *
9  *  Epiphany is free software: you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation, either version 3 of the License, or
12  *  (at your option) any later version.
13  *
14  *  Epiphany is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "config.h"
24 #include "ephy-header-bar.h"
25 
26 #include "ephy-add-bookmark-popover.h"
27 #include "ephy-desktop-utils.h"
28 #include "ephy-embed-utils.h"
29 #include "ephy-file-helpers.h"
30 #include "ephy-flatpak-utils.h"
31 #include "ephy-location-entry.h"
32 #include "ephy-settings.h"
33 #include "ephy-shell.h"
34 #include "ephy-title-box.h"
35 #include "ephy-title-widget.h"
36 #include "ephy-type-builtins.h"
37 
38 #include <glib/gi18n.h>
39 #include <handy.h>
40 
41 #define POPOVER_HIDE_DELAY 300
42 
43 enum {
44   PROP_0,
45   PROP_WINDOW,
46   N_PROPERTIES
47 };
48 
49 static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
50 
51 /* Translators: tooltip for the refresh button */
52 static const char *REFRESH_BUTTON_TOOLTIP = N_("Reload the current page");
53 
54 struct _EphyHeaderBar {
55   GtkHeaderBar parent_instance;
56 
57   EphyWindow *window;
58   EphyTitleWidget *title_widget;
59   GtkRevealer *start_revealer;
60   GtkRevealer *end_revealer;
61   EphyActionBarStart *action_bar_start;
62   EphyActionBarEnd *action_bar_end;
63   GtkWidget *page_menu_button;
64   GtkWidget *zoom_level_label;
65   GtkWidget *restore_button;
66   GtkWidget *combined_stop_reload_button;
67   GtkWidget *combined_stop_reload_image;
68   GtkWidget *page_menu_popover;
69 
70   guint popover_hide_timeout_id;
71 };
72 
G_DEFINE_TYPE(EphyHeaderBar,ephy_header_bar,GTK_TYPE_HEADER_BAR)73 G_DEFINE_TYPE (EphyHeaderBar, ephy_header_bar, GTK_TYPE_HEADER_BAR)
74 
75 static void
76 ephy_header_bar_set_property (GObject      *object,
77                               guint         property_id,
78                               const GValue *value,
79                               GParamSpec   *pspec)
80 {
81   EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object);
82 
83   switch (property_id) {
84     case PROP_WINDOW:
85       header_bar->window = EPHY_WINDOW (g_value_get_object (value));
86       g_object_notify_by_pspec (object, object_properties[PROP_WINDOW]);
87       break;
88     default:
89       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
90   }
91 }
92 
93 static void
ephy_header_bar_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)94 ephy_header_bar_get_property (GObject    *object,
95                               guint       property_id,
96                               GValue     *value,
97                               GParamSpec *pspec)
98 {
99   EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object);
100 
101   switch (property_id) {
102     case PROP_WINDOW:
103       g_value_set_object (value, header_bar->window);
104       break;
105     default:
106       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
107   }
108 }
109 
110 static void
sync_chromes_visibility(EphyHeaderBar * header_bar)111 sync_chromes_visibility (EphyHeaderBar *header_bar)
112 {
113   EphyWindowChrome chrome;
114 
115   chrome = ephy_window_get_chrome (header_bar->window);
116 
117   gtk_widget_set_visible (ephy_action_bar_start_get_navigation_box (header_bar->action_bar_start),
118                           chrome & EPHY_WINDOW_CHROME_HEADER_BAR);
119   ephy_action_bar_end_set_show_bookmarks_button (header_bar->action_bar_end,
120                                                  chrome & EPHY_WINDOW_CHROME_BOOKMARKS);
121   gtk_widget_set_visible (header_bar->page_menu_button, chrome & EPHY_WINDOW_CHROME_MENU);
122 }
123 
124 static gboolean
hide_timeout_cb(EphyHeaderBar * header_bar)125 hide_timeout_cb (EphyHeaderBar *header_bar)
126 {
127   gtk_popover_popdown (GTK_POPOVER (header_bar->page_menu_popover));
128 
129   header_bar->popover_hide_timeout_id = 0;
130 
131   return G_SOURCE_REMOVE;
132 }
133 
134 void
fullscreen_changed_cb(EphyHeaderBar * header_bar)135 fullscreen_changed_cb (EphyHeaderBar *header_bar)
136 {
137   gboolean fullscreen;
138 
139   g_object_get (header_bar->window, "fullscreen", &fullscreen, NULL);
140 
141   gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (header_bar), !fullscreen);
142   gtk_widget_set_visible (header_bar->restore_button, fullscreen);
143 
144   if (fullscreen) {
145     g_clear_handle_id (&header_bar->popover_hide_timeout_id, g_source_remove);
146 
147     header_bar->popover_hide_timeout_id =
148       g_timeout_add (POPOVER_HIDE_DELAY, (GSourceFunc)hide_timeout_cb, header_bar);
149   }
150 }
151 
152 static void
add_bookmark_button_clicked_cb(EphyLocationEntry * entry,gpointer * user_data)153 add_bookmark_button_clicked_cb (EphyLocationEntry *entry,
154                                 gpointer          *user_data)
155 {
156   EphyHeaderBar *header_bar = EPHY_HEADER_BAR (user_data);
157   GActionGroup *action_group;
158   GAction *action;
159 
160   action_group = gtk_widget_get_action_group (GTK_WIDGET (header_bar->window), "win");
161   action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "bookmark-page");
162 
163   g_action_activate (action, NULL);
164 }
165 
166 static void
restore_button_clicked_cb(GtkButton * button,EphyHeaderBar * header_bar)167 restore_button_clicked_cb (GtkButton     *button,
168                            EphyHeaderBar *header_bar)
169 {
170   GActionGroup *action_group;
171   GAction *action;
172 
173   action_group = gtk_widget_get_action_group (GTK_WIDGET (header_bar->window), "win");
174   action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "fullscreen");
175 
176   g_action_activate (action, NULL);
177 }
178 
179 static void
update_revealer_visibility(GtkRevealer * revealer)180 update_revealer_visibility (GtkRevealer *revealer)
181 {
182   gtk_widget_set_visible (GTK_WIDGET (revealer),
183                           gtk_revealer_get_reveal_child (revealer) ||
184                           gtk_revealer_get_child_revealed (revealer));
185 }
186 
187 static void
ephy_header_bar_constructed(GObject * object)188 ephy_header_bar_constructed (GObject *object)
189 {
190   EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object);
191   GtkWidget *button;
192   GtkWidget *event_box;
193   GtkBuilder *builder;
194   EphyEmbedShell *embed_shell;
195   GtkSizeGroup *downloads_size_group;
196 
197   G_OBJECT_CLASS (ephy_header_bar_parent_class)->constructed (object);
198 
199   g_signal_connect_object (header_bar->window, "notify::chrome",
200                            G_CALLBACK (sync_chromes_visibility), header_bar,
201                            G_CONNECT_SWAPPED);
202   g_signal_connect_object (header_bar->window, "notify::fullscreen",
203                            G_CALLBACK (fullscreen_changed_cb), header_bar,
204                            G_CONNECT_SWAPPED);
205 
206   /* Start action elements */
207   header_bar->action_bar_start = ephy_action_bar_start_new ();
208   gtk_widget_show (GTK_WIDGET (header_bar->action_bar_start));
209   header_bar->start_revealer = GTK_REVEALER (gtk_revealer_new ());
210   g_signal_connect (header_bar->start_revealer, "notify::child-revealed",
211                     G_CALLBACK (update_revealer_visibility), NULL);
212   g_signal_connect (header_bar->start_revealer, "notify::reveal-child",
213                     G_CALLBACK (update_revealer_visibility), NULL);
214   gtk_revealer_set_transition_type (GTK_REVEALER (header_bar->start_revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
215   gtk_container_add (GTK_CONTAINER (header_bar->start_revealer), GTK_WIDGET (header_bar->action_bar_start));
216 
217   gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar),
218                              GTK_WIDGET (header_bar->start_revealer));
219 
220   embed_shell = ephy_embed_shell_get_default ();
221 
222   /* Title widget (location entry or title box) */
223   if (ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_APPLICATION)
224     header_bar->title_widget = EPHY_TITLE_WIDGET (ephy_title_box_new ());
225   else {
226     header_bar->title_widget = EPHY_TITLE_WIDGET (ephy_location_entry_new ());
227   }
228 
229   event_box = gtk_event_box_new ();
230   gtk_widget_add_events (event_box, GDK_ALL_EVENTS_MASK);
231   gtk_widget_show (event_box);
232   gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header_bar), event_box);
233   gtk_widget_set_name (event_box, "title-box-container");
234 
235   if (is_desktop_pantheon ()) {
236     /* Use a full-width entry on Pantheon */
237     gtk_widget_set_hexpand (GTK_WIDGET (header_bar->title_widget), TRUE);
238     gtk_widget_set_margin_start (GTK_WIDGET (header_bar->title_widget), 6);
239     gtk_widget_set_margin_end (GTK_WIDGET (header_bar->title_widget), 6);
240 
241     gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET (header_bar->title_widget));
242   } else {
243     GtkWidget *clamp;
244 
245     clamp = hdy_clamp_new ();
246     gtk_widget_set_hexpand (GTK_WIDGET (clamp), TRUE);
247     gtk_widget_show (clamp);
248     hdy_clamp_set_maximum_size (HDY_CLAMP (clamp), 860);
249     hdy_clamp_set_tightening_threshold (HDY_CLAMP (clamp), 560);
250     gtk_container_add (GTK_CONTAINER (clamp), GTK_WIDGET (header_bar->title_widget));
251 
252     gtk_container_add (GTK_CONTAINER (event_box), clamp);
253   }
254 
255   gtk_widget_show (GTK_WIDGET (header_bar->title_widget));
256 
257   if (EPHY_IS_LOCATION_ENTRY (header_bar->title_widget)) {
258     EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (header_bar->title_widget);
259     GtkWidget *popover = ephy_add_bookmark_popover_new (ephy_location_entry_get_bookmark_widget (lentry), GTK_WIDGET (header_bar->window));
260 
261     g_signal_connect_object (popover, "update-state", G_CALLBACK (ephy_window_sync_bookmark_state), header_bar, G_CONNECT_SWAPPED);
262     ephy_location_entry_set_add_bookmark_popover (lentry, GTK_POPOVER (popover));
263 
264     g_signal_connect_object (header_bar->title_widget,
265                              "bookmark-clicked",
266                              G_CALLBACK (add_bookmark_button_clicked_cb),
267                              header_bar,
268                              0);
269   }
270 
271   /* Fullscreen restore button */
272   header_bar->restore_button = gtk_button_new_from_icon_name ("view-restore-symbolic",
273                                                               GTK_ICON_SIZE_BUTTON);
274   gtk_widget_set_valign (header_bar->restore_button, GTK_ALIGN_CENTER);
275   g_signal_connect_object (header_bar->restore_button, "clicked",
276                            G_CALLBACK (restore_button_clicked_cb),
277                            header_bar, 0);
278   gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
279                            GTK_WIDGET (header_bar->restore_button));
280 
281   /* Page Menu */
282   button = gtk_menu_button_new ();
283   header_bar->page_menu_button = button;
284   gtk_button_set_image (GTK_BUTTON (button),
285                         gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON));
286   gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
287   g_type_ensure (G_TYPE_THEMED_ICON);
288   builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/gtk/page-menu-popover.ui");
289   header_bar->page_menu_popover = GTK_WIDGET (gtk_builder_get_object (builder, "page-menu-popover"));
290   header_bar->zoom_level_label = GTK_WIDGET (gtk_builder_get_object (builder, "zoom-level"));
291   if (ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
292     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "new-window-separator")));
293     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "new-window-button")));
294     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "new-incognito-window-button")));
295     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "reopen-closed-tab-button")));
296     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "save-as-application-separator")));
297     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "save-as-application-button")));
298     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "application-manager-button")));
299     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "override-text-encoding-separator")));
300     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "override-text-encoding-button")));
301     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "keyboard-shortcuts-button")));
302     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "help-button")));
303     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "firefox-sync-separator")));
304     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "firefox-sync-button")));
305     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "import-export-menu")));
306   } else if (ephy_is_running_inside_flatpak ()) {
307     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "run-in-background-separator")));
308     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "run-in-background-button")));
309     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "save-as-application-separator")));
310     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "save-as-application-button")));
311     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "application-manager-button")));
312 
313     if (is_desktop_pantheon ())
314       gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "help-button")));
315   } else {
316     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "run-in-background-separator")));
317     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "run-in-background-button")));
318   }
319 
320   header_bar->combined_stop_reload_button = GTK_WIDGET (gtk_builder_get_object (builder, "combined_stop_reload_button"));
321   header_bar->combined_stop_reload_image = GTK_WIDGET (gtk_builder_get_object (builder, "combined_stop_reload_image"));
322   gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button, _(REFRESH_BUTTON_TOOLTIP));
323 
324   if (is_desktop_pantheon ()) {
325     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "about-button")));
326 
327     gtk_button_set_image (GTK_BUTTON (button),
328                           gtk_image_new_from_icon_name ("open-menu",
329                                                         GTK_ICON_SIZE_LARGE_TOOLBAR));
330   }
331   g_settings_bind (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_WEBEXTENSIONS, gtk_builder_get_object (builder, "extensions-button"), "visible", G_SETTINGS_BIND_DEFAULT);
332 
333   gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), header_bar->page_menu_popover);
334   g_object_unref (builder);
335 
336   gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), button);
337 
338   /* End action elements */
339   header_bar->action_bar_end = ephy_action_bar_end_new ();
340   gtk_widget_show (GTK_WIDGET (header_bar->action_bar_end));
341   header_bar->end_revealer = GTK_REVEALER (gtk_revealer_new ());
342   g_signal_connect (header_bar->end_revealer, "notify::child-revealed",
343                     G_CALLBACK (update_revealer_visibility), NULL);
344   g_signal_connect (header_bar->end_revealer, "notify::reveal-child",
345                     G_CALLBACK (update_revealer_visibility), NULL);
346   gtk_revealer_set_transition_type (GTK_REVEALER (header_bar->end_revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
347   gtk_container_add (GTK_CONTAINER (header_bar->end_revealer), GTK_WIDGET (header_bar->action_bar_end));
348 
349   gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
350                            GTK_WIDGET (header_bar->end_revealer));
351 
352   /* Sync the size of placeholder in EphyActionBarStart with downloads button */
353   downloads_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
354   gtk_size_group_add_widget (downloads_size_group,
355                              ephy_action_bar_start_get_placeholder (header_bar->action_bar_start));
356   gtk_size_group_add_widget (downloads_size_group,
357                              ephy_action_bar_end_get_downloads_revealer (header_bar->action_bar_end));
358   g_object_unref (downloads_size_group);
359 
360   if (ephy_profile_dir_is_web_application ()) {
361     GtkWidget *navigation_box = ephy_action_bar_start_get_navigation_box (header_bar->action_bar_start);
362 
363     g_settings_bind (EPHY_SETTINGS_WEB_APP, EPHY_PREFS_WEB_APP_SHOW_NAVIGATION_BUTTONS, navigation_box, "visible", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_INVERT_BOOLEAN);
364   }
365 }
366 
367 static void
ephy_header_bar_dispose(GObject * object)368 ephy_header_bar_dispose (GObject *object)
369 {
370   EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object);
371 
372   g_clear_handle_id (&header_bar->popover_hide_timeout_id, g_source_remove);
373 
374   G_OBJECT_CLASS (ephy_header_bar_parent_class)->dispose (object);
375 }
376 
377 static void
ephy_header_bar_init(EphyHeaderBar * header_bar)378 ephy_header_bar_init (EphyHeaderBar *header_bar)
379 {
380 }
381 
382 static void
ephy_header_bar_class_init(EphyHeaderBarClass * klass)383 ephy_header_bar_class_init (EphyHeaderBarClass *klass)
384 {
385   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
386 
387   gobject_class->set_property = ephy_header_bar_set_property;
388   gobject_class->get_property = ephy_header_bar_get_property;
389   gobject_class->constructed = ephy_header_bar_constructed;
390   gobject_class->dispose = ephy_header_bar_dispose;
391 
392   object_properties[PROP_WINDOW] =
393     g_param_spec_object ("window",
394                          "Window",
395                          "The header_bar's EphyWindow",
396                          EPHY_TYPE_WINDOW,
397                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
398 
399   g_object_class_install_properties (gobject_class,
400                                      N_PROPERTIES,
401                                      object_properties);
402 }
403 
404 GtkWidget *
ephy_header_bar_new(EphyWindow * window)405 ephy_header_bar_new (EphyWindow *window)
406 {
407   g_assert (EPHY_IS_WINDOW (window));
408 
409   return GTK_WIDGET (g_object_new (EPHY_TYPE_HEADER_BAR,
410                                    "show-close-button", TRUE,
411                                    "window", window,
412                                    NULL));
413 }
414 
415 EphyTitleWidget *
ephy_header_bar_get_title_widget(EphyHeaderBar * header_bar)416 ephy_header_bar_get_title_widget (EphyHeaderBar *header_bar)
417 {
418   return header_bar->title_widget;
419 }
420 
421 GtkWidget *
ephy_header_bar_get_page_menu_button(EphyHeaderBar * header_bar)422 ephy_header_bar_get_page_menu_button (EphyHeaderBar *header_bar)
423 {
424   return header_bar->page_menu_button;
425 }
426 
427 EphyWindow *
ephy_header_bar_get_window(EphyHeaderBar * header_bar)428 ephy_header_bar_get_window (EphyHeaderBar *header_bar)
429 {
430   return header_bar->window;
431 }
432 
433 EphyActionBarStart *
ephy_header_bar_get_action_bar_start(EphyHeaderBar * header_bar)434 ephy_header_bar_get_action_bar_start (EphyHeaderBar *header_bar)
435 {
436   return header_bar->action_bar_start;
437 }
438 
439 EphyActionBarEnd *
ephy_header_bar_get_action_bar_end(EphyHeaderBar * header_bar)440 ephy_header_bar_get_action_bar_end (EphyHeaderBar *header_bar)
441 {
442   return header_bar->action_bar_end;
443 }
444 
445 void
ephy_header_bar_set_adaptive_mode(EphyHeaderBar * header_bar,EphyAdaptiveMode adaptive_mode)446 ephy_header_bar_set_adaptive_mode (EphyHeaderBar    *header_bar,
447                                    EphyAdaptiveMode  adaptive_mode)
448 {
449   ephy_action_bar_end_set_show_bookmark_button (header_bar->action_bar_end,
450                                                 adaptive_mode == EPHY_ADAPTIVE_MODE_NARROW);
451 
452   switch (adaptive_mode) {
453     case EPHY_ADAPTIVE_MODE_NORMAL:
454       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), TRUE);
455       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->end_revealer), TRUE);
456       gtk_widget_set_visible (header_bar->combined_stop_reload_button, FALSE);
457 
458       break;
459     case EPHY_ADAPTIVE_MODE_NARROW:
460       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), FALSE);
461       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->end_revealer), FALSE);
462       gtk_widget_set_visible (header_bar->combined_stop_reload_button, TRUE);
463 
464       break;
465   }
466 
467   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION)
468     ephy_location_entry_set_adaptive_mode (EPHY_LOCATION_ENTRY (header_bar->title_widget), adaptive_mode);
469 }
470 
471 void
ephy_header_bar_start_change_combined_stop_reload_state(EphyHeaderBar * header_bar,gboolean loading)472 ephy_header_bar_start_change_combined_stop_reload_state (EphyHeaderBar *header_bar,
473                                                          gboolean       loading)
474 {
475   if (loading) {
476     gtk_image_set_from_icon_name (GTK_IMAGE (header_bar->combined_stop_reload_image),
477                                   "process-stop-symbolic",
478                                   get_icon_size ());
479     /* Translators: tooltip for the stop button */
480     gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button,
481                                  _("Stop loading the current page"));
482   } else {
483     gtk_image_set_from_icon_name (GTK_IMAGE (header_bar->combined_stop_reload_image),
484                                   "view-refresh-symbolic",
485                                   get_icon_size ());
486     gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button,
487                                  _(REFRESH_BUTTON_TOOLTIP));
488   }
489 }
490 
491 void
ephy_header_bar_set_zoom_level(EphyHeaderBar * header_bar,gdouble zoom)492 ephy_header_bar_set_zoom_level (EphyHeaderBar *header_bar,
493                                 gdouble        zoom)
494 {
495   g_autofree gchar *zoom_level = g_strdup_printf ("%2.0f%%", zoom * 100);
496 
497   gtk_label_set_label (GTK_LABEL (header_bar->zoom_level_label), zoom_level);
498 }
499 
500 void
ephy_header_bar_add_browser_action(EphyHeaderBar * header_bar,GtkWidget * action)501 ephy_header_bar_add_browser_action (EphyHeaderBar *header_bar,
502                                     GtkWidget     *action)
503 {
504   ephy_action_bar_end_add_browser_action (header_bar->action_bar_end, action);
505 }
506