Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 9130:933a19e3a6b3
[gaim-migrate @ 9908]
This puts the core in charge of irc-style /commands, which is way cool. Tim did most of the work, I've just been keeping it in sync with CVS, and slowly adding more commands to jabber.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 30 May 2004 19:34:21 +0000 |
parents | 6ea36eac6f22 |
children | 4ae763960140 |
comparison
equal
deleted
inserted
replaced
9129:3e94a77ee0c7 | 9130:933a19e3a6b3 |
---|---|
34 # endif | 34 # endif |
35 #endif | 35 #endif |
36 | 36 |
37 #include <gdk/gdkkeysyms.h> | 37 #include <gdk/gdkkeysyms.h> |
38 | 38 |
39 #include "cmds.h" | |
39 #include "debug.h" | 40 #include "debug.h" |
40 #include "imgstore.h" | 41 #include "imgstore.h" |
41 #include "log.h" | 42 #include "log.h" |
42 #include "multi.h" | 43 #include "multi.h" |
43 #include "notify.h" | 44 #include "notify.h" |
332 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); | 333 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
333 else | 334 else |
334 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | 335 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); |
335 } | 336 } |
336 } | 337 } |
338 | |
339 static const char * | |
340 gaim_gtk_get_cmd_prefix(void) | |
341 { | |
342 return "/"; | |
343 } | |
344 | |
337 static void | 345 static void |
338 send_cb(GtkWidget *widget, GaimConversation *conv) | 346 send_cb(GtkWidget *widget, GaimConversation *conv) |
339 { | 347 { |
340 GaimGtkConversation *gtkconv; | 348 GaimGtkConversation *gtkconv; |
349 char *cmd; | |
350 const char *prefix; | |
341 GaimAccount *account; | 351 GaimAccount *account; |
342 GaimConnection *gc; | 352 GaimConnection *gc; |
343 char *buf, *clean; | 353 char *buf, *clean; |
344 | 354 |
345 gtkconv = GAIM_GTK_CONVERSATION(conv); | 355 gtkconv = GAIM_GTK_CONVERSATION(conv); |
346 account = gaim_conversation_get_account(conv); | 356 account = gaim_conversation_get_account(conv); |
357 prefix = gaim_gtk_get_cmd_prefix(); | |
358 | |
359 if(gaim_prefs_get_bool("/gaim/gtk/conversations/enable_commands")) { | |
360 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
361 if(cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0)) { | |
362 GaimCmdStatus status; | |
363 char *error, *cmdline; | |
364 | |
365 cmdline = cmd + strlen(prefix); | |
366 status = gaim_cmd_do_command(conv, cmdline, &error); | |
367 g_free(cmd); | |
368 | |
369 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
370 default_formatize(conv); | |
371 | |
372 switch(status) { | |
373 case GAIM_CMD_STATUS_OK: | |
374 return; | |
375 case GAIM_CMD_STATUS_NOT_FOUND: | |
376 gaim_conversation_write(conv, "", _("No such command"), | |
377 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
378 return; | |
379 case GAIM_CMD_STATUS_WRONG_ARGS: | |
380 gaim_conversation_write(conv, "", _("Syntax error"), | |
381 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
382 return; | |
383 case GAIM_CMD_STATUS_FAILED: | |
384 gaim_conversation_write(conv, "", error ? error : _("Command failed"), | |
385 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
386 if(error) | |
387 g_free(error); | |
388 return; | |
389 case GAIM_CMD_STATUS_WRONG_TYPE: | |
390 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
391 gaim_conversation_write(conv, "", _("That command only works in Chats, not IMs."), | |
392 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
393 else | |
394 gaim_conversation_write(conv, "", _("That command only works in IMs, not Chats."), | |
395 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
396 return; | |
397 case GAIM_CMD_STATUS_WRONG_PRPL: | |
398 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
399 GAIM_MESSAGE_SYSTEM, time(NULL)); | |
400 return; | |
401 } | |
402 } | |
403 | |
404 g_free(cmd); | |
405 } | |
406 | |
347 | 407 |
348 if (!gaim_account_is_connected(account)) | 408 if (!gaim_account_is_connected(account)) |
349 return; | 409 return; |
350 | 410 |
351 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | 411 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
5813 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); | 5873 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); |
5814 #endif | 5874 #endif |
5815 gaim_prefs_add_bool("/gaim/gtk/conversations/html_shortcuts", FALSE); | 5875 gaim_prefs_add_bool("/gaim/gtk/conversations/html_shortcuts", FALSE); |
5816 gaim_prefs_add_bool("/gaim/gtk/conversations/smiley_shortcuts", FALSE); | 5876 gaim_prefs_add_bool("/gaim/gtk/conversations/smiley_shortcuts", FALSE); |
5817 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); | 5877 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
5878 gaim_prefs_add_bool("/gaim/gtk/conversations/enable_commands", TRUE); | |
5879 | |
5818 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); | 5880 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
5819 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); | 5881 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
5820 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); | 5882 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5821 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | 5883 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); |
5822 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); | 5884 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |