~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.GtkCore/libstetic/wrapper/Window.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using GLib;
 
2
using System;
 
3
using System.CodeDom;
 
4
using System.Collections;
 
5
 
 
6
namespace Stetic.Wrapper {
 
7
 
 
8
        public class Window : Container {
 
9
 
 
10
                public override void Wrap (object obj, bool initialized)
 
11
                {
 
12
                        Gtk.Window window = (Gtk.Window)obj;
 
13
 
 
14
                        window.TypeHint = Gdk.WindowTypeHint.Normal;
 
15
                        base.Wrap (obj, initialized);
 
16
 
 
17
                        if (!initialized) {
 
18
                                if (window.Child is Placeholder)
 
19
                                        window.Child.SetSizeRequest (200, 200);
 
20
                        }
 
21
 
 
22
                        window.DeleteEvent += DeleteEvent;
 
23
                }
 
24
                
 
25
                public override void Dispose ()
 
26
                {
 
27
                        Wrapped.DeleteEvent -= DeleteEvent;
 
28
                        base.Dispose ();
 
29
                }
 
30
 
 
31
                [ConnectBefore]
 
32
                void DeleteEvent (object obj, Gtk.DeleteEventArgs args)
 
33
                {
 
34
                        Wrapped.Hide ();
 
35
                        args.RetVal = true;
 
36
                }
 
37
 
 
38
                public override bool HExpandable { get { return true; } }
 
39
                public override bool VExpandable { get { return true; } }
 
40
 
 
41
                // We don't want to actually set the underlying properties for these;
 
42
                // that would be annoying to interact with.
 
43
                bool modal;
 
44
                public bool Modal {
 
45
                        get {
 
46
                                return modal;
 
47
                        }
 
48
                        set {
 
49
                                modal = value;
 
50
                                EmitNotify ("Modal");
 
51
                        }
 
52
                }
 
53
 
 
54
                Gdk.WindowTypeHint typeHint;
 
55
                public Gdk.WindowTypeHint TypeHint {
 
56
                        get {
 
57
                                return typeHint;
 
58
                        }
 
59
                        set {
 
60
                                typeHint = value;
 
61
                                EmitNotify ("TypeHint");
 
62
                        }
 
63
                }
 
64
 
 
65
                Gtk.WindowType type;
 
66
                public Gtk.WindowType Type {
 
67
                        get {
 
68
                                return type;
 
69
                        }
 
70
                        set {
 
71
                                type = value;
 
72
                                EmitNotify ("Type");
 
73
                        }
 
74
                }
 
75
 
 
76
                Gtk.WindowPosition windowPosition;
 
77
                public Gtk.WindowPosition WindowPosition {
 
78
                        get {
 
79
                                return windowPosition;
 
80
                        }
 
81
                        set {
 
82
                                windowPosition = value;
 
83
                                EmitNotify ("WindowPosition");
 
84
                        }
 
85
                }
 
86
 
 
87
                ImageInfo icon;
 
88
                public ImageInfo Icon {
 
89
                        get {
 
90
                                return icon;
 
91
                        }
 
92
                        set {
 
93
                                icon = value;
 
94
                                Gtk.Window window = (Gtk.Window)Wrapped;
 
95
                                try {
 
96
                                        if (icon != null)
 
97
                                                window.Icon = icon.GetImage (Project);
 
98
                                        else
 
99
                                                window.Icon = null;
 
100
                                } catch {
 
101
                                        window.Icon = null;
 
102
                                }
 
103
                        }
 
104
                }
 
105
 
 
106
                internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
 
107
                {
 
108
                        base.GenerateBuildCode (ctx, var);
 
109
                        
 
110
                        if (((Gtk.Window)Wrapped).DefaultWidth == -1) {
 
111
                                ctx.Statements.Add (
 
112
                                        new CodeAssignStatement (
 
113
                                                new CodePropertyReferenceExpression (
 
114
                                                        var,
 
115
                                                        "DefaultWidth"
 
116
                                                ),
 
117
                                                new CodePrimitiveExpression (DesignWidth)
 
118
                                        )
 
119
                                );
 
120
                        }
 
121
                                
 
122
                        if (((Gtk.Window)Wrapped).DefaultHeight == -1) {
 
123
                                ctx.Statements.Add (
 
124
                                        new CodeAssignStatement  (
 
125
                                                new CodePropertyReferenceExpression (
 
126
                                                        var,
 
127
                                                        "DefaultHeight"
 
128
                                                ),
 
129
                                                new CodePrimitiveExpression (DesignHeight)
 
130
                                        )
 
131
                                );
 
132
                        }
 
133
                }
 
134
                
 
135
                protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
 
136
                {
 
137
                        if (prop.Name != "Type")
 
138
                                base.GeneratePropertySet (ctx, var, prop);
 
139
                }
 
140
        }
 
141
}