~ubuntu-branches/ubuntu/precise/gnome-do/precise-proposed

« back to all changes in this revision

Viewing changes to Do/gtk-gui/generated.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-09-14 10:09:40 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20080914100940-kyghudg7py14bu2z
Tags: upstream-0.6.0.0
ImportĀ upstreamĀ versionĀ 0.6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        }
23
23
    }
24
24
    
 
25
    internal class IconLoader {
 
26
        
 
27
        public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) {
 
28
            Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
 
29
            if ((res != null)) {
 
30
                return res;
 
31
            }
 
32
            else {
 
33
                try {
 
34
                    return Gtk.IconTheme.Default.LoadIcon(name, sz, 0);
 
35
                }
 
36
                catch (System.Exception ) {
 
37
                    if ((name != "gtk-missing-image")) {
 
38
                        return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz);
 
39
                    }
 
40
                    else {
 
41
                        Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
 
42
                        Gdk.GC gc = new Gdk.GC(pmap);
 
43
                        gc.RgbFgColor = new Gdk.Color(255, 255, 255);
 
44
                        pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
 
45
                        gc.RgbFgColor = new Gdk.Color(0, 0, 0);
 
46
                        pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
 
47
                        gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
 
48
                        gc.RgbFgColor = new Gdk.Color(255, 0, 0);
 
49
                        pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
 
50
                        pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
 
51
                        return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
 
52
                    }
 
53
                }
 
54
            }
 
55
        }
 
56
    }
 
57
    
 
58
    internal class BinContainer {
 
59
        
 
60
        private Gtk.Widget child;
 
61
        
 
62
        private Gtk.UIManager uimanager;
 
63
        
 
64
        public static BinContainer Attach(Gtk.Bin bin) {
 
65
            BinContainer bc = new BinContainer();
 
66
            bin.SizeRequested += new Gtk.SizeRequestedHandler(bc.OnSizeRequested);
 
67
            bin.SizeAllocated += new Gtk.SizeAllocatedHandler(bc.OnSizeAllocated);
 
68
            bin.Added += new Gtk.AddedHandler(bc.OnAdded);
 
69
            return bc;
 
70
        }
 
71
        
 
72
        private void OnSizeRequested(object sender, Gtk.SizeRequestedArgs args) {
 
73
            if ((this.child != null)) {
 
74
                args.Requisition = this.child.SizeRequest();
 
75
            }
 
76
        }
 
77
        
 
78
        private void OnSizeAllocated(object sender, Gtk.SizeAllocatedArgs args) {
 
79
            if ((this.child != null)) {
 
80
                this.child.Allocation = args.Allocation;
 
81
            }
 
82
        }
 
83
        
 
84
        private void OnAdded(object sender, Gtk.AddedArgs args) {
 
85
            this.child = args.Widget;
 
86
        }
 
87
        
 
88
        public void SetUiManager(Gtk.UIManager uim) {
 
89
            this.uimanager = uim;
 
90
            this.child.Realized += new System.EventHandler(this.OnRealized);
 
91
        }
 
92
        
 
93
        private void OnRealized(object sender, System.EventArgs args) {
 
94
            if ((this.uimanager != null)) {
 
95
                Gtk.Widget w;
 
96
                w = this.child.Toplevel;
 
97
                if (((w != null) && typeof(Gtk.Window).IsInstanceOfType(w))) {
 
98
                    ((Gtk.Window)(w)).AddAccelGroup(this.uimanager.AccelGroup);
 
99
                    this.uimanager = null;
 
100
                }
 
101
            }
 
102
        }
 
103
    }
 
104
    
25
105
    internal class ActionGroups {
26
106
        
27
107
        public static Gtk.ActionGroup GetActionGroup(System.Type type) {