[epiphany] Do not show close button for pinned tabs in tabs popover



commit f04e085814487dc4d6d7dac134f185cf45d368ae
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Tue May 28 20:24:02 2019 +0200

    Do not show close button for pinned tabs in tabs popover
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/792

 src/ephy-page-row.c           |  5 +++++
 src/ephy-tab-label.c          | 15 +++++++++++++++
 src/resources/gtk/page-row.ui |  2 ++
 3 files changed, 22 insertions(+)
---
diff --git a/src/ephy-page-row.c b/src/ephy-page-row.c
index 24da63723..56a5bb346 100644
--- a/src/ephy-page-row.c
+++ b/src/ephy-page-row.c
@@ -40,6 +40,7 @@ struct _EphyPageRow {
   GtkImage *speaker_icon;
   GtkSpinner *spinner;
   GtkLabel *title;
+  GtkButton *close_button;
 };
 
 static guint signals[LAST_SIGNAL];
@@ -118,6 +119,7 @@ ephy_page_row_class_init (EphyPageRowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, EphyPageRow, speaker_icon);
   gtk_widget_class_bind_template_child (widget_class, EphyPageRow, spinner);
   gtk_widget_class_bind_template_child (widget_class, EphyPageRow, title);
+  gtk_widget_class_bind_template_child (widget_class, EphyPageRow, close_button);
   gtk_widget_class_bind_template_callback (widget_class, close_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, button_release_event);
 }
@@ -151,6 +153,7 @@ ephy_page_row_new (EphyNotebook *notebook,
 {
   EphyPageRow *self;
   GtkWidget *embed;
+  GtkWidget *tab_label;
   EphyWebView *view;
 
   g_assert (notebook != NULL);
@@ -162,6 +165,7 @@ ephy_page_row_new (EphyNotebook *notebook,
 
   g_assert (EPHY_IS_EMBED (embed));
 
+  tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), embed);
   view = ephy_embed_get_web_view (EPHY_EMBED (embed));
 
   sync_favicon (view, NULL, self);
@@ -169,6 +173,7 @@ ephy_page_row_new (EphyNotebook *notebook,
   g_object_bind_property (embed, "title", self->title, "label", G_BINDING_SYNC_CREATE);
   g_object_bind_property (embed, "title", self->title, "tooltip-text", G_BINDING_SYNC_CREATE);
   g_object_bind_property (view, "is-playing-audio", self->speaker_icon, "visible", G_BINDING_SYNC_CREATE);
+  g_object_bind_property (tab_label, "pinned", self->close_button, "visible", G_BINDING_SYNC_CREATE | 
G_BINDING_INVERT_BOOLEAN);
   sync_load_status (view, NULL, self);
   g_signal_connect_object (view, "load-changed",
                            G_CALLBACK (load_changed_cb), self, 0);
diff --git a/src/ephy-tab-label.c b/src/ephy-tab-label.c
index 7a23557dd..0b363693e 100644
--- a/src/ephy-tab-label.c
+++ b/src/ephy-tab-label.c
@@ -53,6 +53,7 @@ enum {
   PROP_ICON_BUF,
   PROP_SPINNING,
   PROP_AUDIO,
+  PROP_PINNED,
   LAST_PROP
 };
 
@@ -120,6 +121,9 @@ ephy_tab_label_set_property (GObject      *object,
   case PROP_AUDIO:
     gtk_widget_set_visible (self->audio_button, g_value_get_boolean (value));
     break;
+  case PROP_PINNED:
+    self->is_pinned = g_value_get_boolean (value);
+    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     break;
@@ -149,6 +153,9 @@ ephy_tab_label_get_property (GObject    *object,
   case PROP_AUDIO:
     g_value_set_boolean (value, gtk_widget_get_visible (self->audio_button));
     break;
+  case PROP_PINNED:
+    g_value_set_boolean (value, self->is_pinned);
+    break;
   default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    break;
@@ -248,6 +255,12 @@ ephy_tab_label_class_init (EphyTabLabelClass *klass)
                                                      FALSE,
                                                      G_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT);
+  obj_properties[PROP_PINNED] = g_param_spec_boolean ("pinned",
+                                                      "Pinned",
+                                                      "Is tab pinned",
+                                                      FALSE,
+                                                      G_PARAM_READWRITE |
+                                                      G_PARAM_CONSTRUCT);
   g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
 
   signals[CLOSE_CLICKED] = g_signal_new ("close-clicked",
@@ -306,6 +319,8 @@ ephy_tab_label_set_pinned (GtkWidget *widget,
   ephy_tab_label_update_icon (self);
 
   update_label (self);
+
+  g_object_notify_by_pspec (G_OBJECT (self), obj_properties[PROP_PINNED]);
 }
 
 gboolean
diff --git a/src/resources/gtk/page-row.ui b/src/resources/gtk/page-row.ui
index 2b6fcadfb..17bcb9278 100644
--- a/src/resources/gtk/page-row.ui
+++ b/src/resources/gtk/page-row.ui
@@ -24,6 +24,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="icon_size">1</property>
+                    <property name="margin_top">6</property>
+                    <property name="margin_bottom">6</property>
                   </object>
                 </child>
                 <child>


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