How to use Pango::Context?



Hello
I try to list the awailable font-families.
If I open and close multiple windows ther is a critical error:
GLib-GObject-CRITICAL **: 15:22:32.722: g_object_unref: assertion
'G_IS_OBJECT (object)' failed

This is the code, the error ocours even without the uncomented code:

#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <gtkmm/textview.h>

class Window: public Gtk::Window
{
public:
        Window()
        {
                this->show();
                this->set_child(this->text);

                auto context = this->text.create_pango_context();
                auto fontMap = context->get_font_map();
//              auto fontList = fontMap->list_families();
//              auto buffer = this->text.get_buffer();
//              auto iter = buffer->get_iter_at_offset(0);
//              for(const auto& fam : fontList)
//              {
//                      iter = buffer->insert(iter,
//                              fam->get_name() + '\n');
//              }
//      }

private:
        Gtk::TextView text;
};

auto main() -> int
{
        std::vector<Window> windows;
        auto app = Gtk::Application::create();

        app->signal_activate().connect([&]
        {
                auto& w0 = windows.emplace_back();
                app->add_window(w0);
                auto& w1 = windows.emplace_back();
                app->add_window(w1);
        });

        return app->run();
}


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