Example #1
0
        public RTPrefs()
        {
            RTPreferences prefs = new RTPreferences();

            this.Build();

            nameColumn       = new Gtk.TreeViewColumn();
            nameColumn.Title = "Name";
            urlColumn        = new Gtk.TreeViewColumn();
            urlColumn.Title  = "URL";

            RTTree.AppendColumn(nameColumn);
            RTTree.AppendColumn(urlColumn);

            rtListStore  = new Gtk.ListStore(typeof(string), typeof(string));
            RTTree.Model = rtListStore;

            Gtk.CellRendererText nameNameCell = new Gtk.CellRendererText();
            nameNameCell.Editable = true;
            nameNameCell.Edited  += OnNameCellEdited;
            nameColumn.PackStart(nameNameCell, true);

            Gtk.CellRendererText urlTitleCell = new Gtk.CellRendererText();
            urlTitleCell.Editable = true;
            urlTitleCell.Edited  += OnURLCellEdited;
            urlColumn.PackStart(urlTitleCell, true);

            nameColumn.AddAttribute(nameNameCell, "text", 0);
            urlColumn.AddAttribute(urlTitleCell, "text", 1);

            if (!string.IsNullOrEmpty(prefs.URLs))
            {
                string[] urlbits = prefs.URLs.Split('|');
                for (int i = 0; i < urlbits.Length; i++)
                {
                    string name = urlbits[i];
                    string uri  = urlbits[++i];
                    Uri    url;
                    try {
                        url = new System.Uri(uri);
                    } catch (System.UriFormatException) {
                        continue;
                    }

                    rtListStore.AppendValues(name, url.ToString());
                }
            }
        }
Example #2
0
 protected virtual void OnAddBtnClicked(object sender, System.EventArgs e)
 {
     Gtk.TreeIter iter = rtListStore.AppendValues("", "");
     Gtk.TreePath path = rtListStore.GetPath(iter);
     RTTree.SetCursor(path, nameColumn, true);
 }