How do I add custom preference into Pidgin?

ε祈祈猫儿з 提交于 2019-12-11 20:26:02

问题


I need to add preference into Pidgin to serve my custom menu item as shown in How do I add item to Pidgin menu. How can I achieve this?


回答1:


You need to find function pidgin_blist_init in pidgin/gtkblist.c and add the following line:

purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/blist/show_groups", FALSE);

after

purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups", FALSE);

There are also functions to add int, string, none, string_list, path and path_list types. Now, we need to associate our custom menu item with custom function. This is done in pidgin_blist_show. Just add the line

purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/blist/show_groups",
                              _prefs_change_redo_list_groups, NULL);

after

purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/blist/show_empty_groups",
                              _prefs_change_redo_list, NULL);

And, finally, add the _prefs_change_redo_list_groups function just after the _prefs_change_redo_list:

static void _prefs_change_redo_list_groups(const char *name, PurplePrefType type,
                                           gconstpointer val, gpointer data)
{
    purple_blist_set_groups_visible(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_groups"));
    _prefs_change_redo_list(name, type, val, data);
}

The purple_blist_set_groups_visible will also be published once I develop it, I promise ;)



来源:https://stackoverflow.com/questions/23379642/how-do-i-add-custom-preference-into-pidgin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!