// Constructor /// <summary>Creates a new Add Song window.</summary> /// <remarks>This is created when "Play Song" is clicked.</remarks> public AddSongWindow() { base.Title = string_title; base.SetGConfSize (GConfKeyWidth, GConfDefaultWidth, GConfKeyHeight, GConfDefaultHeight); base.Items = Global.DB.Songs.Values; base.List.Model.SortFunc = new HandleModel.CompareFunc(SortFunc); // Column Gtk.TreeViewColumn col = new Gtk.TreeViewColumn(); col.Sizing = Gtk.TreeViewColumnSizing.Fixed; col.PackStart(base.TextRenderer, true); Gtk.TreeCellDataFunc func = new Gtk.TreeCellDataFunc(CellDataFunc); col.SetCellDataFunc(base.TextRenderer, func); base.List.AppendColumn(col); // Setup drag and drop base.List.DragSource = source_entries; base.List.DragDataGet += OnDragDataGet; // Setup handlers Global.DB.SongAdded += base.OnAdded; Global.DB.SongChanged += base.OnChanged; Global.DB.SongRemoved += base.OnRemoved; }
public TreeCellDataFuncWrapper(Gtk.TreeCellDataFunc managed) { this.managed = managed; if (managed != null) { NativeDelegate = new TreeCellDataFuncNative(NativeCallback); } }
// Constructor /// <summary>Creates a new Add Album window.</summary> /// <remarks>This is created when "Play Album" is clicked.</remarks> public AddAlbumWindow() { base.Title = string_title; base.SetGConfSize (GConfKeyWidth, GConfDefaultWidth, GConfKeyHeight, GConfDefaultHeight); base.Items = Global.DB.Albums.Values; base.List.Model.SortFunc = new HandleModel.CompareFunc(SortFunc); // Column Gtk.TreeViewColumn col = new Gtk.TreeViewColumn(); col.Sizing = Gtk.TreeViewColumnSizing.Fixed; col.Spacing = 4; col.PackStart(pixbuf_renderer, false); col.PackStart(base.TextRenderer, true); // Data functions Gtk.TreeCellDataFunc func; func = new Gtk.TreeCellDataFunc(PixbufCellDataFunc); col.SetCellDataFunc(pixbuf_renderer, func); func = new Gtk.TreeCellDataFunc(TextCellDataFunc); col.SetCellDataFunc(base.TextRenderer, func); // Add column base.List.AppendColumn(col); // Setup drag and drop base.List.DragSource = source_entries; base.List.DragDataGet += OnDragDataGet; // Setup handlers Global.DB.AlbumAdded += base.OnAdded; Global.DB.AlbumChanged += base.OnChanged; Global.DB.AlbumRemoved += base.OnRemoved; Global.CoverDB.DoneLoading += OnCoversDoneLoading; // Enable drag and drop if we're not busy loading covers. if (!Global.CoverDB.Loading) { EnableDragDest(); } }
public void SetCellDataFunc(Gtk.CellRenderer cell_renderer, Gtk.TreeCellDataFunc func) { GtkSharp.TreeCellDataFuncWrapper func_wrapper = new GtkSharp.TreeCellDataFuncWrapper(func); IntPtr func_data; GLib.DestroyNotify destroy; if (func == null) { func_data = IntPtr.Zero; destroy = null; } else { func_data = (IntPtr)GCHandle.Alloc(func_wrapper); destroy = GLib.DestroyHelper.NotifyHandler; } gtk_tree_view_column_set_cell_data_func(Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, func_wrapper.NativeDelegate, func_data, destroy); }
public SidePaneTreeView(SidePaneTreeStore sidePaneStore) { Model = sidePaneStore; var filterTextDataFunc = new Gtk.TreeCellDataFunc(RenderFilterColumnTextFromBibtexRecords); var col = new Gtk.TreeViewColumn("Filter", new Gtk.CellRendererText(), "text"); col.SetCellDataFunc(col.Cells[0], filterTextDataFunc); col.Sizing = Gtk.TreeViewColumnSizing.Autosize; AppendColumn(col); Gtk.TreePath path = sidePaneStore.GetPathAll(); SetCursor(path, col, false); // Callbacks for the sidePaneTreeView //Selection.Changed += OnSidePaneTreeSelectionChanged; Show(); }
public LitTreeView(Gtk.ITreeModel model) { sorter = new Gtk.TreeModelSort(model); columnsIconSettings = new BibliographerSettings("apps.bibliographer.columns.icon"); columnsAuthorSettings = new BibliographerSettings("apps.bibliographer.columns.author"); columnsTitleSettings = new BibliographerSettings("apps.bibliographer.columns.title"); columnsYearSettings = new BibliographerSettings("apps.bibliographer.columns.year"); columnsJournalSettings = new BibliographerSettings("apps.bibliographer.columns.journal"); columnsBibtexKeySettings = new BibliographerSettings("apps.bibliographer.columns.bibtexkey"); columnsVolumeSettings = new BibliographerSettings("apps.bibliographer.columns.volume"); columnsPagesSettings = new BibliographerSettings("apps.bibliographer.columns.pages"); Model = sorter; Gtk.CellRendererPixbuf columnIconRenderer; Gtk.CellRendererText columnAuthorRenderer; Gtk.CellRendererText columnTitleRenderer; Gtk.CellRendererText columnYearRenderer; Gtk.CellRendererText columnJournalRenderer; Gtk.CellRendererText columnBibtexKeyRenderer; Gtk.CellRendererText columnVolumeRenderer; Gtk.CellRendererText columnPagesRenderer; columnIconRenderer = new Gtk.CellRendererPixbuf(); columnAuthorRenderer = new Gtk.CellRendererText(); columnTitleRenderer = new Gtk.CellRendererText(); columnYearRenderer = new Gtk.CellRendererText(); columnJournalRenderer = new Gtk.CellRendererText(); columnBibtexKeyRenderer = new Gtk.CellRendererText(); columnVolumeRenderer = new Gtk.CellRendererText(); columnPagesRenderer = new Gtk.CellRendererText(); AppendColumn("Icon", columnIconRenderer, "image"); AppendColumn("Author", columnAuthorRenderer, "text"); AppendColumn("Title", columnTitleRenderer, "text"); AppendColumn("Year", columnYearRenderer, "text"); AppendColumn("Journal", columnJournalRenderer, "text"); AppendColumn("Bibtex Key", columnBibtexKeyRenderer, "text"); AppendColumn("Volume", columnVolumeRenderer, "text"); AppendColumn("Pages", columnPagesRenderer, "text"); HeadersClickable = true; var textDataFunc = new Gtk.TreeCellDataFunc(RenderColumnTextFromBibtexRecord); var pixmapDataFunc = new Gtk.TreeCellDataFunc(RenderColumnPixbufFromBibtexRecord); int idx = 0; foreach (Gtk.TreeViewColumn column in Columns) { column.Expand = false; column.Reorderable = true; column.Resizable = true; column.Clickable = true; if (column.Title == "Icon") { column.FixedWidth = columnsIconSettings.GetInt("width"); column.Visible = columnsIconSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], pixmapDataFunc); column.Sizing = Gtk.TreeViewColumnSizing.Fixed; column.Resizable = false; column.Reorderable = false; column.Clickable = false; column.MinWidth = 20; } else if (column.Title == "Author") { column.FixedWidth = columnsAuthorSettings.GetInt("width"); column.Visible = columnsAuthorSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 1; sorter.SetSortFunc(1, StringCompareAuthor); column.Clicked += OnColumnSort; if (column != Columns[columnsAuthorSettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsAuthorSettings.GetInt("order") - 1]); } } else if (column.Title == "Title") { column.Expand = true; column.FixedWidth = columnsTitleSettings.GetInt("width"); column.Visible = columnsTitleSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 2; sorter.SetSortFunc(2, StringCompare); column.Clicked += OnColumnSort; if (column != Columns[columnsTitleSettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsTitleSettings.GetInt("order") - 1]); } } else if (column.Title == "Year") { column.FixedWidth = columnsYearSettings.GetInt("width"); column.Visible = columnsYearSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 3; sorter.SetSortFunc(3, StringCompare); column.Clicked += OnColumnSort; if (column != Columns[columnsYearSettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsYearSettings.GetInt("order") - 1]); } } else if (column.Title == "Journal") { column.FixedWidth = columnsJournalSettings.GetInt("width"); column.Visible = columnsJournalSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 4; sorter.SetSortFunc(4, StringCompare); column.Clicked += OnColumnSort; if (column != Columns[columnsJournalSettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsJournalSettings.GetInt("order") - 1]); } } else if (column.Title == "Bibtex Key") { column.FixedWidth = columnsBibtexKeySettings.GetInt("width"); column.Visible = columnsBibtexKeySettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 5; sorter.SetSortFunc(5, StringCompare); column.Clicked += OnColumnSort; if (column != Columns[columnsBibtexKeySettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsBibtexKeySettings.GetInt("order") - 1]); } } else if (column.Title == "Volume") { column.FixedWidth = columnsVolumeSettings.GetInt("width"); column.Visible = columnsVolumeSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 6; sorter.SetSortFunc(6, StringCompare); column.Clicked += OnColumnSort; if (column != Columns[columnsVolumeSettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsVolumeSettings.GetInt("order") - 1]); } } else if (column.Title == "Pages") { column.FixedWidth = columnsPagesSettings.GetInt("width"); column.Visible = columnsPagesSettings.GetBoolean("visible"); column.SetCellDataFunc(column.Cells[0], textDataFunc); column.SortColumnId = 7; sorter.SetSortFunc(7, StringCompare); column.Clicked += OnColumnSort; if (column != Columns[columnsPagesSettings.GetInt("order") - 1]) { MoveColumnAfter(column, Columns[columnsPagesSettings.GetInt("order") - 1]); } } idx++; } //RedrawColumns (); // Callbacks for the LitTreeView ColumnsChanged += OnColumnsChanged; DragMotion += OnDragMotion; RowActivated += OnRowActivated; DragLeave += OnDragLeave; Show(); }
public TreeCellDataFuncWrapper (Gtk.TreeCellDataFunc managed) { this.managed = managed; if (managed != null) NativeDelegate = new TreeCellDataFuncNative (NativeCallback); }