本文整理汇总了C#中Gtk.TreeStore.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# TreeStore.Clear方法的具体用法?C# TreeStore.Clear怎么用?C# TreeStore.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.TreeStore
的用法示例。
在下文中一共展示了TreeStore.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddinView
public AddinView()
{
var hbox = new HBox () { Spacing = 6 };
var filter_label = new Label (Catalog.GetString ("Show:"));
var filter_combo = new ComboBoxText ();
filter_combo.AppendText (Catalog.GetString ("All"));
filter_combo.AppendText (Catalog.GetString ("Enabled"));
filter_combo.AppendText (Catalog.GetString ("Not Enabled"));
filter_combo.Active = 0;
var search_label = new Label (Catalog.GetString ("Search:"));
var search_entry = new Banshee.Widgets.SearchEntry () {
WidthRequest = 160,
Visible = true,
Ready = true
};
hbox.PackStart (filter_label, false, false, 0);
hbox.PackStart (filter_combo, false, false, 0);
hbox.PackEnd (search_entry, false, false, 0);
hbox.PackEnd (search_label, false, false, 0);
var model = new TreeStore (typeof(bool), typeof(bool), typeof (string), typeof (Addin));
var addins = AddinManager.Registry.GetAddins ().Where (a => { return
a.Name != a.Id && a.Description != null &&
!String.IsNullOrEmpty (a.Description.Category) && !a.Description.Category.StartsWith ("required:") &&
(!a.Description.Category.Contains ("Debug") || ApplicationContext.Debugging);
});
var categorized_addins = addins.GroupBy<Addin, string> (a => a.Description.Category)
.Select (c => new {
Addins = c.OrderBy (a => Catalog.GetString (a.Name)).ToList (),
Name = c.Key,
NameLocalized = Catalog.GetString (c.Key) })
.OrderBy (c => c.NameLocalized)
.ToList ();
tree_view = new TreeView () {
FixedHeightMode = false,
HeadersVisible = false,
SearchColumn = 1,
RulesHint = true,
Model = model
};
var update_model = new System.Action (() => {
string search = search_entry.Query;
bool? enabled = filter_combo.Active > 0 ? (bool?) (filter_combo.Active == 1 ? true : false) : null;
model.Clear ();
foreach (var cat in categorized_addins) {
var cat_iter = model.AppendValues (false, false, String.Format ("<b>{0}</b>", GLib.Markup.EscapeText (cat.NameLocalized)), null);
bool any = false;
foreach (var a in cat.Addins.Matching (search)) {
if (enabled == null || (a.Enabled == enabled.Value)) {
model.AppendValues (cat_iter, true,
a.Enabled,
String.Format (
"<b>{0}</b>\n<small>{1}</small>",
GLib.Markup.EscapeText (Catalog.GetString (a.Name)),
GLib.Markup.EscapeText (Catalog.GetString (a.Description.Description))),
a
);
any = true;
}
}
if (!any) {
model.Remove (ref cat_iter);
}
}
tree_view.ExpandAll ();
});
var txt_cell = new CellRendererText () { WrapMode = Pango.WrapMode.Word };
tree_view.AppendColumn ("Name", txt_cell , "markup", Columns.Name);
var check_cell = new CellRendererToggle () { Activatable = true };
tree_view.AppendColumn ("Enable", check_cell, "visible", Columns.IsAddin, "active", Columns.IsEnabled);
check_cell.Toggled += (o, a) => {
TreeIter iter;
if (model.GetIter (out iter, new TreePath (a.Path))) {
var addin = model.GetValue (iter, 3) as Addin;
bool enabled = (bool) model.GetValue (iter, 1);
addin.Enabled = !enabled;
model.SetValue (iter, 1, addin.Enabled);
model.Foreach (delegate (ITreeModel current_model, TreePath path, TreeIter current_iter) {
var an = current_model.GetValue (current_iter, 3) as Addin;
if (an != null) {
current_model.SetValue (current_iter, 1, an.Enabled);
}
return false;
});
}
};
update_model ();
search_entry.Changed += (o, a) => update_model ();
filter_combo.Changed += (o, a) => update_model ();
//.........这里部分代码省略.........