Kill button as back button when on zavai
[gregoa/zavai.git] / src / app.vala
index 45a22d75bd50e2f0745c3d22756ad18b4180e747..2478d2bac4e5d1b576eb03c06d3423e98162d8eb 100644 (file)
@@ -127,6 +127,12 @@ public class Zavai : Gtk.Window, zavai.Resource
                current.show_all();
        }
 
+       public void back()
+       {
+               if (current != null)
+                       current.back();
+       }
+
        public void shutdown()
        {
        }
@@ -172,6 +178,8 @@ 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;
@@ -182,12 +190,12 @@ public abstract class Applet : Gtk.VBox, Resource
                        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;
@@ -197,8 +205,10 @@ public abstract class Applet : Gtk.VBox, Resource
 
        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();
        }
 /*
@@ -223,6 +233,11 @@ public abstract class Applet : Gtk.VBox, Resource
         self.pack_start(widget, True, True)
 */
 
+       public virtual void back()
+       {
+               _back_link.activate();
+       }
+
        public void shutdown()
        {
                stop();
@@ -303,6 +318,11 @@ public abstract class AppletLink : BigButton
 
                clicked += on_clicked;
        }
+
+       public virtual void activate()
+       {
+               on_clicked(this);
+       }
 }
 
 public class AppletStraightLink : AppletLink