| 1 |
const Gdk = imports.gi.Gdk; |
| 2 |
const GObject = imports.gi.GObject; |
| 3 |
const Gtk = imports.gi.Gtk; |
| 4 |
const Lang = imports.lang; |
| 5 |
|
| 6 |
var TopbarNavButton = new Lang.Class({ |
| 7 |
Name: 'TopbarNavButton', |
| 8 |
GTypeName: 'EosTopbarNavButton', |
| 9 |
Extends: Gtk.Box, |
| 10 |
Properties: { |
| 11 |
'back-button': GObject.ParamSpec.object('back-button', 'Back button', |
| 12 |
'Topbar back button widget', |
| 13 |
GObject.ParamFlags.READABLE, |
| 14 |
Gtk.Button.$gtype), |
| 15 |
'forward-button': GObject.ParamSpec.object('forward-button', |
| 16 |
'Forward button', 'Topbar forward button widget', |
| 17 |
GObject.ParamFlags.READABLE, |
| 18 |
Gtk.Button.$gtype) |
| 19 |
}, |
| 20 |
|
| 21 |
_init: function(props) { |
| 22 |
props = props || {}; |
| 23 |
props.orientation = Gtk.Orientation.HORIZONTAL; |
| 24 |
this.parent(props); |
| 25 |
|
| 26 |
this._back_button = Gtk.Button.new_from_icon_name('go-previous-symbolic', |
| 27 |
Gtk.IconSize.SMALL_TOOLBAR); |
| 28 |
this._forward_button = Gtk.Button.new_from_icon_name('go-next-symbolic', |
| 29 |
Gtk.IconSize.SMALL_TOOLBAR); |
| 30 |
|
| 31 |
this.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED); |
| 32 |
|
| 33 |
let is_rtl = (Gtk.Widget.get_default_direction() === Gtk.TextDirection.RTL); |
| 34 |
if (is_rtl) { |
| 35 |
this._back_button.get_style_context().add_class('rtl'); |
| 36 |
this._forward_button.get_style_context().add_class('rtl'); |
| 37 |
} |
| 38 |
|
| 39 |
this.add(this._back_button); |
| 40 |
this.add(this._forward_button); |
| 41 |
this._back_button.show(); |
| 42 |
this._forward_button.show(); |
| 43 |
}, |
| 44 |
|
| 45 |
get back_button() { |
| 46 |
return this._back_button; |
| 47 |
}, |
| 48 |
|
| 49 |
get forward_button() { |
| 50 |
return this._forward_button; |
| 51 |
} |
| 52 |
}); |