Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从gtk notify信号处理程序获取以前的值?_Gtk - Fatal编程技术网

如何从gtk notify信号处理程序获取以前的值?

如何从gtk notify信号处理程序获取以前的值?,gtk,Gtk,比如说, g_signal_connect(G_OBJECT(window), "notify::title", G_CALLBACK(onTitleChanged), NULL); void onTitleChanged(GtkWidget* widget, GParamSpec* property, gpointer data) { g_message("%s is changed, the ne

比如说,

   g_signal_connect(G_OBJECT(window), "notify::title", G_CALLBACK(onTitleChanged), NULL);

void onTitleChanged(GtkWidget* widget,
                    GParamSpec* property,
                    gpointer data)
{
    g_message("%s is changed, the new value is %s\n", property->name, gtk_window_get_title(GTK_WINDOW(widget)));
}
如何在notify信号处理程序(onTitleChanged)中获取上一个(旧)标题值


谢谢。

这是GObject无法提供的,因此您必须在应用程序中缓存当前值

这样做的安全方法是更新notify处理程序末尾的缓存值——但根据您的使用情况,您可能还需要初始化该值(当然,如果该值是字符串,则必须记住在必要时分配/释放)