[epiphany] Add pinned tabs notification



commit f798206b786b03e5d2696947b305be0b9ba38f1c
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sun Jul 7 20:30:31 2019 +0200

    Add pinned tabs notification
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/797

 src/ephy-notebook.c                     | 23 +++++++++++++++++++----
 src/ephy-tab-label.c                    | 10 ++++++++++
 src/ephy-tab-label.h                    | 12 +++++++-----
 src/resources/themes/Adwaita-dark.css   |  4 ++++
 src/resources/themes/Adwaita.css        |  4 ++++
 src/resources/themes/_Adwaita-base.scss | 10 ++++++++++
 src/resources/themes/_shared-base.scss  |  7 +++++++
 src/resources/themes/shared.css         |  2 ++
 8 files changed, 63 insertions(+), 9 deletions(-)
---
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 8fa0e6cb7..ec3f6dee8 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -255,11 +255,16 @@ ephy_notebook_switch_page_cb (GtkNotebook *notebook,
 {
   EphyNotebook *nb = EPHY_NOTEBOOK (notebook);
   GtkWidget *child;
+  GtkWidget *tab_label;
 
   child = gtk_notebook_get_nth_page (notebook, page_num);
   if (!ephy_web_view_is_in_auth_dialog (ephy_embed_get_web_view (EPHY_EMBED (child))))
     gtk_widget_grab_focus (child);
 
+  tab_label = gtk_notebook_get_tab_label (notebook, page);
+  if (ephy_tab_label_is_pinned (tab_label))
+    ephy_tab_label_set_needs_attention (tab_label, FALSE);
+
   /* Remove the old page, we dont want to grow unnecessarily
    * the list */
   if (nb->focused_pages) {
@@ -671,11 +676,21 @@ ephy_notebook_rebuild_tab_menu (EphyNotebook *notebook)
 }
 
 static void
-rebuild_tab_menu_cb (EphyEmbed    *embed,
-                     GParamSpec   *pspec,
-                     EphyNotebook *notebook)
+title_changed_cb (EphyEmbed    *embed,
+                  GParamSpec   *pspec,
+                  EphyNotebook *notebook)
 {
+  GtkWidget *tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), GTK_WIDGET (embed));
+
   ephy_notebook_rebuild_tab_menu (notebook);
+
+  if (ephy_tab_label_is_pinned (tab_label)) {
+    int current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+    int page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET (embed));
+
+    if (current_page != page_num)
+      ephy_tab_label_set_needs_attention (tab_label, TRUE);
+  }
 }
 
 static void
@@ -708,7 +723,7 @@ build_tab_label (EphyNotebook *nb, EphyEmbed *embed)
   view = ephy_embed_get_web_view (embed);
 
   g_signal_connect_object (embed, "notify::title",
-                           G_CALLBACK (rebuild_tab_menu_cb), nb, 0);
+                           G_CALLBACK (title_changed_cb), nb, 0);
 
   g_object_bind_property (view, "title", tab_label, "label-text", G_BINDING_DEFAULT);
   g_object_bind_property (view, "display-address", tab_label, "label-uri", G_BINDING_DEFAULT);
diff --git a/src/ephy-tab-label.c b/src/ephy-tab-label.c
index a0991a56a..67cdd85c9 100644
--- a/src/ephy-tab-label.c
+++ b/src/ephy-tab-label.c
@@ -333,3 +333,13 @@ ephy_tab_label_is_pinned (GtkWidget *widget)
 
   return self->is_pinned;
 }
+
+void
+ephy_tab_label_set_needs_attention (GtkWidget *widget,
+                                    gboolean   attention)
+{
+  if (attention)
+    gtk_style_context_add_class (gtk_widget_get_style_context (widget), "tab-attention");
+  else
+    gtk_style_context_remove_class (gtk_widget_get_style_context (widget), "tab-attention");
+}
diff --git a/src/ephy-tab-label.h b/src/ephy-tab-label.h
index 4df1ef65f..b444bacfb 100644
--- a/src/ephy-tab-label.h
+++ b/src/ephy-tab-label.h
@@ -30,10 +30,12 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EphyTabLabel, ephy_tab_label, EPHY, TAB_LABEL, GtkBox);
 
-GtkWidget   *ephy_tab_label_new        (void);
-const gchar *ephy_tab_label_get_text   (GtkWidget *self);
-void         ephy_tab_label_set_pinned (GtkWidget *self,
-                                        gboolean   is_pinned);
-gboolean     ephy_tab_label_is_pinned  (GtkWidget *self);
+GtkWidget   *ephy_tab_label_new                 (void);
+const gchar *ephy_tab_label_get_text            (GtkWidget *self);
+void         ephy_tab_label_set_pinned          (GtkWidget *self,
+                                                 gboolean   is_pinned);
+gboolean     ephy_tab_label_is_pinned           (GtkWidget *self);
+void         ephy_tab_label_set_needs_attention (GtkWidget *self,
+                                                 gboolean   attention);
 
 G_END_DECLS
diff --git a/src/resources/themes/Adwaita-dark.css b/src/resources/themes/Adwaita-dark.css
index 66f8d6c81..8094d436b 100644
--- a/src/resources/themes/Adwaita-dark.css
+++ b/src/resources/themes/Adwaita-dark.css
@@ -46,6 +46,8 @@
 
 .url_progress trough { border: none; background-color: transparent; background-image: none; }
 
+.tab-attention { background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, 
to(@theme_selected_bg_color), to(transparent)); background-size: 6px 6px; background-repeat: no-repeat; 
background-position: center bottom; }
+
 .incognito-mode headerbar { background: #141927 -gtk-icontheme("user-not-tracked-symbolic") 180px 0/64px 
64px no-repeat, linear-gradient(to top, #1a2235, #1e263b); box-shadow: inset 0 1px rgba(238, 238, 236, 0.07); 
border-color: #0b0e16; color: rgba(238, 238, 236, 0.2); }
 
 .incognito-mode headerbar:backdrop { background-image: -gtk-icontheme("user-not-tracked-symbolic"), 
image(#252f49); box-shadow: inset 0 1px rgba(238, 238, 236, 0.07); color: rgba(137, 142, 155, 0.1); }
@@ -241,3 +243,5 @@ window:not(.incognito-mode) .main-notebook tab:not(.reorderable-page):checked:ho
 window:not(.incognito-mode) .main-notebook tab:not(.reorderable-page):backdrop:checked { border-color: 
#202020; background-color: #353535; }
 
 .search-entry-occurrences-tag { background-color: @theme_base_color; background-image: none; color: 
shade(@theme_unfocused_fg_color, 0.8); border: 0px; margin: 2px; padding: 2px; }
+
+.tab-attention { background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, to(#1f76e1), 
to(transparent)); background-size: 6px 6px; background-repeat: no-repeat; background-position: center bottom; 
}
diff --git a/src/resources/themes/Adwaita.css b/src/resources/themes/Adwaita.css
index 8eda3d2c4..3f72944cc 100644
--- a/src/resources/themes/Adwaita.css
+++ b/src/resources/themes/Adwaita.css
@@ -46,6 +46,8 @@
 
 .url_progress trough { border: none; background-color: transparent; background-image: none; }
 
+.tab-attention { background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, 
to(@theme_selected_bg_color), to(transparent)); background-size: 6px 6px; background-repeat: no-repeat; 
background-position: center bottom; }
+
 .incognito-mode headerbar { background: #c4d6e9 -gtk-icontheme("user-not-tracked-symbolic") 180px 0/64px 
64px no-repeat, linear-gradient(to top, #bdd1e6, #c8d9ea); box-shadow: inset 0 1px rgba(255, 255, 255, 0.8); 
border-color: #9cb9da; color: rgba(46, 52, 54, 0.2); }
 
 .incognito-mode headerbar:backdrop { background-image: -gtk-icontheme("user-not-tracked-symbolic"), 
image(#eaf0f7); box-shadow: inset 0 1px rgba(255, 255, 255, 0.8); color: rgba(140, 146, 150, 0.1); }
@@ -241,3 +243,5 @@ window:not(.incognito-mode) .main-notebook tab:not(.reorderable-page):checked:ho
 window:not(.incognito-mode) .main-notebook tab:not(.reorderable-page):backdrop:checked { border-color: 
#d5d0cc; background-color: #f6f5f4; }
 
 .search-entry-occurrences-tag { background-color: @theme_base_color; background-image: none; color: 
shade(@theme_unfocused_fg_color, 0.8); border: 0px; margin: 2px; padding: 2px; }
+
+.tab-attention { background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, to(#3584e4), 
to(transparent)); background-size: 6px 6px; background-repeat: no-repeat; background-position: center bottom; 
}
diff --git a/src/resources/themes/_Adwaita-base.scss b/src/resources/themes/_Adwaita-base.scss
index 05743848d..db3b1936c 100644
--- a/src/resources/themes/_Adwaita-base.scss
+++ b/src/resources/themes/_Adwaita-base.scss
@@ -347,3 +347,13 @@ window:not(.incognito-mode) .main-notebook tab:not(.reorderable-page) {
   margin: 2px;
   padding: 2px;
 }
+
+.tab-attention {
+  $_dot_color: if($variant=='light', $selected_bg_color,
+                                   lighten($selected_bg_color,15%));
+  background-image: -gtk-gradient(radial,
+                                  center center, 0,
+                                  center center, 0.5,
+                                  to($_dot_color),
+                                  to(transparent));
+}
diff --git a/src/resources/themes/_shared-base.scss b/src/resources/themes/_shared-base.scss
index 84f339b9c..d2d69b294 100644
--- a/src/resources/themes/_shared-base.scss
+++ b/src/resources/themes/_shared-base.scss
@@ -141,3 +141,10 @@
     background-image: none;
   }
 }
+
+.tab-attention {
+  background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, 
to(themecolor(theme_selected_bg_color)), to(transparent));
+  background-size: 6px 6px;
+  background-repeat: no-repeat;
+  background-position: center bottom;
+}
\ No newline at end of file
diff --git a/src/resources/themes/shared.css b/src/resources/themes/shared.css
index a64e4d8de..21d2c28d2 100644
--- a/src/resources/themes/shared.css
+++ b/src/resources/themes/shared.css
@@ -45,3 +45,5 @@
 .url_progress progress { background-color: @theme_selected_bg_color; background-image: none; border: none; 
min-height: 2px; }
 
 .url_progress trough { border: none; background-color: transparent; background-image: none; }
+
+.tab-attention { background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, 
to(@theme_selected_bg_color), to(transparent)); background-size: 6px 6px; background-repeat: no-repeat; 
background-position: center bottom; }


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