コード例 #1
0
 // This is a hack.  For some reason, our Tree Cell instances in
 // our Gtk.TreeView don't support AtkAction.  I suspect this
 // has something to do with the way the TreeView is
 // initialized, but I don't have the time to research this any
 // further.
 protected override void ExpandTreeView(Atk.Object obj)
 {
     RunInGuiThread(delegate {
         Gtk.TreeView widget = GailTestApp.MainClass.GiveMeARealTreeView();
         widget.ExpandAll();
     });
 }
コード例 #2
0
        public virtual void Load()
        {
            Trace.Call();

            _TreeStore.Clear();

            // group servers by protocol
            Dictionary <string, List <ServerModel> > protocols = new Dictionary <string, List <ServerModel> >();
            IList <ServerModel> servers = _Controller.GetServerList();

            foreach (ServerModel server in servers)
            {
                List <ServerModel> protocolServers = null;
                protocols.TryGetValue(server.Protocol, out protocolServers);
                if (protocolServers == null)
                {
                    protocolServers = new List <ServerModel>();
                    protocols.Add(server.Protocol, protocolServers);
                }
                protocolServers.Add(server);
            }

            // add grouped servers to treeview
            foreach (KeyValuePair <string, List <ServerModel> > pair in protocols)
            {
                Gtk.TreeIter parentIter = _TreeStore.AppendValues(null, pair.Key, String.Empty);
                foreach (ServerModel server in pair.Value)
                {
                    // a server with an empty hostname has only one default/hardcoded
                    // hostname, thus don't create a sub-node for it
                    if (String.IsNullOrEmpty(server.Hostname))
                    {
                        _TreeStore.SetValue(parentIter, 0, server);
                        continue;
                    }

                    _TreeStore.AppendValues(parentIter, server, String.Empty, server.Hostname);
                }
            }

            _TreeView.ExpandAll();
        }