X-Git-Url: https://git.toastfreeware.priv.at/gregoa/zavai.git/blobdiff_plain/6d882d91ba5fbf5b4998eba0c8a082578b89a928..f408e6fef2a2c9764e06ad10de8b0498246897b9:/src/app.vala diff --git a/src/app.vala b/src/app.vala index 8219534..2478d2b 100644 --- a/src/app.vala +++ b/src/app.vala @@ -66,6 +66,17 @@ public class Zavai : Gtk.Window, zavai.Resource } } + public void ensure_visible() + { + if (!visibility) + { + visible = true; + present(); + set_skip_pager_hint(true); + set_skip_taskbar_hint(true); + } + } + public void show_applet(string name) { zavai.Applet applet = zavai.registry.geta(name); @@ -93,13 +104,13 @@ public class Zavai : Gtk.Window, zavai.Resource if (current_name == name) return; -stderr.printf("push applet %s -> %s\n", current_name, name); +//stderr.printf("push applet %s -> %s\n", current_name, name); zavai.Applet applet = zavai.registry.geta(name); // Remove the current applet if (current != null) { -stderr.printf("push applet remove %s\n", current_name); +//stderr.printf("push applet remove %s\n", current_name); applet.back_link = current_name; current.stop(); remove(current); @@ -107,7 +118,7 @@ stderr.printf("push applet remove %s\n", current_name); current_name = null; } -stderr.printf("push applet add %s\n", name); +//stderr.printf("push applet add %s\n", name); // Add the new applet current = applet; current_name = name; @@ -116,6 +127,12 @@ stderr.printf("push applet add %s\n", name); current.show_all(); } + public void back() + { + if (current != null) + current.back(); + } + public void shutdown() { } @@ -161,22 +178,24 @@ public abstract class Applet : Gtk.VBox, Resource } public signal void label_changed(); + protected Gtk.HBox button_box; + // 'back_link' property: link to use to "go back". If null, do not show // a way to go back. protected AppletLink _back_link = null; public string back_link { get { return _back_link.target; } set { -stderr.printf("Set back link of %s to %s\n", _label, value); +//stderr.printf("Set back link of %s to %s\n", _label, value); if (value == null && _back_link != null) { _back_link.target = value; - remove(_back_link); + button_box.remove(_back_link); } else if (value != null) { if (_back_link.target == null) { _back_link.target = value; - pack_end(_back_link, false, false, 0); + button_box.pack_end(_back_link, true, true, 0); _back_link.show(); } else _back_link.target = value; @@ -186,8 +205,10 @@ stderr.printf("Set back link of %s to %s\n", _label, value); public Applet() { + button_box = new Gtk.HBox(true, 0); this.homogeneous = false; this.spacing = 0; + pack_end(button_box, false, true, 0); _back_link = new AppletStraightLink(); } /* @@ -212,6 +233,11 @@ stderr.printf("Set back link of %s to %s\n", _label, value); self.pack_start(widget, True, True) */ + public virtual void back() + { + _back_link.activate(); + } + public void shutdown() { stop(); @@ -230,9 +256,7 @@ public class Menu : Applet public void add_applet(string target) { -stderr.printf("menu.add_applet.packpre me %s them %s\n", _label, target); pack_start(new AppletPushLink(target), false, false, 0); -stderr.printf("menu.add_applet.packpost me %s them %s\n", _label, target); } public void add_service_toggle(string service_name, string label_start, string label_stop) @@ -294,13 +318,18 @@ public abstract class AppletLink : BigButton clicked += on_clicked; } + + public virtual void activate() + { + on_clicked(this); + } } public class AppletStraightLink : AppletLink { private override void on_clicked(Gtk.Button src) { -stderr.printf("straight link: %s\n", _target); +//stderr.printf("straight link: %s\n", _target); if (_target != null) zavai.app.show_applet(_target); } @@ -315,7 +344,7 @@ public class AppletPushLink : AppletLink { private override void on_clicked(Gtk.Button src) { -stderr.printf("push link: %s\n", _target); +//stderr.printf("push link: %s\n", _target); if (_target != null) zavai.app.push_applet(_target); } @@ -354,6 +383,34 @@ public class ServiceRequestLink : Gtk.ToggleButton } } +public class CommandButton : Gtk.Button +{ + private string command; + + public CommandButton(string name, string command) + { + label = name; + this.command = command; + clicked += on_clicked; + set_size_request(0, zavai.config.min_button_height); + } + + public void on_clicked() + { + zavai.log.info("Run program: " + command); + string[] args = command.split(" "); + Pid pid; + Process.spawn_async( + Environment.get_home_dir(), + args, + null, + SpawnFlags.SEARCH_PATH, + null, + out pid); + } +} + + zavai.Zavai app; }