Commit ad509b8c authored by Cédric Bellegarde's avatar Cédric Bellegarde

Remove tab number when there's only one. Fix #308

parent 3c67d9ba
......@@ -23,8 +23,6 @@
<property name="margin_end">3</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="row_spacing">2</property>
<property name="column_spacing">2</property>
<child>
<object class="GtkImage" id="image">
<property name="width_request">22</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.1 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="eolie">
<requires lib="gtk+" version="3.10"/>
<object class="GtkImage" id="image1">
......@@ -143,6 +143,7 @@
<style>
<class name="dim-label"/>
<class name="eolie-count-label"/>
<class name="font-monospace"/>
</style>
</object>
<packing>
......
......@@ -58,6 +58,18 @@
border-radius: 2px;
}
.font-monospace {
font-family: Monospace;
}
.font-small {
font-size: 80%;
}
.bold {
font-weight: bold;
}
.sidebar-item-title {
padding: 0px;
box-shadow: 1px 1px 3px 3px alpha(shade(@theme_bg_color, 1.7), 0.85);
......@@ -136,14 +148,6 @@
background-color: alpha(red, 0.5);
}
.indicator-button {
border: 2px solid white;
background-color: black;
color: white;
padding: 0px;
border-radius: 16px;
}
.tag-base {
box-shadow: none;
background-image: none;
......@@ -193,10 +197,6 @@
color: @theme_selected_bg_color;
}
.bold {
font-weight: bold;
}
.download-button {
padding: 2px;
min-width: 28px;
......
......@@ -20,13 +20,20 @@ class LabelIndicator(Gtk.Label):
Label with an indicator
"""
def __init__(self):
def __init__(self, is_count):
"""
Init label
@param count as bool
"""
Gtk.Label.__init__(self)
if is_count:
self.__margin = 0
self.get_style_context().add_class("font-small")
self.get_style_context().add_class("font-monospace")
else:
self.__margin = 10
self.set_xalign(0.0)
self.set_yalign(0.80)
self.set_yalign(1)
self.__count = 0
self.__unshown = []
......@@ -39,7 +46,11 @@ class LabelIndicator(Gtk.Label):
self.__count += 1
else:
self.__count -= 1
self.set_text(str(max(1, self.__count)))
count = max(1, self.__count)
if count == 1:
self.set_text(" ")
else:
self.set_text(str(count))
def mark_unshown(self, webview):
"""
......@@ -64,7 +75,7 @@ class LabelIndicator(Gtk.Label):
Add circle width
"""
(min, nat) = Gtk.Label.do_get_preferred_width(self)
return (min + 12, nat + 12)
return (min + self.__margin, nat + self.__margin)
def do_draw(self, cr):
"""
......@@ -75,10 +86,10 @@ class LabelIndicator(Gtk.Label):
if self.__unshown:
w = self.get_allocated_width()
cr.stroke()
cr.translate(w - 5, 5)
cr.translate(w - 4, 3)
cr.set_line_width(1)
Gdk.cairo_set_source_color(cr, Gdk.Color.parse("red")[1])
cr.arc(0, 0, 4, 0, 2 * pi)
cr.arc(0, 0, 2, 0, 2 * pi)
cr.stroke_preserve()
Gdk.cairo_set_source_color(cr, Gdk.Color.parse("red")[1])
cr.fill()
......@@ -36,7 +36,7 @@ class PagesManagerChild(Gtk.FlowBoxChild):
builder = Gtk.Builder()
builder.add_from_resource("/org/gnome/Eolie/PagesManagerChild.ui")
builder.connect_signals(self)
self.__indicator_label = LabelIndicator()
self.__indicator_label = LabelIndicator(False)
self.__indicator_label.mark_unshown(view.webview)
self.__indicator_label.set_hexpand(True)
self.__indicator_label.set_margin_right(4)
......
......@@ -161,7 +161,7 @@ class SitesManagerChild(Gtk.ListBoxRow):
builder.add_from_resource("/org/gnome/Eolie/SitesManagerChild.ui")
builder.connect_signals(self)
widget = builder.get_object("widget")
self.__indicator_label = LabelIndicator()
self.__indicator_label = LabelIndicator(True)
self.__indicator_label.set_property("halign", Gtk.Align.CENTER)
self.__indicator_label.show()
self.__separator = builder.get_object("separator")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment