textview.h (4053B)
1 /* 2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client 3 * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __TEXTVIEW_H__ 20 #define __TEXTVIEW_H__ 21 22 #include <glib.h> 23 #include <gtk/gtk.h> 24 25 typedef struct _ClickableText ClickableText; 26 struct _ClickableText 27 { 28 gchar *uri; 29 30 gchar *filename; 31 32 gpointer data; 33 gint data_len; 34 35 guint start; 36 guint end; 37 38 gboolean is_quote; 39 gint quote_level; 40 gboolean q_expanded; 41 gchar *fg_color; 42 }; 43 44 45 #include "viewtypes.h" 46 #include "procmime.h" 47 48 struct _TextView 49 { 50 GtkWidget *vbox; 51 GtkWidget *scrolledwin; 52 GtkWidget *text; 53 54 GtkUIManager *ui_manager; 55 GtkActionGroup *link_action_group; 56 GtkWidget *link_popup_menu; 57 GtkActionGroup *mail_action_group; 58 GtkWidget *mail_popup_menu; 59 GtkActionGroup *file_action_group; 60 GtkWidget *file_popup_menu; 61 62 gboolean default_text; 63 gboolean is_in_signature; 64 gboolean is_diff; 65 gboolean is_attachment; 66 gboolean is_in_git_patch; 67 68 GSList *uri_list; 69 gint body_pos; 70 71 MessageView *messageview; 72 gint last_buttonpress; 73 74 ClickableText *uri_hover; 75 GtkTextIter uri_hover_start_iter; 76 GtkTextIter uri_hover_end_iter; 77 GtkWidget *image; 78 gboolean loading; 79 gboolean stop_loading; 80 gint prev_quote_level; 81 }; 82 83 TextView *textview_create (void); 84 void textview_init (TextView *textview); 85 void textview_reflect_prefs (TextView *textview); 86 87 void textview_show_part (TextView *textview, 88 MimeInfo *mimeinfo, 89 FILE *fp); 90 void textview_show_error (TextView *textview); 91 void textview_show_info (TextView *textview, 92 const gchar *info_str); 93 void textview_show_mime_part (TextView *textview, 94 MimeInfo *partinfo); 95 void textview_clear (TextView *textview); 96 void textview_destroy (TextView *textview); 97 void textview_set_text (TextView *textview, 98 const gchar *text); 99 void textview_set_position (TextView *textview, 100 gint pos); 101 102 gboolean textview_search_string (TextView *textview, 103 const gchar *str, 104 gboolean case_sens); 105 gboolean textview_search_string_backward (TextView *textview, 106 const gchar *str, 107 gboolean case_sens); 108 void textview_cursor_wait(TextView *textview); 109 void textview_cursor_normal(TextView *textview); 110 void textview_show_icon(TextView *textview, const gchar *stock_id); 111 void textview_get_selection_offsets (TextView *textview, 112 gint *sel_start, 113 gint *sel_end); 114 gboolean textview_uri_security_check (TextView *textview, 115 ClickableText *uri, 116 gboolean copied); 117 gchar *textview_get_visible_uri (TextView *textview, 118 ClickableText *uri); 119 120 #define TEXTVIEW_INSERT(str) \ 121 gtk_text_buffer_insert_with_tags_by_name \ 122 (buffer, &iter, str, -1,\ 123 "header", NULL) 124 125 #define TEXTVIEW_INSERT_BOLD(str) \ 126 gtk_text_buffer_insert_with_tags_by_name \ 127 (buffer, &iter, str, -1,\ 128 "header", "header_title", NULL) 129 130 #define TEXTVIEW_INSERT_LINK(str, fname, udata) { \ 131 ClickableText *uri; \ 132 uri = g_new0(ClickableText, 1); \ 133 uri->uri = g_strdup(""); \ 134 uri->start = gtk_text_iter_get_offset(&iter); \ 135 gtk_text_buffer_insert_with_tags_by_name \ 136 (buffer, &iter, str, -1, \ 137 "link", "header_title", "header", \ 138 NULL); \ 139 uri->end = gtk_text_iter_get_offset(&iter); \ 140 uri->filename = fname?g_strdup(fname):NULL; \ 141 uri->data = udata; \ 142 textview->uri_list = \ 143 g_slist_prepend(textview->uri_list, uri); \ 144 } 145 146 #endif /* __TEXTVIEW_H__ */