首页 > 其他分享 >spice手动编写spice-client_F_hawk189_新浪博客

spice手动编写spice-client_F_hawk189_新浪博客

时间:2022-11-02 17:06:01浏览次数:80  
标签:hawk189 gtk client session usr new spice


在 ​​spice-gtk​​ 的帮助下, spice client 的编写非常简单. 以致于我在做 Spice Server 的测试的时候, 顺手写了一个简单的 spice client.

把下面的一些核心部分做一个剖析:

static void channel_new(SpiceSession *s, SpiceChannel *c, gpointer *data);


spice_session = spice_session_new();


g_object_set(spice_session, "host", host, NULL);
g_object_set(spice_session, "port", port, NULL);


g_signal_connect(spice_session, "channel-new",
G_CALLBACK(channel_new), NULL);


spice_session_connect(spice_session);

static void channel_new(SpiceSession *s, SpiceChannel *c, gpointer *data)
{
int id = 0;


g_object_get(c, "channel-id", &id, NULL);

if (SPICE_IS_DISPLAY_CHANNEL(c)) {

spice_display = spice_display_new(s, id);
gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(spice_display));
gtk_widget_show_all(main_window);
}

}

事实上, 核心代码不超过 10 行, 如此的简单, 当然更多的鼠标, 键盘事件, USB 重定向 等, 只要自己写 signal 的 callback 就可以了.


完整代码可以访问我的GitHub

​ https://github.com/Fhawk189/spice-client​

在spice-tools目录下的client.c

make的时候记得修改Makefile文件,也可以直接gcc

g++ -o client  client.c /usr/local/spice-gtk/lib/libspice-client-glib-2.0.so /usr/local/spice-gtk/lib/libspice-client-gtk-3.0.
so /usr/local/spice-gtk/lib/libspice-controller.so /usr/lib64/libgobject-2.0.so.0.5000.3 /usr/lib64/libgtk-3.so.0.2200.10


这是我当时的编译过程

 

标签:hawk189,gtk,client,session,usr,new,spice
From: https://blog.51cto.com/u_15858333/5817781

相关文章