Advertisement
Guest User

Untitled

a guest
May 20th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 4.39 KB | None | 0 0
  1.  
  2. [CCode (cname="clutter_x11_handle_event")]
  3. public extern int x_handle_event (X.Event xevent);
  4.  
  5. public class GalaPlugin : Meta.Plugin {
  6.     public override void start () {
  7.     }
  8.     public override void minimize (Meta.WindowActor actor) {
  9.         print ("MINIMIZE\n");
  10.         this.minimize_completed (actor);
  11.     }
  12.     public override void maximize (Meta.WindowActor actor, int x, int y, int w, int h) {
  13.         this.maximize_completed (actor);
  14.     }
  15.     public override void map (Meta.WindowActor actor) {
  16.         actor.show ();
  17.         switch (actor.meta_window.window_type) {
  18.             case Meta.WindowType.NORMAL:
  19.                 actor.scale_gravity = Clutter.Gravity.CENTER;
  20.                 actor.scale_x = 0.0f;
  21.                 actor.scale_y = 0.0f;
  22.                 actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400,
  23.                     scale_x:1.0f, scale_y:1.0f).completed.connect ( () => {
  24.                     this.map_completed (actor);
  25.                 });
  26.                 break;
  27.             case Meta.WindowType.MENU:
  28.             case Meta.WindowType.DROPDOWN_MENU:
  29.             case Meta.WindowType.POPUP_MENU:
  30.                 actor.scale_gravity = Clutter.Gravity.NORTH;
  31.                 actor.scale_x = 1.0f;
  32.                 actor.scale_y = 0.0f;
  33.                 actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
  34.                     scale_y:1.0f).completed.connect ( () => {
  35.                     this.map_completed (actor);
  36.                 });
  37.                 break;
  38.             default:
  39.                 this.map_completed (actor);
  40.                 break;
  41.         }
  42.     }
  43.     public override void destroy (Meta.WindowActor actor) {
  44.         if (actor.meta_window.window_type == Meta.WindowType.NORMAL) {
  45.             actor.scale_gravity = Clutter.Gravity.CENTER;
  46.             actor.show ();
  47.             actor.animate (Clutter.AnimationMode.EASE_IN_QUAD, 400,
  48.                 scale_x:0.0f, scale_y:0.0f).completed.connect ( () => {
  49.                 this.destroy_completed (actor);
  50.             });
  51.         } else if (actor.meta_window.window_type == Meta.WindowType.MENU) {
  52.             actor.scale_gravity = Clutter.Gravity.NORTH;
  53.             actor.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
  54.                 scale_y:0.0f).completed.connect ( () => {
  55.                 this.map_completed (actor);
  56.             });
  57.         } else
  58.             this.destroy_completed (actor);
  59.     }
  60.     public override void switch_workspace (int from, int to, Meta.MotionDirection direction) {
  61.         /*var windows = Meta.get_window_actors (this.get_screen ());
  62.         FIXME js/ui/windowManager.js line 430
  63.         int w, h;
  64.         this.get_screen ().get_size (out w, out h);
  65.        
  66.         var x2 = 0; var y2 = 0;
  67.         if (direction == Meta.MotionDirection.UP ||
  68.             direction == Meta.MotionDirection.UP_LEFT ||
  69.             direction == Meta.MotionDirection.UP_RIGHT)
  70.                 y2 = h;
  71.         else if (direction == Meta.MotionDirection.DOWN ||
  72.                   direction == Meta.MotionDirection.DOWN_LEFT ||
  73.                   direction == Meta.MotionDirection.DOWN_RIGHT)
  74.                 y2 = -h;
  75.        
  76.         if (direction == Meta.MotionDirection.LEFT ||
  77.             direction == Meta.MotionDirection.UP_LEFT ||
  78.             direction == Meta.MotionDirection.DOWN_LEFT)
  79.                 x2 = w;
  80.         else if (direction == Meta.MotionDirection.RIGHT ||
  81.                   direction == Meta.MotionDirection.UP_RIGHT ||
  82.                   direction == Meta.MotionDirection.DOWN_RIGHT)
  83.                 x2 = -w;
  84.        
  85.         windows.foreach ( (w) => {
  86.             if (!w.showing_on_its_workspace ())
  87.                 continue;
  88.         });
  89.         */
  90.         this.switch_workspace_completed ();
  91.     }
  92.     public override void kill_window_effects (Meta.WindowActor actor){
  93.        
  94.     }
  95.     public override void kill_switch_workspace () {
  96.        
  97.     }
  98.     public override bool xevent_filter (X.Event event) {
  99.         return x_handle_event (event) != 0;
  100.     }
  101.    
  102.     public override Meta.PluginInfo plugin_info () {
  103.         return {"Gala", "0.1", "Tom Beckmann", "GPLv3", "A nice window manager"};
  104.     }
  105. }
  106.  
  107. public static int main (string [] args) {
  108.     Gtk.init (ref args);
  109.    
  110.     Meta.set_replace_current_wm (true);
  111.     Meta.Plugin.type_register (new GalaPlugin ().get_type ());
  112.    
  113.     Meta.init ();
  114.    
  115.     return Meta.run ();
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement