#include <tny-camel-folder.h>
#include <tny-simple-list.h>
#include <tny-camel-account.h>
+#include <modest-defs.h>
#include <modest-tny-account.h>
#include <modest-tny-folder.h>
#include <modest-tny-local-folders-account.h>
FOLDER_SELECTION_CHANGED_SIGNAL,
FOLDER_DISPLAY_NAME_CHANGED_SIGNAL,
FOLDER_ACTIVATED_SIGNAL,
+ VISIBLE_ACCOUNT_CHANGED_SIGNAL,
LAST_SIGNAL
};
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+ /*
+ * Emitted whenever the visible account changes
+ */
+ signals[VISIBLE_ACCOUNT_CHANGED_SIGNAL] =
+ g_signal_new ("visible-account-changed",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ModestFolderViewClass,
+ visible_account_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
treeview_class->select_cursor_parent = NULL;
#ifdef MODEST_TOOLKIT_HILDON2
return retval;
}
+typedef struct _ForeachFolderInfo {
+ gchar *needle;
+ gboolean found;
+} ForeachFolderInfo;
+
+static gboolean
+foreach_folder_with_id (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ ForeachFolderInfo *info;
+ GObject *instance;
+
+ info = (ForeachFolderInfo *) data;
+ gtk_tree_model_get (model, iter,
+ INSTANCE_COLUMN, &instance,
+ -1);
+
+ if (TNY_IS_FOLDER (instance)) {
+ const gchar *id;
+ gchar *collate;
+ id = tny_folder_get_id (TNY_FOLDER (instance));
+ if (id) {
+ collate = g_utf8_collate_key (id, -1);
+ info->found = !strcmp (info->needle, collate);
+ g_free (collate);
+ }
+ }
+
+ return info->found;
+
+}
+
+
static gboolean
has_folder_with_id (ModestFolderView *self, const gchar *id)
{
- return FALSE;
+ GtkTreeModel *model;
+ ForeachFolderInfo info = {NULL, FALSE};
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
+ info.needle = g_utf8_collate_key (id, -1);
+
+ gtk_tree_model_foreach (model, foreach_folder_with_id, &info);
+ g_free (info.needle);
+
+ return info.found;
}
static gboolean
const gchar *last_bar;
gchar *string_to_match;
last_bar = g_strrstr (b_id, "/");
- if (!last_bar)
+ if (last_bar)
+ last_bar++;
+ else
last_bar = b_id;
string_to_match = g_strconcat (a_id, "/", last_bar, NULL);
retval = has_folder_with_id (self, string_to_match);
}
g_object_unref (instance);
}
+ g_object_unref (iterator);
return retval;
}
/* Save settings to gconf */
modest_widget_memory_save (modest_runtime_get_conf (), G_OBJECT(self),
MODEST_CONF_FOLDER_VIEW_KEY);
+
+ /* Notify observers */
+ g_signal_emit (G_OBJECT(self),
+ signals[VISIBLE_ACCOUNT_CHANGED_SIGNAL], 0,
+ account_id);
}
const gchar *