本文整理汇总了C#中Gtk.ListStore.Append方法的典型用法代码示例。如果您正苦于以下问题:C# ListStore.Append方法的具体用法?C# ListStore.Append怎么用?C# ListStore.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.Append方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserView
public UserView()
{
Store = new Gtk.ListStore(typeof(Gdk.Pixbuf), typeof(string));
Model = Store;
InsertColumn(-1, "Pix", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
InsertColumn(-1, "Name", new Gtk.CellRendererText(), "text", 1);
HeadersVisible = false;
string[] users = new string[10];
users[0] = "Bob";
users[1] = "Bill";
users[2] = "Norma Jean";
users[3] = "Susie";
users[4] = "Katie";
users[5] = "Mbutu";
users[6] = "KoolKat74383u";
foreach ( string user in users ) {
Gtk.TreeIter iter = Store.Append();
Model.SetValue(iter, 0, null);
Model.SetValue(iter, 1, user);
}
}
示例2: LaunchDialogue
public override void LaunchDialogue ()
{
//the Type in the collection
IList collection = (IList) Value;
string displayName = Property.DisplayName;
//populate list with existing items
ListStore itemStore = new ListStore (typeof (object), typeof (int), typeof (string));
for (int i=0; i<collection.Count; i++)
itemStore.AppendValues(collection [i], i, collection [i].ToString ());
#region Building Dialogue
TreeView itemTree;
PropertyGrid grid;
TreeIter previousIter = TreeIter.Zero;
//dialogue and buttons
Dialog dialog = new Dialog () {
Title = displayName + " Editor",
Modal = true,
AllowGrow = true,
AllowShrink = true,
};
var toplevel = this.Container.Toplevel as Window;
if (toplevel != null)
dialog.TransientFor = toplevel;
dialog.AddActionWidget (new Button (Stock.Cancel), ResponseType.Cancel);
dialog.AddActionWidget (new Button (Stock.Ok), ResponseType.Ok);
//three columns for items, sorting, PropGrid
HBox hBox = new HBox ();
dialog.VBox.PackStart (hBox, true, true, 5);
//propGrid at end
grid = new PropertyGrid (base.EditorManager) {
CurrentObject = null,
WidthRequest = 200,
ShowHelp = false
};
hBox.PackEnd (grid, true, true, 5);
//followed by a ButtonBox
VBox buttonBox = new VBox ();
buttonBox.Spacing = 6;
hBox.PackEnd (buttonBox, false, false, 5);
//add/remove buttons
Button addButton = new Button (new Image (Stock.Add, IconSize.Button));
buttonBox.PackStart (addButton, false, false, 0);
if (types [0].IsAbstract)
addButton.Sensitive = false;
Button removeButton = new Button (new Gtk.Image (Stock.Remove, IconSize.Button));
buttonBox.PackStart (removeButton, false, false, 0);
//sorting buttons
Button upButton = new Button (new Image (Stock.GoUp, IconSize.Button));
buttonBox.PackStart (upButton, false, false, 0);
Button downButton = new Button (new Image (Stock.GoDown, IconSize.Button));
buttonBox.PackStart (downButton, false, false, 0);
//Third column has list (TreeView) in a ScrolledWindow
ScrolledWindow listScroll = new ScrolledWindow ();
listScroll.WidthRequest = 200;
listScroll.HeightRequest = 320;
hBox.PackStart (listScroll, false, false, 5);
itemTree = new TreeView (itemStore);
itemTree.Selection.Mode = SelectionMode.Single;
itemTree.HeadersVisible = false;
listScroll.AddWithViewport (itemTree);
//renderers and attribs for TreeView
CellRenderer rdr = new CellRendererText ();
itemTree.AppendColumn (new TreeViewColumn ("Index", rdr, "text", 1));
rdr = new CellRendererText ();
itemTree.AppendColumn (new TreeViewColumn ("Object", rdr, "text", 2));
#endregion
#region Events
addButton.Clicked += delegate {
//create the object
object instance = System.Activator.CreateInstance (types[0]);
//get existing selection and insert after it
TreeIter oldIter, newIter;
if (itemTree.Selection.GetSelected (out oldIter))
newIter = itemStore.InsertAfter (oldIter);
//or append if no previous selection
else
newIter = itemStore.Append ();
itemStore.SetValue (newIter, 0, instance);
//select, set name and update all the indices
itemTree.Selection.SelectIter (newIter);
UpdateName (itemStore, newIter);
UpdateIndices (itemStore);
//.........这里部分代码省略.........
示例3: PopulateGrid
/// <summary>
/// Populate the grid from the DataSource.
/// </summary>
private void PopulateGrid()
{
WaitCursor = true;
ClearGridColumns();
fixedcolview.Visible = false;
colLookup.Clear();
// Begin by creating a new ListStore with the appropriate number of
// columns. Use the string column type for everything.
int nCols = DataSource != null ? this.DataSource.Columns.Count : 0;
Type[] colTypes = new Type[nCols];
for (int i = 0; i < nCols; i++)
colTypes[i] = typeof(string);
gridmodel = new ListStore(colTypes);
gridview.ModifyBase(StateType.Active, fixedcolview.Style.Base(StateType.Selected));
gridview.ModifyText(StateType.Active, fixedcolview.Style.Text(StateType.Selected));
fixedcolview.ModifyBase(StateType.Active, gridview.Style.Base(StateType.Selected));
fixedcolview.ModifyText(StateType.Active, gridview.Style.Text(StateType.Selected));
image1.Visible = false;
// Now set up the grid columns
for (int i = 0; i < nCols; i++)
{
/// Design plan: include renderers for text, toggles and combos, but hide all but one of them
CellRendererText textRender = new Gtk.CellRendererText();
CellRendererToggle toggleRender = new Gtk.CellRendererToggle();
toggleRender.Visible = false;
toggleRender.Toggled += ToggleRender_Toggled;
CellRendererCombo comboRender = new Gtk.CellRendererCombo();
comboRender.Edited += ComboRender_Edited;
comboRender.Xalign = 1.0f;
comboRender.Visible = false;
colLookup.Add(textRender, i);
textRender.FixedHeightFromFont = 1; // 1 line high
textRender.Editable = !isReadOnly;
textRender.EditingStarted += OnCellBeginEdit;
textRender.Edited += OnCellValueChanged;
textRender.Xalign = i == 0 ? 0.0f : 1.0f; // For right alignment of text cell contents; left align the first column
TreeViewColumn column = new TreeViewColumn();
column.Title = this.DataSource.Columns[i].ColumnName;
column.PackStart(textRender, true); // 0
column.PackStart(toggleRender, true); // 1
column.PackStart(comboRender, true); // 2
column.Sizing = TreeViewColumnSizing.Autosize;
//column.FixedWidth = 100;
column.Resizable = true;
column.SetCellDataFunc(textRender, OnSetCellData);
column.Alignment = 0.5f; // For centered alignment of the column header
gridview.AppendColumn(column);
// Gtk Treeview doesn't support "frozen" columns, so we fake it by creating a second, identical, TreeView to display
// the columns we want frozen
// For now, these frozen columns will be treated as read-only text
TreeViewColumn fixedColumn = new TreeViewColumn(this.DataSource.Columns[i].ColumnName, textRender, "text", i);
fixedColumn.Sizing = TreeViewColumnSizing.Autosize;
fixedColumn.Resizable = true;
fixedColumn.SetCellDataFunc(textRender, OnSetCellData);
fixedColumn.Alignment = 0.5f; // For centered alignment of the column header
fixedColumn.Visible = false;
fixedcolview.AppendColumn(fixedColumn);
}
// Add an empty column at the end; auto-sizing will give this any "leftover" space
TreeViewColumn fillColumn = new TreeViewColumn();
gridview.AppendColumn(fillColumn);
fillColumn.Sizing = TreeViewColumnSizing.Autosize;
// Now let's apply center-justification to all the column headers, just for the heck of it
for (int i = 0; i < nCols; i++)
{
Label label = GetColumnHeaderLabel(i);
label.Justify = Justification.Center;
label.Style.FontDescription.Weight = Pango.Weight.Bold;
label = GetColumnHeaderLabel(i, fixedcolview);
label.Justify = Justification.Center;
label.Style.FontDescription.Weight = Pango.Weight.Bold;
}
int nRows = DataSource != null ? this.DataSource.Rows.Count : 0;
gridview.Model = null;
fixedcolview.Model = null;
for (int row = 0; row < nRows; row++)
{
// We could store data into the grid model, but we don't.
// Instead, we retrieve the data from our datastore when the OnSetCellData function is called
gridmodel.Append();
}
gridview.Model = gridmodel;
gridview.Show();
while (Gtk.Application.EventsPending())
Gtk.Application.RunIteration();
WaitCursor = false;
}
示例4: AddTagsTab
private void AddTagsTab()
{
Table tags_table = new Table(1, 2, false);
tags_table.BorderWidth = 5;
tags_table.ColumnSpacing = 10;
tags_table.RowSpacing = 10;
ScrolledWindow tags_swin = new ScrolledWindow();
tags_swin.ShadowType = ShadowType.In;
tags_swin.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
tags_table.Attach(tags_swin, 0, 1, 0, 1);
cr_toggle = new CellRendererToggle();
cr_toggle.Activatable = true;
cr_toggle.Toggled += new ToggledHandler(OnCrToggleToggled);
tv_tags = new TreeView();
tags_swin.Add(tv_tags);
store_tags = new ListStore(typeof(bool), typeof(string));
tv_tags.Model = store_tags;
// set up the columns for the view
TreeViewColumn column_Read = new TreeViewColumn("Use", cr_toggle, "active", 0);
tv_tags.AppendColumn(column_Read);
TreeViewColumn column_Name = new TreeViewColumn("Title", new CellRendererText(), "text", 1);
tv_tags.AppendColumn(column_Name);
foreach ( string tag in Feeds.GetTags() ) {
TreeIter iter = store_tags.Append();
if ( feed.Tags.Contains(tag) ) {
store_tags.SetValue(iter, 0, true);
} else {
store_tags.SetValue(iter, 0, false);
}
store_tags.SetValue(iter, 1, tag);
}
ButtonBox tags_bbox = new HButtonBox();
tags_bbox.Layout = ButtonBoxStyle.End;
tags_table.Attach(tags_bbox, 0, 1, 1, 2);
Button add_button = new Button(Stock.Add);
add_button.Clicked += new EventHandler(OnAddButtonClicked);
tags_bbox.PackStart(add_button);
notebook.AppendPage(tags_table, new Label("Tags"));
}
示例5: Append
private void Append (ListStore store, MemberRecord mr, Type type)
{
TreeIter iter;
store.Append (out iter);
store.SetValue (iter, 0, new GLib.Value (mr.Label));
store.SetValue (iter, 1, new GLib.Value (type.FullName));
store.SetValue (iter, 2, new GLib.Value (mr.Icon));
store.SetValue (iter, 3, new GLib.Value (mr.GetType () == typeof (TypeRecord)));
}
示例6: Copy
public static void Copy(TreeModel tree, TreeIter tree_iter, ListStore list, bool first)
{
// Copy this iter's values to the list
TreeIter list_iter = list.Append();
for (int i = 0; i < list.NColumns; i++) {
list.SetValue(list_iter, i, tree.GetValue(tree_iter, i));
if (i == 1) {
//Console.WriteLine("Copying {0}", list.GetValue(list_iter, i));
}
}
// Copy the first child, which will trigger the copy if its siblings (and their children)
TreeIter child_iter;
if (tree.IterChildren(out child_iter, tree_iter)) {
Copy(tree, child_iter, list, true);
}
// Add siblings and their children if we are the first child, otherwise doing so would repeat
if (first) {
while (tree.IterNext(ref tree_iter)) {
Copy(tree, tree_iter, list, false);
}
}
}
示例7: MakeSyncPane
public Gtk.Widget MakeSyncPane ()
{
Gtk.VBox vbox = new Gtk.VBox (false, 0);
vbox.Spacing = 4;
vbox.BorderWidth = 8;
Gtk.HBox hbox = new Gtk.HBox (false, 4);
Gtk.Label label = new Gtk.Label (Catalog.GetString ("Ser_vice:"));
label.Xalign = 0;
label.Show ();
hbox.PackStart (label, false, false, 0);
// Populate the store with all the available SyncServiceAddins
syncAddinStore = new Gtk.ListStore (typeof (SyncServiceAddin));
syncAddinIters = new Dictionary<string,Gtk.TreeIter> ();
SyncServiceAddin [] addins = Tomboy.DefaultNoteManager.AddinManager.GetSyncServiceAddins ();
Array.Sort (addins, CompareSyncAddinsByName);
foreach (SyncServiceAddin addin in addins) {
Gtk.TreeIter iter = syncAddinStore.Append ();
syncAddinStore.SetValue (iter, 0, addin);
syncAddinIters [addin.Id] = iter;
}
syncAddinCombo = new Gtk.ComboBox (syncAddinStore);
label.MnemonicWidget = syncAddinCombo;
Gtk.CellRendererText crt = new Gtk.CellRendererText ();
syncAddinCombo.PackStart (crt, true);
syncAddinCombo.SetCellDataFunc (crt,
new Gtk.CellLayoutDataFunc (ComboBoxTextDataFunc));
// Read from Preferences which service is configured and select it
// by default. Otherwise, just select the first one in the list.
string addin_id = Preferences.Get (
Preferences.SYNC_SELECTED_SERVICE_ADDIN) as String;
Gtk.TreeIter active_iter;
if (addin_id != null && syncAddinIters.ContainsKey (addin_id)) {
active_iter = syncAddinIters [addin_id];
syncAddinCombo.SetActiveIter (active_iter);
} else {
if (syncAddinStore.GetIterFirst (out active_iter) == true) {
syncAddinCombo.SetActiveIter (active_iter);
}
}
syncAddinCombo.Changed += OnSyncAddinComboChanged;
syncAddinCombo.Show ();
hbox.PackStart (syncAddinCombo, true, true, 0);
hbox.Show ();
vbox.PackStart (hbox, false, false, 0);
// Get the preferences GUI for the Sync Addin
if (active_iter.Stamp != Gtk.TreeIter.Zero.Stamp)
selectedSyncAddin = syncAddinStore.GetValue (active_iter, 0) as SyncServiceAddin;
if (selectedSyncAddin != null)
syncAddinPrefsWidget = selectedSyncAddin.CreatePreferencesControl (OnSyncAddinPrefsChanged);
if (syncAddinPrefsWidget == null) {
Gtk.Label l = new Gtk.Label (Catalog.GetString ("Not configurable"));
l.Yalign = 0.5f;
l.Yalign = 0.5f;
syncAddinPrefsWidget = l;
}
if (syncAddinPrefsWidget != null && addin_id != null &&
syncAddinIters.ContainsKey (addin_id) && selectedSyncAddin.IsConfigured)
syncAddinPrefsWidget.Sensitive = false;
syncAddinPrefsWidget.Show ();
syncAddinPrefsContainer = new Gtk.VBox (false, 0);
syncAddinPrefsContainer.PackStart (syncAddinPrefsWidget, false, false, 0);
syncAddinPrefsContainer.Show ();
vbox.PackStart (syncAddinPrefsContainer, true, true, 10);
// Autosync preference
int timeout = (int) Preferences.Get (Preferences.SYNC_AUTOSYNC_TIMEOUT);
if (timeout > 0 && timeout < 5) {
timeout = 5;
Preferences.Set (Preferences.SYNC_AUTOSYNC_TIMEOUT, 5);
}
Gtk.HBox autosyncBox = new Gtk.HBox (false, 5);
// Translators: This is and the next string go together.
// Together they look like "Automatically Sync in Background Every [_] Minutes",
// where "[_]" is a GtkSpinButton.
autosyncCheck =
new Gtk.CheckButton (Catalog.GetString ("Automaticall_y Sync in Background Every"));
autosyncSpinner = new Gtk.SpinButton (5, 1000, 1);
autosyncSpinner.Value = timeout >= 5 ? timeout : 10;
Gtk.Label autosyncExtraText =
// Translators: See above comment for details on
// this string.
new Gtk.Label (Catalog.GetString ("Minutes"));
autosyncCheck.Active = autosyncSpinner.Sensitive = timeout >= 5;
EventHandler updateTimeoutPref = (o, e) => {
Preferences.Set (Preferences.SYNC_AUTOSYNC_TIMEOUT,
autosyncCheck.Active ? (int) autosyncSpinner.Value : -1);
};
autosyncCheck.Toggled += (o, e) => {
//.........这里部分代码省略.........
示例8: ShowContributors
public static void ShowContributors(TreeView treeview)
{
#if DEBUG
Console.WriteLine("TreeViewHelper.ShowContributors");
#endif
string helpFile = FileHelper.FindSupportFile("bygfoot_help", true);
if (string.IsNullOrEmpty(helpFile))
{
GameGUI.ShowWarning(Mono.Unix.Catalog.GetString("Didn't find file 'bygfoot_help'."));
return;
}
OptionList helpList = null;
FileHelper.LoadOptFile(helpFile, ref helpList, false);
// Set treeview properties
treeview.Selection.Mode = SelectionMode.None;
treeview.RulesHint = false;
treeview.HeadersVisible = false;
TreeViewColumn column = new TreeViewColumn();
treeview.AppendColumn(column);
CellRenderer cell = TreeViewHelper.TextCellRenderer();
column.PackStart(cell, true);
column.AddAttribute(cell, "markup", 0);
ListStore ls = new ListStore(typeof(string));
for (int i = 0; i < helpList.list.Count; i++)
{
TreeIter iter = ls.Append();
OptionStruct option = (OptionStruct)helpList.list[i];
if (option.name.StartsWith("string_contrib_title"))
{
string value = string.Format("\n<span {0}>{1}</span>", Option.ConstApp("string_help_window_title_attribute"), option.stringValue);
ls.SetValue(iter, 0, value);
}
else
{
ls.SetValue(iter, 0, option.stringValue);
}
}
treeview.Model = ls;
}
示例9: ICSelector
private Container ICSelector ()
{
ScrolledWindow sw = new ScrolledWindow ();
ICStore = new ListStore ((int) GLib.TypeFundamentals.TypeString, (int) GLib.TypeFundamentals.TypeInt);
ICView = new TreeView (ICStore);
TreeViewColumn col = new TreeViewColumn ();
TreeIter iter;
CellRenderer renderer = new CellRendererText ();
col.Title = "MemberType";
col.PackStart (renderer, true);
col.AddAttribute (renderer, "markup", 0);
ICView.AppendColumn (col);
ICView.HeadersVisible = false;
ICStore.Append (out iter);
ICStore.SetValue (iter, 0, new GLib.Value (ICLabel ("all", factory.staticCount + factory.instanceCount)));
ICStore.SetValue (iter, 1, new GLib.Value ((int) (BindingFlags.Static | BindingFlags.Instance)));
ICStore.Append (out iter);
ICStore.SetValue (iter, 0, new GLib.Value (ICLabel ("instance", factory.instanceCount)));
ICStore.SetValue (iter, 1, new GLib.Value ((int) BindingFlags.Instance));
ICStore.Append (out iter);
ICStore.SetValue (iter, 0, new GLib.Value (ICLabel ("class", factory.staticCount)));
ICStore.SetValue (iter, 1, new GLib.Value ((int) BindingFlags.Static));
ICView.Selection.SelectPath (new TreePath ("0"));
ICView.Selection.Changed += new EventHandler (ICSelectionChanged);
ICView.BorderWidth = 5;
sw.Add (ICView);
return sw;
}
示例10: MemberSelector
private Container MemberSelector ()
{
ScrolledWindow sw = new ScrolledWindow ();
memberStore = new ListStore ((int) GLib.TypeFundamentals.TypeString, (int) GLib.TypeFundamentals.TypeInt);
MTView = new TreeView (memberStore);
TreeViewColumn col = new TreeViewColumn ();
TreeIter iter;
CellRenderer renderer = new CellRendererText ();
col.Title = "MemberType";
col.PackStart (renderer, true);
col.AddAttribute (renderer, "markup", 0);
MTView.AppendColumn (col);
MTView.HeadersVisible = false;
foreach (MemberRecordFactory rv in recordFactory) {
memberStore.Append (out iter);
memberStore.SetValue (iter, 0, new GLib.Value (rv.FullTitle));
}
MTView.Selection.SelectPath (new TreePath ("0"));
MTView.Selection.Changed += new EventHandler (MemberFilterSelectionChanged);
MTView.BorderWidth = 5;
sw.Add (MTView);
return sw;
}
示例11: AddToStore
private void AddToStore (ListStore store, GLib.Value field, GLib.Value value, GLib.Value details, GLib.Value icon)
{
TreeIter iter = store.Append ();
store.SetValue (iter, 0, field);
store.SetValue (iter, 1, value);
store.SetValue (iter, 2, details);
store.SetValue (iter, 3, icon);
}
示例12: UpdateAttachments
void UpdateAttachments()
{
var task = SelectedTask;
var model = new ListStore (typeof (Gdk.Pixbuf),
typeof (String),
typeof (String));
if (task != null && task.Attachments != null) {
foreach (string item in task.Attachments) {
var iter = model.Append ();
var info = new System.IO.FileInfo (item);
model.SetValue (iter, 0, GetPixbuf (Stock.File));
model.SetValue (iter, 1, info.Name);
model.SetValue (iter, 2, item);
}
}
m_tasksIconView.Model = model;
}
示例13: FilterComboBox
private Gtk.ComboBox FilterComboBox ()
{
filter_data = new Gtk.ListStore (new Type[] { typeof (string), typeof (string) });
Gtk.TreeIter iter;
iter = filter_data.Append ();
filter_data.SetValue (iter, 0, Catalog.GetString ("Anywhere"));
filter_data.SetValue (iter, 1, null);
iter = filter_data.Append ();
filter_data.SetValue (iter, 0, Catalog.GetString ("in Files"));
filter_data.SetValue (iter, 1, "File");
iter = filter_data.Append ();
filter_data.SetValue (iter, 0, Catalog.GetString ("in Addressbook"));
filter_data.SetValue (iter, 1, "Contact");
iter = filter_data.Append ();
filter_data.SetValue (iter, 0, Catalog.GetString ("in Mail"));
filter_data.SetValue (iter, 1, "MailMessage");
iter = filter_data.Append ();
filter_data.SetValue (iter, 0, Catalog.GetString ("in Web Pages"));
filter_data.SetValue (iter, 1, "WebHistory");
iter = filter_data.Append ();
filter_data.SetValue (iter, 0, Catalog.GetString ("in Chats"));
filter_data.SetValue (iter, 1, "IMLog");
Gtk.ComboBox combo = new Gtk.ComboBox (filter_data);
combo.Active = 0;
Gtk.CellRendererText renderer = new Gtk.CellRendererText ();
combo.PackStart (renderer, false);
combo.SetAttributes (renderer, new object[] { "text", 0 });
return combo;
}