Re: Wrapping GApplication inside Gtk module



Gtkmm must be initialized before a gtk+ object can be wrapped in a gtkmm object. This is handled by Gtk::Application::create(). If someone else creates the application in your case, and you won't call Gtk::Application::create(), I think the only way to initialize gtkmm (except creating a deprecated Gtk::Main object) is to call the static Gtk::Main::init_gtkmm_internals() function.


Den 2015-03-22 13:02, 张海 skrev:
I'm writing a Gtk module for keyboard navigation like vimium in Chromium, so I'd like to add a keybinding to the host application using Gtk::Application.set_accel_for_action().

But when I try to call Gio::Application::get_default() in gtk_module_init(), the returned value is null, and a warning is issued: 

Glib::RefPtr<Gio::Application> application = Gio::Application::get_default();

(gedit:8868): glibmm-WARNING **: Failed to wrap object of type 'GeditAppX11'. Hint: this error is commonly caused by failing to call a library init() function.

While using pure C worked properly:

std::cout << g_application_get_application_id(g_application_get_default()) << std::endl;

org.gnome.gedit

I primarily used Gedit for testing, and using gtk3-widget-factory also produced the same output.

Any idea? Thanks in advance.




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