pidgin/gtkconv.c

changeset 39683
51736838507d
parent 39682
08137d9c52b4
child 39684
763e71cb2ad7
equal deleted inserted replaced
39682:08137d9c52b4 39683:51736838507d
485 485
486 static gboolean 486 static gboolean
487 check_for_and_do_command(PurpleConversation *conv) 487 check_for_and_do_command(PurpleConversation *conv)
488 { 488 {
489 PidginConversation *gtkconv; 489 PidginConversation *gtkconv;
490 char *cmd; 490 GtkWidget *view = NULL;
491 const char *prefix; 491 GtkTextBuffer *buffer = NULL;
492 gchar *cmd;
493 const gchar *prefix;
492 gboolean retval = FALSE; 494 gboolean retval = FALSE;
493 495
494 gtkconv = PIDGIN_CONVERSATION(conv); 496 gtkconv = PIDGIN_CONVERSATION(conv);
495 prefix = pidgin_get_cmd_prefix(); 497 prefix = pidgin_get_cmd_prefix();
496 498
497 cmd = pidgin_webview_get_body_text(PIDGIN_WEBVIEW(gtkconv->entry)); 499 view = talkatu_editor_get_view(TALKATU_EDITOR(gtkconv->editor));
500 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
501
502 cmd = talkatu_buffer_get_plain_text(TALKATU_BUFFER(buffer));
498 503
499 if (cmd && purple_str_has_prefix(cmd, prefix)) { 504 if (cmd && purple_str_has_prefix(cmd, prefix)) {
500 PurpleCmdStatus status; 505 PurpleCmdStatus status;
501 char *error, *cmdline, *markup, *send_history; 506 char *error, *cmdline, *markup, *send_history;
502 507
511 "Nothing happens", PURPLE_MESSAGE_NO_LOG); 516 "Nothing happens", PURPLE_MESSAGE_NO_LOG);
512 g_free(cmd); 517 g_free(cmd);
513 return TRUE; 518 return TRUE;
514 } 519 }
515 520
516 /* TODO WebKit: Cut out prefix for markup... */ 521 /* Docs are unclear on whether or not prefix should be removed from
517 markup = pidgin_webview_get_body_html(PIDGIN_WEBVIEW(gtkconv->entry)); 522 * the markup so, ignoring for now. Notably if the markup is
523 * `<b>/foo arg1</b>` we now have to move the bold tag around?
524 * - gk 20190709 */
525 markup = talkatu_markup_get_html(buffer, NULL);
518 status = purple_cmd_do_command(conv, cmdline, markup, &error); 526 status = purple_cmd_do_command(conv, cmdline, markup, &error);
519 g_free(markup); 527 g_free(markup);
520 528
521 switch (status) { 529 switch (status) {
522 case PURPLE_CMD_STATUS_OK: 530 case PURPLE_CMD_STATUS_OK:
595 GtkTextBuffer *buffer = NULL; 603 GtkTextBuffer *buffer = NULL;
596 gchar *content; 604 gchar *content;
597 605
598 account = purple_conversation_get_account(conv); 606 account = purple_conversation_get_account(conv);
599 607
600 // if (check_for_and_do_command(conv)) { 608 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
601 // conversation_entry_clear(gtkconv); 609
602 // return; 610 if (check_for_and_do_command(conv)) {
603 // } 611 talkatu_buffer_clear(TALKATU_BUFFER(buffer));
612 return;
613 }
604 614
605 if (PURPLE_IS_CHAT_CONVERSATION(conv) && 615 if (PURPLE_IS_CHAT_CONVERSATION(conv) &&
606 purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv))) { 616 purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv))) {
607 return; 617 return;
608 } 618 }
609 619
610 if (!purple_account_is_connected(account)) { 620 if (!purple_account_is_connected(account)) {
611 return; 621 return;
612 } 622 }
613 623
614 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); 624 content = talkatu_markup_get_html(buffer, NULL);
615
616 content = talkatu_markup_get_html(TALKATU_BUFFER(buffer), NULL);
617 625
618 purple_idle_touch(); 626 purple_idle_touch();
619 627
620 /* XXX: is there a better way to tell if the message has images? */ 628 /* XXX: is there a better way to tell if the message has images? */
621 // if (strstr(buf, "<img ") != NULL) 629 // if (strstr(buf, "<img ") != NULL)

mercurial