comparison console/gntconv.c @ 14091:ae4cbed1b309

[gaim-migrate @ 16715] Add support for tab-completion and save-history in GntEntry. Also, the keyboard-commands should now work for Xterms. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 12 Aug 2006 10:27:29 +0000
parents 81648c6aa918
children b71bfeaaed58
comparison
equal deleted inserted replaced
14090:983fbec46eb0 14091:ae4cbed1b309
121 g_free(escape); 121 g_free(escape);
122 g_return_val_if_reached(FALSE); 122 g_return_val_if_reached(FALSE);
123 } 123 }
124 g_free(escape); 124 g_free(escape);
125 } 125 }
126 gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text);
126 gnt_entry_clear(GNT_ENTRY(ggconv->entry)); 127 gnt_entry_clear(GNT_ENTRY(ggconv->entry));
127 return TRUE; 128 return TRUE;
128 } 129 }
129 else if (key[0] == 27) 130 else if (key[0] == 27)
130 { 131 {
196 gaim_prefs_get_int(PREF_ROOT "/size/height")); 197 gaim_prefs_get_int(PREF_ROOT "/size/height"));
197 198
198 ggc->entry = gnt_entry_new(NULL); 199 ggc->entry = gnt_entry_new(NULL);
199 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); 200 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry);
200 gnt_widget_set_name(ggc->entry, "conversation-window-entry"); 201 gnt_widget_set_name(ggc->entry, "conversation-window-entry");
201 202 gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1);
202 g_signal_connect(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); 203 gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE);
204 gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE);
205
206 g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc);
203 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); 207 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc);
204 208
205 gnt_widget_set_position(ggc->window, gaim_prefs_get_int(PREF_ROOT "/position/x"), 209 gnt_widget_set_position(ggc->window, gaim_prefs_get_int(PREF_ROOT "/position/x"),
206 gaim_prefs_get_int(PREF_ROOT "/position/y")); 210 gaim_prefs_get_int(PREF_ROOT "/position/y"));
207 gnt_widget_show(ggc->window); 211 gnt_widget_show(ggc->window);
313 } 317 }
314 318
315 static void 319 static void
316 gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals) 320 gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals)
317 { 321 {
322 GGConv *ggc = conv->ui_data;
323 GntEntry *entry = GNT_ENTRY(ggc->entry);
324
318 if (!new_arrivals) 325 if (!new_arrivals)
319 { 326 {
320 /* Print the list of users in the room */ 327 /* Print the list of users in the room */
321 GString *string = g_string_new(_("List of users:\n")); 328 GString *string = g_string_new(_("List of users:\n"));
322 GList *iter; 329 GList *iter;
333 340
334 gaim_conversation_write(conv, NULL, string->str, 341 gaim_conversation_write(conv, NULL, string->str,
335 GAIM_MESSAGE_SYSTEM, time(NULL)); 342 GAIM_MESSAGE_SYSTEM, time(NULL));
336 g_string_free(string, TRUE); 343 g_string_free(string, TRUE);
337 } 344 }
338 /* XXX: Add the names for string completion */ 345
346 for (; users; users = users->next)
347 {
348 GaimConvChatBuddy *cbuddy = users->data;
349 gnt_entry_add_suggest(entry, cbuddy->name);
350 gnt_entry_add_suggest(entry, cbuddy->alias);
351 }
339 } 352 }
340 353
341 static void 354 static void
342 gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a) 355 gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a)
343 { 356 {
344 /* XXX: Update the name for string completion */ 357 /* XXX: Update the name for string completion */
358 GGConv *ggc = conv->ui_data;
359 GntEntry *entry = GNT_ENTRY(ggc->entry);
360 gnt_entry_remove_suggest(entry, old);
361 gnt_entry_add_suggest(entry, new_n);
362 gnt_entry_add_suggest(entry, new_a);
345 } 363 }
346 364
347 static void 365 static void
348 gg_chat_remove_user(GaimConversation *conv, GList *list) 366 gg_chat_remove_user(GaimConversation *conv, GList *list)
349 { 367 {
350 /* XXX: Remove the name from string completion */ 368 /* XXX: Remove the name from string completion */
369 GGConv *ggc = conv->ui_data;
370 GntEntry *entry = GNT_ENTRY(ggc->entry);
371 for (; list; list = list->next)
372 gnt_entry_remove_suggest(entry, list->data);
351 } 373 }
352 374
353 static void 375 static void
354 gg_chat_update_user(GaimConversation *conv, const char *user) 376 gg_chat_update_user(GaimConversation *conv, const char *user)
355 { 377 {
356 /* XXX: This probably will not require updating the string completion */
357 } 378 }
358 379
359 static GaimConversationUiOps conv_ui_ops = 380 static GaimConversationUiOps conv_ui_ops =
360 { 381 {
361 .create_conversation = gg_create_conversation, 382 .create_conversation = gg_create_conversation,