0

每次我启动一个简单的 GTK 应用程序时都会收到此警告:

GLib-GIO-WARNING **: HH:MM:SS.XXX: Your application does not implement g_application_activate() and has no handlers connected to the 'activate' signal.  It should do one of these.

这是应用程序的完整代码:

extern crate glib;
extern crate gio;
extern crate gtk;

use gtk::prelude::*;
use gio::prelude::*;
use std::env::args;

fn build_ui(application: &gtk::Application) {
    let builder = gtk::Builder::from_string(include_str!("ui.glade"));
    let win: gtk::ApplicationWindow = builder.get_object("application_window").expect("err build win");
    win.set_application(Some(application));
    win.set_title("Test");
    win.set_position(gtk::WindowPosition::Center);
    win.show_all();
}

// Init app
fn main() {
    if gtk::init().is_err() {
        println!("Failed to initialize GTK.");
        return;
    }

    let application = gtk::Application::new(
        Some("com.github.gtk-rs.examples.cairotest"),
        Default::default(),
    )
    .expect("Initialization failed...");

    application.connect_startup(move |app| {
        build_ui(app);
    });

    application.run(&args().collect::<Vec<_>>());
}

难道我做错了什么?是因为林间空地建造者吗?我尝试了这种方法,但它让事情变得更糟:应用程序仍然可以编译,但输出会抛出一个额外的严重错误:

GLib-GIO-CRITICAL **: HH:MM:SS.XXX: g_application_activate: assertion 'application->priv->is_registered' failed
4

0 回答 0