def __init__(self, uuid):
Budgie.Applet.__init__(self)
self.uuid = uuid
self.connect("destroy", Gtk.main_quit)
self.settings = cw.settings
icon = Gtk.Image.new_from_icon_name(
"budgie-clockworks-panel", Gtk.IconSize.MENU
)
self.provider = Gtk.CssProvider.new()
self.provider.load_from_data(css_data.encode())
# maingrid
self.maingrid = Gtk.Grid()
self.maingrid.set_row_spacing(2)
self.maingrid.attach(Gtk.Label(" " * 10), 0, 0, 1, 1)
self.maingrid.set_column_spacing(5)
self.clocklist = {}
# create initial clock if it does not exists
currcl_data = self.read_datafile()
if currcl_data:
for cl in currcl_data:
off = cl[1]
clname = cl[2]
self.create_newclock(offset=off, clockname=clname)
else:
self.create_newclock(offset=0)
self.dashbuttonbox = Gtk.Box()
self.add_button = Gtk.Button()
self.add_button.set_relief(Gtk.ReliefStyle.NONE)
self.add_icon = Gtk.Image.new_from_icon_name(
"list-add-symbolic", Gtk.IconSize.MENU
)
self.add_button.set_image(self.add_icon)
self.search_button = Gtk.Button()
self.search_button.set_relief(Gtk.ReliefStyle.NONE)
self.search_icon = Gtk.Image.new_from_icon_name(
"system-search-symbolic", Gtk.IconSize.MENU
)
self.search_button.set_image(self.search_icon)
self.add_button.connect("clicked", self.create_newclock)
self.search_button.connect("clicked", self.run_search)
self.maingrid.attach(self.add_button, 100, 3, 1, 1)
self.maingrid.attach(self.search_button, 100, 4, 1, 1)
# throw it in popover
self.box = Gtk.EventBox()
self.box.add(icon)
self.add(self.box)
self.popover = Budgie.Popover.new(self.box)
self.popover.add(self.maingrid)
self.popover.get_child().show_all()
self.box.show_all()
self.show_all()
self.box.connect("button-press-event", self.on_press)
self.settings.connect("changed", self.update_clockcolor)
# thread
GObject.threads_init()
self.update = Thread(target=self.update_gmt)
# daemonize the thread to make the indicator stopable
self.update.setDaemon(True)
self.update.start()
评论列表
文章目录