pidgin/gtkconv.c

changeset 29318
d80f659fb1aa
parent 29309
b94fa8bc1a03
child 29322
22e1df5df513
child 29693
1f3d2781dc78
equal deleted inserted replaced
29317:d46d080a42cc 29318:d80f659fb1aa
4148 if (is_me && color) 4148 if (is_me && color)
4149 gdk_color_free(color); 4149 gdk_color_free(color);
4150 g_free(alias_key); 4150 g_free(alias_key);
4151 } 4151 }
4152 4152
4153 static void 4153 /**
4154 tab_complete_process_item(int *most_matched, char *entered, gsize entered_bytes, char **partial, char *nick_partial, 4154 * @param most_matched Used internally by this function.
4155 GList **matches, gboolean command, char *name) 4155 * @param entered The partial string that the user types before hitting the
4156 * tab key.
4157 * @param entered_bytes The length of entered.
4158 * @param partial This is a return variable. This will be set to a string
4159 * containing the largest common string between all matches. This will
4160 * be inserted into the input box at the start of the word that the
4161 * user is tab completing. For example, if a chat room contains
4162 * "AlfFan" and "AlfHater" and the user types "a<TAB>" then this will
4163 * contain "Alf"
4164 * @param nick_partial Used internally by this function. Shoudl be a
4165 * temporary buffer that is entered_bytes+1 bytes long.
4166 * @param matches This is a return variable. If the given name is a potential
4167 * match for the entered string, then add a copy of the name to this
4168 * list. The caller is responsible for g_free'ing the data in this
4169 * list.
4170 * @param name The buddy name or alias or slash command name that we're
4171 * checking for a match.
4172 */
4173 static void
4174 tab_complete_process_item(int *most_matched, const char *entered, gsize entered_bytes, char **partial, char *nick_partial,
4175 GList **matches, char *name)
4156 { 4176 {
4157 memcpy(nick_partial, name, entered_bytes); 4177 memcpy(nick_partial, name, entered_bytes);
4158 if (purple_utf8_strcasecmp(nick_partial, entered)) 4178 if (purple_utf8_strcasecmp(nick_partial, entered))
4159 return; 4179 return;
4160 4180
4259 GList *l; 4279 GList *l;
4260 4280
4261 /* Commands */ 4281 /* Commands */
4262 for (l = list; l != NULL; l = l->next) { 4282 for (l = list; l != NULL; l = l->next) {
4263 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, 4283 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
4264 &matches, TRUE, l->data); 4284 &matches, l->data);
4265 } 4285 }
4266 g_list_free(list); 4286 g_list_free(list);
4267 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 4287 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
4268 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); 4288 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv);
4269 GList *l = purple_conv_chat_get_users(chat); 4289 GList *l = purple_conv_chat_get_users(chat);
4272 int f; 4292 int f;
4273 4293
4274 /* Users */ 4294 /* Users */
4275 for (; l != NULL; l = l->next) { 4295 for (; l != NULL; l = l->next) {
4276 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, 4296 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
4277 &matches, FALSE, ((PurpleConvChatBuddy *)l->data)->name); 4297 &matches, ((PurpleConvChatBuddy *)l->data)->name);
4278 } 4298 }
4279 4299
4280 4300
4281 /* Aliases */ 4301 /* Aliases */
4282 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) 4302 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
4290 CHAT_USERS_ALIAS_COLUMN, &alias, 4310 CHAT_USERS_ALIAS_COLUMN, &alias,
4291 -1); 4311 -1);
4292 4312
4293 if (name && alias && strcmp(name, alias)) 4313 if (name && alias && strcmp(name, alias))
4294 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, 4314 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
4295 &matches, FALSE, alias); 4315 &matches, alias);
4296 g_free(name); 4316 g_free(name);
4297 g_free(alias); 4317 g_free(alias);
4298 4318
4299 f = gtk_tree_model_iter_next(model, &iter); 4319 f = gtk_tree_model_iter_next(model, &iter);
4300 } while (f != 0); 4320 } while (f != 0);

mercurial