def titlebar(self): header = Handy.Leaflet() header.set_mode_transition_type(Handy.LeafletModeTransitionType.SLIDE) header.set_child_transition_type( Handy.LeafletChildTransitionType.SLIDE) header.connect("notify::visible-child", self._update_decorations) header.connect("notify::fold", self._update_decorations) left_header = Gtk.HeaderBar() left_header.props.show_close_button = True right_header = Gtk.HeaderBar() right_header.props.show_close_button = True right_header.props.hexpand = True self._left_header = left_header self._right_header = right_header left_header.get_style_context().add_class("titlebar") left_header.get_style_context().add_class("tweak-titlebar-left") right_header.get_style_context().add_class("titlebar") right_header.get_style_context().add_class("tweak-titlebar-right") self._group_titlebar_widget = None self.title = Gtk.Label(label="") self.title.get_style_context().add_class("title") right_header.set_custom_title(self.title) self.back_button = Gtk.Button.new_from_icon_name( "go-previous-symbolic", 1) self.back_button.connect("clicked", self._on_back_clicked) header.bind_property("folded", self.back_button, "visible") right_header.pack_start(self.back_button) icon = Gtk.Image() icon.set_from_icon_name("edit-find-symbolic", Gtk.IconSize.MENU) self.button = Gtk.ToggleButton() self.button.add(icon) self.button.connect("toggled", self._on_find_toggled) self.button.props.valign = Gtk.Align.CENTER self.button.get_style_context().add_class("image-button") left_header.pack_start(self.button) lbl = Gtk.Label(label=_("Tweaks")) lbl.get_style_context().add_class("title") left_header.set_custom_title(lbl) self.builder = Gtk.Builder() assert (os.path.exists(gtweak.PKG_DATA_DIR)) filename = os.path.join(gtweak.PKG_DATA_DIR, 'shell.ui') self.builder.add_from_file(filename) appmenu = self.builder.get_object('appmenu') icon = Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="open-menu-symbolic"), Gtk.IconSize.BUTTON) self.menu_btn.set_image(icon) self.menu_btn.set_menu_model(appmenu) left_header.pack_end(self.menu_btn) header.add(left_header) header.child_set(left_header, name="sidebar") header.add(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)) header.add(right_header) header.child_set(right_header, name="content") self.header_group = Handy.HeaderGroup() self.header_group.add_header_bar(left_header) self.header_group.add_header_bar(right_header) self.hsize_group.add_widget(left_header) return header
def create_titlebar(self): self._group_titlebar_widget = None header = Handy.Leaflet() header.set_mode_transition_type(Handy.LeafletModeTransitionType.SLIDE) header.set_child_transition_type( Handy.LeafletChildTransitionType.SLIDE) header.connect("notify::visible-child", self._update_decorations) header.connect("notify::fold", self._update_decorations) lbl = Gtk.Label(label="Options") lbl.get_style_context().add_class("title") icon1 = Gtk.Image() icon1.set_from_icon_name("edit-find-symbolic", Gtk.IconSize.MENU) icon2 = Gtk.Image.new_from_gicon( Gio.ThemedIcon(name="open-menu-symbolic"), Gtk.IconSize.BUTTON) self.button = Gtk.ToggleButton() self.button.add(icon1) self.button.connect("toggled", self._on_find_toggled) self.button.props.valign = Gtk.Align.CENTER appmenu = Gio.Menu() appmenu.append("About Magnifier Tweaks", "win.about") self.menu_btn = Gtk.MenuButton() self.menu_btn.set_image(icon2) self.menu_btn.set_menu_model(appmenu) left_header = Gtk.HeaderBar() left_header.props.show_close_button = True left_header.set_custom_title(lbl) left_header.pack_start(self.button) left_header.pack_end(self.menu_btn) self._left_header = left_header self.title = Gtk.Label(label="") self.back_button = Gtk.Button.new_from_icon_name( "go-previous-symbolic", 1) self.back_button.connect("clicked", self._on_back_clicked) right_header = Gtk.HeaderBar() right_header.props.show_close_button = True right_header.props.hexpand = True right_header.set_custom_title(self.title) right_header.pack_start(self.back_button) self._right_header = right_header header.add(left_header) header.add(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)) header.add(right_header) header.child_set(left_header, name="sidebar") header.child_set(right_header, name="content") header.bind_property("folded", self.back_button, "visible") self.header_group = Handy.HeaderGroup() self.header_group.add_header_bar(left_header) self.header_group.add_header_bar(right_header) self.hsize_group.add_widget(left_header) action_about = Gio.SimpleAction.new("about", None) action_about.connect("activate", self._on_activate_about) self.add_action(action_about) return header