Bugs in To: entry
- From: Emmanuel <e allaud wanadoo fr>
- To: balsa-list gnome org
- Subject: Bugs in To: entry
- Date: Thu, 11 Oct 2001 14:07:39 +0200
Hi all,
here is a little bug but still annoying. When you compose a new message,
type something in the to: address field, select it and erase it with
backspace or del, as you want, then open your address book, select one
person, you'll see the correct address in the to: field. But now press send
button, this will erase the To: field, causing the message not to be sent
(because Balsa does not send message with empty address).
It's related with libbalsa_..._clear_to_send function, but I was not able
to really find it. So if someone who knows this code better than me.
Moreover look at this function in libbalsa/address-entry.c :
/*************************************************************
* libbalsa_address_entry_show:
* Shows the widget. This will work out the aliases,
* and set the widget text to that, and then call
* libbalsa_address_entry_draw_text() to draw the
* widget.
*
* arguments:
* address_entry: the widget.
*
* results:
* modifies address_entry
*
* FIXME:
* - Adding the lists together should be easier.
* - It should make more use of helper functions
* that got written after this function got written,
* like libbalsa_make_address_string()
*************************************************************/
void
libbalsa_address_entry_show(LibBalsaAddressEntry *address_entry)
{
GtkEditable *editable;
GString *show;
GList *list;
emailData *addy;
gchar *out;
gint cursor, start, end;
gboolean found;
inputData *input;
gint tmp_pos;
g_return_if_fail(address_entry != NULL);
g_return_if_fail(LIBBALSA_IS_ADDRESS_ENTRY(address_entry));
g_return_if_fail(address_entry->input != NULL);
if (!GTK_WIDGET_DRAWABLE(address_entry)) return;
editable = GTK_EDITABLE(address_entry);
input = address_entry->input;
show = g_string_new("");
cursor = start = end = 0;
found = FALSE;
for (list = g_list_first(input->list);
list != NULL;
list = g_list_next(list)) {
/*
* Is it a normal string, or is it a match that requires ()
*/
addy = (emailData *)list->data;
g_assert(addy != NULL);
if (addy->match != NULL) {
out = g_strconcat("", addy->user, " (", addy->match, ")",
NULL);
} else {
out = g_strdup(addy->user);
}
/*
* Copy the string, adding a delimiter if need be.
*/
show = g_string_append(show, out);
if (g_list_next(list) != NULL)
show = g_string_append(show, ", ");
/*
* Check for the cursor position.
*/
if (!found) {
if (list != input->active) {
cursor += strlen(out);
if (g_list_next(list) != NULL) cursor += 2;
} else {
---> found = TRUE;
cursor += addy->cursor;
if (addy->match) {
start = cursor - addy->cursor;
start += strlen(addy->user) + 1;
end = start + strlen(addy->match) + 2;
}
}
}
g_free(out);
}
...
You see that in the line pointed by the arrow, you are in the else case,
meaning that found is already TRUE, so you don't have to assign the TRUE
value to it. Moreover found is always FALSE, because it is first
initialized to FALSE.
Here is the patch to correct that : it just moves the found=TRUE assignment
to the if block, where I think it normally belongs to. Please review that,
I'm not sure of what I'm doing.
And a small correction where we used strlen(show->str) whereas show is a
GString *, so you can directly use the len field of show, this is just a
small improvment.
An another small patch that corrects a "strlen(gchar *)==0" thing.
Bye
Manu
--- balsa-1.2.0/libbalsa/address-entry.c Fri Aug 24 18:27:00 2001
+++ balsa-1.2.0-curr/libbalsa/address-entry.c Thu Oct 11 14:04:56 2001
@@ -2919,8 +2919,8 @@
if (list != input->active) {
cursor += strlen(out);
if (g_list_next(list) != NULL) cursor += 2;
- } else {
found = TRUE;
+ } else {
cursor += addy->cursor;
if (addy->match) {
start = cursor - addy->cursor;
@@ -2942,7 +2942,7 @@
tmp_pos = 0;
libbalsa_address_entry_delete_text(editable, 0,
GTK_ENTRY(address_entry)->text_length);
- gtk_editable_insert_text(editable, show->str, strlen(show->str), &tmp_pos);
+ gtk_editable_insert_text(editable, show->str, show->len, &tmp_pos);
gtk_editable_set_position(GTK_EDITABLE(address_entry), cursor);
editable->selection_start_pos = start;
editable->selection_end_pos = end;
@@ -2952,7 +2952,7 @@
/*************************************************************
- * libbalsa_address_entry_show:
+ * libbalsa_address_clear_match:
* Clears the input cache of any data.
*
* arguments:
--- balsa-1.2.0/src/expand-alias.c Thu Sep 6 10:59:38 2001
+++ balsa-1.2.0-curr/src/expand-alias.c Thu Oct 11 13:36:58 2001
@@ -100,7 +100,7 @@
g_free(addy->match);
addy->match = NULL;
- if(strlen(input) == 0) {
+ if(input[0] == '\0') {
addy->match = g_strdup("");
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]