🎉 Add a menu button

This commit is contained in:
Simon Schneegans
2022-01-02 12:37:51 +01:00
parent 7e05588682
commit 8c7e3abbeb
3 changed files with 92 additions and 0 deletions
+30
View File
@@ -75,6 +75,36 @@ var PreferencesDialog = class PreferencesDialog {
// Initialize the fire-preset dropdown.
this._createFirePresets();
// Add a menu to the title bar of the preferences dialog.
this._widget.connect('realize', (widget) => {
const window = widget.get_root();
// Show the version number in the title bar.
window.set_title(`Burn-My-Windows ${Me.metadata.version}`);
// Add the menu.
const menu = this._builder.get_object('menu-button');
window.get_titlebar().pack_end(menu);
// Populate the actions.
const group = Gio.SimpleActionGroup.new();
const addAction = (name, uri) => {
const action = Gio.SimpleAction.new(name, null);
action.connect('activate', () => Gtk.show_uri(null, uri, Gdk.CURRENT_TIME));
group.add_action(action);
};
addAction('homepage', 'https://github.com/Schneegans/Burn-My-Windows');
addAction('bugs', 'https://github.com/Schneegans/Burn-My-Windows/issues');
addAction(
'donate-paypal',
'https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE');
addAction('donate-github', 'https://github.com/sponsors/Schneegans');
window.insert_action_group('prefs', group);
});
// As we do not have something like a destructor, we just listen for the destroy
// signal of our main widget.
this._widget.connect('destroy', () => {
+31
View File
@@ -19,6 +19,37 @@
</data>
</object>
<menu id="main-menu">
<section>
<item>
<attribute name="label" translatable="yes">Visit Homepage</attribute>
<attribute name="action">prefs.homepage</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Report a Bug</attribute>
<attribute name="action">prefs.bugs</attribute>
</item>
</section>
<section>
<submenu>
<attribute name="label" translatable="yes">Donate</attribute>
<item>
<attribute name="label" translatable="yes">Via PayPal</attribute>
<attribute name="action">prefs.donate-paypal</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Via GitHub</attribute>
<attribute name="action">prefs.donate-github</attribute>
</item>
</submenu>
</section>
</menu>
<object class="GtkMenuButton" id="menu-button">
<property name="menu-model">main-menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
<object class="GtkAdjustment" id="destroy-animation-time">
<property name="upper">10000</property>
<property name="lower">500</property>
+31
View File
@@ -27,6 +27,37 @@
</data>
</object>
<menu id="main-menu">
<section>
<item>
<attribute name="label" translatable="yes">Visit Homepage</attribute>
<attribute name="action">prefs.homepage</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Report a Bug</attribute>
<attribute name="action">prefs.bugs</attribute>
</item>
</section>
<section>
<submenu>
<attribute name="label" translatable="yes">Donate</attribute>
<item>
<attribute name="label" translatable="yes">Via PayPal</attribute>
<attribute name="action">prefs.donate-paypal</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Via GitHub</attribute>
<attribute name="action">prefs.donate-github</attribute>
</item>
</submenu>
</section>
</menu>
<object class="GtkMenuButton" id="menu-button">
<property name="menu-model">main-menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
<object class="GtkScrolledWindow" id="settings-widget">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">200</property>