2006-08-16 [colin] 2.4.0cvs54
[claws.git] / src / textview.c
index dd2e345ea0da2bad8cb23cebc1af81fae7a70baf..db6a40e79f1715e637ba5e654e1a350fcb46172e 100644 (file)
@@ -953,8 +953,8 @@ textview_default:
                tmpfp = g_fopen(mimeinfo->data.filename, "rb");
                fseek(tmpfp, mimeinfo->offset, SEEK_SET);
                debug_print("Viewing text content of type: %s (length: %d)\n", mimeinfo->subtype, mimeinfo->length);
-               while ((fgets(buf, sizeof(buf), tmpfp) != NULL) && 
-                      (ftell(tmpfp) <= mimeinfo->offset + mimeinfo->length))
+               while ((ftell(tmpfp) < mimeinfo->offset + mimeinfo->length) &&
+                      (fgets(buf, sizeof(buf), tmpfp) != NULL))
                        textview_write_line(textview, buf, conv);
                fclose(tmpfp);
        }
@@ -1303,7 +1303,7 @@ static void textview_write_line(TextView *textview, const gchar *str,
        GtkTextIter iter;
        gchar buf[BUFFSIZE];
        gchar *fg_color;
-       gint quotelevel = -1;
+       gint quotelevel = -1, real_quotelevel = -1;
        gchar quote_tag_str[10];
 
        text = GTK_TEXT_VIEW(textview->text);
@@ -1324,8 +1324,8 @@ static void textview_write_line(TextView *textview, const gchar *str,
           level is colored using a different color. */
        if (prefs_common.enable_color 
            && line_has_quote_char(buf, prefs_common.quote_chars)) {
-               quotelevel = get_quote_level(buf, prefs_common.quote_chars);
-
+               real_quotelevel = get_quote_level(buf, prefs_common.quote_chars);
+               quotelevel = real_quotelevel;
                /* set up the correct foreground color */
                if (quotelevel > 2) {
                        /* recycle colors */
@@ -1349,8 +1349,8 @@ static void textview_write_line(TextView *textview, const gchar *str,
                textview->is_in_signature = TRUE;
        }
 
-       if (quotelevel > -1) {
-               if ( previousquotelevel != quotelevel ) {
+       if (real_quotelevel > -1) {
+               if ( previousquotelevel != real_quotelevel ) {
                        ClickableText *uri;
                        uri = g_new0(ClickableText, 1);
                        uri->uri = g_strdup("");
@@ -1363,12 +1363,12 @@ static void textview_write_line(TextView *textview, const gchar *str,
                        uri->filename = NULL;
                        uri->fg_color = g_strdup(fg_color);
                        uri->is_quote = TRUE;
-                       uri->quote_level = quotelevel;
+                       uri->quote_level = real_quotelevel;
                        textview->uri_list =
                                g_slist_append(textview->uri_list, uri);
                        gtk_text_buffer_insert(buffer, &iter, "  \n", -1);
                
-                       previousquotelevel = quotelevel;
+                       previousquotelevel = real_quotelevel;
                } else {
                        GSList *last = g_slist_last(textview->uri_list);
                        ClickableText *lasturi = (ClickableText *)last->data;
@@ -2398,7 +2398,10 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
        bevent = (GdkEventButton *) event;
        
        /* doubleclick: open compose / add address / browser */
-       if ((event->type == (qlink ? GDK_2BUTTON_PRESS:GDK_BUTTON_PRESS) && bevent->button == 1) ||
+       if (qlink && event->type == GDK_BUTTON_PRESS && bevent->button != 1) {
+               /* pass rightclick through */
+               return FALSE;
+       } else if ((event->type == (qlink ? GDK_2BUTTON_PRESS:GDK_BUTTON_PRESS) && bevent->button == 1) ||
                bevent->button == 2 || bevent->button == 3) {
                if (uri->filename && !g_ascii_strncasecmp(uri->filename, "sc://", 5)) {
                        MimeView *mimeview = 
@@ -2417,7 +2420,6 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
                } else if (qlink && bevent->button == 1) {
                        textview_toggle_quote(textview, uri, FALSE);
                        return TRUE;
-                               
                } else if (!g_ascii_strncasecmp(uri->uri, "mailto:", 7)) {
                        if (bevent->button == 3) {
                                g_object_set_data(