2004-11-14 [colin] 0.9.12cvs146.9
[claws.git] / src / textview.c
index 550f398ebf7f4844722a9fd048fc8bd0f2fbf1c6..ba97f5076b9b1dc80d443a93bb81ebf4a75321dc 100644 (file)
@@ -1824,70 +1824,6 @@ static gint textview_key_pressed(GtkWidget *widget, GdkEventKey *event,
        return TRUE;
 }
 
-/*!
- *\brief    Check to see if a web URL has been disguised as a different
- *          URL (possible with HTML email).
- *
- *\param    uri The uri to check
- *
- *\param    textview The TextView the URL is contained in
- *
- *\return   gboolean TRUE if the URL is ok, or if the user chose to open
- *          it anyway, otherwise FALSE          
- */
-static gboolean uri_security_check(RemoteURI *uri, TextView *textview) 
-{
-       gchar *clicked_str;
-       gboolean retval = TRUE;
-
-       if (g_ascii_strncasecmp(uri->uri, "http:", 5) &&
-           g_ascii_strncasecmp(uri->uri, "https:", 6) &&
-           g_ascii_strncasecmp(uri->uri, "www.", 4)) 
-               return retval;
-
-       clicked_str = gtk_editable_get_chars(GTK_EDITABLE(textview->text),
-                                            uri->start,
-                                            uri->end);
-       if (clicked_str == NULL)
-               return TRUE;
-
-       if (strcmp(clicked_str, uri->uri) &&
-           (!g_ascii_strncasecmp(clicked_str, "http:",  5) ||
-            !g_ascii_strncasecmp(clicked_str, "https:", 6) ||
-            !g_ascii_strncasecmp(clicked_str, "www.",   4))) {
-               gchar *str;
-               retval = FALSE;
-
-               /* allow uri->uri    == http://somewhere.com
-                  and   clicked_str ==        somewhere.com */
-               str = g_strconcat("http://", clicked_str, NULL);
-
-               if (!g_ascii_strcasecmp(str, uri->uri))
-                       retval = TRUE;
-               g_free(str);
-       }
-
-       if (retval == FALSE) {
-               gchar *msg = NULL;
-               AlertValue resp;
-
-               msg = g_strdup_printf(_("The real URL (%s) is different from\n"
-                                       "the apparent URL (%s).  \n"
-                                       "Open it anyway?"),
-                                       uri->uri, clicked_str);
-               resp = alertpanel_with_type(_("Warning"), 
-                                 msg,
-                                 _("Yes"), 
-                                 _("No"),
-                                 NULL, NULL, ALERT_WARNING);
-               g_free(msg);
-               if (resp == G_ALERTDEFAULT)
-                       retval = TRUE;
-       } 
-       g_free(clicked_str);
-       return retval;
-}
-
 static gboolean textview_motion_notify(GtkWidget *widget,
                                       GdkEventMotion *event,
                                       TextView *textview)
@@ -1912,7 +1848,15 @@ static gboolean textview_visibility_notify(GtkWidget *widget,
                                           TextView *textview)
 {
        gint wx, wy;
-  
+       GdkWindow *window;
+
+       window = gtk_text_view_get_window(GTK_TEXT_VIEW(widget),
+                                         GTK_TEXT_WINDOW_TEXT);
+
+       /* check if occurred for the text window part */
+       if (window != event->window)
+               return FALSE;
+       
        gdk_window_get_pointer(widget->window, &wx, &wy, NULL);
        textview_uri_update(textview, wx, wy);
 
@@ -2155,12 +2099,19 @@ static gboolean textview_uri_security_check(TextView *textview, RemoteURI *uri)
 {
        gchar *visible_str;
        gboolean retval = TRUE;
+       GtkTextBuffer *buffer;
+       GtkTextIter start, end;
 
        if (is_uri_string(uri->uri) == FALSE)
                return TRUE;
 
-       visible_str = gtk_editable_get_chars(GTK_EDITABLE(textview->text),
-                                            uri->start, uri->end);
+       buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text));
+
+       gtk_text_buffer_get_iter_at_offset(buffer, &start, uri->start);
+       gtk_text_buffer_get_iter_at_offset(buffer, &end,   uri->end);
+
+       visible_str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+
        if (visible_str == NULL)
                return TRUE;