visibility_notify_event += on_visibility;
set_skip_pager_hint(true);
set_skip_taskbar_hint(true);
-
+ //set_type_hint(Gdk.WindowTypeHint.DESKTOP);
}
private bool on_visibility(Gdk.Event event)
} else {
visible = true;
present();
+ set_skip_pager_hint(true);
+ set_skip_taskbar_hint(true);
+ }
+ }
+
+ public void ensure_visible()
+ {
+ if (!visibility)
+ {
+ visible = true;
+ present();
+ set_skip_pager_hint(true);
+ set_skip_taskbar_hint(true);
}
}
public void push_applet(string name)
{
-stderr.printf("push applet %s -> %s\n", current_name, name);
+ // Make the function idempotent
+ if (current_name == name)
+ return;
+
+//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);
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;
current.show_all();
}
+ public void back()
+ {
+ if (current != null)
+ current.back();
+ }
+
public void shutdown()
{
}
}
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;
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();
}
/*
self.pack_start(widget, True, True)
*/
+ public virtual void back()
+ {
+ _back_link.activate();
+ }
+
public void shutdown()
{
stop();
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)
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);
}
{
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);
}
}
}
+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;
}