class HeaderBar(gtk.HeaderBar): def __init__(self): gtk.HeaderBar.__init__(self) self.set_show_close_button(True) box = gtk.Box(False) time_back = gtk.Button.new_from_icon_name("go-previous-symbolic", gtk.IconSize.MENU) time_forth = gtk.Button.new_from_icon_name("go-next-symbolic", gtk.IconSize.MENU) box.add(time_back) box.add(time_forth) gtk.StyleContext.add_class(box.get_style_context(), "linked") self.pack_start(box) self.range_pick = RangePick( dt.datetime.today()) # TODO - use hamster day self.pack_start(self.range_pick) self.add_activity_button = gtk.Button() self.add_activity_button.set_image( gtk.Image.new_from_icon_name("list-add-symbolic", gtk.IconSize.MENU)) self.pack_end(self.add_activity_button) self.search_button = gtk.ToggleButton() self.search_button.set_image( gtk.Image.new_from_icon_name("edit-find-symbolic", gtk.IconSize.MENU)) self.pack_end(self.search_button) self.system_button = gtk.MenuButton() self.system_button.set_image( gtk.Image.new_from_icon_name("emblem-system-symbolic", gtk.IconSize.MENU)) self.pack_end(self.system_button) self.system_menu = gtk.Menu() self.system_button.set_popup(self.system_menu) self.menu_export = gtk.MenuItem(label=_("Export...")) self.system_menu.append(self.menu_export) self.menu_prefs = gtk.MenuItem(label=_("Tracking Settings")) self.system_menu.append(self.menu_prefs) self.system_menu.show_all() time_back.connect("clicked", self.on_time_back_click) time_forth.connect("clicked", self.on_time_forth_click) self.connect("button-press-event", self.on_button_press) def on_button_press(self, bar, event): """swallow clicks on the interactive parts to avoid triggering switch to full-window""" return True def on_time_back_click(self, button): self.range_pick.prev_range() def on_time_forth_click(self, button): self.range_pick.next_range()
class HeaderBar(gtk.HeaderBar): def __init__(self): gtk.HeaderBar.__init__(self) self.set_show_close_button(True) box = gtk.Box(False) time_back = gtk.Button.new_from_icon_name("go-previous-symbolic", gtk.IconSize.MENU) time_forth = gtk.Button.new_from_icon_name("go-next-symbolic", gtk.IconSize.MENU) box.add(time_back) box.add(time_forth) gtk.StyleContext.add_class(box.get_style_context(), "linked") self.pack_start(box) self.range_pick = RangePick(dt.datetime.today()) # TODO - use hamster day self.pack_start(self.range_pick) self.add_activity_button = gtk.Button() self.add_activity_button.set_image(gtk.Image.new_from_icon_name("list-add-symbolic", gtk.IconSize.MENU)) self.pack_end(self.add_activity_button) self.search_button = gtk.ToggleButton() self.search_button.set_image(gtk.Image.new_from_icon_name("edit-find-symbolic", gtk.IconSize.MENU)) self.pack_end(self.search_button) self.system_button = gtk.MenuButton() self.system_button.set_image(gtk.Image.new_from_icon_name("emblem-system-symbolic", gtk.IconSize.MENU)) self.pack_end(self.system_button) self.system_menu = gtk.Menu() self.system_button.set_popup(self.system_menu) self.menu_export = gtk.MenuItem(label="Export...") self.system_menu.append(self.menu_export) self.menu_prefs = gtk.MenuItem(label="Tracking Settings") self.system_menu.append(self.menu_prefs) self.system_menu.show_all() time_back.connect("clicked", self.on_time_back_click) time_forth.connect("clicked", self.on_time_forth_click) self.connect("button-press-event", self.on_button_press) def on_button_press(self, bar, event): """swallow clicks on the interactive parts to avoid triggering switch to full-window""" return True def on_time_back_click(self, button): self.range_pick.prev_range() def on_time_forth_click(self, button): self.range_pick.next_range()