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()
def __init__(self): gtk.HeaderBar.__init__(self) self.set_show_close_button(True) box = gtk.Box(False) self.time_back = gtk.Button.new_from_icon_name("go-previous-symbolic", gtk.IconSize.MENU) self.time_forth = gtk.Button.new_from_icon_name( "go-next-symbolic", gtk.IconSize.MENU) box.add(self.time_back) box.add(self.time_forth) gtk.StyleContext.add_class(box.get_style_context(), "linked") self.pack_start(box) self.range_pick = RangePick(dt.hday.today()) self.pack_start(self.range_pick) self.system_button = gtk.MenuButton() self.system_button.set_image( gtk.Image.new_from_icon_name("open-menu-symbolic", gtk.IconSize.MENU)) self.system_button.set_tooltip_markup(_("Menu")) self.pack_end(self.system_button) self.search_button = gtk.ToggleButton() self.search_button.set_image( gtk.Image.new_from_icon_name("edit-find-symbolic", gtk.IconSize.MENU)) self.search_button.set_tooltip_markup(_("Filter activities")) self.pack_end(self.search_button) self.stop_button = gtk.Button() self.stop_button.set_image( gtk.Image.new_from_icon_name("process-stop-symbolic", gtk.IconSize.MENU)) self.stop_button.set_tooltip_markup(_("Stop tracking (Ctrl-SPACE)")) self.pack_end(self.stop_button) 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.add_activity_button.set_tooltip_markup(_("Add activity (Ctrl-+)")) self.pack_end(self.add_activity_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.menu_help = gtk.MenuItem(label=_("Help")) self.system_menu.append(self.menu_help) self.system_menu.show_all() self.time_back.connect("clicked", self.on_time_back_click) self.time_forth.connect("clicked", self.on_time_forth_click) self.connect("button-press-event", self.on_button_press)