parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = modest_folder_view_finalize;
- gobject_class->finalize = modest_folder_view_dispose;
+ gobject_class->dispose = modest_folder_view_dispose;
g_type_class_add_private (gobject_class,
sizeof(ModestFolderViewPrivate));
buffer = g_string_append (buffer, *item_name);
if (concat_folder_name) {
- buffer = g_string_append (buffer, folder_name);
+ if (!is_special && folder_type == TNY_FOLDER_TYPE_DRAFTS) {
+ buffer = g_string_append (buffer, folder_name);
+ /* TODO: append a sensitive string to the remote drafts to
+ * be able to know it's the remote one */
+/* buffer = g_string_append (buffer, " (TODO:remote)"); */
+ } else {
+ buffer = g_string_append (buffer, folder_name);
+ }
}
g_free (*item_name);
g_object_unref (account);
}
static void
+replace_special_folder_prefix (gchar **item_name)
+{
+ const gchar *separator;
+ gchar *prefix;
+
+ if (item_name == NULL || *item_name == NULL || **item_name == '\0')
+ return;
+ separator = g_strstr_len (*item_name, -1, MODEST_FOLDER_PATH_SEPARATOR);
+ if (separator == NULL)
+ return;
+
+ prefix = g_strndup (*item_name, separator - *item_name);
+ g_strstrip (prefix);
+
+ if (prefix && *prefix != '\0') {
+ TnyFolderType folder_type;
+ gchar *new_name;
+ gchar *downcase;
+
+ downcase = g_utf8_strdown (prefix, -1);
+ g_free (prefix);
+ prefix = downcase;
+
+ if (strcmp (downcase, "inbox") == 0) {
+ folder_type = TNY_FOLDER_TYPE_INBOX;
+ new_name = g_strconcat (_("mcen_me_folder_inbox"), separator, NULL);
+ g_free (*item_name);
+ *item_name = new_name;
+ } else {
+ folder_type = modest_local_folder_info_get_type (prefix);
+ switch (folder_type) {
+ case TNY_FOLDER_TYPE_INBOX:
+ case TNY_FOLDER_TYPE_ARCHIVE:
+ new_name = g_strconcat (modest_local_folder_info_get_type_display_name (folder_type), separator, NULL);
+ g_free (*item_name);
+ *item_name = new_name;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ g_free (prefix);
+}
+
+static void
text_cell_data (GtkTreeViewColumn *column,
GtkCellRenderer *renderer,
GtkTreeModel *tree_model,
/* Convert INBOX */
if (type == TNY_FOLDER_TYPE_INBOX &&
- !g_ascii_strcasecmp (fname, "Inbox")) {
+ g_str_has_suffix (fname, "Inbox")) {
g_free (item_name);
item_name = g_strdup (_("mcen_me_folder_inbox"));
}
format_compact_style (&item_name, instance, priv->mailbox,
item_weight == 800,
multiaccount, &use_markup);
+ } else {
+ replace_special_folder_prefix (&item_name);
}
if (item_name && item_weight) {
{
ThreePixbufs *retval;
- if (!*pixbuf) {
+ if (pixbuf && !*pixbuf) {
GdkPixbuf *icon;
icon = modest_platform_get_icon (icon_code, FOLDER_ICON_SIZE);
if (icon) {
}
}
- if (!*pixbuf_open && pixbuf && *pixbuf)
+ if (pixbuf_open && !*pixbuf_open && pixbuf && *pixbuf)
*pixbuf_open = get_composite_pixbuf ("qgn_list_gene_fldr_exp",
FOLDER_ICON_SIZE,
*pixbuf);
- if (!*pixbuf_close && pixbuf && *pixbuf)
+ if (pixbuf_close && !*pixbuf_close && pixbuf && *pixbuf)
*pixbuf_close = get_composite_pixbuf ("qgn_list_gene_fldr_clp",
FOLDER_ICON_SIZE,
*pixbuf);
retval = g_slice_new0 (ThreePixbufs);
- if (*pixbuf)
+ if (pixbuf && *pixbuf)
retval->pixbuf = g_object_ref (*pixbuf);
- if (*pixbuf_open)
+ else
+ retval->pixbuf = NULL;
+ if (pixbuf_open && *pixbuf_open)
retval->pixbuf_open = g_object_ref (*pixbuf_open);
- if (*pixbuf_close)
+ else
+ retval->pixbuf_open = NULL;
+ if (pixbuf_close && *pixbuf_close)
retval->pixbuf_close = g_object_ref (*pixbuf_close);
+ else
+ retval->pixbuf_close = NULL;
return retval;
}
static void
modest_folder_view_dispose (GObject *obj)
{
- static gboolean disposed = FALSE;
ModestFolderViewPrivate *priv;
-
- if (disposed)
- return;
+ GtkTreeModel *model = NULL;
priv = MODEST_FOLDER_VIEW_GET_PRIVATE (obj);
+ get_inner_models (MODEST_FOLDER_VIEW (obj),
+ NULL, NULL, &model);
+
#ifdef MODEST_TOOLKIT_HILDON2
- modest_signal_mgr_disconnect_all_and_destroy (priv->signal_handlers);
+ if (priv->signal_handlers) {
+ modest_signal_mgr_disconnect_all_and_destroy (priv->signal_handlers);
+ priv->signal_handlers = NULL;
+ }
#endif
/* Free external references */
g_object_unref (priv->list_to_move);
priv->list_to_move = NULL;
}
+
+ G_OBJECT_CLASS(parent_class)->dispose (obj);
}
static void
g_object_unref (account);
}
- /* Get the accounts: */
- tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
- TNY_LIST (model),
- TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+ if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ALL) {
+ /* Get the accounts */
+ tny_account_store_get_accounts (TNY_ACCOUNT_STORE(account_store),
+ TNY_LIST (model),
+ TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
+ } else {
+ if (priv->visible_account_id) {
+ TnyAccount *account;
+
+ /* Add local folders account */
+ account = modest_tny_account_store_get_local_folders_account ((ModestTnyAccountStore *) account_store);
+
+ if (account) {
+ tny_list_append (TNY_LIST (model), (GObject *) account);
+ g_object_unref (account);
+ }
+
+ account = modest_tny_account_store_get_mmc_folders_account ((ModestTnyAccountStore *) account_store);
+
+ if (account) {
+ tny_list_append (TNY_LIST (model), (GObject *) account);
+ g_object_unref (account);
+ }
+
+ /* Add visible account */
+ account = modest_tny_account_store_get_tny_account_by ((ModestTnyAccountStore *) account_store,
+ MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+ priv->visible_account_id);
+ if (account) {
+ tny_list_append (TNY_LIST (model), (GObject *) account);
+ g_object_unref (account);
+ } else {
+ g_warning ("You need to set an account first");
+ g_object_unref (model);
+ return FALSE;
+ }
+ } else {
+ g_warning ("You need to set an account first");
+ g_object_unref (model);
+ return FALSE;
+ }
+ }
sortable = gtk_tree_model_sort_new_with_model (model);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(sortable),
self,
NULL);
- if (priv->signal_handlers > 0) {
- GtkTreeModel *old_tny_model;
-
- if (get_inner_models (self, NULL, NULL, &old_tny_model)) {
+ GtkTreeModel *old_tny_model = NULL;
+ if (get_inner_models (self, NULL, NULL, &old_tny_model)) {
+ if (priv->signal_handlers > 0) {
priv->signal_handlers = modest_signal_mgr_disconnect (priv->signal_handlers,
G_OBJECT (old_tny_model),
"activity-changed");
priv->signal_handlers = modest_signal_mgr_connect (priv->signal_handlers,
G_OBJECT (model),
"activity-changed",
- G_CALLBACK (on_activity_changed),
+ G_CALLBACK (on_activity_changed),
self);
#endif
model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
if (GTK_IS_TREE_MODEL_FILTER (model))
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
+ else
+ modest_folder_view_update_model(self,
+ (TnyAccountStore *) modest_runtime_get_account_store());
/* Save settings to gconf */
modest_widget_memory_save (modest_runtime_get_conf (), G_OBJECT(self),
activity);
}
#endif
+
+TnyList *
+modest_folder_view_get_model_tny_list (ModestFolderView *self)
+{
+ GtkTreeModel *model;
+ TnyList *ret_value;
+
+ ret_value = NULL;
+ model = NULL;
+
+ if (get_inner_models (MODEST_FOLDER_VIEW (self), NULL, NULL, (GtkTreeModel **) &model)) {
+ ret_value = TNY_LIST (model);
+ g_object_ref (ret_value);
+ }
+
+ return ret_value;
+
+}