summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/meson.build6
-rw-r--r--src/widget/box.vala1
-rw-r--r--src/widget/centerbox.vala11
-rw-r--r--src/widget/circularprogress.vala1
-rw-r--r--src/widget/icon.vala4
-rw-r--r--src/widget/levelbar.vala15
-rw-r--r--src/widget/overlay.vala50
-rw-r--r--src/widget/scrollable.vala42
-rw-r--r--src/widget/slider.vala59
9 files changed, 187 insertions, 2 deletions
diff --git a/src/meson.build b/src/meson.build
index f6b0db0..80e5a33 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -30,9 +30,13 @@ sources = [
'widget/box.vala',
'widget/button.vala',
'widget/centerbox.vala',
+ # 'widget/circularprogress.vala', # TODO: math lib -X -lm
'widget/eventbox.vala',
'widget/icon.vala',
- # 'widget/circularprogress.vala', # TODO: math lib -X -lm
+ 'widget/levelbar.vala',
+ 'widget/overlay.vala',
+ 'widget/scrollable.vala',
+ 'widget/slider.vala',
'widget/widget.vala',
'widget/window.vala',
'astal.vala',
diff --git a/src/widget/box.vala b/src/widget/box.vala
index 482948d..9993a38 100644
--- a/src/widget/box.vala
+++ b/src/widget/box.vala
@@ -1,5 +1,6 @@
namespace Astal {
public class Box : Gtk.Box {
+ [CCode (notify = false)]
public bool vertical {
get { return orientation == Gtk.Orientation.VERTICAL; }
set { orientation = value ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; }
diff --git a/src/widget/centerbox.vala b/src/widget/centerbox.vala
index 5f41600..eedee9b 100644
--- a/src/widget/centerbox.vala
+++ b/src/widget/centerbox.vala
@@ -1,10 +1,21 @@
namespace Astal {
public class CenterBox : Gtk.Box {
+ [CCode (notify = false)]
public bool vertical {
get { return orientation == Gtk.Orientation.VERTICAL; }
set { orientation = value ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; }
}
+ construct {
+ notify["orientation"].connect(() => {
+ notify_property("vertical");
+ });
+ }
+
+ static construct {
+ set_css_name("centerbox");
+ }
+
private Gtk.Widget _start_widget;
public Gtk.Widget start_widget {
get { return _start_widget; }
diff --git a/src/widget/circularprogress.vala b/src/widget/circularprogress.vala
index e96c4de..9cd3e26 100644
--- a/src/widget/circularprogress.vala
+++ b/src/widget/circularprogress.vala
@@ -20,7 +20,6 @@ public class CircularProgress : Gtk.Bin {
set_css_name("circular-progress");
}
-
public new void get_preferred_height(out int minh, out int nath) {
var val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL);
if (val.get_int() <= 0) {
diff --git a/src/widget/icon.vala b/src/widget/icon.vala
index fc493da..5dffd9b 100644
--- a/src/widget/icon.vala
+++ b/src/widget/icon.vala
@@ -44,6 +44,10 @@ public class Icon : Gtk.Image {
}
}
+ static construct {
+ set_css_name("icon");
+ }
+
construct {
notify["icon"].connect(() => {
if(FileUtils.test(icon, GLib.FileTest.EXISTS))
diff --git a/src/widget/levelbar.vala b/src/widget/levelbar.vala
new file mode 100644
index 0000000..1db2cc7
--- /dev/null
+++ b/src/widget/levelbar.vala
@@ -0,0 +1,15 @@
+namespace Astal {
+public class LevelBar : Gtk.LevelBar {
+ [CCode (notify = false)]
+ public bool vertical {
+ get { return orientation == Gtk.Orientation.VERTICAL; }
+ set { orientation = value ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; }
+ }
+
+ construct {
+ notify["orientation"].connect(() => {
+ notify_property("vertical");
+ });
+ }
+}
+}
diff --git a/src/widget/overlay.vala b/src/widget/overlay.vala
new file mode 100644
index 0000000..4833180
--- /dev/null
+++ b/src/widget/overlay.vala
@@ -0,0 +1,50 @@
+namespace Astal {
+public class Overlay : Gtk.Overlay {
+ public bool pass_through { get; set; }
+
+ public Gtk.Widget overlay {
+ get { return overlays.nth_data(0); }
+ set {
+ foreach (var ch in get_children())
+ remove(ch);
+
+ add_overlay(value);
+ }
+ }
+
+ public List<weak Gtk.Widget> overlays {
+ owned get { return get_children(); }
+ set {
+ foreach (var ch in get_children())
+ remove(ch);
+
+ foreach (var ch in value)
+ add_overlay(ch);
+ }
+ }
+
+ public void set_child(Gtk.Widget widget) {
+ var ch = get_child();
+ if (ch != null) {
+ remove(ch);
+ }
+ add(widget);
+ }
+
+ construct {
+ notify["pass-through"].connect(() => {
+ update_pass_through();
+ });
+ }
+
+ private void update_pass_through() {
+ foreach (var child in get_children())
+ set_overlay_pass_through(child, pass_through);
+ }
+
+ public new void add_overlay(Gtk.Widget widget) {
+ base.add_overlay(widget);
+ set_overlay_pass_through(widget, pass_through);
+ }
+}
+}
diff --git a/src/widget/scrollable.vala b/src/widget/scrollable.vala
new file mode 100644
index 0000000..1a0e081
--- /dev/null
+++ b/src/widget/scrollable.vala
@@ -0,0 +1,42 @@
+namespace Astal {
+public class Scrollable : Gtk.ScrolledWindow {
+ private Gtk.PolicyType _hscroll = Gtk.PolicyType.AUTOMATIC;
+ private Gtk.PolicyType _vscroll = Gtk.PolicyType.AUTOMATIC;
+
+ public Gtk.PolicyType hscroll {
+ get { return _hscroll; }
+ set {
+ _hscroll = value;
+ set_policy(value, vscroll);
+ }
+ }
+
+ public Gtk.PolicyType vscroll {
+ get { return _vscroll; }
+ set {
+ _vscroll = value;
+ set_policy(hscroll, value);
+ }
+ }
+
+ static construct {
+ set_css_name("scrollable");
+ }
+
+ construct {
+ if (hadjustment != null)
+ hadjustment = new Gtk.Adjustment(0,0,0,0,0,0);
+
+ if (vadjustment != null)
+ vadjustment = new Gtk.Adjustment(0,0,0,0,0,0);
+ }
+
+ public new Gtk.Widget get_child() {
+ var ch = base.get_child();
+ if (ch is Gtk.Viewport) {
+ return ch.get_child();
+ }
+ return ch;
+ }
+}
+}
diff --git a/src/widget/slider.vala b/src/widget/slider.vala
new file mode 100644
index 0000000..4c6cb88
--- /dev/null
+++ b/src/widget/slider.vala
@@ -0,0 +1,59 @@
+namespace Astal {
+public class Slider : Gtk.Scale {
+ [CCode (notify = false)]
+ public bool vertical {
+ get { return orientation == Gtk.Orientation.VERTICAL; }
+ set { orientation = value ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; }
+ }
+
+ static construct {
+ set_css_name("slider");
+ }
+
+ construct {
+ if (adjustment == null)
+ adjustment = new Gtk.Adjustment(0,0,0,0,0,0);
+
+ notify["orientation"].connect(() => {
+ notify_property("vertical");
+ });
+
+ button_press_event.connect(() => { dragging = true; });
+ key_press_event.connect(() => { dragging = true; });
+ button_release_event.connect(() => { dragging = false; });
+ key_release_event.connect(() => { dragging = false; });
+ scroll_event.connect((event) => {
+ dragging = true;
+ if (event.delta_y > 0)
+ value -= step;
+ else
+ value += step;
+ dragging = false;
+ });
+ }
+
+ public bool dragging { get; private set; }
+
+ public double value {
+ get { return adjustment.value; }
+ set { adjustment.value = value; }
+ }
+
+ public double min {
+ get { return adjustment.lower; }
+ set { adjustment.lower = value; }
+ }
+
+ public double max {
+ get { return adjustment.upper; }
+ set { adjustment.upper = value; }
+ }
+
+ public double step {
+ get { return adjustment.step_increment; }
+ set { adjustment.step_increment = value; }
+ }
+
+ // TODO: marks
+}
+}