~ted/unity/set-indicator-env

« back to all changes in this revision

Viewing changes to src/window.vala

  • Committer: Gordon Allott
  • Date: 2009-10-21 18:13:02 UTC
  • mto: (1.2.11 unity-ql-uc1)
  • mto: This revision was merged to the branch mainline in revision 2.
  • Revision ID: mail@gordallott.com-20091021181302-fzyivsmhvn74abs2
added support for a unity window with a clutter stage
no support for "fullscreen" mode yet, but the api is there. code can be taken 
from the old liblauncher, launcher-session.c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by Gordon Allott <gord.allott@canonical.com>
 
17
 *
 
18
 */
 
19
using GtkClutter;
 
20
 
 
21
namespace Unity {
 
22
  
 
23
  public interface UnderlayWindow : Gtk.Window
 
24
  {
 
25
    public abstract void setup_window ();
 
26
    public abstract void set_fullscreen ();
 
27
  }
 
28
  
 
29
  public class Workarea 
 
30
  {
 
31
    public signal void workarea_changed ();
 
32
    public int left;
 
33
    public int top;
 
34
    public int right;
 
35
    public int bottom;
 
36
    
 
37
    public Workarea ()
 
38
    {
 
39
      left = 0;
 
40
      right = 0;
 
41
      top = 0;
 
42
      bottom = 0;
 
43
      
 
44
      update_net_workarea ();
 
45
    }
 
46
    
 
47
 
 
48
    public void update_net_workarea () 
 
49
    {
 
50
      /* FIXME - steal code from the old liblauncher to do this (launcher-session.c)
 
51
       * this is just fake code to get it running
 
52
       */
 
53
      
 
54
      left = 0;
 
55
      right = 800;
 
56
      top = 0;
 
57
      bottom = 600;
 
58
    }
 
59
  }
 
60
  
 
61
  public class Window : Gtk.Window, UnderlayWindow
 
62
  {
 
63
    
 
64
    private GtkClutter.Embed gtk_clutter;
 
65
    public Clutter.Stage stage;
 
66
    private Workarea workarea_size;
 
67
    
 
68
    public void setup_window ()
 
69
    {
 
70
      this.decorated = false;
 
71
      this.skip_taskbar_hint = true;
 
72
      this.skip_pager_hint = true;
 
73
      this.type_hint = Gdk.WindowTypeHint.NORMAL;
 
74
      
 
75
      this.realize ();
 
76
    }
 
77
    
 
78
    public void set_fullscreen ()
 
79
    {
 
80
      int width;
 
81
      int height;
 
82
      
 
83
      width = this.workarea_size.right - this.workarea_size.left;
 
84
      height = this.workarea_size.bottom - this.workarea_size.top;
 
85
 
 
86
      resize (width, height);
 
87
      this.stage.set_size(width, height);
 
88
      
 
89
    }
 
90
    
 
91
    public Window ()
 
92
    {
 
93
      this.workarea_size = new Workarea ();
 
94
      this.workarea_size.update_net_workarea ();
 
95
      
 
96
      setup_window ();
 
97
      
 
98
      this.gtk_clutter = new GtkClutter.Embed ();
 
99
      this.add (this.gtk_clutter);
 
100
      this.gtk_clutter.realize ();
 
101
 
 
102
      this.stage = (Clutter.Stage)this.gtk_clutter.get_stage ();
 
103
      Clutter.Color stage_bg = Clutter.Color ()
 
104
        { 
 
105
          red = 0x00,
 
106
          green = 0x00,
 
107
          blue = 0x00,
 
108
          alpha = 0xB0
 
109
        };
 
110
      this.stage.set_color (stage_bg);
 
111
      this.show_all ();
 
112
      this.stage.show_all ();
 
113
    }
 
114
    
 
115
  }
 
116
}