Esempio n. 1
0
    public static Gtk.Widget MakeToolbarToggleButton(Gtk.Toolbar toolbar, string stock_id, System.EventHandler e)
    {
        Gtk.StockItem item = Gtk.StockItem.Zero;
        if (Gtk.StockManager.Lookup(stock_id, ref item))
        {
            SignalFuncHelper helper = new SignalFuncHelper(e);

            // FIXME current gtk-sharp bindings don't have a null_ok flag on the
            // widget parameter so it is impossible to make a toggle button in toolbar.
            Gtk.Widget w;
            try {
                w = toolbar.AppendElement(Gtk.ToolbarChildType.Togglebutton,
                                          null,
                                          item.Label.Replace("_", null),
                                          null, null,
                                          new Gtk.Image(item.StockId, Gtk.IconSize.LargeToolbar),
                                          new Gtk.SignalFunc(helper.Func));
            } catch {
                w = toolbar.AppendItem(item.Label.Replace("_", null),
                                       null, null,
                                       new Gtk.Image(item.StockId, Gtk.IconSize.LargeToolbar),
                                       new Gtk.SignalFunc(helper.Func));
            }

            helper.Sender = w;
            return(w);
        }
        return(null);
    }
Esempio n. 2
0
    public static Gtk.MenuItem MakeMenuItem(Gtk.Menu menu, string l, EventHandler e, bool enabled)
    {
        Gtk.MenuItem  i;
        Gtk.StockItem item = Gtk.StockItem.Zero;

        if (Gtk.StockManager.Lookup(l, ref item))
        {
            i = new Gtk.ImageMenuItem(l, new Gtk.AccelGroup());
        }
        else
        {
            i = new Gtk.MenuItem(l);
        }

        if (e != null)
        {
            i.Activated += e;
        }

        i.Sensitive = enabled;

        menu.Append(i);
        i.Show();

        return(i);
    }
Esempio n. 3
0
 public static Gtk.Widget MakeToolbarButton(Gtk.Toolbar toolbar, string stock_id, string label, System.EventHandler e)
 {
     Gtk.StockItem item = Gtk.StockItem.Zero;
     if (Gtk.StockManager.Lookup(stock_id, ref item))
     {
         SignalFuncHelper helper = new SignalFuncHelper(e);
         Gtk.Widget       w      = toolbar.AppendItem(label ?? item.Label.Replace("_", null),
                                                      null, null,
                                                      new Gtk.Image(item.StockId, Gtk.IconSize.LargeToolbar),
                                                      new Gtk.SignalFunc(helper.Func));
         helper.Sender = w;
         return(w);
     }
     return(null);
 }
Esempio n. 4
0
        public static void Initialize()
        {
            IconFactory icon_factory = new IconFactory();
            icon_factory.AddDefault();

            foreach (string item_id in stock_icon_names) {
                StockItem item = new StockItem(item_id, null, 0, Gdk.ModifierType.ShiftMask, null);

                IconSet icon_set = null;

                string file = System.IO.Path.Combine(MainClass.Paths.ResDir, item_id);

                icon_set = new IconSet();

                if (System.IO.File.Exists(file)){
                    try{
                        IconSource source = new IconSource();
                        source.Pixbuf = new Pixbuf(file);
                        source.Size = IconSize.LargeToolbar;
                        icon_set.AddSource(source);
                    }catch(Exception ex){
                        Tool.Logger.Error(ex.Message);
                        //continue;
                    }
                }

                if (icon_set == null) {
                    continue;
                }

                icon_factory.Add(item.StockId, icon_set);
                StockManager.Add(item);
            }
        }