Re: Problem enabling Pango markup in a TreeView



Thank you very much Murray.

On 2/2/07, Murray Cumming <murrayc murrayc com> wrote:

[snip]

This convenience functions connects the "text" property to the view
column. But later you explicitly connect the "markup" property as well.
You'll need to create the CellRenderer manually instead of using the
append_column() convenience function. There's more about that here:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch08s02.html#id2525308

[snip]

For the list archives, here is what I changed it too:

PropertiesEditor::PropertiesEditor(Gtk::TreeView *treeView)
      : m_TreeView(treeView)
{
      // Create the Tree model
      m_PropertiesTreeModel = Gtk::TreeStore::create(m_PropertiesColumns);
      m_TreeView->set_model(m_PropertiesTreeModel);

      // Fill the TreeView's model FIXME
      Gtk::TreeModel::Row row = *(m_PropertiesTreeModel->append());
      row[m_PropertiesColumns.m_PropName] = "<b>Speed</b>";
      row[m_PropertiesColumns.m_PropValue] = "";

      Gtk::TreeModel::Row childrow =
*(m_PropertiesTreeModel->append(row.children()));
      childrow[m_PropertiesColumns.m_PropName] = "<i>Value</i>";
      childrow[m_PropertiesColumns.m_PropValue] = "3.14159";

      childrow = *(m_PropertiesTreeModel->append(row.children()));
      childrow[m_PropertiesColumns.m_PropName] = "Units";
      childrow[m_PropertiesColumns.m_PropValue] = "ms<sup>-1</sup>";

      // Add the Properties TreeView's view columns (and enable markup)
      Gtk::CellRendererText *renderer1 = Gtk::manage(new
Gtk::CellRendererText());
      m_TreeView->append_column("Property", *renderer1);
      Gtk::TreeViewColumn *col = m_TreeView->get_column(0);
      col->add_attribute(renderer1->property_markup(),
m_PropertiesColumns.m_PropName);
      col->set_resizable(true);

      Gtk::CellRendererText *renderer2 = Gtk::manage(new
Gtk::CellRendererText());
      m_TreeView->append_column("Value", *renderer2);
      col = m_TreeView->get_column(1);
      col->add_attribute(renderer2->property_markup(),
m_PropertiesColumns.m_PropValue);
      col->set_resizable(true);
}

Cheers,
Hugo Vincent



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]