[Pango] Calls to Pango::Layout without effect



Hi there,

I have been trying for hours now, but I can't figure out how to use a Pango::Layout to ellipsize a long-winded filename. I looked at the Nautilus source code, and tried to reproduce each step using the pangomm equivalents, but still, no luck.

I am trying to do this in a dialog. Here is my code so far:

TransferOverwriteDialog::TransferOverwriteDialog(const Glib::ustring& filename)
    : Gtk::MessageDialog(
	MainWindow::instance(),
	"foo", // overwritten in body
	true, // use markup
	Gtk::MESSAGE_QUESTION,
	Gtk::BUTTONS_NONE,
	true), // modal
      check_button_(LABEL_REMEMBER_CHOICE),
      remember_choice_(false)
{
    using sigc::mem_fun;
    using namespace Pango;

    typedef Glib::RefPtr<Context> PangoContextPtr;
    typedef Glib::RefPtr<Layout>  PangoLayoutPtr;

    PangoContextPtr pango_context = get_pango_context();
    PangoLayoutPtr  pango_layout  = create_pango_layout(filename);

    pango_layout->set_single_paragraph_mode();
    pango_layout->set_ellipsize(ELLIPSIZE_END);

    Glib::ustring header_text =
	DIALOG_HEADER_XFER_OVERWRITE + pango_layout->get_text();

    set_markup(header_text);
    set_secondary_text(DIALOG_BODY_XFER_OVERWRITE);

    // <snip irrelevant stuff>
}

The text in the 'filename'-object will not get ellipsized, but just printed as is. I noticed that /nothing/ I apply to the layout text will get recognized. For example, I tried to replace 'filename' with some custom marked-up text, i.e. "<i>this is some italic test text</i>" and tried to render that, but again, the text is displayed as plain text (no italics).

On top of that, calls to set_width() seem to be ignored, too. Regardless what I set there, it has no effect whatsoever.

It looks as if every call I make to pango_layout doesn't have any effect. Any ideas what is wrong with my code?

Thanks in advance,
Matthias Kaeppler




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