diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2003-03-27 03:30:54 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2003-03-27 03:30:54 +0800 |
commit | 8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2 (patch) | |
tree | b976d38add0304d262b40a1bc86df5535018c587 | |
parent | f4e863ea7f2ead82a3678cbe8870e01a3a3bf14e (diff) | |
download | gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.tar gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.tar.gz gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.tar.bz2 gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.tar.lz gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.tar.xz gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.tar.zst gsoc2013-evolution-8cca88b4f676ac7cc4b719264c7a6c9d965bc8e2.zip |
New member physical_uri in struct ESummaryMailFolder. (new_folder_cb): Set
* e-summary-mail.c: New member physical_uri in struct
ESummaryMailFolder.
(new_folder_cb): Set it.
(remove_folder_cb): Free it.
(make_pretty_foldername): Rewritten to honour the display_name.
[#7153]
* e-summary.c (destroy): Only remove the source with ID
tomorrow_timeout_id if the ID is nonzero.
svn path=/trunk/; revision=20521
-rw-r--r-- | my-evolution/ChangeLog | 12 | ||||
-rw-r--r-- | my-evolution/e-summary-mail.c | 308 | ||||
-rw-r--r-- | my-evolution/e-summary.c | 3 |
3 files changed, 74 insertions, 249 deletions
diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog index debba7cccc..ad4044ab6f 100644 --- a/my-evolution/ChangeLog +++ b/my-evolution/ChangeLog @@ -1,3 +1,15 @@ +2003-03-26 Ettore Perazzoli <ettore@ximian.com> + + * e-summary-mail.c: New member physical_uri in struct + ESummaryMailFolder. + (new_folder_cb): Set it. + (remove_folder_cb): Free it. + (make_pretty_foldername): Rewritten to honour the display_name. + [#7153] + + * e-summary.c (destroy): Only remove the source with ID + tomorrow_timeout_id if the ID is nonzero. + 2003-03-25 Dan Winship <danw@ximian.com> * e-summary.c: Update for e_notice move diff --git a/my-evolution/e-summary-mail.c b/my-evolution/e-summary-mail.c index 20684dbb0f..94b7ec8aa2 100644 --- a/my-evolution/e-summary-mail.c +++ b/my-evolution/e-summary-mail.c @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* e-summary-mail.c * - * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2001, 2002, 2003 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -66,18 +66,6 @@ typedef struct _FolderStore { } FolderStore; struct _ESummaryMail { -#if 0 - GNOME_Evolution_FolderInfo folder_info; - GNOME_Evolution_StorageRegistry registry; - BonoboListener *listener; - EvolutionStorageListener *storage_listener; - - GSList *storage_list; - - GHashTable *folders; - GList *shown; - ESummaryMailMode mode; -#endif char *html; }; @@ -87,7 +75,7 @@ typedef struct _StorageInfo { GNOME_Evolution_Storage storage; EvolutionStorageListener *listener; -/* ESummary *summary; */ + GList *folders; } StorageInfo; @@ -95,6 +83,7 @@ typedef struct _ESummaryMailFolder { char *path; char *uri; char *physical_uri; + char *display_name; int count; int unread; @@ -105,22 +94,61 @@ typedef struct _ESummaryMailFolder { static FolderStore *folder_store = NULL; -/* Work out what to do with folder names */ + static char * make_pretty_foldername (ESummary *summary, - const char *foldername) + const ESummaryMailFolder *folder) { - char *pretty; + GString *pretty_path; + const char *p, *previous_p; + char *retval; + + if (! summary->preferences->show_full_path) + return g_strdup (folder->display_name); + + g_assert (folder->path[0] == '/'); - if (summary->preferences->show_full_path == FALSE) { - if ((pretty = strrchr (foldername, '/'))) { - return g_strdup (pretty + 1); + pretty_path = g_string_new (""); + + previous_p = folder->path; + while (previous_p != NULL) { + const ESummaryMailFolder *ancestor_folder; + char *path; + + g_string_append (pretty_path, "/"); + + p = strchr (previous_p + 1, '/'); + + if (p == NULL) + path = g_strdup (folder->path); + else + path = g_strndup (folder->path, p - folder->path); + + ancestor_folder = g_hash_table_lookup (folder_store->path_to_folder, path); + + if (ancestor_folder != NULL) { + g_string_append (pretty_path, ancestor_folder->display_name); } else { - return g_strdup (foldername); + char *path_element; + + if (p == NULL) + path_element = g_strdup (previous_p + 1); + else + path_element = g_strndup (previous_p + 1, p - (previous_p + 1)); + + g_string_append (pretty_path, path_element); + g_free (path_element); } - } else { - return g_strdup (foldername); + + g_free (path); + + previous_p = p; } + + retval = pretty_path->str; + g_string_free (pretty_path, FALSE); + + return retval; } static void @@ -130,9 +158,13 @@ folder_gen_html (ESummary *summary, { char *str, *pretty_name; - pretty_name = make_pretty_foldername (summary, folder->path); - str = g_strdup_printf ("<tr><td><a href=\"%s\"><pre>%s</pre></a></td><td align=\"Left\"><pre>%d/%d</pre></td></tr>", - folder->uri, pretty_name, folder->unread, folder->count); + pretty_name = make_pretty_foldername (summary, folder); + str = g_strdup_printf ("<tr><td><a href=\"%s\">" + "<pre>%s</pre></a></td><td align=\"Left\">" + "<pre>%d/%d</pre>" + "</td></tr>", + folder->uri, pretty_name, + folder->unread, folder->count); g_string_append (string, str); g_free (pretty_name); g_free (str); @@ -239,6 +271,7 @@ new_folder_cb (EvolutionStorageListener *listener, mail_folder->uri = g_strdup (folder->evolutionUri); mail_folder->physical_uri = g_strdup (folder->physicalUri); mail_folder->path = g_strdup (path); + mail_folder->display_name = g_strdup (folder->displayName); mail_folder->count = -1; mail_folder->unread = -1; mail_folder->init = FALSE; @@ -309,6 +342,7 @@ remove_folder_cb (EvolutionStorageListener *listener, g_free (mail_folder->path); g_free (mail_folder->uri); g_free (mail_folder->physical_uri); + g_free (mail_folder->display_name); g_free (mail_folder); } @@ -555,228 +589,6 @@ e_summary_mail_reconfigure (void) /* e_summary_redraw_all (); */ } -#if 0 -static int -str_compare (gconstpointer a, - gconstpointer b) -{ - ESummaryMailFolder *folder_a, *folder_b; - - folder_a = (ESummaryMailFolder *) a; - folder_b = (ESummaryMailFolder *) b; - return strcasecmp (folder_a->name, folder_b->name); -} - -static int -sort_storages (gconstpointer a, - gconstpointer b) -{ - StorageInfo *si_a, *si_b; - - si_a = (StorageInfo *) a; - si_b = (StorageInfo *) b; - - return strcasecmp (si_a->name, si_b->name); -} - -static char * -get_parent_path (const char *path) -{ - char *last; - - if (strncmp (path, "vfolder", 7) == 0) { - last = strrchr (path, '#'); - if (last == NULL) { - return g_strdup (path); - } - return g_strndup (path, last - path); - } else { - last = strrchr (path, '/'); - return g_strndup (path, last - path); - } -} - -static gboolean -is_folder_shown (const char *path) -{ - GList *p; - - for (p = folder_store->shown; p; p = p->next) { - ESummaryMailFolder *folder = p->data; - if (strcmp (folder->path, path) == 0) { - return TRUE; - } - } - - return FALSE; -} - -static ETreePath -insert_path_recur (ESummaryTable *est, - StorageInfo *si, - GHashTable *hash_table, - const char *path) -{ - char *parent_path, *name; - ETreePath parent_node, node; - ESummaryTableModelEntry *entry; - int children; - - parent_path = get_parent_path (path); - - parent_node = g_hash_table_lookup (hash_table, parent_path); - if (parent_node == NULL) { - if (si->toplevel == NULL) { - char *third_slash; - /* Generate the toplevel from the path */ - - if (strncmp (path, "imap://", 7) == 0) { - /* IMAP */ - third_slash = strchr (path + 8, '/'); - if (third_slash == NULL) { - /* EEk */ - si->toplevel = g_strdup (path + 8); - } else { - si->toplevel = g_strndup (path, third_slash - path); - } - } else { - /* FIXME: Not sure I like this, but... */ - si->toplevel = g_strdup (path); - } - } - - if (strcmp (si->toplevel, path) == 0) { - /* Insert root */ - children = e_summary_table_get_num_children (est, NULL); - node = e_summary_table_add_node (est, NULL, children, NULL); - entry = g_new (ESummaryTableModelEntry, 1); - entry->path = node; - entry->location = NULL; - entry->name = g_strdup (si->name); - entry->editable = FALSE; - entry->removable = FALSE; - entry->shown = FALSE; - - g_hash_table_insert (est->model, entry->path, entry); - g_hash_table_insert (hash_table, g_strdup (path), node); - return node; - } else { - parent_node = insert_path_recur (est, si, hash_table, parent_path); - } - } - - g_free (parent_path); - if (strcmp (si->name, "VFolders") == 0) { - name = strrchr (path, '#'); - } else { - name = strrchr (path, '/'); - } - - /* Leave out folders called "subfolder" */ - if (strcmp (name + 1, "subfolders") == 0) { - return parent_node; - } - - children = e_summary_table_get_num_children (est, parent_node); - node = e_summary_table_add_node (est, parent_node, children, NULL); - entry = g_new (ESummaryTableModelEntry, 1); - entry->path = node; - entry->location = g_strdup (path); - entry->name = g_strdup (name + 1); - entry->editable = TRUE; - entry->removable = FALSE; - - /* Check if shown */ - entry->shown = is_folder_shown (path); - g_hash_table_insert (est->model, entry->path, entry); - g_hash_table_insert (hash_table, g_strdup (path), node); - - return node; -} - -static void -free_path_hash (gpointer key, - gpointer value, - gpointer data) -{ - g_free (key); -} - -static void -add_storage_to_table (ESummaryTable *est, - StorageInfo *si) -{ - GHashTable *path_hash; - GList *p; - - path_hash = g_hash_table_new (g_str_hash, g_str_equal); - si->folders = g_list_sort (si->folders, str_compare); - - for (p = si->folders; p; p = p->next) { - ESummaryMailFolder *folder = p->data; - - insert_path_recur (est, si, path_hash, folder->path); - } - - g_hash_table_foreach (path_hash, free_path_hash, NULL); - g_hash_table_destroy (path_hash); -} - -static void -make_toplevel (StorageInfo *si) -{ - if (si->toplevel != NULL) { - return; - } - - if (strcmp (si->name, _("VFolders")) == 0) { - si->toplevel = g_strdup_printf ("vfolder:%s/evolution/vfolder", - g_get_home_dir ()); - } else if (strcmp (si->name, _("Local Folders")) == 0) { - si->toplevel = g_strdup_printf ("file://%s/evolution/local", - g_get_home_dir ()); - } else { - si->toplevel = NULL; - } -} - -void -e_summary_mail_fill_list (ESummaryTable *est) -{ - GSList *p; - - g_return_if_fail (IS_E_SUMMARY_TABLE (est)); - - g_return_if_fail (folder_store != NULL); - - folder_store->storage_list = g_slist_sort (folder_store->storage_list, - sort_storages); - for (p = folder_store->storage_list; p; p = p->next) { - StorageInfo *si = p->data; - - if (si->toplevel == NULL) { - make_toplevel (si); - } - - add_storage_to_table (est, si); - } -} -#endif - -#if 0 -static void -free_folder (gpointer key, - gpointer value, - gpointer data) -{ - ESummaryMailFolder *folder = value; - - g_free (folder->name); - g_free (folder->path); - g_free (folder->uri); - g_free (folder); -} -#endif void e_summary_mail_free (ESummary *summary) diff --git a/my-evolution/e-summary.c b/my-evolution/e-summary.c index a32713b2de..bc7316d107 100644 --- a/my-evolution/e-summary.c +++ b/my-evolution/e-summary.c @@ -167,7 +167,8 @@ destroy (GtkObject *object) e_summary_tasks_free (summary); } - g_source_remove (priv->tomorrow_timeout_id); + if (priv->tomorrow_timeout_id != 0) + g_source_remove (priv->tomorrow_timeout_id); if (priv->protocol_hash) { g_hash_table_foreach (priv->protocol_hash, free_protocol, NULL); |