Exemplo n.º 1
0
        int NormalPackageCompareNodes(Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b)
        {
            string name1 = (string)model.GetValue(a, NormalPackageNameID);
            string name2 = (string)model.GetValue(b, NormalPackageNameID);

            return(string.Compare(name1, name2, true));
        }
Exemplo n.º 2
0
 // Delegate Functions :: Data Function
 // Delegate Functions :: Data Function :: PixbufCellDataFunc
 /// <summary>Delegate used to render the covers.</summary>
 private void PixbufCellDataFunc
     (Gtk.TreeViewColumn col, Gtk.CellRenderer cell, Gtk.TreeModel model,
     Gtk.TreeIter iter)
 {
     Gtk.CellRendererPixbuf cell_pb = (Gtk.CellRendererPixbuf)cell;
     SetCoverImage(cell_pb, iter);
 }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 // Delegate Functions :: Data Function :: TextCellDataFunc
 /// <summary>Delegate used to render the album text.</summary>
 private void TextCellDataFunc
     (Gtk.TreeViewColumn col, Gtk.CellRenderer cell, Gtk.TreeModel model,
     Gtk.TreeIter iter)
 {
     Gtk.CellRendererText cell_txt = (Gtk.CellRendererText)cell;
     SetText(cell_txt, iter);
 }
Exemplo n.º 6
0
        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;
        }
        /// <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());
        }
        /// <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);
        }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        void OnSetPolicyData(Gtk.TreeViewColumn treeColumn, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            MimeTypePanelData mt = (MimeTypePanelData)store.GetValue(iter, 0);

            string selection;

            if (mt.UseParentPolicy)
            {
                selection = panel.IsCustomUserPolicy ? systemPolicyText : parentPolicyText;
            }
            else
            {
                PolicySet matchingSet = mt.GetMatchingSet(GetCandidateSets(mt));
                if (matchingSet != null)
                {
                    selection = matchingSet.Name;
                }
                else
                {
                    selection = customPolicyText;
                }
            }

            CellRendererComboBox comboCell = (CellRendererComboBox)cell;

            comboCell.Values = GetComboOptions(mt);
            comboCell.Text   = selection;
        }
Exemplo n.º 12
0
        protected void attachSubTree(Gtk.TreeModel model, Gtk.TreeIter parent, params object[] elements)
        {
            Gtk.TreeStore store = model as Gtk.TreeStore;

            // remove the values if they were added before.
            Gtk.TreePath path = store.GetPath(parent);
            path.Down();
            Gtk.TreeIter iter;
            while (store.GetIter(out iter, path))
            {
                store.Remove(ref iter);
            }

            // Add the elements to the tree view.
            DirectoryInfo[] di = elements[0] as DirectoryInfo[];
            FileInfo[]      fi = elements[1] as FileInfo[];

            for (uint i = 0; i < di.Length; ++i)
            {
                store.AppendValues(parent, di[i].ToString());
            }

            for (uint i = 0; i < fi.Length; ++i)
            {
                store.AppendValues(parent, fi[i].ToString());
            }
        }
        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;
        }
Exemplo n.º 14
0
        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;
        }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
0
 public void LoadData(Gtk.TreeModel model, Gtk.TreeIter iter)
 {
     TreeModel            = model;
     CurrentIter          = iter;
     EventSink            = Frontend.Load(this);
     CellRenderer.Visible = Frontend.Visible;
     OnLoadData();
 }
Exemplo n.º 17
0
        /// <summary>
        /// Use reflection to get the TreePath of the Graphs node. This is kind of ugly...
        /// </summary>
        /// <param name="tree">Instance of a Gtk.TreeView.</param>
        /// <param name="treeModel">Instance of a Gtk.TreeModel.</param>
        /// <param name="path">Path string - e.g. ".Simulations.ContinuousWheat.Paddock"</param>
        private Gtk.TreePath GetTreePath(TreeView tree, string path)
        {
            Gtk.TreeModel treeModel = (Gtk.TreeModel)ReflectionUtilities.GetValueOfFieldOrProperty("treemodel", tree);
            MethodInfo    findNode  = typeof(TreeView).GetMethod("FindNode", BindingFlags.NonPublic | BindingFlags.Instance);

            Gtk.TreeIter iter = (Gtk.TreeIter)findNode.Invoke(tree, new[] { path });
            return(treeModel.GetPath(iter));
        }
Exemplo n.º 18
0
 public void Dispose()
 {
     model.RowChanged    -= row_event;
     model.RowDeleted    -= row_event;
     model.RowInserted   -= row_event;
     model.RowsReordered -= row_event;
     model = null;
 }
Exemplo n.º 19
0
 private bool ForeachRow(Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter)
 {
     if (assemblyTree.GetRowExpanded(path))
     {
         treePaths.Add(path.ToString());
     }
     return(false);
 }
Exemplo n.º 20
0
 public TreeEnumerator(TreeModel model)
 {
     this.model           = model;
     model.RowChanged    += row_event;
     model.RowDeleted    += row_event;
     model.RowInserted   += row_event;
     model.RowsReordered += row_event;
 }
 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();
 }
Exemplo n.º 22
0
        /// <summary>
        /// Synchronize data into a GTK model.
        /// </summary>
        /// <typeparam name="T">Type of element in the collection.</typeparam>
        /// <param name="model">The model to synchronize into.</param>
        /// <param name="collectionChangedArgs">Description of what has changed.</param>
        /// <remarks>Wacky idea: Wrap TreeModel in an INotifyCollection directly?</remarks>
        public static void SynchronizeCollection <T>(this Gtk.TreeModel model, NotifyCollectionChangedEventArgs collectionChangedArgs) where T : class
        {
            if (model == null)
            {
                return;
            }
            if (!(model is Gtk.ListStore))
            {
                throw new System.InvalidOperationException("Only implemented for Gtk.ListStore!");
            }
            var listStore = (Gtk.ListStore)model;

            switch (collectionChangedArgs.Action)
            {
            case NotifyCollectionChangedAction.Add:
                ////var newItems = collectionChangedArgs.NewItems.Cast<T>();
                var insertIndex = collectionChangedArgs.NewStartingIndex;
                foreach (T item in collectionChangedArgs.NewItems)
                {
                    if (insertIndex < 0)
                    {
                        listStore.AppendValues(item);
                    }
                    else
                    {
                        listStore.InsertWithValues(insertIndex++, item);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Move:
                ErrorReporting.ReportNotImplementedError("ObservableColletionHelpers.SynchronizeCollection:NotifyCollectionChangedAction.Move");
                break;

            case NotifyCollectionChangedAction.Remove:
                listStore.RemoveItems <T>(collectionChangedArgs.OldItems);
                break;

            case NotifyCollectionChangedAction.Replace:
                // remove
                listStore.RemoveItems <T>(collectionChangedArgs.OldItems);

                // add
                foreach (T item in collectionChangedArgs.NewItems)
                {
                    listStore.AppendValues(item);
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                listStore.Clear();
                break;

            default:
                break;
            }
        }
Exemplo n.º 23
0
        private void OnTextFunc(
            Gtk.TreeViewColumn col, Gtk.CellRenderer cell,
            Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            Node node = GetNodeFromIter(iter);

            Gtk.CellRendererText c = cell as Gtk.CellRendererText;
            c.Text = node.Name;
        }
Exemplo n.º 24
0
		public TreeEnumerator (TreeModel model)
		{
			this.model = model;
			
			model.RowChanged += new RowChangedHandler (row_changed);
			model.RowDeleted += new RowDeletedHandler (row_deleted);
			model.RowInserted += new RowInsertedHandler (row_inserted);
			model.RowsReordered += new RowsReorderedHandler (rows_reordered);
		}
Exemplo n.º 25
0
        public TreeEnumerator(TreeModel model)
        {
            this.model = model;

            model.RowChanged    += new RowChangedHandler(row_changed);
            model.RowDeleted    += new RowDeletedHandler(row_deleted);
            model.RowInserted   += new RowInsertedHandler(row_inserted);
            model.RowsReordered += new RowsReorderedHandler(rows_reordered);
        }
Exemplo n.º 26
0
        bool IsRowSeparator(Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            Gtk.TreePath path = model.GetPath(iter);
            bool         res  = false;

            ApplicationContext.InvokeUserCode(delegate {
                res = EventSink.RowIsSeparator(path.Indices[0]);
            });
            return(res);
        }
Exemplo n.º 27
0
        bool IsRowSeparator(Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            Gtk.TreePath path = model.GetPath(iter);
            bool         res  = false;

            Toolkit.Invoke(delegate {
                res = EventSink.RowIsSeparator(path.Indices[0]);
            });
            return(res);
        }
Exemplo n.º 28
0
        public void NativeCallback(IntPtr model, ref Gtk.TreeIter iter, IntPtr uri, IntPtr title, out bool custom_title, IntPtr user_data)
        {
            Gtk.TreeModel _arg0 = GLib.Object.GetObject(model) as Gtk.TreeModel;
            Gtk.TreeIter  _arg1 = iter;
            string        _arg2 = GLib.Marshaller.PtrToStringGFree(uri);
            string        _arg3 = GLib.Marshaller.PtrToStringGFree(title);
            bool          _arg4;

            managed(_arg0, _arg1, _arg2, _arg3, out _arg4);
            custom_title = _arg4;
        }
Exemplo n.º 29
0
        protected virtual int SortPersonListStore(Gtk.TreeModel model,
                                                  Gtk.TreeIter iter1,
                                                  Gtk.TreeIter iter2)
        {
            Gtk.ListStore liststore = (Gtk.ListStore)model;

            PersonModel person1 = (PersonModel)liststore.GetValue(iter1, 0);
            PersonModel person2 = (PersonModel)liststore.GetValue(iter2, 0);

            return(person1.CompareTo(person2));
        }
Exemplo n.º 30
0
        /// <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);
        }
Exemplo n.º 31
0
 public void Initialize(Type[] columnTypes)
 {
     Type[] types = new Type[columnTypes.Length];
     for (int n=0; n<types.Length; n++) {
         if (columnTypes [n] == typeof(Image))
             types [n] = typeof(Gdk.Pixbuf);
         else
             types [n] = columnTypes [n];
     }
     store = InitializeModel (types);
 }
Exemplo n.º 32
0
        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)
                );
        }
Exemplo n.º 33
0
 public void Initialize(Type[] columnTypes)
 {
     types = new Type[columnTypes.Length];
     for (int n=0; n<types.Length; n++) {
         if (columnTypes [n] == typeof(Image))
             types [n] = typeof(ImageDescription);
         else if (columnTypes [n] == typeof(Object))
             types [n] = typeof(ObjectWrapper);
         else
             types [n] = columnTypes [n];
     }
     store = InitializeModel (types);
 }
Exemplo n.º 34
0
 public void LoadData(Gtk.TreeModel model, Gtk.TreeIter iter)
 {
     TreeModel = model;
     CurrentIter = iter;
     EventSink = Frontend.Load (this);
     CellRenderer.Visible = Frontend.Visible;
     OnLoadData ();
 }