~ubuntu-branches/ubuntu/hardy/pidgin/hardy

« back to all changes in this revision

Viewing changes to pidgin/gtkimhtml.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-21 02:48:06 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071221024806-pd44a5k9tiyh12mp
Tags: 1:2.3.1-2ubuntu1
* Sync with Debian, remaining Ubuntu changes; (LP: #177811)
  - Set Maintainer to Ubuntu Core Developers.
  - Add build-deps on liblaunchpad-integration-dev, intltool,
    libnm-glib-dev (for --enable-nm) (Ubuntu #112720).
  - Drop build-deps on libsilc-1.1-2-dev | libsilc-dev (>= 1.1.1) as 
    this library is in universe.
  - Drop the libpurple0 recommends on libpurple-bin.
  - Add a gaim transitionnal package for upgrades.
  - Ship compatibility symlinks via debian/gaim.links.
  - Pass --enable-nm to configure to enable NetworkManager support.
  - Pass --disable-silc to configure to disable silc support even if 
    it's installed in the build environment.
  - Add X-Ubuntu-Gettext-Domain to the desktop file and update the
    translation templates in common-install-impl::.
   - Update debian/prefs.xml to set the notify plugin prefs
    /plugins/gtk/X11/notify/* and set /pidgin/plugins/loaded to load 
    the notify plugin; Ubuntu: #13389.
  - Add LPI integration patch, 02_lpi.
  - Add patch 04_let_crasher_for_apport to stop catching the SIGSEGV signal
    and let apport handle it.
  - Add patch 05_default_to_irc_ubuntu_com to set the default IRC 
    server to irc.ubuntu.com.
  - Add autoconf patch, 70_autoconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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};
117
117
 
118
118
enum {
119
119
        TARGET_HTML,
138
138
 
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;
142
142
 
143
 
static GtkTargetEntry selection_targets[] = {
 
143
static const GtkTargetEntry selection_targets[] = {
144
144
#ifndef _WIN32
145
145
        { "text/html", 0, TARGET_HTML },
146
146
#else
151
151
        { "STRING", 0, TARGET_STRING },
152
152
        { "TEXT", 0, TARGET_TEXT}};
153
153
 
154
 
static GtkTargetEntry link_drag_drop_targets[] = {
 
154
static const GtkTargetEntry link_drag_drop_targets[] = {
155
155
        GTK_IMHTML_DND_TARGETS
156
156
};
157
157
 
204
204
        html = g_strjoinv("\n", split);
205
205
        g_strfreev(split);
206
206
 
207
 
        html = g_strstrip(html);
208
 
 
209
207
#if 0 /* Debugging for Windows clipboard */
210
208
        purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html);
211
209
#endif
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; 
903
 
 
904
 
        if (primary) { 
 
899
 
 
900
        if (primary) {
 
901
                GtkTextMark *sel = NULL, *ins = NULL;
 
902
 
 
903
                g_return_if_fail(imhtml != NULL);
 
904
 
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)
962
962
{
963
 
        clipboard_selection = NULL;
964
963
}
965
964
 
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);
976
975
 
977
976
                g_free(html_clipboard);
978
977
                g_free(text_clipboard);
979
978
 
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);
982
 
 
983
 
                text_clipboard = imhtml->clipboard_text_string;
984
 
                html_clipboard = imhtml->clipboard_html_string;
985
 
        
 
979
                html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end);
 
980
                text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end);
986
981
        }
987
982
 
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);
1001
996
 
1002
997
                g_free(html_clipboard);
1003
998
                g_free(text_clipboard);
1004
999
 
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);
1007
 
 
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);
1010
1002
 
1011
1003
                if (imhtml->editable)
1012
1004
                        gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE);
1175
1167
static void
1176
1168
gtk_imhtml_undo(GtkIMHtml *imhtml) {
1177
1169
        g_return_if_fail(GTK_IS_IMHTML(imhtml));
1178
 
        g_return_if_fail(imhtml->editable);
1179
 
        
1180
 
        gtk_source_undo_manager_undo(imhtml->undo_manager);
 
1170
        if (imhtml->editable)
 
1171
                gtk_source_undo_manager_undo(imhtml->undo_manager);
1181
1172
}
1182
1173
 
1183
1174
static void
1184
1175
gtk_imhtml_redo(GtkIMHtml *imhtml) {
1185
1176
        g_return_if_fail(GTK_IS_IMHTML(imhtml));
1186
 
        g_return_if_fail(imhtml->editable);
1187
 
        
1188
 
        gtk_source_undo_manager_redo(imhtml->undo_manager);
 
1177
        if (imhtml->editable)
 
1178
                gtk_source_undo_manager_redo(imhtml->undo_manager);
1189
1179
 
1190
1180
}
1191
1181
 
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));
1277
1262
 
1278
1263
}
1279
1264
 
1464
1449
        gtk_widget_add_events(GTK_WIDGET(imhtml),
1465
1450
                        GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK);
1466
1451
 
1467
 
        imhtml->clipboard_text_string = NULL;
1468
 
        imhtml->clipboard_html_string = NULL;
1469
 
 
1470
1452
        imhtml->tip = NULL;
1471
1453
        imhtml->tip_timer = 0;
1472
1454
        imhtml->tip_window = NULL;
2851
2833
                                                {
2852
2834
                                                    gtk_imhtml_toggle_underline(imhtml);
2853
2835
                                                    font->underline = 1;
2854
 
                                                } else
2855
 
                                                        g_free(textdec);
 
2836
                                                }
 
2837
                                                g_free(textdec);
2856
2838
 
2857
2839
                                                if (oldfont)
2858
2840
                                                {
2968
2950
                } else if (imhtml->edit.link == NULL &&
2969
2951
                                gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) {
2970
2952
                        GtkIMHtmlFontDetail *fd;
2971
 
 
2972
2953
                        gchar *sml = NULL;
 
2954
 
 
2955
                        br = FALSE;
 
2956
 
2973
2957
                        if (fonts) {
2974
2958
                                fd = fonts->data;
2975
2959
                                sml = fd->sml;
2987
2971
                        wpos = 0;
2988
2972
                        ws[0] = 0;
2989
2973
                } else if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) {
 
2974
                        br = FALSE;
2990
2975
                        while(*amp) {
2991
2976
                                ws [wpos++] = *amp++;
2992
2977
                        }
3015
3000
                        c++;
3016
3001
                        pos++;
3017
3002
                } else if ((len_protocol = gtk_imhtml_is_protocol(c)) > 0){
 
3003
                        br = FALSE;
3018
3004
                        while(len_protocol--){
3019
3005
                                /* Skip the next len_protocol characters, but make sure they're
3020
3006
                                   copied into the ws array.
3023
3009
                                 pos++;
3024
3010
                        }
3025
3011
                } else if (*c) {
 
3012
                        br = FALSE;
3026
3013
                        ws [wpos++] = *c++;
3027
3014
                        pos++;
3028
3015
                } else {
3132
3119
                gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer,
3133
3120
                        &i, sd->mark);
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);
 
3124
                        g_free(sd);
 
3125
                        imhtml->scalables = g_list_delete_link(imhtml->scalables, l);
3138
3126
                }
3139
3127
                l = next;
3140
3128
        }