Mercurial > pidgin
comparison src/pluginpref.c @ 8745:6c0fae7a4f1a
[gaim-migrate @ 9500]
" fixed up an issue in the example plugin and a memory
leak and some other code.." --Gary Kramlich
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 21 Apr 2004 21:05:08 +0000 |
| parents | 7024b595b6ae |
| children | ffb333368cdc |
comparison
equal
deleted
inserted
replaced
| 8744:0f73e8204529 | 8745:6c0fae7a4f1a |
|---|---|
| 56 } | 56 } |
| 57 | 57 |
| 58 void | 58 void |
| 59 gaim_plugin_pref_frame_destroy(GaimPluginPrefFrame *frame) { | 59 gaim_plugin_pref_frame_destroy(GaimPluginPrefFrame *frame) { |
| 60 GaimPluginPref *pref; | 60 GaimPluginPref *pref; |
| 61 GList *l, *ll; | 61 GList *l; |
| 62 | 62 |
| 63 g_return_if_fail(frame); | 63 g_return_if_fail(frame); |
| 64 | 64 |
| 65 for(l = frame->prefs; l != NULL; l = ll) { | 65 for(l = frame->prefs; l != NULL; l = l->next) { |
| 66 ll = l->next; | |
| 67 | |
| 68 pref = (GaimPluginPref *)l->data; | 66 pref = (GaimPluginPref *)l->data; |
| 69 gaim_plugin_pref_destroy(pref); | 67 gaim_plugin_pref_destroy(pref); |
| 70 | 68 } |
| 71 g_list_free_1(l); | 69 |
| 72 } | 70 g_list_free(frame->prefs); |
| 73 | 71 frame->prefs = NULL; |
| 72 | |
| 73 g_free(frame); | |
| 74 frame = NULL; | 74 frame = NULL; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void | 77 void |
| 78 gaim_plugin_pref_frame_add(GaimPluginPrefFrame *frame, GaimPluginPref *pref) { | 78 gaim_plugin_pref_frame_add(GaimPluginPrefFrame *frame, GaimPluginPref *pref) { |
| 79 g_return_if_fail(frame); | 79 g_return_if_fail(frame); |
| 80 g_return_if_fail(pref); | 80 g_return_if_fail(pref); |
| 81 | 81 |
| 82 frame->prefs = g_list_append(frame->prefs, (gpointer)pref); | 82 frame->prefs = g_list_append(frame->prefs, pref); |
| 83 } | 83 } |
| 84 | 84 |
| 85 GList * | 85 GList * |
| 86 gaim_plugin_pref_frame_get_prefs(GaimPluginPrefFrame *frame) { | 86 gaim_plugin_pref_frame_get_prefs(GaimPluginPrefFrame *frame) { |
| 87 g_return_val_if_fail(frame, NULL); | |
| 88 g_return_val_if_fail(frame->prefs, NULL); | |
| 89 | |
| 87 return frame->prefs; | 90 return frame->prefs; |
| 88 } | 91 } |
| 89 | 92 |
| 90 GaimPluginPref * | 93 GaimPluginPref * |
| 91 gaim_plugin_pref_new() { | 94 gaim_plugin_pref_new() { |
| 138 gaim_plugin_pref_destroy(GaimPluginPref *pref) { | 141 gaim_plugin_pref_destroy(GaimPluginPref *pref) { |
| 139 GList *l, *ll; | 142 GList *l, *ll; |
| 140 | 143 |
| 141 g_return_if_fail(pref); | 144 g_return_if_fail(pref); |
| 142 | 145 |
| 143 if(pref->name) | 146 if(pref->name) { |
| 144 g_free(pref->name); | 147 g_free(pref->name); |
| 145 | 148 pref->name = NULL; |
| 146 if(pref->label) | 149 } |
| 150 | |
| 151 if(pref->label) { | |
| 147 g_free(pref->label); | 152 g_free(pref->label); |
| 148 | 153 pref->label = NULL; |
| 149 l = pref->choices; | 154 } |
| 150 while(l) { | 155 |
| 151 ll = l->next; | 156 if(pref->choices) { |
| 152 | 157 g_list_free(pref->choices); |
| 153 g_free(l->data); | 158 pref->choices = NULL; |
| 154 g_list_free_1(l); | |
| 155 | |
| 156 l = l->next; | |
| 157 } | 159 } |
| 158 | 160 |
| 159 g_free(pref); | 161 g_free(pref); |
| 160 } | 162 } |
| 161 | 163 |
| 256 | 258 |
| 257 pref->choices = g_list_append(pref->choices, label); | 259 pref->choices = g_list_append(pref->choices, label); |
| 258 pref->choices = g_list_append(pref->choices, choice); | 260 pref->choices = g_list_append(pref->choices, choice); |
| 259 } | 261 } |
| 260 | 262 |
| 261 gpointer | |
| 262 gaim_plugin_pref_get_choice(GaimPluginPref *pref, unsigned int index) { | |
| 263 g_return_val_if_fail(pref, NULL); | |
| 264 | |
| 265 if(index > g_list_length(pref->choices)) | |
| 266 return NULL; | |
| 267 | |
| 268 return g_list_nth_data(pref->choices, index); | |
| 269 } | |
| 270 | |
| 271 GList * | 263 GList * |
| 272 gaim_plugin_pref_get_choices(GaimPluginPref *pref) { | 264 gaim_plugin_pref_get_choices(GaimPluginPref *pref) { |
| 273 g_return_val_if_fail(pref, NULL); | 265 g_return_val_if_fail(pref, NULL); |
| 274 | 266 |
| 275 return pref->choices; | 267 return pref->choices; |
