Commit 0ff90740 authored by Cédric Bellegarde's avatar Cédric Bellegarde

Add LabelIndicator

parent e8b6167a
......@@ -32,20 +32,6 @@
<property name="can_focus">False</property>
<property name="valign">end</property>
<property name="vexpand">True</property>
<child>
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEventBox" id="close">
<property name="visible">True</property>
......@@ -65,6 +51,9 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<style>
<class name="sidebar-item-title"/>
</style>
......
......@@ -6,28 +6,14 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkGrid">
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_right">2</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="column_spacing">2</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">end</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="image">
<property name="width_request">22</property>
......@@ -44,6 +30,9 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<style>
......
......@@ -52,10 +52,6 @@
outline-width: 0px;
}
.sidebar-item-unread {
border-color: red;
}
.sidebar-item-selected {
border-color: @theme_selected_bg_color;
background-color: @theme_selected_bg_color;
......
......@@ -22,6 +22,7 @@ app_PYTHON = \
helper_dbus.py\
helper_passwords.py\
helper_task.py\
label_indicator.py\
languages.py\
list.py\
localized.py\
......
......@@ -99,11 +99,11 @@ class PagesManager(Gtk.EventBox):
class_name = "sidebar-item-selected"
if child.view == visible:
style_context.add_class(class_name)
style_context.remove_class("sidebar-item-unread")
child.label_indicator.show_indicator(False)
else:
style_context.remove_class(class_name)
if child.view.webview.access_time == 0:
style_context.add_class("sidebar-item-unread")
child.label_indicator.show_indicator(True)
self.__window.container.sites_manager.update_visible_child()
def destroy(self):
......
......@@ -15,6 +15,7 @@ from gi.repository import Gtk, GLib, WebKit2
import cairo
from urllib.parse import urlparse
from eolie.label_indicator import LabelIndicator
from eolie.define import El, ArtSize
from eolie.utils import resize_favicon
......@@ -38,7 +39,11 @@ class PagesManagerChild(Gtk.FlowBoxChild):
builder = Gtk.Builder()
builder.add_from_resource("/org/gnome/Eolie/PagesManagerChild.ui")
builder.connect_signals(self)
self.__title = builder.get_object("title")
self.__title = LabelIndicator()
self.__title.set_hexpand(True)
self.__title.set_property("halign", Gtk.Align.CENTER)
self.__title.show()
builder.get_object("grid").attach(self.__title, 0, 0, 1, 1)
self.__image = builder.get_object("image")
self.__image_close = builder.get_object("image_close")
self.__audio_indicator = builder.get_object("audio_indicator")
......@@ -113,6 +118,14 @@ class PagesManagerChild(Gtk.FlowBoxChild):
self.__on_snapshot,
uri)
@property
def label_indicator(self):
"""
Get label indicator
@return LabelIndicator
"""
return self.__title
@property
def view(self):
"""
......
......@@ -12,6 +12,7 @@
from gi.repository import Gtk
from eolie.label_indicator import LabelIndicator
from eolie.define import El, ArtSize
......@@ -38,7 +39,9 @@ class SitesManagerChild(Gtk.ListBoxRow):
builder.add_from_resource("/org/gnome/Eolie/SitesManagerChild.ui")
builder.connect_signals(self)
widget = builder.get_object("widget")
self.__label = builder.get_object("label")
self.__label = LabelIndicator()
self.__label.show()
builder.get_object("grid").add(self.__label)
self.__image = builder.get_object("image")
self.__image.set_property("pixel-size", ArtSize.FAVICON)
self.add(widget)
......@@ -83,9 +86,10 @@ class SitesManagerChild(Gtk.ListBoxRow):
unread = True
i += 1
if unread:
self.__label.set_markup("<span color='red'><b>%s</b></span>" % i)
self.__label.show_indicator(True)
else:
self.__label.set_text(str(i))
self.__label.show_indicator(False)
self.__label.set_text(str(i))
def reset(self, netloc):
"""
......
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