62a63 > GdkColor signature_color; 70a72,92 > /** > * Determine if the current line denotes a signature delimitor > */ > static gboolean > is_signature (const gchar * line, size_t len) > { > if (len!=3 && len!=2) > return FALSE; > > if (line[0]=='-' && line[1]=='-') > { > > /* More than a few news clients tend to forget the trailing space > * after the two dashes. This is non-standard behaviour but should > * be probably be handled anyway, because it occurs often > */ > if (len == 2) return TRUE; > if (line[2] == ' ')return TRUE; > } > return FALSE; > } 119d140 < 178a200 > gboolean is_sig = FALSE; 205a228,232 > > if (!is_sig) > { > is_sig = is_signature (line, line_len); > } 206a234,238 > > if (strcmp (quote_tag, "quote_0")) > is_sig = FALSE; > > quote_tag = is_sig?"signature":quote_tag; 895a928,932 > if (url_tag == NULL) > { > g_assert (url_tag != NULL ); > return NULL; > } 896a934,936 > > /* ASSERTION FAILED */ > g_assert( GTK_IS_TEXT_TAG(url_tag)); 1011a1052,1184 > /* > * The following code was "stolen" from the gtk-devel archives > */ > static void > gtk_text_tag_copy_values (GtkTextTag *dest, GtkTextTag *src) > { > g_return_if_fail (dest); > g_return_if_fail (src); > g_return_if_fail (GTK_IS_TEXT_TAG (dest)); > g_return_if_fail (GTK_IS_TEXT_TAG (src)); > > gtk_text_attributes_copy_values (src->values, dest->values); > > #define _COPY_FLAG(flag) dest->flag = src->flag > _COPY_FLAG (bg_color_set); > _COPY_FLAG (bg_color_set); > _COPY_FLAG (bg_stipple_set); > _COPY_FLAG (fg_color_set); > // _COPY_FLAG (family_set); > // _COPY_FLAG (style_set); > // _COPY_FLAG (variant_set); > // _COPY_FLAG (weight_set); > // _COPY_FLAG (stretch_set); > // _COPY_FLAG (size_set); > _COPY_FLAG (fg_stipple_set); > _COPY_FLAG (justification_set); > _COPY_FLAG (left_margin_set); > _COPY_FLAG (indent_set); > _COPY_FLAG (rise_set); > _COPY_FLAG (strikethrough_set); > _COPY_FLAG (right_margin_set); > _COPY_FLAG (pixels_above_lines_set); > _COPY_FLAG (pixels_below_lines_set); > _COPY_FLAG (pixels_inside_wrap_set); > _COPY_FLAG (tabs_set); > _COPY_FLAG (underline_set); > _COPY_FLAG (wrap_mode_set); > _COPY_FLAG (bg_full_height_set); > _COPY_FLAG (invisible_set); > _COPY_FLAG (editable_set); > _COPY_FLAG (language_set); > #undef _COPY_FLAG > } > > > /** > ** gtk_text_tag_copy: -duplicate a tag > ** @tag: the #GtkTextTag to duplicate > ** > ** Create a new #GtkTextTag with same values as @tag. The returned > ** #GtkTextTag doesn't belong to any $GtkTextTagTable. > ** > ** Return value: the newly created #GtkTextTag > ***/ > GtkTextTag* gtk_text_tag_copy (GtkTextTag *tag) > { > GtkTextTag *ntag; > > g_return_val_if_fail (tag, NULL); > g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), NULL); > > ntag = gtk_text_tag_new (tag->name); > gtk_text_tag_copy_values (ntag, tag); > return ntag; > } > > > /** > ** gtk_text_tag_table_install: > ** @table: a #GtkTextTagTable > ** @tag: a #GtkTextTag > ** > ** Add @tag to the tag table @table or, if a tag with the same name > ** already exists in @table, update the existing tag in the table with > ** the values in @tag. If the tag is anonymous, it is simply added to > ** the table. > ***/ > void gtk_text_tag_table_install (GtkTextTagTable *table, GtkTextTag *tag) > { > GtkTextTag *existing_tag; > g_return_if_fail (table); > g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table)); > g_return_if_fail (tag); > g_return_if_fail (GTK_IS_TEXT_TAG (tag)); > > if (!tag->name) > gtk_text_tag_table_add(table, tag); > else { > existing_tag = gtk_text_tag_table_lookup(table, tag->name); > if (existing_tag) > gtk_text_tag_copy_values(existing_tag, tag); > else > gtk_text_tag_table_add(table, tag); > } > } > /* setup the buffer tags */ > void > set_text_buffer_tags (GtkTextBuffer * buffer) > { > GtkTextTag * tag; > GtkTextTagTable * table = gtk_text_buffer_get_tag_table (buffer); > > tag = gtk_text_tag_new ("center"); > g_object_set (tag, "justification", GTK_JUSTIFY_CENTER, NULL); > gtk_text_tag_table_install (table, tag); > > tag = gtk_text_tag_new ("url"); > g_object_set (tag, "underline", PANGO_UNDERLINE_SINGLE, "foreground_gdk", &text_url_color, NULL); > gtk_text_tag_table_install (table, tag); > > tag = gtk_text_tag_new ("quote_0"); > g_object_set (tag, NULL); > gtk_text_tag_table_install (table, tag); > > tag = gtk_text_tag_new ("quote_1"); > g_object_set (tag, "foreground_gdk", &text_quoted_color[0], NULL); > gtk_text_tag_table_install (table, tag); > > tag = gtk_text_tag_new ("quote_2"); > g_object_set (tag, "foreground_gdk", &text_quoted_color[1], NULL); > gtk_text_tag_table_install (table, tag); > > tag = gtk_text_tag_new ("quote_3"); > g_object_set (tag, "foreground_gdk", &text_quoted_color[2], NULL); > gtk_text_tag_table_install (table, tag); > > tag = gtk_text_tag_new ("signature"); > g_object_set (tag, "foreground_gdk", &signature_color, NULL); > gtk_text_tag_table_install (table, tag); > > } > > 1016c1189 < --- > 1018c1191 < text_view = gtk_text_view_new (); --- > text_view = gtk_text_view_new (); 1033,1041c1206 < gtk_text_buffer_create_tag (_text_buffer, "center", < "justification", GTK_JUSTIFY_CENTER, < NULL); < /* add the new tags */ < gtk_text_buffer_create_tag (_text_buffer, "url", < "underline", PANGO_UNDERLINE_SINGLE, < "foreground_gdk", &text_url_color, < NULL); < --- > set_text_buffer_tags (_text_buffer); 1049,1054d1213 < /* set the quote colors */ < gtk_text_buffer_create_tag (_text_buffer, "quote_0", NULL); < gtk_text_buffer_create_tag (_text_buffer, "quote_1", "foreground_gdk", &text_quoted_color[0], NULL); < gtk_text_buffer_create_tag (_text_buffer, "quote_2", "foreground_gdk", &text_quoted_color[1], NULL); < gtk_text_buffer_create_tag (_text_buffer, "quote_3", "foreground_gdk", &text_quoted_color[2], NULL); < /* FIXME need some way to refresh these tags when user changes text color via prefs */ 1121a1281,1285 > > /*try alternate signature delimitor*/ > if (!pch) > pch = pan_strstr (body,"\n--\n"); >