balsa r7894 - in trunk: . libbalsa libinit_balsa src
- From: PeterB svn gnome org
- To: svn-commits-list gnome org
- Subject: balsa r7894 - in trunk: . libbalsa libinit_balsa src
- Date: Thu, 20 Mar 2008 22:32:59 +0000 (GMT)
Author: PeterB
Date: Thu Mar 20 22:32:58 2008
New Revision: 7894
URL: http://svn.gnome.org/viewvc/balsa?rev=7894&view=rev
Log:
use various glib utilities
Modified:
trunk/ChangeLog
trunk/libbalsa/misc.c
trunk/libbalsa/misc.h
trunk/libinit_balsa/assistant_page_directory.c
trunk/src/mailbox-conf.c
trunk/src/mailbox-node.c
trunk/src/save-restore.c
trunk/src/sendmsg-window.c
Modified: trunk/libbalsa/misc.c
==============================================================================
--- trunk/libbalsa/misc.c (original)
+++ trunk/libbalsa/misc.c Thu Mar 20 22:32:58 2008
@@ -1366,3 +1366,16 @@
guesses[i], NULL); /* *** Or NULL */
}
+
+gboolean
+libbalsa_path_is_below_dir(const gchar * path, const gchar * dir)
+{
+ gsize len;
+
+ if (!path || !dir || !g_str_has_prefix(path, dir))
+ return FALSE;
+
+ len = strlen(dir);
+
+ return dir[len - 1] == G_DIR_SEPARATOR || path[len] == G_DIR_SEPARATOR;
+}
Modified: trunk/libbalsa/misc.h
==============================================================================
--- trunk/libbalsa/misc.h (original)
+++ trunk/libbalsa/misc.h Thu Mar 20 22:32:58 2008
@@ -186,4 +186,6 @@
gboolean libbalsa_ldap_exists(const gchar *server);
+gboolean libbalsa_path_is_below_dir(const gchar * path, const gchar * dir);
+
#endif /* __LIBBALSA_MISC_H__ */
Modified: trunk/libinit_balsa/assistant_page_directory.c
==============================================================================
--- trunk/libinit_balsa/assistant_page_directory.c (original)
+++ trunk/libinit_balsa/assistant_page_directory.c Thu Mar 20 22:32:58 2008
@@ -294,21 +294,23 @@
*/
if (!dir->paths_locked) {
- buf = g_strconcat(balsa_app.local_mail_directory, "/outbox", NULL);
+ buf = g_build_filename(balsa_app.local_mail_directory, "outbox",
+ NULL);
gtk_entry_set_text(GTK_ENTRY(dir->outbox), buf);
g_free(buf);
- buf =
- g_strconcat(balsa_app.local_mail_directory, "/sentbox", NULL);
+ buf = g_build_filename(balsa_app.local_mail_directory, "sentbox",
+ NULL);
gtk_entry_set_text(GTK_ENTRY(dir->sentbox), buf);
g_free(buf);
- buf =
- g_strconcat(balsa_app.local_mail_directory, "/draftbox", NULL);
+ buf = g_build_filename(balsa_app.local_mail_directory, "draftbox",
+ NULL);
gtk_entry_set_text(GTK_ENTRY(dir->draftbox), buf);
g_free(buf);
- buf = g_strconcat(balsa_app.local_mail_directory, "/trash", NULL);
+ buf = g_build_filename(balsa_app.local_mail_directory, "trash",
+ NULL);
gtk_entry_set_text(GTK_ENTRY(dir->trash), buf);
g_free(buf);
}
Modified: trunk/src/mailbox-conf.c
==============================================================================
--- trunk/src/mailbox-conf.c (original)
+++ trunk/src/mailbox-conf.c Thu Mar 20 22:32:58 2008
@@ -993,9 +993,9 @@
return;
}
- save_to_config = balsa_app.local_mail_directory == NULL
- || strncmp(balsa_app.local_mail_directory, path,
- strlen(balsa_app.local_mail_directory)) != 0;
+ save_to_config =
+ !libbalsa_path_is_below_dir(path,
+ balsa_app.local_mail_directory);
printf("Save to config: %d\n", save_to_config);
mcw->mailbox->name = g_path_get_basename(path);
balsa_mailbox_local_append(mcw->mailbox);
Modified: trunk/src/mailbox-node.c
==============================================================================
--- trunk/src/mailbox-node.c (original)
+++ trunk/src/mailbox-node.c Thu Mar 20 22:32:58 2008
@@ -341,7 +341,7 @@
return TRUE;
len = strlen(balsa_app.local_mail_directory);
- if (!strncmp(path, balsa_app.local_mail_directory, len)
+ if (libbalsa_path_is_below_dir(path, balsa_app.local_mail_directory)
&& !strchr(&path[++len], G_DIR_SEPARATOR))
/* Top level folder. */
return TRUE;
Modified: trunk/src/save-restore.c
==============================================================================
--- trunk/src/save-restore.c (original)
+++ trunk/src/save-restore.c Thu Mar 20 22:32:58 2008
@@ -195,11 +195,10 @@
if (*special) {
g_free((*special)->config_prefix);
(*special)->config_prefix = NULL;
- if(balsa_app.local_mail_directory == NULL
- || !LIBBALSA_IS_MAILBOX_LOCAL(*special)
- || strncmp(balsa_app.local_mail_directory,
- libbalsa_mailbox_local_get_path(*special),
- strlen(balsa_app.local_mail_directory)) != 0)
+ if (!LIBBALSA_IS_MAILBOX_LOCAL(*special)
+ || !libbalsa_path_is_below_dir(libbalsa_mailbox_local_get_path
+ (*special),
+ balsa_app.local_mail_directory))
config_mailbox_add(*special, NULL);
g_object_remove_weak_pointer(G_OBJECT(*special), (gpointer) special);
Modified: trunk/src/sendmsg-window.c
==============================================================================
--- trunk/src/sendmsg-window.c (original)
+++ trunk/src/sendmsg-window.c Thu Mar 20 22:32:58 2008
@@ -2837,12 +2837,17 @@
ATTACH_SIZE_COLUMN, &size, -1);
if (mode == LIBBALSA_ATTACH_AS_EXTBODY)
sstr = g_strdup("-");
+#if GLIB_CHECK_VERSION(2, 16, 0)
+ else
+ sstr = g_format_size_for_display((goffset) size);
+#else /* GLIB_CHECK_VERSION(2, 16, 0) */
else if (size > 1.2e6)
sstr = g_strdup_printf("%.2fMB", size / (1024 * 1024));
else if (size > 1.2e3)
sstr = g_strdup_printf("%.2fkB", size / 1024);
else
sstr = g_strdup_printf("%dB", (gint) size);
+#endif /* GLIB_CHECK_VERSION(2, 16, 0) */
g_object_set(cell, "text", sstr, NULL);
g_free(sstr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]