Mercurial > hg
changeset 1649:44bbdc961234
Allow commands shading
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Tue, 17 Nov 2009 00:51:55 +0200 |
parents | 63d8473df2c3 |
children | cd81806b5947 |
files | mcabber/src/commands.c |
diffstat | 1 files changed, 11 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/src/commands.c Mon Nov 16 19:26:41 2009 +0200 +++ b/mcabber/src/commands.c Tue Nov 17 00:51:55 2009 +0200 @@ -106,21 +106,18 @@ GSList *loaded_modules = NULL; -static gint cmd_del_comparator (cmd *a, const char *name) -{ - return strcmp(a->name, name); -} - gpointer cmd_del(const char *name) { - GSList *command = g_slist_find_custom (Commands, name, (GCompareFunc) cmd_del_comparator); - if (command) { - cmd *cmnd = command->data; - gpointer userdata = cmnd->userdata; - Commands = g_slist_delete_link(Commands, command); - compl_del_category_word(COMPL_CMD, cmnd->name); - g_free(cmnd); - return userdata; + GSList *sl_cmd; + for (sl_cmd = Commands; sl_cmd; sl_cmd = sl_cmd->next) { + cmd *command = (cmd *) sl_cmd->data; + if (!strcmp (command->name, name)) { + gpointer userdata = command->userdata; + Commands = g_slist_delete_link(Commands, sl_cmd); + compl_del_category_word(COMPL_CMD, command->name); + g_free(command); + return userdata; + } } return NULL; } @@ -144,7 +141,7 @@ #ifdef MODULES_ENABLE n_cmd->userdata = userdata; #endif - Commands = g_slist_append(Commands, n_cmd); + Commands = g_slist_prepend(Commands, n_cmd); // Add to completion CMD category compl_add_category_word(COMPL_CMD, name); }