[epiphany] Add combined stop reload button to page menu in narrow mode



commit cd152a60eaf5a63f1e02009c59178988942dcfa7
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Tue Apr 21 08:52:19 2020 +0200

    Add combined stop reload button to page menu in narrow mode
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1162

 src/ephy-action-bar-start.c            |  9 ---------
 src/ephy-desktop-utils.c               | 11 +++++++++++
 src/ephy-desktop-utils.h               |  3 +++
 src/ephy-header-bar.c                  | 34 ++++++++++++++++++++++++++++++----
 src/ephy-header-bar.h                  |  2 ++
 src/ephy-window.c                      |  3 +++
 src/resources/gtk/page-menu-popover.ui | 20 ++++++++++++--------
 7 files changed, 61 insertions(+), 21 deletions(-)
---
diff --git a/src/ephy-action-bar-start.c b/src/ephy-action-bar-start.c
index 96fe63fa7..65fa4ac3b 100644
--- a/src/ephy-action-bar-start.c
+++ b/src/ephy-action-bar-start.c
@@ -466,15 +466,6 @@ ephy_action_bar_start_dispose (GObject *object)
   G_OBJECT_CLASS (ephy_action_bar_start_parent_class)->dispose (object);
 }
 
-static GtkIconSize
-get_icon_size (void)
-{
-  if (is_desktop_pantheon ())
-    return GTK_ICON_SIZE_LARGE_TOOLBAR;
-
-  return GTK_ICON_SIZE_BUTTON;
-}
-
 static void
 update_new_tab_button_visibility (EphyActionBarStart *action_bar_start)
 {
diff --git a/src/ephy-desktop-utils.c b/src/ephy-desktop-utils.c
index 9adabce3f..df8620063 100644
--- a/src/ephy-desktop-utils.c
+++ b/src/ephy-desktop-utils.c
@@ -21,6 +21,8 @@
 #include "config.h"
 #include "ephy-desktop-utils.h"
 
+#include <gtk/gtk.h>
+
 gboolean
 is_desktop_pantheon (void)
 {
@@ -31,3 +33,12 @@ is_desktop_pantheon (void)
 
   return strstr (xdg_current_desktop, "Pantheon") != NULL;
 }
+
+GtkIconSize
+get_icon_size (void)
+{
+  if (is_desktop_pantheon ())
+    return GTK_ICON_SIZE_LARGE_TOOLBAR;
+
+  return GTK_ICON_SIZE_BUTTON;
+}
diff --git a/src/ephy-desktop-utils.h b/src/ephy-desktop-utils.h
index a2bbd031c..29fcc76ae 100644
--- a/src/ephy-desktop-utils.h
+++ b/src/ephy-desktop-utils.h
@@ -21,9 +21,12 @@
 #pragma once
 
 #include <glib.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
 gboolean is_desktop_pantheon (void);
 
+GtkIconSize get_icon_size (void);
+
 G_END_DECLS
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 8739dbfae..f5fd75103 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -48,6 +48,9 @@ enum {
 
 static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
 
+/* Translators: tooltip for the refresh button */
+static const char *REFRESH_BUTTON_TOOLTIP = N_("Reload the current page");
+
 struct _EphyHeaderBar {
   GtkHeaderBar parent_instance;
 
@@ -60,7 +63,8 @@ struct _EphyHeaderBar {
   GtkWidget *page_menu_button;
   GtkWidget *zoom_level_button;
   GtkWidget *restore_button;
-  GtkWidget *reload_button;
+  GtkWidget *combined_stop_reload_button;
+  GtkWidget *combined_stop_reload_image;
 };
 
 G_DEFINE_TYPE (EphyHeaderBar, ephy_header_bar, GTK_TYPE_HEADER_BAR)
@@ -331,7 +335,9 @@ ephy_header_bar_constructed (GObject *object)
       gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "help-button")));
   }
 
-  header_bar->reload_button = GTK_WIDGET (gtk_builder_get_object (builder, "reload_button"));
+  header_bar->combined_stop_reload_button = GTK_WIDGET (gtk_builder_get_object (builder, 
"combined_stop_reload_button"));
+  header_bar->combined_stop_reload_image = GTK_WIDGET (gtk_builder_get_object (builder, 
"combined_stop_reload_image"));
+  gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button, _(REFRESH_BUTTON_TOOLTIP));
 
   if (is_desktop_pantheon ()) {
     gtk_widget_destroy (GTK_WIDGET (gtk_builder_get_object (builder, "about-button")));
@@ -456,13 +462,13 @@ ephy_header_bar_set_adaptive_mode (EphyHeaderBar    *header_bar,
     case EPHY_ADAPTIVE_MODE_NORMAL:
       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), TRUE);
       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->end_revealer), TRUE);
-      gtk_widget_set_visible (header_bar->reload_button, FALSE);
+      gtk_widget_set_visible (header_bar->combined_stop_reload_button, FALSE);
 
       break;
     case EPHY_ADAPTIVE_MODE_NARROW:
       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), FALSE);
       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->end_revealer), FALSE);
-      gtk_widget_set_visible (header_bar->reload_button, TRUE);
+      gtk_widget_set_visible (header_bar->combined_stop_reload_button, TRUE);
 
       break;
   }
@@ -470,3 +476,23 @@ ephy_header_bar_set_adaptive_mode (EphyHeaderBar    *header_bar,
   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION)
     ephy_location_entry_set_mobile_popdown (EPHY_LOCATION_ENTRY (header_bar->title_widget), adaptive_mode == 
EPHY_ADAPTIVE_MODE_NARROW);
 }
+
+void
+ephy_header_bar_start_change_combined_stop_reload_state (EphyHeaderBar *header_bar,
+                                                         gboolean       loading)
+{
+  if (loading) {
+    gtk_image_set_from_icon_name (GTK_IMAGE (header_bar->combined_stop_reload_image),
+                                  "process-stop-symbolic",
+                                  get_icon_size ());
+    /* Translators: tooltip for the stop button */
+    gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button,
+                                 _("Stop loading the current page"));
+  } else {
+    gtk_image_set_from_icon_name (GTK_IMAGE (header_bar->combined_stop_reload_image),
+                                  "view-refresh-symbolic",
+                                  get_icon_size ());
+    gtk_widget_set_tooltip_text (header_bar->combined_stop_reload_button,
+                                 _(REFRESH_BUTTON_TOOLTIP));
+  }
+}
diff --git a/src/ephy-header-bar.h b/src/ephy-header-bar.h
index 13ea51793..206c34268 100644
--- a/src/ephy-header-bar.h
+++ b/src/ephy-header-bar.h
@@ -45,5 +45,7 @@ EphyActionBarStart *ephy_header_bar_get_action_bar_start           (EphyHeaderBa
 EphyActionBarEnd   *ephy_header_bar_get_action_bar_end             (EphyHeaderBar *header_bar);
 void                ephy_header_bar_set_adaptive_mode              (EphyHeaderBar    *header_bar,
                                                                     EphyAdaptiveMode  adaptive_mode);
+void                ephy_header_bar_start_change_combined_stop_reload_state (EphyHeaderBar *header_bar,
+                                                                             gboolean       loading);
 
 G_END_DECLS
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 36d0535a8..76e976895 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -806,11 +806,14 @@ change_combined_stop_reload_state (GSimpleAction *action,
   EphyWindow *window = EPHY_WINDOW (user_data);
   EphyActionBarStart *header_bar_start = ephy_header_bar_get_action_bar_start (EPHY_HEADER_BAR 
(window->header_bar));
   EphyActionBarStart *action_bar_start = ephy_action_bar_get_action_bar_start (EPHY_ACTION_BAR 
(window->action_bar));
+  EphyHeaderBar *header_bar = EPHY_HEADER_BAR (window->header_bar);
 
   ephy_action_bar_start_change_combined_stop_reload_state (header_bar_start,
                                                            g_variant_get_boolean (loading));
   ephy_action_bar_start_change_combined_stop_reload_state (action_bar_start,
                                                            g_variant_get_boolean (loading));
+  ephy_header_bar_start_change_combined_stop_reload_state (header_bar,
+                                                           g_variant_get_boolean (loading));
 
   g_simple_action_set_state (action, loading);
 }
diff --git a/src/resources/gtk/page-menu-popover.ui b/src/resources/gtk/page-menu-popover.ui
index 05cb269b9..4100654e3 100644
--- a/src/resources/gtk/page-menu-popover.ui
+++ b/src/resources/gtk/page-menu-popover.ui
@@ -125,13 +125,20 @@
               </packing>
             </child>
             <child>
-              <object class="GtkModelButton" id="reload_button">
+              <object class="GtkButton" id="combined_stop_reload_button">
                 <property name="tooltip_text" translatable="yes">Reload</property>
-                <property name="action-name">toolbar.reload</property>
-                <property name="iconic">True</property>
-                <property name="centered">True</property>
-                <property name="icon">reload</property>
+                <property name="action-name">toolbar.combined-stop-reload</property>
                 <property name="visible">True</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child>
+                  <object class="GtkImage" id="combined_stop_reload_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">view-refresh-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -331,7 +338,4 @@
   <object class="GThemedIcon" id="fullscreen">
     <property name="name">view-fullscreen-symbolic</property>
   </object>
-  <object class="GThemedIcon" id="reload">
-    <property name="name">view-refresh-symbolic</property>
-  </object>
 </interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]