Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 1649:44bbdc961234
Allow commands shading
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Tue, 17 Nov 2009 00:51:55 +0200 |
parents | 63d8473df2c3 |
children | fca9a4c17432 |
comparison
equal
deleted
inserted
replaced
1648:63d8473df2c3 | 1649:44bbdc961234 |
---|---|
104 GModule *module; | 104 GModule *module; |
105 } loaded_module_t; | 105 } loaded_module_t; |
106 | 106 |
107 GSList *loaded_modules = NULL; | 107 GSList *loaded_modules = NULL; |
108 | 108 |
109 static gint cmd_del_comparator (cmd *a, const char *name) | |
110 { | |
111 return strcmp(a->name, name); | |
112 } | |
113 | |
114 gpointer cmd_del(const char *name) | 109 gpointer cmd_del(const char *name) |
115 { | 110 { |
116 GSList *command = g_slist_find_custom (Commands, name, (GCompareFunc) cmd_del_comparator); | 111 GSList *sl_cmd; |
117 if (command) { | 112 for (sl_cmd = Commands; sl_cmd; sl_cmd = sl_cmd->next) { |
118 cmd *cmnd = command->data; | 113 cmd *command = (cmd *) sl_cmd->data; |
119 gpointer userdata = cmnd->userdata; | 114 if (!strcmp (command->name, name)) { |
120 Commands = g_slist_delete_link(Commands, command); | 115 gpointer userdata = command->userdata; |
121 compl_del_category_word(COMPL_CMD, cmnd->name); | 116 Commands = g_slist_delete_link(Commands, sl_cmd); |
122 g_free(cmnd); | 117 compl_del_category_word(COMPL_CMD, command->name); |
123 return userdata; | 118 g_free(command); |
119 return userdata; | |
120 } | |
124 } | 121 } |
125 return NULL; | 122 return NULL; |
126 } | 123 } |
127 | 124 |
128 // cmd_add() | 125 // cmd_add() |
142 n_cmd->completion_flags[1] = flags_row2; | 139 n_cmd->completion_flags[1] = flags_row2; |
143 n_cmd->func = f; | 140 n_cmd->func = f; |
144 #ifdef MODULES_ENABLE | 141 #ifdef MODULES_ENABLE |
145 n_cmd->userdata = userdata; | 142 n_cmd->userdata = userdata; |
146 #endif | 143 #endif |
147 Commands = g_slist_append(Commands, n_cmd); | 144 Commands = g_slist_prepend(Commands, n_cmd); |
148 // Add to completion CMD category | 145 // Add to completion CMD category |
149 compl_add_category_word(COMPL_CMD, name); | 146 compl_add_category_word(COMPL_CMD, name); |
150 } | 147 } |
151 | 148 |
152 // cmd_init() | 149 // cmd_init() |