On Tue, Nov 1, 2011 at 6:02 AM, LDel001 <[email protected]> wrote:
> Now they all appear at once to me, sorry, terrible firewall in work.
>
> Thanks for the help. :)
>
> --
> View this message in context: 
> http://mono.1490590.n4.nabble.com/Can-someone-explain-this-in-C-as-opposed-to-python-please-its-for-custom-tabs-tp3963321p3963413.html
> Sent from the Mono - Gtk# mailing list archive at Nabble.com.
> _______________________________________________
> Gtk-sharp-list maillist  -  [email protected]
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>


Here is a very poorly ported example of doing something similar to the
Python code.

public class CustomNotebook : Gtk.Notebook
        {
                public CustomNotebook ()
                {
                        Homogeneous = true;
                        ShowTabs = false;                       
                }
                
                public void NewTab() {
                        string[] icons = { Gtk.Stock.About, Gtk.Stock.Add, 
Gtk.Stock.Apply,
Gtk.Stock.Bold };
                        Gtk.Image image = new Gtk.Image();
                        int nbpages = NPages;
                        string icon = icons[nbpages % icons.Length];
                        image.SetFromStock(icon, Gtk.IconSize.Dialog);
                        
                        
                        Widget label = CreateTableLabel(icon, image);
                        label.ShowAll();
                        
                        SetTabLabelPacking(image, true, true, 
Gtk.PackType.Start);
                        image.ShowAll();
                        
                        AppendPage(image, label);
                        
                        if((nbpages + 1) > 1) {
                                ShowTabs = true;
                        }
                        
                        CurrentPage = nbpages;                  
                }
                
                private Widget CreateTableLabel(string title, Widget child) {
                        Gtk.HBox box = new Gtk.HBox();
                        Gtk.Image icon = new Gtk.Image();
                        icon.SetFromStock(title, Gtk.IconSize.Menu);
                        Label label = new Label(title);
                        Button closebtn = new Button();
                        // the close button is made of an empty button
                        // where we set an image
                        Image image = new Image();
                        image.SetFromStock(Gtk.Stock.Close, Gtk.IconSize.Menu);
                        closebtn.Clicked += (sender, e) => {
                                // close the tab here...
                        };
                        closebtn.Image = image;
                        closebtn.Relief = ReliefStyle.None;
                        box.PackStart(icon, false, false, 0);
                        box.PackStart(label, true, true, 0);
                        box.PackEnd(closebtn, false, false, 0);
                        return box;
                }
        }


-- 
slide-o-blog
http://slide-o-blog.blogspot.com/
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to