예제 #1
0
파일: Image.cs 프로젝트: mono/stetic
        public Image(bool allowStock, bool allowFile)
            : base(false, 6)
        {
            image = new Gtk.Image (Gnome.Stock.Blank, Gtk.IconSize.Button);
            PackStart (image, false, false, 0);

            if (allowStock) {
                store = new Gtk.ListStore (typeof (string), typeof (string));
                store.AppendValues (Gnome.Stock.Blank, Catalog.GetString ("(None)"));
                for (int i = 0; i < stockIds.Length; i++)
                    store.AppendValues (stockIds[i], stockLabels[i]);

                combo = new Gtk.ComboBoxEntry (store, LabelColumn);
                Gtk.CellRendererPixbuf iconRenderer = new Gtk.CellRendererPixbuf ();
                iconRenderer.StockSize = (uint)Gtk.IconSize.Menu;
                combo.PackStart (iconRenderer, false);
                combo.Reorder (iconRenderer, 0);
                combo.AddAttribute (iconRenderer, "stock-id", IconColumn);
                combo.Changed += combo_Changed;

                // Pack the combo non-expandily into a VBox so it doesn't
                // get stretched to the file button's height
                Gtk.VBox vbox = new Gtk.VBox (false, 0);
                vbox.PackStart (combo, true, false, 0);
                PackStart (vbox, true, true, 0);

                entry = (Gtk.Entry)combo.Child;
                entry.Changed += entry_Changed;

                useStock = true;
            }

            if (allowFile) {
                if (!allowStock) {
                    entry = new Gtk.Entry ();
                    PackStart (entry, true, true, 0);
                    entry.Changed += entry_Changed;
                }

                button = new Gtk.Button ();
                Gtk.Image icon = new Gtk.Image (Gtk.Stock.Open, Gtk.IconSize.Button);
                button.Add (icon);
                PackStart (button, false, false, 0);
                button.Clicked += button_Clicked;
            }
            ShowAll ();
        }