我在python中使用libwnck获取窗口列表。但我无法获得应用程序的图标路径。
import wnck
screenW = wnck.screen_get_default();
screenW.force_update()
windows = screenW.get_windows()
list = []
for window in windows:
print 'icon name: ' + window.get_application().get_icon_name()
get_icon_name返回窗口的名称/标题,而不是图标名称。
例如chrome图标是: /usr/share/icons/hicolor/16x16/apps/google-chrome.png
我怎么能得到这条路?
答案 0 :(得分:0)
libwnck的source code表明该函数现在并未真正实现(并且只返回您已编写的应用程序的名称):
const char*
wnck_application_get_icon_name (WnckApplication *app)
{
g_return_val_if_fail (WNCK_IS_APPLICATION (app), NULL);
/* FIXME this isn't actually implemented, should be different
* from regular name
*/
if (app->priv->name)
return app->priv->name;
else
return FALLBACK_NAME;
}
另外,查看gtk_window_set_icon_from_file
code我甚至不确定是否可以获取此路径,因为它未存储在pixbuf中:
gboolean
gtk_window_set_icon_from_file (GtkWindow *window,
const gchar *filename,
GError **err)
{
GdkPixbuf *pixbuf = load_pixbuf_verbosely (filename, err);
if (pixbuf)
{
gtk_window_set_icon (window, pixbuf);
g_object_unref (pixbuf);
return TRUE;
}
else
return FALSE;
}