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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.GtkCore/lib/stetic/libstetic/wrapper/ImageMenuItem.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 System;
2
 
using System.Xml;
3
 
 
4
 
namespace Stetic.Wrapper {
5
 
 
6
 
        public class ImageMenuItem : MenuItem {
7
 
 
8
 
                public static new Gtk.ImageMenuItem CreateInstance ()
9
 
                {
10
 
                        // Use the ctor that will create an AccelLabel
11
 
                        return new Gtk.ImageMenuItem ("");
12
 
                }
13
 
 
14
 
                protected override void ReadProperties (ObjectReader reader, XmlElement elem)
15
 
                {
16
 
                        Gtk.StockItem stockItem = Gtk.StockItem.Zero;
17
 
                        bool use_stock = (bool)GladeUtils.ExtractProperty (elem, "use_stock", false);
18
 
                        if (use_stock) {
19
 
                                string label = (string)GladeUtils.GetProperty (elem, "label", "");
20
 
                                stockItem = Gtk.Stock.Lookup (label);
21
 
                                if (stockItem.Label != null)
22
 
                                        GladeUtils.ExtractProperty (elem, "label", "");
23
 
                        }
24
 
                        base.ReadProperties (reader, elem);
25
 
 
26
 
                        if (stockItem.StockId != null)
27
 
                                Image = "stock:" + stockItem.StockId;
28
 
                        if (stockItem.Keyval != 0)
29
 
                                Accelerator = Gtk.Accelerator.Name (stockItem.Keyval, stockItem.Modifier);
30
 
                }
31
 
 
32
 
                string image;
33
 
 
34
 
                public string Image {
35
 
                        get {
36
 
                                return image;
37
 
                        }
38
 
                        set {
39
 
                                image = value;
40
 
 
41
 
                                Gtk.Widget icon;
42
 
                                Gtk.StockItem stockItem = Gtk.StockItem.Zero;
43
 
 
44
 
                                if (image.StartsWith ("stock:"))
45
 
                                        stockItem = Gtk.Stock.Lookup (image.Substring (6));
46
 
 
47
 
                                if (stockItem.StockId != null) {
48
 
                                        icon = new Gtk.Image (stockItem.StockId, Gtk.IconSize.Menu);
49
 
                                        Label = stockItem.Label;
50
 
                                        UseUnderline = true;
51
 
                                } else if (image.StartsWith ("file:"))
52
 
                                        icon = new Gtk.Image (image.Substring (5));
53
 
                                else
54
 
                                        icon = new Gtk.Image (WidgetUtils.MissingIcon);
55
 
 
56
 
                                ((Gtk.ImageMenuItem)Wrapped).Image = icon;
57
 
 
58
 
                                EmitNotify ("Image");
59
 
                        }
60
 
                }
61
 
        }
62
 
}