How do I add custom preference into Pidgin?

2019-09-17 09: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 ;)



标签: c pidgin