static int CompareNotebooksSortFunc(Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) { Notebook notebook_a = model.GetValue(a, 0) as Notebook; Notebook notebook_b = model.GetValue(b, 0) as Notebook; if (notebook_a == null || notebook_b == null) { return(0); } if (notebook_a is SpecialNotebook && notebook_b is SpecialNotebook) { if (notebook_a is AllNotesNotebook) { return(-1); } else { return(1); } } else if (notebook_a is SpecialNotebook) { return(-1); } else if (notebook_b is SpecialNotebook) { return(1); } return(string.Compare(notebook_a.Name, notebook_b.Name)); }
protected virtual int SortTreeStore(Gtk.TreeModel model, Gtk.TreeIter iter1, Gtk.TreeIter iter2) { var server1 = (ServerModel)model.GetValue(iter1, 0); var server2 = (ServerModel)model.GetValue(iter2, 0); // protocol nodes don't have a ServerModel if (server1 == null && server2 == null) { return(0); } if (server2 == null) { return(1); } if (server1 == null) { return(-1); } var s1 = String.Format("{0}/{1}:{2} ({3})", server1.Protocol, server1.Hostname, server1.Port, server1.ServerID); var s2 = String.Format("{0}/{1}:{2} ({3})", server2.Protocol, server2.Hostname, server2.Port, server2.ServerID); return(s1.CompareTo(s2)); }
int SelectedPackageCompareNodes(Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) { string name1 = (string)model.GetValue(a, SelectedPackageNameID); string name2 = (string)model.GetValue(b, SelectedPackageNameID); return(string.Compare(name1, name2, true)); }
static int CompareTasksSortFunc(Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) { ITask taskA = model.GetValue(a, 0) as ITask; ITask taskB = model.GetValue(b, 0) as ITask; if (taskA == null || taskB == null) { return(0); } return(taskA.CompareTo(taskB)); }
protected virtual void RenderChatViewIcon(Gtk.TreeViewColumn column, Gtk.CellRenderer cellr, Gtk.TreeModel model, Gtk.TreeIter iter) { if (cellr == null) { throw new ArgumentNullException("cellr"); } if (model == null) { throw new ArgumentNullException("model"); } var chat = (ChatView)model.GetValue(iter, 0); var renderer = (Gtk.CellRendererPixbuf)cellr; switch (chat.TabImage.StorageType) { case Gtk.ImageType.Pixbuf: renderer.Pixbuf = chat.TabImage.Pixbuf; break; case Gtk.ImageType.Stock: renderer.StockId = chat.TabImage.Stock; break; default: renderer.Pixbuf = null; break; } }
/// <summary> /// Sets the category of a task for a given ID /// </summary> /// <param name="id"> /// A <see cref="System.String"/> for the ID of the task /// </param> /// <param name="category"> /// A <see cref="System.String"/> the category of the task /// </param> /// <returns> /// A <see cref="System.Boolean"/>, true for success, false /// for failure. /// </returns> public bool SetCategoryForTaskById(string id, string categoryName) { ITask task = GetTaskById(id); if (task == null) { return(false); } Gtk.TreeIter iter; Gtk.TreeModel model = Application.Backend.Categories; if (!model.GetIterFirst(out iter)) { return(false); } do { ICategory category = model.GetValue(iter, 0) as ICategory; if (string.Compare(category.Name, categoryName) == 0) { task.Category = category; return(true); } } while (model.IterNext(ref iter)); return(false); }
/// <summary> /// Return an array of Category names. /// </summary> /// <returns> /// A <see cref="System.String"/> /// </returns> public string[] GetCategoryNames() { List <string> categories = new List <string> (); string[] emptyArray = categories.ToArray(); Gtk.TreeIter iter; Gtk.TreeModel model = Application.Backend.Categories; if (!model.GetIterFirst(out iter)) { return(emptyArray); } do { ICategory category = model.GetValue(iter, 0) as ICategory; if (category is AllCategory) { continue; // Prevent the AllCategory from being returned } categories.Add(category.Name); } while (model.IterNext(ref iter)); return(categories.ToArray()); }
void OutlineTreeDataFunc(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { Gtk.CellRendererText txtRenderer = (Gtk.CellRendererText)cell; OutlineNode n = (OutlineNode)model.GetValue(iter, 0); txtRenderer.Text = n.Name; }
void RenderProtocol(Gtk.TreeViewColumn column, Gtk.CellRenderer cellr, Gtk.TreeModel model, Gtk.TreeIter iter) { FilterModel filter = (FilterModel)model.GetValue(iter, 0); (cellr as Gtk.CellRendererCombo).Text = filter.Protocol; }
void outlineTreeDataFunc(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { Gtk.CellRendererText txtRenderer = (Gtk.CellRendererText)cell; XNode n = (XNode)model.GetValue(iter, 0); txtRenderer.Text = n.FriendlyPathRepresentation; }
static void TypeDataFunc(Gtk.CellLayout cell_layout, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { var dataNode = (ResXNode)tree_model.GetValue(iter, 0); var crt = (Gtk.CellRendererText)cell; crt.Text = dataNode.TypeName; }
protected static void CommentDataFunc(Gtk.CellLayout cell_layout, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { var dataNode = (ResXNode)tree_model.GetValue(iter, 0); var crt = (Gtk.CellRendererText)cell; crt.Text = dataNode.Comment; }
protected static void ValueDataFunc(Gtk.CellLayout cell_layout, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { var dataNode = (ResXNode)tree_model.GetValue(iter, 0); var crt = (Gtk.CellRendererText)cell; crt.Text = Convert.ToString(dataNode.Value); }
private void _RenderIrcGroupPersonMode(Gtk.TreeViewColumn column, Gtk.CellRenderer cellr, Gtk.TreeModel model, Gtk.TreeIter iter) { IrcGroupPersonModel person = model.GetValue(iter, 0) as IrcGroupPersonModel; if (person == null) { #if LOG4NET _Logger.Error("_RenderIrcGroupPersonMode(): person == null"); #endif return; } string mode; if (person.IsOp) { mode = "@"; } else if (person.IsVoice) { mode = "+"; } else { mode = String.Empty; } (cellr as Gtk.CellRendererText).Text = mode; }
void OnCursorChanged(object sender, EventArgs e) { Gtk.TreeView treeView = Utils.dynamic_cast <Gtk.TreeView>(sender); Gtk.TreeSelection selection = treeView.Selection; Gtk.TreeModel treeModel = null; Gtk.TreeIter treeIter; selection.GetSelected(out treeModel, out treeIter); _selectedCommand = treeModel.GetValue(treeIter, 0).ToString(); }
private void RenderCellFamilyName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { Pango.FontFamily family = model.GetValue(iter, 1) as Pango.FontFamily; (cell as Gtk.CellRendererText).Text = family.Name; Pango.FontDescription desc = new Pango.FontDescription(); desc.Family = family.Name; desc.Size = (int)(FontTool.FontService.FONT_DEFAULT_SIZE * Pango.Scale.PangoScale); (cell as Gtk.CellRendererText).FontDesc = desc; }
/// <summary> /// Filter out SpecialNotebooks from the model /// </summary> static bool FilterNotebooks(Gtk.TreeModel model, Gtk.TreeIter iter) { Notebook notebook = model.GetValue(iter, 0) as Notebook; if (notebook == null || notebook is SpecialNotebook) { return(false); } return(true); }
protected virtual void RenderChatViewActivity(Gtk.TreeViewColumn column, Gtk.CellRenderer cellr, Gtk.TreeModel model, Gtk.TreeIter iter) { if (cellr == null) { throw new ArgumentNullException("cellr"); } if (model == null) { throw new ArgumentNullException("model"); } var chat = (ChatView)model.GetValue(iter, 0); var renderer = (Gtk.CellRendererText)cellr; Gdk.Color color; string text = null; if (chat.HighlightCount >= 1) { color = ThemeSettings.HighlightColor; text = chat.HighlightCount.ToString(); } else if (chat.ActivityCount >= 1) { color = ThemeSettings.ActivityColor; text = chat.ActivityCount.ToString(); } else { // no highlight counter renderer.Markup = String.Empty; return; } if (text == null) { return; } var textColor = TextColorTools.GetBestTextColor( ColorConverter.GetTextColor(color), ColorConverter.GetTextColor( Gtk.Rc.GetStyle(this).Base(Gtk.StateType.Normal) ), TextColorContrast.High ); renderer.Markup = String.Format( "<span foreground=\"{0}\">({1})</span>", GLib.Markup.EscapeText(textColor.ToString()), GLib.Markup.EscapeText(text) ); }
protected virtual void RenderChatViewName(Gtk.TreeViewColumn column, Gtk.CellRenderer cellr, Gtk.TreeModel model, Gtk.TreeIter iter) { var chat = (ChatView)model.GetValue(iter, 0); var renderer = (Gtk.CellRendererText)cellr; Gdk.Color color; string text; if (chat.HighlightCount > 1) { color = ThemeSettings.HighlightColor; text = String.Format("{0} ({1})", chat.Name, chat.HighlightCount.ToString()); } else if (chat.HighlightCount == 1) { color = ThemeSettings.HighlightColor; text = chat.Name; } else if (chat.HasActivity) { color = ThemeSettings.ActivityColor; text = chat.Name; } else if (chat.HasEvent) { color = ThemeSettings.EventColor; text = chat.Name; } else { // no activity color = ThemeSettings.NoActivityColor; text = chat.Name; } var textColor = TextColorTools.GetBestTextColor( ColorConverter.GetTextColor(color), ColorConverter.GetTextColor( Gtk.Rc.GetStyle(this).Base(Gtk.StateType.Normal) ), TextColorContrast.High ); renderer.Markup = String.Format( "<span foreground=\"{0}\">{1}</span>", GLib.Markup.EscapeText(textColor.ToString()), GLib.Markup.EscapeText(text) ); }
private bool ShouldSelectPort(Gtk.TreeSelection selection, Gtk.TreeModel model, Gtk.TreePath path, bool path_currently_selected) { var shouldSelect = true; Gtk.TreeIter iter; if (selection.GetSelected(out iter)) { var viewModel = DataContext as SerialPortSelectorViewModel; var item = model.GetValue(iter, 0) as SerialPortViewModel; shouldSelect = (item != null) && !viewModel.DisabledSerialPorts.Contains(item.PortName); } return(shouldSelect); }
void outlineTreeDataFunc(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { Gtk.CellRendererText txtRenderer = (Gtk.CellRendererText)cell; Node n = (Node)model.GetValue(iter, 0); string name = null; if (n is TagNode) { TagNode tn = (TagNode)n; name = tn.TagName; string att = null; if (tn.Attributes != null) { att = tn.Attributes["id"] as string; } if (att != null) { name = "<" + name + "#" + att + ">"; } else { name = "<" + name + ">"; } } else if (n is DirectiveNode) { DirectiveNode dn = (DirectiveNode)n; name = "<%@ " + dn.Name + " %>"; } else if (n is ExpressionNode) { ExpressionNode en = (ExpressionNode)n; string expr = en.Expression; if (string.IsNullOrEmpty(expr)) { name = "<% %>"; } else { if (expr.Length > 10) { expr = expr.Substring(0, 10) + "..."; } name = "<% " + expr + "%>"; } } if (name != null) { txtRenderer.Text = name; } }
void RenderMessageType(Gtk.TreeViewColumn column, Gtk.CellRenderer cellr, Gtk.TreeModel model, Gtk.TreeIter iter) { FilterModel filter = (FilterModel)model.GetValue(iter, 0); foreach (object[] row in f_MessageTypeListStore) { if ((MessageType?)row[1] == filter.MessageType) { (cellr as Gtk.CellRendererCombo).Text = (string)row[0]; break; } } }
static int CompareCategorySortFunc(Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) { ICategory categoryA = model.GetValue(a, 0) as ICategory; ICategory categoryB = model.GetValue(b, 0) as ICategory; if (categoryA == null || categoryB == null) { return(0); } if (categoryA is Tasque.AllCategory) { return(-1); } else if (categoryB is Tasque.AllCategory) { return(1); } return(categoryA.Name.CompareTo(categoryB.Name)); }
private void RenderArtistName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { Song song = (Song)model.GetValue(iter, 0); if (song.Artist.StartsWith("X") == true) { (cell as Gtk.CellRendererText).Foreground = "red"; } else { (cell as Gtk.CellRendererText).Foreground = "darkgreen"; } (cell as Gtk.CellRendererText).Text = song.Artist; }
protected virtual int SortTreeStore(Gtk.TreeModel model, Gtk.TreeIter iter1, Gtk.TreeIter iter2) { var chat1 = (ChatView)model.GetValue(iter1, 0); var chat2 = (ChatView)model.GetValue(iter2, 0); // Smuxi is always the first item if (chat1 is SessionChatView && chat2 is SessionChatView) { return(0); } else if (chat1 is SessionChatView) { return(-1); } else if (chat2 is SessionChatView) { return(1); } else if (chat1 is GroupChatView && chat2 is GroupChatView) { // let Name decide } else if (chat1 is GroupChatView) { return(-1); } else if (chat2 is GroupChatView) { return(1); } return(chat1.Name.CompareTo(chat2.Name)); }
public object GetValue(Gtk.TreeIter it, int column) { object val = store.GetValue(it, column); if (val is Gdk.Pixbuf) { return(WidgetRegistry.CreateFrontend <Image> (val)); } else if (val is DBNull) { return(null); } else { return(val); } }
private void RenderObject(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { object obj = model.GetValue(iter, 1); Type dossierType = typeof(Dossier); Type documentType = typeof(Document); if (dossierType.IsInstanceOfType(obj)) { Dossier dossier = (Dossier)obj; (cell as Gtk.CellRendererText).Text = dossier.Caption; } else if (documentType.IsInstanceOfType(obj)) { Document document = (Document)obj; (cell as Gtk.CellRendererText).Text = document.Caption; } }
private bool FilterTree(Gtk.TreeModel model, Gtk.TreeIter iter) { string artistName = model.GetValue(iter, 0).ToString(); if (filterEntry.Text == "") { return(true); } if (artistName.IndexOf(filterEntry.Text) > -1) { return(true); } else { return(false); } }
public object GetValue(Gtk.TreeIter it, int column) { object val = store.GetValue(it, column); if (val is Gdk.Pixbuf) { return(ApplicationContext.Toolkit.WrapImage(val)); } else if (val is DBNull) { return(null); } else if (val is ObjectWrapper) { return(((ObjectWrapper)val).Object); } else { return(val); } }
List <NotebookMenuItem> GetNotebookMenuItems() { List <NotebookMenuItem> items = new List <NotebookMenuItem> (); Gtk.TreeModel model = NotebookManager.Notebooks; Gtk.TreeIter iter; if (model.GetIterFirst(out iter) == true) { do { Notebook notebook = model.GetValue(iter, 0) as Notebook; NotebookMenuItem item = new NotebookMenuItem(Note, notebook); items.Add(item); } while (model.IterNext(ref iter) == true); } items.Sort(); return(items); }