aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-01-27 06:41:31 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-01-27 06:41:31 +0000
commitc46ac89a27c4efd60921bc075fc79ef7b1a56364 (patch)
treed1d2c25d0c76b55ba5395b8d354d86aa6e8470d7 /src
parentaf7c0d4c4d5f20cc09dc7f709cd88c43dab567b8 (diff)
show translated messages on the statusbar. Prohibit addressbook names begin with '@'.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2443 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/addressbook.c81
-rw-r--r--src/editbook.c3
2 files changed, 41 insertions, 43 deletions
diff --git a/src/addressbook.c b/src/addressbook.c
index e8b1bf2c..f7d9e9b5 100644
--- a/src/addressbook.c
+++ b/src/addressbook.c
@@ -116,9 +116,6 @@ static GdkPixbuf *jpilotpix;
static GdkPixbuf *categorypix;
static GdkPixbuf *ldappix;
-/* Message buffer */
-static gchar addressbook_msgbuf[ADDRESSBOOK_MSGBUF_SIZE];
-
/* Address list selection */
static GList *_addressListSelection_ = NULL;
@@ -940,26 +937,23 @@ static void addressbook_ds_show_message(AddressDataSource *ds)
{
gint retVal;
gchar *name;
-
- *addressbook_msgbuf = '\0';
+ gchar msgbuf[ADDRESSBOOK_MSGBUF_SIZE] = "";
if (ds) {
name = addrindex_ds_get_name(ds);
+ if (ds->type == ADDR_IF_BOOK && name &&
+ !strcmp(name, ADDR_DS_AUTOREG))
+ name = _("Auto-registered address");
retVal = addrindex_ds_get_status_code(ds);
if (retVal == MGU_SUCCESS) {
- if (ds) {
- g_snprintf(addressbook_msgbuf, sizeof(addressbook_msgbuf), "%s", name);
- }
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s", name);
} else {
- if (ds == NULL) {
- g_snprintf(addressbook_msgbuf, sizeof(addressbook_msgbuf), "%s", mgu_error2string(retVal));
- } else {
- g_snprintf(addressbook_msgbuf, sizeof(addressbook_msgbuf), "%s: %s", name, mgu_error2string(retVal));
- }
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s: %s",
+ name, mgu_error2string(retVal));
}
}
- addressbook_status_show(addressbook_msgbuf);
+ addressbook_status_show(msgbuf);
}
/*
@@ -3075,7 +3069,8 @@ static gboolean addressbook_add_object(GtkTreeIter *iter, GtkTreeIter *new_iter,
if (atci && atci->showInTree) {
/* Add object to tree */
debug_print("addressbook_add_object: obj: %s\n", obj->name);
- if (otype == ADDR_BOOK && !strcmp(obj->name, ADDR_DS_AUTOREG))
+ if (otype == ADDR_BOOK && obj->name &&
+ !strcmp(obj->name, ADDR_DS_AUTOREG))
name = _("Auto-registered address");
else
name = obj->name;
@@ -3378,15 +3373,16 @@ gint addressbook_obj_name_compare(gconstpointer a, gconstpointer b)
#if 0
static void addressbook_book_show_message( AddressBookFile *abf ) {
- *addressbook_msgbuf = '\0';
- if( abf ) {
- if( abf->retVal == MGU_SUCCESS ) {
- sprintf( addressbook_msgbuf, "%s", abf->name );
+ gchar msgbuf[ADDRESSBOOK_MSGBUF_SIZE] = "";
+
+ if (abf) {
+ if (abf->retVal == MGU_SUCCESS) {
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s", abf->name);
} else {
- sprintf( addressbook_msgbuf, "%s: %s", abf->name, mgu_error2string( abf->retVal ) );
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s: %s", abf->name, mgu_error2string(abf->retVal));
}
}
- addressbook_status_show( addressbook_msgbuf );
+ addressbook_status_show(msgbuf);
}
#endif
@@ -3442,16 +3438,16 @@ static void addressbook_new_vcard_cb(gpointer data, guint action, GtkWidget *wid
#if 0
static void addressbook_vcard_show_message( VCardFile *vcf ) {
- *addressbook_msgbuf = '\0';
- if( vcf ) {
- if( vcf->retVal == MGU_SUCCESS ) {
- sprintf( addressbook_msgbuf, "%s", vcf->name );
- }
- else {
- sprintf( addressbook_msgbuf, "%s: %s", vcf->name, mgu_error2string( vcf->retVal ) );
+ gchar msgbuf[ADDRESSBOOK_MSGBUF_SIZE] = "";
+
+ if (vcf) {
+ if (vcf->retVal == MGU_SUCCESS) {
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s", vcf->name);
+ } else {
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s: %s", vcf->name, mgu_error2string(vcf->retVal));
}
}
- addressbook_status_show( addressbook_msgbuf );
+ addressbook_status_show(msgbuf);
}
#endif
@@ -3487,16 +3483,16 @@ static void addressbook_new_jpilot_cb(gpointer data, guint action, GtkWidget *wi
#if 0
static void addressbook_jpilot_show_message( JPilotFile *jpf ) {
- *addressbook_msgbuf = '\0';
- if( jpf ) {
- if( jpf->retVal == MGU_SUCCESS ) {
- sprintf( addressbook_msgbuf, "%s", jpf->name );
- }
- else {
- sprintf( addressbook_msgbuf, "%s: %s", jpf->name, mgu_error2string( jpf->retVal ) );
+ gchar msgbuf[ADDRESSBOOK_MSGBUF_SIZE] = "";
+
+ if (jpf) {
+ if (jpf->retVal == MGU_SUCCESS) {
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s", jpf->name);
+ } else {
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s: %s", jpf->name, mgu_error2string(jpf->retVal));
}
}
- addressbook_status_show( addressbook_msgbuf );
+ addressbook_status_show(msgbuf);
}
#endif
#endif /* USE_JPILOT */
@@ -3533,19 +3529,20 @@ static void addressbook_new_ldap_cb(gpointer data, guint action, GtkWidget *widg
static void addressbook_ldap_show_message(SyldapServer *svr)
{
- *addressbook_msgbuf = '\0';
+ gchar msgbuf[ADDRESSBOOK_MSGBUF_SIZE] = "";
+
if (svr) {
if (svr->busyFlag) {
- sprintf(addressbook_msgbuf, "%s: %s", svr->name, ADDRESSBOOK_LDAP_BUSYMSG);
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s: %s", svr->name, ADDRESSBOOK_LDAP_BUSYMSG);
} else {
if (svr->retVal == MGU_SUCCESS) {
- sprintf(addressbook_msgbuf, "%s", svr->name);
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s", svr->name);
} else {
- sprintf(addressbook_msgbuf, "%s: %s", svr->name, mgu_error2string(svr->retVal));
+ g_snprintf(msgbuf, sizeof(msgbuf), "%s: %s", svr->name, mgu_error2string(svr->retVal));
}
}
}
- addressbook_status_show(addressbook_msgbuf);
+ addressbook_status_show(msgbuf);
}
static void ldapsearch_callback(SyldapServer *sls)
diff --git a/src/editbook.c b/src/editbook.c
index 9f935bde..4e42e43a 100644
--- a/src/editbook.c
+++ b/src/editbook.c
@@ -325,7 +325,8 @@ AdapterDSource *addressbook_edit_book( AddressIndex *addrIndex, AdapterDSource *
fin = FALSE;
sName = gtk_editable_get_chars( GTK_EDITABLE(addrbookedit_dlg.name_entry), 0, -1 );
- if( *sName == '\0' ) fin = TRUE;
+ g_strstrip(sName);
+ if( *sName == '\0' || *sName == '@' ) fin = TRUE;
if( fin ) {
if( newBook ) {