(gushort)0
};
-static GtkTextTag *no_wrap_tag = NULL;
-
static void compose_create_tags(GtkTextView *text, Compose *compose)
{
GtkTextBuffer *buffer;
gtk_text_buffer_create_tag(buffer, "link",
"foreground-gdk", &uri_color,
NULL);
- no_wrap_tag = gtk_text_buffer_create_tag(buffer, "no_wrap", NULL);
+ compose->no_wrap_tag = gtk_text_buffer_create_tag(buffer, "no_wrap", NULL);
}
Compose *compose_new(PrefsAccount *account, const gchar *mailto,
lastp = strchr(p, '\n');
len = lastp ? lastp - p + 1 : -1;
- gtk_text_buffer_insert(buffer, &iter, p, len);
+ if (g_utf8_validate(p, -1, NULL)) {
+ gtk_text_buffer_insert(buffer, &iter, p, len);
+ } else {
+ gchar *tmpin = g_strdup(p);
+ gchar *tmpout = NULL;
+ tmpin[len] = '\0';
+ tmpout = conv_codeset_strdup
+ (tmpin, conv_get_locale_charset_str(),
+ CS_INTERNAL);
+ gtk_text_buffer_insert(buffer, &iter, tmpout, -1);
+ g_free(tmpin);
+ g_free(tmpout);
+ }
if (lastp)
p = lastp + 1;
gchar *o_walk = NULL, *walk = NULL, *bp = NULL, *ep = NULL;
gint walk_pos;
- if (gtk_text_iter_has_tag(&iter, no_wrap_tag) && !force)
+ if (gtk_text_iter_has_tag(&iter, compose->no_wrap_tag) && !force)
goto colorize;
uri_start = uri_stop = -1;
if (compose->privacy_system != NULL) {
fprintf(fp, "X-Sylpheed-Privacy-System:%s\n", compose->privacy_system);
fprintf(fp, "X-Sylpheed-Sign:%d\n", compose->use_signing);
- fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
if (compose->use_encryption) {
gchar *encdata;
encdata = privacy_get_encrypt_data(compose->privacy_system, compose->to_list);
- if (encdata != NULL)
- fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n",
- encdata);
+ if (encdata != NULL) {
+ if (strcmp(encdata, "_DONT_ENCRYPT_")) {
+ fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
+ fprintf(fp, "X-Sylpheed-Encrypt-Data:%s\n",
+ encdata);
+ } /* else we finally dont want to encrypt */
+ } else {
+ fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);
+ /* and if encdata was null, it means there's been a problem in
+ * key selection */
+ }
g_free(encdata);
}
}
/* Subject */
str = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
+
if (*str != '\0' && !IS_IN_CUSTOM_HEADER("Subject")) {
g_strstrip(str);
if (*str != '\0') {
subst_char(tmpstr, '\r', ' ');
g_strchomp(tmpstr);
+ if (!g_utf8_validate(tmpstr, -1, NULL)) {
+ gchar *mybuf = g_malloc(strlen(tmpstr)*2 +1);
+ conv_localetodisp(mybuf, strlen(tmpstr)*2 +1, tmpstr);
+ g_free(tmpstr);
+ tmpstr = mybuf;
+ }
conv_encode_header_full(dest, len, tmpstr, header_len, addr_field,
conv_get_charset_str(compose->out_encoding));
g_free(tmpstr);
static void entry_paste_clipboard(Compose *compose, GtkWidget *entry, gboolean wrap,
GdkAtom clip);
+
+#define BLOCK_WRAP() { \
+ prev_autowrap = compose->autowrap; \
+ buffer = gtk_text_view_get_buffer( \
+ GTK_TEXT_VIEW(compose->text)); \
+ compose->autowrap = FALSE; \
+ \
+ g_signal_handlers_block_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(compose_changed_cb), \
+ compose); \
+ g_signal_handlers_block_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(text_inserted), \
+ compose); \
+}
+#define UNBLOCK_WRAP() { \
+ compose->autowrap = prev_autowrap; \
+ if (compose->autowrap) \
+ compose_wrap_all(compose); \
+ \
+ g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(compose_changed_cb), \
+ compose); \
+ g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
+ G_CALLBACK(text_inserted), \
+ compose); \
+}
+
+
static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
Compose *compose)
{
+ gint prev_autowrap;
+ GtkTextBuffer *buffer;
if (event->button == 2) {
+ BLOCK_WRAP();
entry_paste_clipboard(compose, compose->focused_editable,
prefs_common.linewrap_pastes,
GDK_SELECTION_PRIMARY);
+ UNBLOCK_WRAP();
return TRUE;
}
return FALSE;
geometry.max_width = gdk_screen_width();
geometry.max_height = gdk_screen_height();
}
+
gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
&geometry, GDK_HINT_MAX_SIZE);
if (!geometry.min_width) {
gpointer data)
{
Compose *compose = (Compose *)data;
-
+ GtkTreeSelection *attach_selection;
+ gint attach_nr_selected;
+ GtkItemFactory *ifactory;
+
if (!event) return FALSE;
if (event->button == 3) {
+ attach_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
+ attach_nr_selected = gtk_tree_selection_count_selected_rows(attach_selection);
+ ifactory = gtk_item_factory_from_widget(compose->popupmenu);
+
+ if (attach_nr_selected > 0)
+ {
+ menu_set_sensitive(ifactory, "/Remove", TRUE);
+ menu_set_sensitive(ifactory, "/Properties...", TRUE);
+ } else {
+ menu_set_sensitive(ifactory, "/Remove", FALSE);
+ menu_set_sensitive(ifactory, "/Properties...", FALSE);
+ }
+
gtk_menu_popup(GTK_MENU(compose->popupmenu), NULL, NULL,
NULL, NULL, event->button, event->time);
return TRUE;
entry_copy_clipboard(compose->focused_editable);
}
-#define BLOCK_WRAP() { \
- prev_autowrap = compose->autowrap; \
- buffer = gtk_text_view_get_buffer( \
- GTK_TEXT_VIEW(compose->text)); \
- compose->autowrap = FALSE; \
- \
- g_signal_handlers_block_by_func(G_OBJECT(buffer), \
- G_CALLBACK(compose_changed_cb), \
- compose); \
- g_signal_handlers_block_by_func(G_OBJECT(buffer), \
- G_CALLBACK(text_inserted), \
- compose); \
-}
-#define UNBLOCK_WRAP() { \
- compose->autowrap = prev_autowrap; \
- if (compose->autowrap) \
- compose_wrap_all(compose); \
- \
- g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
- G_CALLBACK(compose_changed_cb), \
- compose); \
- g_signal_handlers_unblock_by_func(G_OBJECT(buffer), \
- G_CALLBACK(text_inserted), \
- compose); \
-}
-
static void compose_paste_cb(Compose *compose)
{
gint prev_autowrap;
gtk_editable_set_position(GTK_EDITABLE(widget),
strlen(str));
g_free(str);
+ if (widget->parent && widget->parent->parent
+ && widget->parent->parent->parent) {
+ if (GTK_IS_SCROLLED_WINDOW(widget->parent->parent->parent)) {
+ gint y = widget->allocation.y;
+ gint height = widget->allocation.height;
+ GtkAdjustment *shown = gtk_scrolled_window_get_vadjustment
+ (GTK_SCROLLED_WINDOW(widget->parent->parent->parent));
+
+ if (y < (int)shown->value) {
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(shown), y - 1);
+ }
+ if (y + height > (int)shown->value + (int)shown->page_size) {
+ if (y - height - 1 < (int)shown->upper - (int)shown->page_size) {
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(shown),
+ y + height - (int)shown->page_size - 1);
+ } else {
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(shown),
+ (int)shown->upper - (int)shown->page_size - 1);
+ }
+ }
+ }
+ }
}
if (GTK_IS_EDITABLE(widget) || GTK_IS_TEXT_VIEW(widget))