Mercurial > pidgin
changeset 19156:f65c287e466e
Update the way _get_children_names is used.
applied changes from afa84ce2e5e448ce3233a9effb3136e1e23fb969
through d7c71ed89067d861b85108f04ea056f23320d33d
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 11 Jul 2007 19:44:32 +0000 |
parents | 53ad073898d0 |
children | 3266c971527e |
files | finch/gntsound.c libpurple/prefs.c libpurple/prefs.h |
diffstat | 3 files changed, 40 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntsound.c Wed Jul 11 18:41:02 2007 +0000 +++ b/finch/gntsound.c Wed Jul 11 19:44:32 2007 +0000 @@ -597,18 +597,23 @@ GList * finch_sound_get_profiles() { - return purple_prefs_get_children_names(FINCH_PREFS_ROOT "/sound/profiles"); + GList *list = NULL, *iter; + iter = purple_prefs_get_children_names(FINCH_PREFS_ROOT "/sound/profiles"); + while (iter) { + list = g_list_append(list, g_strdup(strrchr(iter->data, '/') + 1)); + g_free(iter->data); + iter = g_list_delete_link(iter, iter); + } + return list; } static gboolean profile_exists(const char *name) { - GList *itr = NULL; - for(itr = finch_sound_get_profiles();itr;itr = itr->next){ - if(!strcmp(itr->data,name)) - return TRUE; - } - return FALSE; + char *str = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s", name); + gboolean ret = purple_prefs_exists(str); + g_free(str); + return ret; } void @@ -908,6 +913,7 @@ box = gnt_hbox_new(FALSE); pref_dialog->profiles = cmbox = gnt_combo_box_new(); list = itr = finch_sound_get_profiles(); + gnt_tree_set_hash_fns(GNT_TREE(GNT_COMBO_BOX(cmbox)->dropdown), g_str_hash, g_str_equal, g_free); for(;itr;itr = itr->next){ gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),itr->data,itr->data); }
--- a/libpurple/prefs.c Wed Jul 11 18:41:02 2007 +0000 +++ b/libpurple/prefs.c Wed Jul 11 19:44:32 2007 +0000 @@ -1325,6 +1325,24 @@ disco_callback_helper_handle(&prefs, handle); } +GList * +purple_prefs_get_children_names(const char *name) +{ + GList * list = NULL; + struct purple_pref *pref = find_pref(name), *child; + char sep[2] = "\0\0";; + + if (pref == NULL) + return NULL; + + if (name[strlen(name) - 1] != '/') + sep[0] = '/'; + for (child = pref->first_child; child; child = child->sibling) { + list = g_list_append(list, g_strdup_printf("%s%s%s", name, sep, child->name)); + } + return list; +} + void purple_prefs_update_old() {
--- a/libpurple/prefs.h Wed Jul 11 18:41:02 2007 +0000 +++ b/libpurple/prefs.h Wed Jul 11 19:44:32 2007 +0000 @@ -281,6 +281,15 @@ */ GList *purple_prefs_get_path_list(const char *name); +/* + * Returns a list of children for a pref + * + * @param name The parent pref + * @return A list of newly allocated strings denoting the names of the children. + * Returns @c NULL if there are no children or if pref doesn't exist. + * The caller must free all the strings and the list. + */ +GList *purple_prefs_get_children_names(const char *name); /** * Add a callback to a pref (and its children)