Inheritance: Gtk.CellRendererText
Beispiel #1
0
        public static void CellDataHandler(ICellLayout layout, CellRenderer cell, ITreeModel model, TreeIter iter)
        {
            SourceRowRenderer renderer = cell as SourceRowRenderer;

            if (renderer == null)
            {
                return;
            }

            var type = model.GetValue(iter, (int)SourceModel.Columns.Type);

            if (type == null || (SourceModel.EntryType)type != SourceModel.EntryType.Source)
            {
                renderer.Visible = false;
                return;
            }

            Source source = model.GetValue(iter, 0) as Source;

            renderer.Source = source;
            renderer.Iter   = iter;

            if (source == null)
            {
                return;
            }

            renderer.Visible   = true;
            renderer.Text      = source.Name;
            renderer.Sensitive = source.CanActivate;
        }
Beispiel #2
0
        private void BuildColumns()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn();

            col.Visible = false;
            AppendColumn(col);
            ExpanderColumn = col;

            source_column        = new TreeViewColumn();
            source_column.Sizing = TreeViewColumnSizing.Autosize;

            uint xpad = 2;

            // Special renderer for header rows; hidden for normal source rows
            header_renderer = new CellRendererText()
            {
                Xpad      = xpad,
                Ypad      = 4,
                Ellipsize = Pango.EllipsizeMode.End,
                Weight    = (int)Pango.Weight.Bold,
                Variant   = Pango.Variant.SmallCaps
            };

            // Renderer for source rows; hidden for header rows
            source_renderer      = new SourceRowRenderer();
            source_renderer.Xpad = xpad;

            source_column.PackStart(header_renderer, true);
            source_column.SetCellDataFunc(header_renderer, new Gtk.CellLayoutDataFunc((layout, cell, model, iter) => {
                var type = (SourceModel.EntryType)model.GetValue(iter, (int)SourceModel.Columns.Type);
                header_renderer.Visible = type == SourceModel.EntryType.Group;
                source_renderer.Visible = type == SourceModel.EntryType.Source;
                if (type == SourceModel.EntryType.Group)
                {
                    var source = model.GetValue(iter, (int)SourceModel.Columns.Source) as Source;
                    header_renderer.Visible = true;
                    header_renderer.Text    = source.Name;
                }
                else
                {
                    header_renderer.Visible = false;
                }
            }));

            int width, height;

            Gtk.Icon.SizeLookup(IconSize.Menu, out width, out height);
            source_renderer.RowHeight = RowHeight.Get();
            source_renderer.RowHeight = height;

            source_renderer.Ypad = (uint)RowPadding.Get();
            source_renderer.Ypad = 2;
            source_column.PackStart(source_renderer, true);
            source_column.SetCellDataFunc(source_renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));
            AppendColumn(source_column);

            HeadersVisible = false;
        }
Beispiel #3
0
        private void BuildColumns()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn();

            col.Visible = false;
            AppendColumn(col);
            ExpanderColumn = col;

            focus_column       = new TreeViewColumn();
            renderer           = new SourceRowRenderer();
            renderer.RowHeight = RowHeight.Get();
            renderer.Padding   = RowPadding.Get();
            focus_column.PackStart(renderer, true);
            focus_column.SetCellDataFunc(renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));
            AppendColumn(focus_column);

            HeadersVisible = false;
        }
Beispiel #4
0
        public static void CellDataHandler (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            SourceRowRenderer renderer = cell as SourceRowRenderer;
            Source source = model.GetValue (iter, 0) as Source;

            if (renderer == null) {
                return;
            }

            renderer.Source = source;
            renderer.Path = model.GetPath (iter);

            if (source == null) {
                return;
            }

            renderer.Text = source.Name;
            renderer.Sensitive = source.CanActivate;
        }
Beispiel #5
0
        public SourceComboBox()
        {
            renderer = new SourceRowRenderer();
            renderer.ParentWidget = this;
            PackStart(renderer, true);
            SetCellDataFunc(renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));

            store = new SourceModel();
            Model = store;

            ServiceManager.SourceManager.ActiveSourceChanged += delegate {
                ThreadAssist.ProxyToMain(UpdateActiveSource);
            };

            ServiceManager.SourceManager.SourceUpdated += delegate {
                ThreadAssist.ProxyToMain(QueueDraw);
            };

            store.Refresh();
        }
Beispiel #6
0
        public SourceComboBox()
        {
            renderer = new SourceRowRenderer ();
            renderer.ParentWidget = this;
            PackStart (renderer, true);
            SetCellDataFunc (renderer, new CellLayoutDataFunc (SourceRowRenderer.CellDataHandler));

            store = new SourceModel ();
            Model = store;

            ServiceManager.SourceManager.ActiveSourceChanged += delegate {
                ThreadAssist.ProxyToMain (UpdateActiveSource);
            };

            ServiceManager.SourceManager.SourceUpdated += delegate {
                ThreadAssist.ProxyToMain (QueueDraw);
            };

            store.Refresh ();
        }
        private void BuildColumns ()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn ();
            col.Visible = false;
            AppendColumn (col);
            ExpanderColumn = col;

            focus_column = new TreeViewColumn ();
            renderer = new SourceRowRenderer ();
            renderer.RowHeight = RowHeight.Get ();
            renderer.Padding = RowPadding.Get ();
            focus_column.PackStart (renderer, true);
            focus_column.SetCellDataFunc (renderer, new CellLayoutDataFunc (SourceRowRenderer.CellDataHandler));
            AppendColumn (focus_column);

            HeadersVisible = false;
        }
Beispiel #8
0
        private void BuildColumns ()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn ();
            col.Visible = false;
            AppendColumn (col);
            ExpanderColumn = col;

            source_column = new TreeViewColumn ();
            source_column.Sizing = TreeViewColumnSizing.Autosize;

            uint xpad = 2;

            // Special renderer for header rows; hidden for normal source rows
            header_renderer = new CellRendererText () {
                Xpad = xpad,
                Ypad = 4,
                Ellipsize = Pango.EllipsizeMode.End,
                Weight = (int)Pango.Weight.Bold,
                Variant = Pango.Variant.SmallCaps
            };

            // Renderer for source rows; hidden for header rows
            source_renderer = new SourceRowRenderer ();
            source_renderer.Xpad = xpad;

            source_column.PackStart (header_renderer, true);
            source_column.SetCellDataFunc (header_renderer, new Gtk.CellLayoutDataFunc ((layout, cell, model, iter) => {
                var type = (SourceModel.EntryType) model.GetValue (iter, (int)SourceModel.Columns.Type);
                header_renderer.Visible = type == SourceModel.EntryType.Group;
                source_renderer.Visible = type == SourceModel.EntryType.Source;
                if (type == SourceModel.EntryType.Group) {
                    var source = model.GetValue (iter, (int)SourceModel.Columns.Source) as Source;
                    header_renderer.Visible = true;
                    header_renderer.Text = source.Name;
                } else {
                    header_renderer.Visible = false;
                }
            }));

            int width, height;
            Gtk.Icon.SizeLookup (IconSize.Menu, out width, out height);
            source_renderer.RowHeight = RowHeight.Get ();
            source_renderer.RowHeight = height;

            source_renderer.Ypad = (uint)RowPadding.Get ();
            source_renderer.Ypad = 2;
            source_column.PackStart (source_renderer, true);
            source_column.SetCellDataFunc (source_renderer, new CellLayoutDataFunc (SourceRowRenderer.CellDataHandler));
            AppendColumn (source_column);

            HeadersVisible = false;
        }
Beispiel #9
0
        private void BuildColumns()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn();

            col.Visible = false;
            AppendColumn(col);
            ExpanderColumn = col;

            source_column        = new TreeViewColumn();
            source_column.Sizing = TreeViewColumnSizing.Autosize;

            uint xpad = 2;

            // Special renderer for header rows; hidden for normal source rows
            header_renderer = new CellRendererText()
            {
                Xpad      = xpad,
                Ypad      = 4,
                Ellipsize = Pango.EllipsizeMode.End,
                Weight    = (int)Pango.Weight.Bold,
                Variant   = Pango.Variant.SmallCaps
            };

            // Renderer for source rows; hidden for header rows
            source_renderer      = new SourceRowRenderer();
            source_renderer.Xpad = xpad;

            source_column.PackStart(header_renderer, true);
            source_column.SetCellDataFunc(header_renderer, new Gtk.CellLayoutDataFunc((layout, cell, model, iter) => {
                if (model == null)
                {
                    throw new ArgumentNullException("model");
                }

                // be paranoid about the values returned from model.GetValue(), they may be null or have unexpected types, see bgo#683359
                var obj_type = model.GetValue(iter, (int)SourceModel.Columns.Type);
                if (obj_type == null || !(obj_type is SourceModel.EntryType))
                {
                    var source      = model.GetValue(iter, (int)SourceModel.Columns.Source) as Source;
                    var source_name = source == null ? "some source" : String.Format("source {0}", source.Name);

                    Log.ErrorFormat(
                        "SourceView of {0} could not render its source column because its type value returned {1} from the iter",
                        source_name, obj_type == null ? "null" : String.Format("an instance of {0}", obj_type.GetType().FullName));

                    header_renderer.Visible = false;
                    source_renderer.Visible = false;

                    return;
                }

                var type = (SourceModel.EntryType)obj_type;
                header_renderer.Visible = type == SourceModel.EntryType.Group;
                source_renderer.Visible = type == SourceModel.EntryType.Source;
                if (type == SourceModel.EntryType.Group)
                {
                    var source = (Source)model.GetValue(iter, (int)SourceModel.Columns.Source);
                    header_renderer.Visible = true;
                    header_renderer.Text    = source.Name;
                }
                else
                {
                    header_renderer.Visible = false;
                }
            }));

            int width, height;

            Gtk.Icon.SizeLookup(IconSize.Menu, out width, out height);
            source_renderer.RowHeight = RowHeight.Get();
            source_renderer.RowHeight = height;

            source_renderer.Ypad = (uint)RowPadding.Get();
            source_renderer.Ypad = 2;
            source_column.PackStart(source_renderer, true);
            source_column.SetCellDataFunc(source_renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler));
            AppendColumn(source_column);

            HeadersVisible = false;
        }
Beispiel #10
0
        private void BuildColumns ()
        {
            // Hidden expander column
            TreeViewColumn col = new TreeViewColumn ();
            col.Visible = false;
            AppendColumn (col);
            ExpanderColumn = col;

            source_column = new TreeViewColumn ();
            source_column.Sizing = TreeViewColumnSizing.Autosize;

            uint xpad = 2;

            // Special renderer for header rows; hidden for normal source rows
            header_renderer = new CellRendererText () {
                Xpad = xpad,
                Ypad = 4,
                Ellipsize = Pango.EllipsizeMode.End,
                Weight = (int)Pango.Weight.Bold,
                Variant = Pango.Variant.SmallCaps
            };

            // Renderer for source rows; hidden for header rows
            source_renderer = new SourceRowRenderer ();
            source_renderer.Xpad = xpad;

            source_column.PackStart (header_renderer, true);
            source_column.SetCellDataFunc (header_renderer, new Gtk.CellLayoutDataFunc ((layout, cell, model, iter) => {
                if (model == null) {
                    throw new ArgumentNullException ("model");
                }

                // be paranoid about the values returned from model.GetValue(), they may be null or have unexpected types, see bgo#683359
                var obj_type = model.GetValue (iter, (int)SourceModel.Columns.Type);
                if (obj_type == null || !(obj_type is SourceModel.EntryType)) {

                    var source = model.GetValue (iter, (int)SourceModel.Columns.Source) as Source;
                    var source_name = source == null ? "some source" : String.Format ("source {0}", source.Name);

                    Log.ErrorFormat (
                        "SourceView of {0} could not render its source column because its type value returned {1} from the iter",
                        source_name, obj_type == null ? "null" : String.Format ("an instance of {0}", obj_type.GetType ().FullName));

                    header_renderer.Visible = false;
                    source_renderer.Visible = false;

                    return;
                }

                var type = (SourceModel.EntryType) obj_type;
                header_renderer.Visible = type == SourceModel.EntryType.Group;
                source_renderer.Visible = type == SourceModel.EntryType.Source;
                if (type == SourceModel.EntryType.Group) {
                    var source = (Source) model.GetValue (iter, (int)SourceModel.Columns.Source);
                    header_renderer.Visible = true;
                    header_renderer.Text = source.Name;
                } else {
                    header_renderer.Visible = false;
                }
            }));

            int width, height;
            Gtk.Icon.SizeLookup (IconSize.Menu, out width, out height);
            source_renderer.RowHeight = RowHeight.Get ();
            source_renderer.RowHeight = height;

            source_renderer.Ypad = (uint)RowPadding.Get ();
            source_renderer.Ypad = 2;
            source_column.PackStart (source_renderer, true);
            source_column.SetCellDataFunc (source_renderer, new CellLayoutDataFunc (SourceRowRenderer.CellDataHandler));
            AppendColumn (source_column);

            HeadersVisible = false;
        }