Exemple #1
0
    def __init__(self, uuid):
        Budgie.Applet.__init__(self)

        # files & colors
        self.tcolorfile = clt.timecolor
        self.dcolorfile = clt.datecolor
        mute_time = clt.mute_time
        mute_date = clt.mute_date
        # grid & layout
        maingrid = Gtk.Grid()
        maingrid.set_row_spacing(10)
        element_hsizer1 = self.h_spacer(13)
        maingrid.attach(element_hsizer1, 0, 0, 1, 7)
        element_hsizer2 = self.h_spacer(25)
        maingrid.attach(element_hsizer2, 2, 0, 1, 7)
        # toggle buttons
        self.runtime = Gtk.CheckButton("Show time")
        self.rundate = Gtk.CheckButton("Show date")
        self.runtime.set_active(not os.path.exists(mute_time))
        self.rundate.set_active(not os.path.exists(mute_date))
        self.runtime.connect("toggled", self.toggle_show, mute_time)
        self.rundate.connect("toggled", self.toggle_show, mute_date)
        maingrid.attach(self.runtime, 1, 1, 1, 1)
        maingrid.attach(self.rundate, 1, 2, 1, 1)
        # color buttons & labels
        bholder1 = Gtk.Box()
        maingrid.attach(bholder1, 1, 4, 1, 1)
        self.t_color = Gtk.Button()
        self.t_color.connect("clicked", self.pick_color, self.tcolorfile)
        self.t_color.set_size_request(25, 25)
        bholder1.pack_start(self.t_color, False, False, 0)
        timelabel = Gtk.Label(" Set time color")
        bholder1.pack_start(timelabel, False, False, 0)
        #
        bholder2 = Gtk.Box()
        maingrid.attach(bholder2, 1, 5, 1, 1)
        self.d_color = Gtk.Button()
        self.d_color.connect("clicked", self.pick_color, self.dcolorfile)
        self.d_color.set_size_request(25, 25)
        bholder2.pack_start(self.d_color, False, False, 0)
        datelabel = Gtk.Label(" Set date color")
        bholder2.pack_start(datelabel, False, False, 0)
        # and the rest
        self.box = Gtk.EventBox()
        icon = Gtk.Image.new_from_icon_name("bshowtime-panel",
                                            Gtk.IconSize.MENU)
        self.box.add(icon)
        self.add(self.box)
        self.popover = Budgie.Popover.new(self.box)
        self.popover.add(maingrid)
        self.popover.get_child().show_all()
        self.box.show_all()
        self.show_all()
        self.box.connect("button-press-event", self.on_press)
        # set colors and run clock
        self.update_color()
        clt.restart_clock()
Exemple #2
0
 def toggle_show(self, button, file):
     newstate = button.get_active()
     if newstate:
         try:
             os.remove(file)
         except FileNotGoundError:
             pass
     else:
         open(file, "wt").write("")
     clt.restart_clock()
 def get_xy(self, button):
     x = self.xpos.get_text()
     y = self.ypos.get_text()
     # check for correct input
     try:
         newpos = [str(int(p)) for p in [x, y]]
         open(cpos_file, "wt").write("\n".join(newpos))
     except (FileNotFoundError, ValueError, IndexError):
         pass
     clt.restart_clock()
 def toggle_12(self, button, file):
     # cannot be included in toggle_show, flipped boolean
     if not button.get_active():
         try:
             os.remove(file)
         except FileNotFoundError:
             pass
     else:
         open(file, "wt").write("")
     clt.restart_clock()
 def toggle_cuspos(self, button):
     newstate = button.get_active()
     for widget in [
             self.ypos, self.xpos, self.xpos_label, self.ypos_label,
             self.apply
     ]:
         widget.set_sensitive(newstate)
     if newstate is False:
         self.xpos.set_text("")
         self.ypos.set_text("")
         try:
             os.remove(cpos_file)
         except FileNotFoundError:
             pass
         else:
             clt.restart_clock()
 def toggle_show(self, button, file):
     try:
         corr_file = [self.mute_time, self.mute_date].index(file)
     except ValueError:
         pass
     newstate = button.get_active()
     if newstate:
         try:
             os.remove(file)
         except FileNotFoundError:
             pass
     else:
         open(file, "wt").write("")
     try:
         if corr_file == 0:
             self.set_timestate()
         elif corr_file == 1:
             self.set_datestate()
     except UnboundLocalError:
         pass
     clt.restart_clock()
 def __init__(self, uuid):
     Budgie.Applet.__init__(self)
     self.uuid = uuid
     clt.restart_clock()