Unify menus and put all headerbar buttons on the left

This commit is contained in:
Rafał Dzięgiel
2021-02-04 15:47:14 +01:00
parent a7d99c4f81
commit 3cd98befb1
2 changed files with 7 additions and 19 deletions

View File

@@ -14,27 +14,17 @@ class ClapperHeaderBarBase extends Gtk.HeaderBar
const uiBuilder = Gtk.Builder.new_from_file( const uiBuilder = Gtk.Builder.new_from_file(
`${clapperPath}/ui/clapper.ui` `${clapperPath}/ui/clapper.ui`
); );
const models = {
addMediaMenu: uiBuilder.get_object('addMediaMenu'),
settingsMenu: uiBuilder.get_object('settingsMenu'),
};
this.add_css_class('noborder'); this.add_css_class('noborder');
this.set_title_widget(this._createWidgetForWindow(window)); this.set_title_widget(this._createWidgetForWindow(window));
const addMediaButton = new Gtk.MenuButton({ const mainMenuButton = new Gtk.MenuButton({
icon_name: 'list-add-symbolic',
});
const addMediaPopover = new HeaderBarPopover(models.addMediaMenu);
addMediaButton.set_popover(addMediaPopover);
this.pack_start(addMediaButton);
const openMenuButton = new Gtk.MenuButton({
icon_name: 'open-menu-symbolic', icon_name: 'open-menu-symbolic',
}); });
const settingsPopover = new HeaderBarPopover(models.settingsMenu); const mainMenuModel = uiBuilder.get_object('mainMenu');
openMenuButton.set_popover(settingsPopover); const mainMenuPopover = new HeaderBarPopover(mainMenuModel);
this.pack_end(openMenuButton); mainMenuButton.set_popover(mainMenuPopover);
this.pack_start(mainMenuButton);
const buttonsBox = new Gtk.Box({ const buttonsBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL, orientation: Gtk.Orientation.HORIZONTAL,
@@ -53,7 +43,7 @@ class ClapperHeaderBarBase extends Gtk.HeaderBar
fullscreenButton.connect('clicked', this._onFullscreenButtonClicked.bind(this)); fullscreenButton.connect('clicked', this._onFullscreenButtonClicked.bind(this));
buttonsBox.append(fullscreenButton); buttonsBox.append(fullscreenButton);
this.pack_end(buttonsBox); this.pack_start(buttonsBox);
} }
updateHeaderBar(title, subtitle) updateHeaderBar(title, subtitle)

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<menu id="addMediaMenu"> <menu id="mainMenu">
<section> <section>
<item> <item>
<attribute name="label" translatable="yes">Open Local...</attribute> <attribute name="label" translatable="yes">Open Local...</attribute>
@@ -11,8 +11,6 @@
<attribute name="action">app.openUri</attribute> <attribute name="action">app.openUri</attribute>
</item> </item>
</section> </section>
</menu>
<menu id="settingsMenu">
<section> <section>
<item> <item>
<attribute name="label" translatable="yes">Preferences</attribute> <attribute name="label" translatable="yes">Preferences</attribute>