static void RenderColumnTextFromBibtexRecord(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { // See here for an example of how you can highlight cells // based on something todo with the entry // // TODO: extend this feature to highlight entries that // are missing required fields if ((model != null) && (column != null) && (column.Title != null)) { var record = (BibtexRecord)model.GetValue(iter, 0); if (record != null) { if (record.HasField(column.Title) && column.Title != "Author") { (cell as Gtk.CellRendererText).Text = StringOps.TeXToUnicode(record.GetField(column.Title)); (cell as Gtk.CellRendererText).Background = "white"; (cell as Gtk.CellRendererText).Ellipsize = Pango.EllipsizeMode.End; } else if (record.HasField(column.Title) && column.Title == "Author") { StringArrayList authors = record.GetAuthors(); string author_string = ""; foreach (string author in authors) { if (author_string == "") { author_string = author; } else { author_string = String.Concat(author_string, "; ", author); } } (cell as Gtk.CellRendererText).Text = StringOps.TeXToUnicode(author_string); (cell as Gtk.CellRendererText).Background = "white"; (cell as Gtk.CellRendererText).Ellipsize = Pango.EllipsizeMode.End; } else { (cell as Gtk.CellRendererText).Text = ""; // could highlight important fields that are missing data too, // for e.g. the line below: //(cell as Gtk.CellRendererText).Background = "green"; } if (!BibtexRecordTypeLibrary.Contains(record.RecordType)) { (cell as Gtk.CellRendererText).Foreground = "red"; } else { (cell as Gtk.CellRendererText).Foreground = "black"; } } } }
public static void Main(string[] args) { BibliographerMainWindow mainWindow; Builder gui; string filename; try { Utilities.SetProcessName("bibliographer"); } catch { Debug.WriteLine(0, "Cannot set process name"); } filename = ""; // Handle startup arguments foreach (string arg in args) { string st = arg.Trim(); if (st.IndexOf("-", StringComparison.CurrentCultureIgnoreCase) == 0 && st.IndexOf("=", StringComparison.CurrentCultureIgnoreCase) >= 0) { string[] str = st.Split('='); str[0] = (str[0]).Trim('-'); // Enable debugging if (str[0] == "debug") { if (str[1] == "true") { Debug.Enable(true); } // Modify debug level } else if (str[0] == "debug_level") { Debug.SetLevel(Convert.ToInt16(str[1])); } } else { if (st != "") { filename = st; } } } if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Environment.SetEnvironmentVariable("BIBTEX_TYPE_LIB", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\bibliographer\\bibtex_records"); Environment.SetEnvironmentVariable("BIBTEX_FIELDTYPE_LIB", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\bibliographer\\bibtex_fields"); } else { Environment.SetEnvironmentVariable("BIBTEX_TYPE_LIB", Environment.GetEnvironmentVariable("HOME") + "/.config/bibliographer/bibtex_records"); Environment.SetEnvironmentVariable("BIBTEX_FIELDTYPE_LIB", Environment.GetEnvironmentVariable("HOME") + "/.config/bibliographer/bibtex_fields"); } BibtexRecordTypeLibrary.Load(); BibtexRecordFieldTypeLibrary.Load(); Cache.Initialise(); Application.Init(); try { gui = new Builder(); System.IO.Stream guiStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("bibliographer.glade"); try { System.IO.StreamReader reader = new System.IO.StreamReader(guiStream); gui.AddFromString(reader.ReadToEnd()); } catch (ArgumentNullException e) { WriteLine(0, "GUI configuration file not found.\n" + e.Message); } mainWindow = new BibliographerMainWindow(gui); mainWindow.am.alterationMonitorThread.Start(); mainWindow.am.thumbGenThread.Start(); mainWindow.am.indexerThread.Start(); mainWindow.am.doiQueryThread.Start(); Application.Run(); mainWindow.am.FlushQueues(); mainWindow.am.alterationMonitorThread.Abort(); mainWindow.am.alterationMonitorThread.Join(); mainWindow.am.indexerThread.Abort(); mainWindow.am.indexerThread.Join(); mainWindow.am.thumbGenThread.Abort(); mainWindow.am.thumbGenThread.Join(); mainWindow.am.doiQueryThread.Abort(); mainWindow.am.doiQueryThread.Join(); mainWindow.sp.splashThread.Abort(); mainWindow.sp.splashThread.Join(); } catch (NullReferenceException e) { WriteLine(0, "Bibliographer window not initialized."); WriteLine(0, e.Message); WriteLine(0, e.StackTrace); } }