Mercurial > pidgin.yaz
comparison pidgin/gtkimhtml.c @ 23113:8c3444f04709
propagate from branch 'im.pidgin.pidgin' (head d7144f5dbbde09137aff1ceadfd419e25303bf7d)
to branch 'im.pidgin.pidgin.next.minor' (head b6f1c6f279a87ac4b59426eea116c349eb31fe8c)
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Wed, 07 May 2008 12:14:28 +0000 |
parents | 900c7b5660d5 |
children | f11fc3fb5b8c 25233b528b66 ac567757d236 1dd0e007514d |
comparison
equal
deleted
inserted
replaced
23112:bb41bdce8981 | 23113:8c3444f04709 |
---|---|
812 static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) | 812 static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
813 { | 813 { |
814 gtk_imhtml_clear_formatting(imhtml); | 814 gtk_imhtml_clear_formatting(imhtml); |
815 } | 815 } |
816 | 816 |
817 static void disable_smiley_selected(GtkMenuItem *item, GtkIMHtml *imhtml) | |
818 { | |
819 GtkTextIter start, end; | |
820 GtkTextMark *mark; | |
821 char *text; | |
822 | |
823 if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) | |
824 return; | |
825 | |
826 text = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
827 | |
828 mark = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); | |
829 gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); | |
830 | |
831 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, mark); | |
832 gtk_imhtml_insert_html_at_iter(imhtml, text, GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_SMILEY, &start); | |
833 | |
834 g_free(text); | |
835 } | |
836 | |
817 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) | 837 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
818 { | 838 { |
819 GtkWidget *menuitem; | 839 GtkWidget *menuitem; |
840 GtkTextIter start, end; | |
820 | 841 |
821 menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); | 842 menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
822 gtk_widget_show(menuitem); | 843 gtk_widget_show(menuitem); |
823 /* | 844 /* |
824 * TODO: gtk_clipboard_wait_is_text_available() iterates the glib | 845 * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
840 gtk_widget_set_sensitive(menuitem, imhtml->editable); | 861 gtk_widget_set_sensitive(menuitem, imhtml->editable); |
841 /* put it after Delete */ | 862 /* put it after Delete */ |
842 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); | 863 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); |
843 | 864 |
844 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml); | 865 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml); |
866 | |
867 menuitem = gtk_menu_item_new_with_mnemonic(_("Disable _smileys in selected text")); | |
868 gtk_widget_show(menuitem); | |
869 if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { | |
870 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(disable_smiley_selected), imhtml); | |
871 } else { | |
872 gtk_widget_set_sensitive(menuitem, FALSE); | |
873 } | |
874 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6); | |
845 } | 875 } |
846 | 876 |
847 static char * | 877 static char * |
848 ucs2_order(gboolean swap) | 878 ucs2_order(gboolean swap) |
849 { | 879 { |
1456 | 1486 |
1457 } | 1487 } |
1458 | 1488 |
1459 static void gtk_imhtml_init (GtkIMHtml *imhtml) | 1489 static void gtk_imhtml_init (GtkIMHtml *imhtml) |
1460 { | 1490 { |
1461 GtkTextIter iter; | |
1462 imhtml->text_buffer = gtk_text_buffer_new(NULL); | 1491 imhtml->text_buffer = gtk_text_buffer_new(NULL); |
1463 imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); | 1492 imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
1464 gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter); | |
1465 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); | 1493 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); |
1466 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); | 1494 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
1467 gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(imhtml), 2); | 1495 gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(imhtml), 2); |
1468 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); | 1496 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); |
1469 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); | 1497 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |