0.8.6claws107

* src/Makefile.am
* src/compose.c
* src/gtkstext.[ch]             ** REMOVE **
* src/gtkutils.[ch]
* src/textview.c
* src/gtk/gtkstext.[ch]         ** NEW **
* src/gtk/Makefile.am
        o move stext functions to gtkstext.c to remove
          dependency of gtkutils
        o move gtkstext files to common

* src/gtk/Makefile.am
* src/gtk/sslcertwindow.[ch]
        UI stuff can always depend on common code so
        it's ok to add ../common to include path
This commit is contained in:
Christoph Hohmann 2002-12-13 17:43:59 +00:00
parent 01f52c7371
commit b07ad749aa
12 changed files with 148 additions and 119 deletions

View file

@ -1,3 +1,21 @@
2002-12-13 [christoph] 0.8.6claws107
* src/Makefile.am
* src/compose.c
* src/gtkstext.[ch] ** REMOVE **
* src/gtkutils.[ch]
* src/textview.c
* src/gtk/gtkstext.[ch] ** NEW **
* src/gtk/Makefile.am
o move stext functions to gtkstext.c to remove
dependency of gtkutils
o move gtkstext files to common
* src/gtk/Makefile.am
* src/gtk/sslcertwindow.[ch]
UI stuff can always depend on common code so
it's ok to add ../common to include path
2002-12-13 [colin] 0.8.6claws106
* src/summaryview.c

View file

@ -11,7 +11,7 @@ MINOR_VERSION=8
MICRO_VERSION=6
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_VERSION=claws106
EXTRA_VERSION=claws107
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target

View file

@ -23,7 +23,6 @@ sylpheed_SOURCES = \
procheader.c procheader.h \
compose.c compose.h \
gtkshruler.c gtkshruler.h \
gtkstext.c gtkstext.h \
menu.c menu.h \
stock_pixmap.c stock_pixmap.h \
prefs.c prefs.h \

View file

@ -2431,7 +2431,7 @@ static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
/* skip delete if it is continuous URL */
if (do_delete && (line_pos - p_pos <= i_len) &&
gtkut_stext_is_uri_string(text, line_pos, tlen))
gtk_stext_is_uri_string(text, line_pos, tlen))
do_delete = FALSE;
#ifdef WRAP_DEBUG
@ -2450,7 +2450,7 @@ static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
indent string, delete them */
if (i_len) {
guint ilen;
ilen = gtkut_stext_str_compare_n
ilen = gtk_stext_str_compare_n
(text, cur_pos, p_pos, i_len,
tlen);
if (ilen) {
@ -2513,7 +2513,7 @@ static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
#endif
/* force wrapping if it is one long word but not URL */
if (line_pos - p_pos <= i_len)
if (!gtkut_stext_is_uri_string
if (!gtk_stext_is_uri_string
(text, line_pos, tlen))
line_pos = cur_pos - 1;
#ifdef WRAP_DEBUG
@ -2525,7 +2525,7 @@ static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
/* if next character is space delete it */
if (clen == 1 && isspace(*cbuf)) {
if (p_pos + i_len != line_pos ||
!gtkut_stext_is_uri_string
!gtk_stext_is_uri_string
(text, line_pos, tlen)) {
STEXT_FREEZE();
/* workaround for correct cursor
@ -2547,7 +2547,7 @@ static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
/* if it is URL at beginning of line don't wrap */
if (p_pos + i_len == line_pos &&
gtkut_stext_is_uri_string(text, line_pos, tlen)) {
gtk_stext_is_uri_string(text, line_pos, tlen)) {
#ifdef WRAP_DEBUG
g_print("found URL at ");
dump_text(text, line_pos, tlen, 1);
@ -2580,7 +2580,7 @@ static void compose_wrap_line_all_full(Compose *compose, gboolean autowrap)
/* should we insert quotation ? */
if (linewrap_quote && i_len) {
/* only if line is not already quoted */
if (!gtkut_stext_str_compare
if (!gtk_stext_str_compare
(text, line_pos, tlen, qfmt)) {
guint ins_len;

View file

@ -2,9 +2,11 @@ noinst_LTLIBRARIES = libsylpheedgtk.la
libsylpheedgtk_la_SOURCES = \
gtksctree.c gtksctree.h \
gtkstext.c gtkstext.h \
sslcertwindow.c sslcertwindow.h
INCLUDES = \
-I../common \
$(GTK_CFLAGS)
libsylpheedgtk_la_LIBADD = \

View file

@ -36,15 +36,15 @@
#include <ctype.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdki18n.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkselection.h>
#include <gtk/gtksignal.h>
/* #include "compose.h" */
#include "gtkstext.h"
#include "gtkutils.h"
#include "utils.h"
/* line_arrow.xbm */
#define line_arrow_width 6
@ -5246,7 +5246,7 @@ find_line_params (GtkSText* text,
if (lp.end.index == lp.start.index)
{
/* SYLPHEED: don't wrap URLs */
if (gtkut_stext_is_uri_string(text, lp.end.index,
if (gtk_stext_is_uri_string(text, lp.end.index,
gtk_stext_get_length(text)))
{
lp.end = saved_mark;
@ -6169,6 +6169,88 @@ void gtk_stext_set_wrap_rmargin (GtkSText *text, gint rmargin)
text->wrap_rmargin = rmargin >= 0 ? rmargin : 0;
}
gboolean gtk_stext_match_string(GtkSText *text, gint pos, wchar_t *wcs,
gint len, gboolean case_sens)
{
gint match_count = 0;
for (; match_count < len; pos++, match_count++) {
if (case_sens) {
if (GTK_STEXT_INDEX(text, pos) != wcs[match_count])
break;
} else {
if (towlower(GTK_STEXT_INDEX(text, pos)) !=
towlower(wcs[match_count]))
break;
}
}
if (match_count == len)
return TRUE;
else
return FALSE;
}
guint gtk_stext_str_compare_n(GtkSText *text, guint pos1, guint pos2,
guint len, guint text_len)
{
guint i;
GdkWChar ch1, ch2;
for (i = 0; i < len && pos1 + i < text_len && pos2 + i < text_len; i++) {
ch1 = GTK_STEXT_INDEX(text, pos1 + i);
ch2 = GTK_STEXT_INDEX(text, pos2 + i);
if (ch1 != ch2)
break;
}
return i;
}
guint gtk_stext_str_compare(GtkSText *text, guint start_pos, guint text_len,
const gchar *str)
{
wchar_t *wcs;
guint len;
gboolean result;
if (!str) return 0;
wcs = strdup_mbstowcs(str);
if (!wcs) return 0;
len = wcslen(wcs);
if (len > text_len - start_pos)
result = FALSE;
else
result = gtk_stext_match_string(text, start_pos, wcs, len,
TRUE);
g_free(wcs);
return result ? len : 0;
}
gboolean gtk_stext_is_uri_string(GtkSText *text,
guint start_pos, guint text_len)
{
if (gtk_stext_str_compare(text, start_pos, text_len, "http://") ||
gtk_stext_str_compare(text, start_pos, text_len, "ftp://") ||
gtk_stext_str_compare(text, start_pos, text_len, "https://") ||
gtk_stext_str_compare(text, start_pos, text_len, "www."))
return TRUE;
return FALSE;
}
void gtk_stext_clear(GtkSText *text)
{
gtk_stext_freeze(text);
gtk_stext_set_point(text, 0);
gtk_stext_forward_delete(text, gtk_stext_get_length(text));
gtk_stext_thaw(text);
}
/**********************************************************************/
/* Debug */
/**********************************************************************/

View file

@ -31,6 +31,14 @@
#ifndef __GTK_STEXT_H__
#define __GTK_STEXT_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
#endif
#include <gdk/gdk.h>
#include <gtk/gtkadjustment.h>
@ -266,6 +274,27 @@ void gtk_stext_delete_to_line_end (GtkSText *text);
* behaviour */
void gtk_stext_set_wrap_rmargin (GtkSText *text, gint rmargin);
/* gtk stext functions */
gboolean gtk_stext_match_string (GtkSText *text,
gint pos,
wchar_t *wcs,
gint len,
gboolean case_sens);
guint gtk_stext_str_compare_n (GtkSText *text,
guint pos1,
guint pos2,
guint len,
guint text_len);
guint gtk_stext_str_compare (GtkSText *text,
guint start_pos,
guint text_len,
const gchar *str);
gboolean gtk_stext_is_uri_string (GtkSText *text,
guint start_pos,
guint text_len);
void gtk_stext_clear (GtkSText *text);
#define GTK_STEXT_INDEX(t, index) (((t)->use_wchar) \
? ((index) < (t)->gap_position ? (t)->text.wc[index] : \

View file

@ -26,11 +26,11 @@
#include <openssl/ssl.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "../common/intl.h"
#include "../common/ssl_certificate.h"
#include "../common/utils.h"
#include "intl.h"
#include "ssl_certificate.h"
#include "utils.h"
#include "../alertpanel.h"
#include "../common/hooks.h"
#include "hooks.h"
static void toggle_cert_cb(GtkWidget *widget,
gpointer data);

View file

@ -30,7 +30,7 @@
#include <openssl/objects.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "../common/ssl_certificate.h"
#include "ssl_certificate.h"
GtkWidget *cert_presenter(SSLCertificate *cert);
void sslcertwindow_show_cert(SSLCertificate *cert);

View file

@ -367,88 +367,6 @@ void gtkut_container_remove(GtkContainer *container, GtkWidget *widget)
gtk_container_remove(container, widget);
}
gboolean gtkut_stext_match_string(GtkSText *text, gint pos, wchar_t *wcs,
gint len, gboolean case_sens)
{
gint match_count = 0;
for (; match_count < len; pos++, match_count++) {
if (case_sens) {
if (GTK_STEXT_INDEX(text, pos) != wcs[match_count])
break;
} else {
if (towlower(GTK_STEXT_INDEX(text, pos)) !=
towlower(wcs[match_count]))
break;
}
}
if (match_count == len)
return TRUE;
else
return FALSE;
}
guint gtkut_stext_str_compare_n(GtkSText *text, guint pos1, guint pos2,
guint len, guint text_len)
{
guint i;
GdkWChar ch1, ch2;
for (i = 0; i < len && pos1 + i < text_len && pos2 + i < text_len; i++) {
ch1 = GTK_STEXT_INDEX(text, pos1 + i);
ch2 = GTK_STEXT_INDEX(text, pos2 + i);
if (ch1 != ch2)
break;
}
return i;
}
guint gtkut_stext_str_compare(GtkSText *text, guint start_pos, guint text_len,
const gchar *str)
{
wchar_t *wcs;
guint len;
gboolean result;
if (!str) return 0;
wcs = strdup_mbstowcs(str);
if (!wcs) return 0;
len = wcslen(wcs);
if (len > text_len - start_pos)
result = FALSE;
else
result = gtkut_stext_match_string(text, start_pos, wcs, len,
TRUE);
g_free(wcs);
return result ? len : 0;
}
gboolean gtkut_stext_is_uri_string(GtkSText *text,
guint start_pos, guint text_len)
{
if (gtkut_stext_str_compare(text, start_pos, text_len, "http://") ||
gtkut_stext_str_compare(text, start_pos, text_len, "ftp://") ||
gtkut_stext_str_compare(text, start_pos, text_len, "https://") ||
gtkut_stext_str_compare(text, start_pos, text_len, "www."))
return TRUE;
return FALSE;
}
void gtk_stext_clear(GtkSText *text)
{
gtk_stext_freeze(text);
gtk_stext_set_point(text, 0);
gtk_stext_forward_delete(text, gtk_stext_get_length(text));
gtk_stext_thaw(text);
}
void gtkut_widget_disable_theme_engine(GtkWidget *widget)
{
GtkStyle *style, *new_style;

View file

@ -122,25 +122,6 @@ gchar *gtkut_editable_get_selection (GtkEditable *editable);
void gtkut_container_remove (GtkContainer *container,
GtkWidget *widget);
gboolean gtkut_stext_match_string (GtkSText *text,
gint pos,
wchar_t *wcs,
gint len,
gboolean case_sens);
guint gtkut_stext_str_compare_n (GtkSText *text,
guint pos1,
guint pos2,
guint len,
guint text_len);
guint gtkut_stext_str_compare (GtkSText *text,
guint start_pos,
guint text_len,
const gchar *str);
gboolean gtkut_stext_is_uri_string (GtkSText *text,
guint start_pos,
guint text_len);
void gtk_stext_clear (GtkSText *text);
void gtkut_widget_disable_theme_engine (GtkWidget *widget);
void gtkut_widget_wait_for_draw (GtkWidget *widget);
void gtkut_widget_get_uposition (GtkWidget *widget,

View file

@ -1441,7 +1441,7 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
for (; pos < text_len; pos++) {
if (text_len - pos < len) break;
if (gtkut_stext_match_string(text, pos, wcs, len, case_sens)
if (gtk_stext_match_string(text, pos, wcs, len, case_sens)
== TRUE) {
gtk_widget_hide(GTK_WIDGET(textview->scrolledwin));
gtk_editable_set_position(GTK_EDITABLE(text),
@ -1484,7 +1484,7 @@ gboolean textview_search_string_backward(TextView *textview, const gchar *str,
pos = text_len - len;
for (; pos >= textview->body_pos; pos--) {
if (gtkut_stext_match_string(text, pos, wcs, len, case_sens)
if (gtk_stext_match_string(text, pos, wcs, len, case_sens)
== TRUE) {
gtk_editable_set_position(GTK_EDITABLE(text), pos);
gtk_editable_select_region(GTK_EDITABLE(text),