113
113
/* POINT_SIZE converts from AIM font sizes to a point size scale factor. */
114
114
#define MAX_FONT_SIZE 7
115
115
#define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1])
116
static gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736};
116
static const gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736};
139
139
static char *html_clipboard = NULL;
140
140
static char *text_clipboard = NULL;
141
GtkClipboard *clipboard_selection = NULL;
141
static GtkClipboard *clipboard_selection = NULL;
143
static GtkTargetEntry selection_targets[] = {
143
static const GtkTargetEntry selection_targets[] = {
145
145
{ "text/html", 0, TARGET_HTML },
151
151
{ "STRING", 0, TARGET_STRING },
152
152
{ "TEXT", 0, TARGET_TEXT}};
154
static GtkTargetEntry link_drag_drop_targets[] = {
154
static const GtkTargetEntry link_drag_drop_targets[] = {
155
155
GTK_IMHTML_DND_TARGETS
204
204
html = g_strjoinv("\n", split);
205
205
g_strfreev(split);
207
html = g_strstrip(html);
209
207
#if 0 /* Debugging for Windows clipboard */
210
208
purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html);
898
896
char *text = NULL;
899
897
gboolean primary = (clipboard != clipboard_selection);
900
898
GtkTextIter start, end;
901
GtkTextMark *sel = NULL;
902
GtkTextMark *ins = NULL;
901
GtkTextMark *sel = NULL, *ins = NULL;
903
g_return_if_fail(imhtml != NULL);
905
905
ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
906
906
sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
907
907
gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
960
960
static void gtk_imhtml_clipboard_clear (GtkClipboard *clipboard, GtkSelectionData *sel_data,
961
961
guint info, gpointer user_data_or_owner)
963
clipboard_selection = NULL;
966
965
static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused)
969
968
if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
970
969
if (!clipboard_selection)
971
970
clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
972
gtk_clipboard_set_with_owner(clipboard_selection,
971
gtk_clipboard_set_with_data(clipboard_selection,
973
972
selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
974
973
(GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
975
(GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, G_OBJECT(imhtml));
974
(GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL);
977
976
g_free(html_clipboard);
978
977
g_free(text_clipboard);
980
imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
981
imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
983
text_clipboard = imhtml->clipboard_text_string;
984
html_clipboard = imhtml->clipboard_html_string;
979
html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end);
980
text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end);
988
983
g_signal_stop_emission_by_name(imhtml, "copy-clipboard");
994
989
if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
995
990
if (!clipboard_selection)
996
991
clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD);
997
gtk_clipboard_set_with_owner(clipboard_selection,
992
gtk_clipboard_set_with_data(clipboard_selection,
998
993
selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
999
994
(GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
1000
(GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, G_OBJECT(imhtml));
995
(GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL);
1002
997
g_free(html_clipboard);
1003
998
g_free(text_clipboard);
1005
imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
1006
imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
1008
text_clipboard = imhtml->clipboard_text_string;
1009
html_clipboard = imhtml->clipboard_html_string;
1000
html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end);
1001
text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end);
1011
1003
if (imhtml->editable)
1012
1004
gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE);
1176
1168
gtk_imhtml_undo(GtkIMHtml *imhtml) {
1177
1169
g_return_if_fail(GTK_IS_IMHTML(imhtml));
1178
g_return_if_fail(imhtml->editable);
1180
gtk_source_undo_manager_undo(imhtml->undo_manager);
1170
if (imhtml->editable)
1171
gtk_source_undo_manager_undo(imhtml->undo_manager);
1184
1175
gtk_imhtml_redo(GtkIMHtml *imhtml) {
1185
1176
g_return_if_fail(GTK_IS_IMHTML(imhtml));
1186
g_return_if_fail(imhtml->editable);
1188
gtk_source_undo_manager_redo(imhtml->undo_manager);
1177
if (imhtml->editable)
1178
gtk_source_undo_manager_redo(imhtml->undo_manager);
1269
1259
g_free(imhtml->search_string);
1270
1260
g_object_unref(imhtml->undo_manager);
1271
1261
G_OBJECT_CLASS(parent_class)->finalize (object);
1272
if (clipboard_selection)
1273
gtk_clipboard_set_with_owner(clipboard_selection,
1274
selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
1275
(GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
1276
(GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
1464
1449
gtk_widget_add_events(GTK_WIDGET(imhtml),
1465
1450
GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK);
1467
imhtml->clipboard_text_string = NULL;
1468
imhtml->clipboard_html_string = NULL;
1470
1452
imhtml->tip = NULL;
1471
1453
imhtml->tip_timer = 0;
1472
1454
imhtml->tip_window = NULL;
3132
3119
gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer,
3134
3121
if (gtk_text_iter_in_range(&i, start, end)) {
3135
GtkIMHtmlScalable *scale = sd->scalable;
3122
GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable);
3136
3123
scale->free(scale);
3137
imhtml->scalables = g_list_remove_link(imhtml->scalables, l);
3125
imhtml->scalables = g_list_delete_link(imhtml->scalables, l);